1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Thomas Richter 2013-07-27 14:49:53 +02:00
commit a564d1decd
10 changed files with 159 additions and 121 deletions

View File

@ -4079,7 +4079,7 @@ bool TRI_DropIndexDocumentCollection (TRI_document_collection_t* document,
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
vocbase = primary->base._vocbase; vocbase = primary->base._vocbase;
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
@ -4118,7 +4118,7 @@ bool TRI_DropIndexDocumentCollection (TRI_document_collection_t* document,
TRI_WRITE_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary); TRI_WRITE_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -4404,7 +4404,7 @@ TRI_index_t* TRI_EnsureCapConstraintDocumentCollection (TRI_document_collection_
// ............................................................................. // .............................................................................
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
TRI_WRITE_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary); TRI_WRITE_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);
@ -4430,7 +4430,7 @@ TRI_index_t* TRI_EnsureCapConstraintDocumentCollection (TRI_document_collection_
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -4821,7 +4821,7 @@ TRI_index_t* TRI_EnsureGeoIndex1DocumentCollection (TRI_document_collection_t* d
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -4851,7 +4851,7 @@ TRI_index_t* TRI_EnsureGeoIndex1DocumentCollection (TRI_document_collection_t* d
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -4873,7 +4873,7 @@ TRI_index_t* TRI_EnsureGeoIndex2DocumentCollection (TRI_document_collection_t* d
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -4903,7 +4903,7 @@ TRI_index_t* TRI_EnsureGeoIndex2DocumentCollection (TRI_document_collection_t* d
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -5109,7 +5109,7 @@ TRI_index_t* TRI_EnsureHashIndexDocumentCollection (TRI_document_collection_t* d
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -5140,7 +5140,7 @@ TRI_index_t* TRI_EnsureHashIndexDocumentCollection (TRI_document_collection_t* d
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -5338,7 +5338,7 @@ TRI_index_t* TRI_EnsureSkiplistIndexDocumentCollection (TRI_document_collection_
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -5368,7 +5368,7 @@ TRI_index_t* TRI_EnsureSkiplistIndexDocumentCollection (TRI_document_collection_
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -5634,7 +5634,7 @@ TRI_index_t* TRI_EnsureFulltextIndexDocumentCollection (TRI_document_collection_
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -5664,7 +5664,7 @@ TRI_index_t* TRI_EnsureFulltextIndexDocumentCollection (TRI_document_collection_
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -5902,7 +5902,7 @@ TRI_index_t* TRI_EnsurePriorityQueueIndexDocumentCollection(TRI_document_collect
primary = &document->base; primary = &document->base;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -5933,7 +5933,7 @@ TRI_index_t* TRI_EnsurePriorityQueueIndexDocumentCollection(TRI_document_collect
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
return idx; return idx;
@ -6200,7 +6200,7 @@ TRI_index_t* TRI_EnsureBitarrayIndexDocumentCollection (TRI_document_collection_
*errorStr = NULL; *errorStr = NULL;
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadLockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................
@ -6242,7 +6242,7 @@ TRI_index_t* TRI_EnsureBitarrayIndexDocumentCollection (TRI_document_collection_
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&primary->base._vocbase->_inventoryLock);
#endif #endif
// ............................................................................. // .............................................................................

View File

@ -1557,7 +1557,7 @@ TRI_vocbase_t* TRI_OpenVocBase (char const* path,
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_InitReadWriteLock(&vocbase->_objectLock); TRI_InitReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_InitReadWriteLock(&vocbase->_authInfoLock); TRI_InitReadWriteLock(&vocbase->_authInfoLock);
@ -1804,7 +1804,7 @@ void TRI_DestroyVocBase (TRI_vocbase_t* vocbase) {
// destroy locks // destroy locks
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_DestroyReadWriteLock(&vocbase->_objectLock); TRI_DestroyReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_DestroyReadWriteLock(&vocbase->_authInfoLock); TRI_DestroyReadWriteLock(&vocbase->_authInfoLock);
TRI_DestroyReadWriteLock(&vocbase->_lock); TRI_DestroyReadWriteLock(&vocbase->_lock);
@ -1898,7 +1898,7 @@ TRI_json_t* TRI_InventoryCollectionsVocBase (TRI_vocbase_t* vocbase,
TRI_InitVectorPointer(&collections, TRI_CORE_MEM_ZONE); TRI_InitVectorPointer(&collections, TRI_CORE_MEM_ZONE);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_WriteLockReadWriteLock(&vocbase->_objectLock); TRI_WriteLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
// copy collection pointers into vector so we can work with the copy without // copy collection pointers into vector so we can work with the copy without
@ -1965,7 +1965,7 @@ TRI_json_t* TRI_InventoryCollectionsVocBase (TRI_vocbase_t* vocbase,
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_WriteUnlockReadWriteLock(&vocbase->_objectLock); TRI_WriteUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_DestroyVectorPointer(&collections); TRI_DestroyVectorPointer(&collections);
@ -2116,7 +2116,7 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase,
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_WRITE_LOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_LOCK_COLLECTIONS_VOCBASE(vocbase);
@ -2131,7 +2131,7 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
LOG_DEBUG("collection named '%s' already exists", name); LOG_DEBUG("collection named '%s' already exists", name);
@ -2150,7 +2150,7 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return NULL; return NULL;
@ -2176,7 +2176,7 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return NULL; return NULL;
@ -2194,7 +2194,7 @@ TRI_vocbase_col_t* TRI_CreateCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
@ -2284,7 +2284,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
} }
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
// mark collection as deleted // mark collection as deleted
@ -2300,7 +2300,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
@ -2320,7 +2320,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return TRI_set_errno(res); return TRI_set_errno(res);
} }
@ -2345,7 +2345,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return TRI_set_errno(res); return TRI_set_errno(res);
} }
@ -2360,7 +2360,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
DropCollectionCallback(0, collection); DropCollectionCallback(0, collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
@ -2379,7 +2379,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
return res; return res;
@ -2391,7 +2391,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
// added callback for dropping // added callback for dropping
@ -2416,7 +2416,7 @@ int TRI_DropCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection); TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
LOG_WARNING("internal error in TRI_DropCollectionVocBase"); LOG_WARNING("internal error in TRI_DropCollectionVocBase");
@ -2534,13 +2534,13 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_CopyString(info._name, newName, sizeof(info._name)); TRI_CopyString(info._name, newName, sizeof(info._name));
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
res = TRI_SaveCollectionInfo(collection->_path, &info, vocbase->_forceSyncProperties); res = TRI_SaveCollectionInfo(collection->_path, &info, vocbase->_forceSyncProperties);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_FreeCollectionInfoOptions(&info); TRI_FreeCollectionInfoOptions(&info);
@ -2561,13 +2561,13 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
else if (collection->_status == TRI_VOC_COL_STATUS_LOADED || collection->_status == TRI_VOC_COL_STATUS_UNLOADING) { else if (collection->_status == TRI_VOC_COL_STATUS_LOADED || collection->_status == TRI_VOC_COL_STATUS_UNLOADING) {
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
res = TRI_RenameCollection(&collection->_collection->base, newName); res = TRI_RenameCollection(&collection->_collection->base, newName);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
@ -2598,7 +2598,7 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
// ............................................................................. // .............................................................................
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadLockReadWriteLock(&vocbase->_objectLock); TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_RemoveKeyAssociativePointer(&vocbase->_collectionsByName, oldName); TRI_RemoveKeyAssociativePointer(&vocbase->_collectionsByName, oldName);
@ -2608,7 +2608,7 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
TRI_InsertKeyAssociativePointer(&vocbase->_collectionsByName, newName, CONST_CAST(collection), false); TRI_InsertKeyAssociativePointer(&vocbase->_collectionsByName, newName, CONST_CAST(collection), false);
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_ReadUnlockReadWriteLock(&vocbase->_objectLock); TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
#endif #endif
TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase); TRI_WRITE_UNLOCK_COLLECTIONS_VOCBASE(vocbase);

View File

@ -353,7 +353,7 @@ typedef struct TRI_vocbase_s {
TRI_associative_pointer_t _collectionsById; // collections by id TRI_associative_pointer_t _collectionsById; // collections by id
#ifdef TRI_ENABLE_REPLICATION #ifdef TRI_ENABLE_REPLICATION
TRI_read_write_lock_t _objectLock; // object lock needed when replication is assessing the state of the vocbase TRI_read_write_lock_t _inventoryLock; // object lock needed when replication is assessing the state of the vocbase
#endif #endif
TRI_associative_pointer_t _authInfo; TRI_associative_pointer_t _authInfo;

View File

@ -256,7 +256,10 @@ var helpArangoCollection = arangosh.createHelpHeadline("ArangoCollection help")
' <overwrite>) ' + "\n" + ' <overwrite>) ' + "\n" +
' update(<id>, <data>, partially update document ' + "\n" + ' update(<id>, <data>, partially update document ' + "\n" +
' <overwrite>, <keepNull>) ' + "\n" + ' <overwrite>, <keepNull>) ' + "\n" +
' delete(<id>) delete document ' + "\n" + ' remove(<id>) delete document ' + "\n" +
' exists(<id>) checks whether a document exists ' + "\n" +
' first() get first inserted/update document' + "\n" +
' last() get last inserted/update document ' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Attributes: ' + "\n" + 'Attributes: ' + "\n" +
' _database database object ' + "\n" + ' _database database object ' + "\n" +
@ -919,7 +922,7 @@ ArangoCollection.prototype.exists = function (id) {
arangosh.checkRequestResult(requestResult); arangosh.checkRequestResult(requestResult);
return requestResult; return true;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -211,6 +211,7 @@ var helpArangoDatabase = arangosh.createHelpHeadline("ArangoDatabase help") +
' ' + "\n" + ' ' + "\n" +
'Administration Functions: ' + "\n" + 'Administration Functions: ' + "\n" +
' _help(); this help ' + "\n" + ' _help(); this help ' + "\n" +
' _flushCache(); flush and refill collection cache' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Collection Functions: ' + "\n" + 'Collection Functions: ' + "\n" +
' _collections() list all collections ' + "\n" + ' _collections() list all collections ' + "\n" +
@ -225,9 +226,11 @@ var helpArangoDatabase = arangosh.createHelpHeadline("ArangoDatabase help") +
' _update(<id>, <data>, update document ' + "\n" + ' _update(<id>, <data>, update document ' + "\n" +
' <overwrite>, <keepNull>) ' + "\n" + ' <overwrite>, <keepNull>) ' + "\n" +
' _remove(<id>) delete document ' + "\n" + ' _remove(<id>) delete document ' + "\n" +
' _exists(<id>) checks whether a document exists ' + "\n" +
' _truncate() delete all documents ' + "\n" + ' _truncate() delete all documents ' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Query Functions: ' + "\n" + 'Query / Transaction Functions: ' + "\n" +
' _executeTransaction(<trx>); execute transaction ' + "\n" +
' _query(<query>); execute AQL query ' + "\n" + ' _query(<query>); execute AQL query ' + "\n" +
' _createStatement(<data>); create and return AQL query '; ' _createStatement(<data>); create and return AQL query ';
@ -616,7 +619,7 @@ ArangoDatabase.prototype._exists = function (id) {
arangosh.checkRequestResult(requestResult); arangosh.checkRequestResult(requestResult);
return requestResult; return true;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -255,7 +255,10 @@ var helpArangoCollection = arangosh.createHelpHeadline("ArangoCollection help")
' <overwrite>) ' + "\n" + ' <overwrite>) ' + "\n" +
' update(<id>, <data>, partially update document ' + "\n" + ' update(<id>, <data>, partially update document ' + "\n" +
' <overwrite>, <keepNull>) ' + "\n" + ' <overwrite>, <keepNull>) ' + "\n" +
' delete(<id>) delete document ' + "\n" + ' remove(<id>) delete document ' + "\n" +
' exists(<id>) checks whether a document exists ' + "\n" +
' first() get first inserted/update document' + "\n" +
' last() get last inserted/update document ' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Attributes: ' + "\n" + 'Attributes: ' + "\n" +
' _database database object ' + "\n" + ' _database database object ' + "\n" +
@ -918,7 +921,7 @@ ArangoCollection.prototype.exists = function (id) {
arangosh.checkRequestResult(requestResult); arangosh.checkRequestResult(requestResult);
return requestResult; return true;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -210,6 +210,7 @@ var helpArangoDatabase = arangosh.createHelpHeadline("ArangoDatabase help") +
' ' + "\n" + ' ' + "\n" +
'Administration Functions: ' + "\n" + 'Administration Functions: ' + "\n" +
' _help(); this help ' + "\n" + ' _help(); this help ' + "\n" +
' _flushCache(); flush and refill collection cache' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Collection Functions: ' + "\n" + 'Collection Functions: ' + "\n" +
' _collections() list all collections ' + "\n" + ' _collections() list all collections ' + "\n" +
@ -224,9 +225,11 @@ var helpArangoDatabase = arangosh.createHelpHeadline("ArangoDatabase help") +
' _update(<id>, <data>, update document ' + "\n" + ' _update(<id>, <data>, update document ' + "\n" +
' <overwrite>, <keepNull>) ' + "\n" + ' <overwrite>, <keepNull>) ' + "\n" +
' _remove(<id>) delete document ' + "\n" + ' _remove(<id>) delete document ' + "\n" +
' _exists(<id>) checks whether a document exists ' + "\n" +
' _truncate() delete all documents ' + "\n" + ' _truncate() delete all documents ' + "\n" +
' ' + "\n" + ' ' + "\n" +
'Query Functions: ' + "\n" + 'Query / Transaction Functions: ' + "\n" +
' _executeTransaction(<trx>); execute transaction ' + "\n" +
' _query(<query>); execute AQL query ' + "\n" + ' _query(<query>); execute AQL query ' + "\n" +
' _createStatement(<data>); create and return AQL query '; ' _createStatement(<data>); create and return AQL query ';
@ -615,7 +618,7 @@ ArangoDatabase.prototype._exists = function (id) {
arangosh.checkRequestResult(requestResult); arangosh.checkRequestResult(requestResult);
return requestResult; return true;
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -642,6 +642,10 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
part = ''; part = '';
} }
// .............................................................................
// exact match
// .............................................................................
if (typeof part === "string") { if (typeof part === "string") {
if (! subwhere.hasOwnProperty('exact')) { if (! subwhere.hasOwnProperty('exact')) {
subwhere.exact = {}; subwhere.exact = {};
@ -657,21 +661,22 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
defineRoutePart(route, subpart, parts, pos + 1, constraint, callback); defineRoutePart(route, subpart, parts, pos + 1, constraint, callback);
} }
else { else {
if (subpart.hasOwnProperty('route')) { if (! subpart.hasOwnProperty('routes')) {
p1 = subpart.route.priority || 0; subpart.routes = [];
p2 = route.priority || 0; }
if (p1 <= p2) { subpart.routes.push({
subpart.route = route; priority: route.priority || 0,
subpart.callback = callback; route: route,
} callback: callback
} });
else {
subpart.route = route;
subpart.callback = callback;
}
} }
} }
// .............................................................................
// parameter match
// .............................................................................
else if (part.hasOwnProperty('parameters')) { else if (part.hasOwnProperty('parameters')) {
if (! subwhere.hasOwnProperty('parameters')) { if (! subwhere.hasOwnProperty('parameters')) {
subwhere.parameters = []; subwhere.parameters = [];
@ -693,7 +698,7 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
if (ok) { if (ok) {
for (i = 0; i < part.parameters.length; ++i) { for (i = 0; i < part.parameters.length; ++i) {
p = part.parameters[i]; p = part.parameters[i];
subsub = { parameter: p, match: {}}; subsub = { parameter: p, match: {} };
subwhere.parameters.push(subsub); subwhere.parameters.push(subsub);
if (constraint.hasOwnProperty(p)) { if (constraint.hasOwnProperty(p)) {
@ -706,15 +711,27 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
defineRoutePart(route, subsub.match, parts, pos + 1, constraint, callback); defineRoutePart(route, subsub.match, parts, pos + 1, constraint, callback);
} }
else { else {
subsub.match.route = route; if (! subsub.match.hasOwnProperty('routes')) {
subsub.match.callback = callback; subsub.match.routes = [];
}
subsub.match.routes.push({
priority: route.priority || 0,
route: route,
callback: callback
});
} }
} }
} }
} }
// .............................................................................
// prefix match
// .............................................................................
else if (part.hasOwnProperty('prefix')) { else if (part.hasOwnProperty('prefix')) {
if (! subwhere.hasOwnProperty('prefix')) { if (! subwhere.hasOwnProperty('prefix')) {
subwhere.prefix = {}; subwhere.prefix = [];
} }
var subprefix = subwhere.prefix; var subprefix = subwhere.prefix;
@ -723,19 +740,11 @@ function defineRoutePart (route, subwhere, parts, pos, constraint, callback) {
console.error("cannot define prefix match within url, ignoring route"); console.error("cannot define prefix match within url, ignoring route");
} }
else { else {
if (subprefix.hasOwnProperty('route')) { subprefix.push({
p1 = subprefix.route.priority || 0; priority: route.priority || 0,
p2 = route.priority || 0; route: route,
callback: callback
if (p1 <= p2) { });
subprefix.route = route;
subprefix.callback = callback;
}
}
else {
subprefix.route = route;
subprefix.callback = callback;
}
} }
} }
} }
@ -776,7 +785,10 @@ function flattenRouting (routes, path, urlParameters, depth, prefix) {
var match; var match;
var result = []; var result = [];
// start with exact matches // .............................................................................
// descend down to the next exact matches
// .............................................................................
if (routes.hasOwnProperty('exact')) { if (routes.hasOwnProperty('exact')) {
for (k in routes.exact) { for (k in routes.exact) {
if (routes.exact.hasOwnProperty(k)) { if (routes.exact.hasOwnProperty(k)) {
@ -792,7 +804,10 @@ function flattenRouting (routes, path, urlParameters, depth, prefix) {
} }
} }
// next are parameter matches // .............................................................................
// descend down the parameter matches
// .............................................................................
if (routes.hasOwnProperty('parameters')) { if (routes.hasOwnProperty('parameters')) {
for (i = 0; i < routes.parameters.length; ++i) { for (i = 0; i < routes.parameters.length; ++i) {
parameter = routes.parameters[i]; parameter = routes.parameters[i];
@ -830,32 +845,41 @@ function flattenRouting (routes, path, urlParameters, depth, prefix) {
} }
} }
// next use the current callback // .............................................................................
if (routes.hasOwnProperty('callback')) { // we have done the depth first descend, now add the current callback(s)
result = result.concat([{ // .............................................................................
if (routes.hasOwnProperty('routes')) {
var sorted = routes.routes.sort(function(a,b) {
return b.priority - a.priority;
});
for (i = 0; i < sorted.length; ++i) {
sorted[i] = {
path: path, path: path,
regexp: new RegExp("^" + path + "$"), regexp: new RegExp("^" + path + "$"),
prefix: prefix, prefix: prefix,
depth: depth, depth: depth,
urlParameters: urlParameters, urlParameters: urlParameters,
callback: routes.callback, callback: sorted[i].callback,
route: routes.route route: sorted[i].route
}]); };
}
result = result.concat(sorted);
} }
// finally use a prefix match // .............................................................................
// finally append the prefix matches
// .............................................................................
if (routes.hasOwnProperty('prefix')) { if (routes.hasOwnProperty('prefix')) {
if (! routes.prefix.hasOwnProperty('callback')) { cur = path + "(/[^/]+)*";
console.error("prefix match must specify a callback"); result = result.concat(flattenRouting(routes.prefix,
} cur,
else { urlParameters._shallowCopy,
cur = path + "(/[^/]+)*"; depth + 1,
result = result.concat(flattenRouting(routes.prefix, true));
cur,
urlParameters._shallowCopy,
depth + 1,
true));
}
} }
return result; return result;

View File

@ -258,7 +258,8 @@ function executeAppScript (app, name, mount, prefix) {
appModule: app.createAppModule(), appModule: app.createAppModule(),
isDevelopment: devel, isDevelopment: devel,
isProduction: ! devel, isProduction: ! devel,
options: app._options options: app._options,
basePath: fs.join(root, app._path)
}; };
var cp = appContext.collectionPrefix; var cp = appContext.collectionPrefix;
@ -472,9 +473,14 @@ function routingAalApp (app, mount, options) {
if (apps.hasOwnProperty(i)) { if (apps.hasOwnProperty(i)) {
var file = apps[i]; var file = apps[i];
var devel = false; var devel = false;
var root;
if (app._id.substr(0,4) === "dev:") { if (app._id.substr(0,4) === "dev:") {
devel = true; devel = true;
root = module.devAppPath();
}
else {
root = module.appPath();
} }
// set up a context for the application start function // set up a context for the application start function
@ -487,6 +493,7 @@ function routingAalApp (app, mount, options) {
collectionPrefix: prefix, // collection prefix collectionPrefix: prefix, // collection prefix
appModule: app.createAppModule(), // app module appModule: app.createAppModule(), // app module
options: options, options: options,
basePath: fs.join(root, app._path),
isDevelopment: devel, isDevelopment: devel,
isProduction: ! devel, isProduction: ! devel,

View File

@ -125,8 +125,6 @@ Application = function (context, options) {
} }
} }
this.isDevelopment = context.isDevelopment;
this.isProduction = context.isProduction;
this.helperCollection = {}; this.helperCollection = {};
this.routingInfo.urlPrefix = urlPrefix; this.routingInfo.urlPrefix = urlPrefix;
@ -144,16 +142,14 @@ Application = function (context, options) {
action: { action: {
callback: myMiddleware.stringRepresentation, callback: myMiddleware.stringRepresentation,
options: { options: {
name: context.name,
version: context.version,
appId: context.appId,
mount: context.mount,
isDevelopment: context.isDevelopment, isDevelopment: context.isDevelopment,
isProduction: context.isProduction, isProduction: context.isProduction,
app: { prefix: context.prefix,
appId: context.appId, options: context.options
name: context.name,
version: context.version,
mount: context.mount,
prefix: context.prefix,
options: context.options
}
} }
} }
} }
@ -409,7 +405,7 @@ _.extend(Application.prototype, {
this.routingInfo.middleware.push({ this.routingInfo.middleware.push({
url: {match: path}, url: {match: path},
action: { action: {
callback: "function (req, res, opts, next) { " + String(func) + "(req, res); next(); }" callback: function (req, res, opts, next) { func(req, res, opts); next(); }
} }
}); });
}, },
@ -442,7 +438,7 @@ _.extend(Application.prototype, {
this.routingInfo.middleware.push({ this.routingInfo.middleware.push({
url: {match: path}, url: {match: path},
action: { action: {
callback: "function (req, res, opts, next) { next(); " + String(func) + "(req, res); }" callback: function (req, res, opts, next) { next(); func(req, res, opts); }
} }
}); });
}, },
@ -855,35 +851,34 @@ BaseMiddleware = function (templateCollection, helperCollection) {
}; };
var trace = options.isDevelopment; var trace = options.isDevelopment;
if (!trace && options.hasOwnProperty("app") && options.app.hasOwnProperty("options")) { if (!trace && options.hasOwnProperty("options")) {
trace = options.app.options.trace; trace = options.options.trace;
} }
if (trace) { if (trace) {
console.log("%s, incoming request from %s: %s", console.log("%s, incoming request from %s: %s",
options.app.mount, options.mount,
request.client.address, request.client.address,
actions.stringifyRequestAddress(request)); actions.stringifyRequestAddress(request));
} }
request = _.extend(request, requestFunctions); _.extend(request, requestFunctions);
response = _.extend(response, responseFunctions); _.extend(response, responseFunctions);
next(); next();
if (trace) { if (trace) {
if (response.hasOwnProperty("body")) { if (response.hasOwnProperty("body")) {
console.log("%s, outgoing response of type %s, body length: %d", console.log("%s, outgoing response of type %s, body length: %d",
options.app.mount, options.mount,
response.contentType, response.contentType,
parseInt(response.body.length, 10)); parseInt(response.body.length, 10));
} else if (response.hasOwnProperty("bodyFromFile")) { } else if (response.hasOwnProperty("bodyFromFile")) {
console.log("%s, outgoing response of type %s, body file: %s", console.log("%s, outgoing response of type %s, body file: %s",
options.app.mount, options.mount,
response.contentType, response.contentType,
response.bodyFromFile); response.bodyFromFile);
} else { } else {
console.log("%s, outgoing response of type %s, no body", console.log("%s, outgoing response of type %s, no body",
options.app.mount, options.mount,
response.contentType); response.contentType);
} }
} }