mirror of https://gitee.com/bigwinds/arangodb
dropping databases, unfinished
This commit is contained in:
parent
803bd32ebc
commit
5bc1e5ecea
|
@ -7529,7 +7529,7 @@ static v8::Handle<v8::Value> JS_UpdateVocbase (v8::Arguments const& argv) {
|
|||
/// Returns the server version string.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_VersionVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_VersionServer (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
return scope.Close(v8::String::New(TRI_VERSION));
|
||||
|
@ -7543,7 +7543,7 @@ static v8::Handle<v8::Value> JS_VersionVocbase (v8::Arguments const& argv) {
|
|||
/// Returns the path.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_PathVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_PathDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TRI_vocbase_t* vocbase = GetContextVocBase();
|
||||
|
@ -7559,7 +7559,7 @@ static v8::Handle<v8::Value> JS_PathVocbase (v8::Arguments const& argv) {
|
|||
/// Returns the name of the current database.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_NameVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_NameDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TRI_vocbase_t* vocbase = GetContextVocBase();
|
||||
|
@ -7576,7 +7576,7 @@ static v8::Handle<v8::Value> JS_NameVocbase (v8::Arguments const& argv) {
|
|||
/// database.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_IsSystemVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_IsSystemDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
TRI_vocbase_t* vocbase = GetContextVocBase();
|
||||
|
@ -7599,7 +7599,7 @@ static v8::Handle<v8::Value> JS_IsSystemVocbase (v8::Arguments const& argv) {
|
|||
/// credentials.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_UseVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_UseDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (argv.Length() != 1) {
|
||||
|
@ -7628,7 +7628,7 @@ static v8::Handle<v8::Value> JS_UseVocbase (v8::Arguments const& argv) {
|
|||
/// Returns the list of all databases.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_ListVocbases (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_ListDatabases (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (argv.Length() != 0) {
|
||||
|
@ -7667,7 +7667,7 @@ static v8::Handle<v8::Value> JS_ListVocbases (v8::Arguments const& argv) {
|
|||
/// Returns the new database as an object.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_CreateUserVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_CreateDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (argv.Length() < 1) {
|
||||
|
@ -7772,7 +7772,7 @@ static v8::Handle<v8::Value> JS_CreateUserVocbase (v8::Arguments const& argv) {
|
|||
/// default database. The default database itself cannot be dropped.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static v8::Handle<v8::Value> JS_DropUserVocbase (v8::Arguments const& argv) {
|
||||
static v8::Handle<v8::Value> JS_DropDatabase (v8::Arguments const& argv) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
if (argv.Length() != 1) {
|
||||
|
@ -7790,48 +7790,13 @@ static v8::Handle<v8::Value> JS_DropUserVocbase (v8::Arguments const& argv) {
|
|||
}
|
||||
|
||||
const string name = TRI_ObjectToString(argv[0]);
|
||||
TRI_v8_global_t* v8g = (TRI_v8_global_t*) v8::Isolate::GetCurrent()->GetData();
|
||||
|
||||
// exclusive lock start
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// TODO FIXME
|
||||
/*
|
||||
VocbaseManager::manager.lockCreation();
|
||||
int res = TRI_DropDatabaseServer((TRI_server_t*) v8g->_server, name.c_str());
|
||||
|
||||
int res = VocbaseManager::manager.deleteVocbase(name);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
TRI_vocbase_col_t* col = TRI_LookupCollectionByNameVocBase(vocbase, TRI_COL_NAME_DATABASES);
|
||||
|
||||
if (col == 0) {
|
||||
VocbaseManager::manager.unlockCreation();
|
||||
TRI_V8_EXCEPTION_INTERNAL(scope, "cannot extract collection");
|
||||
}
|
||||
|
||||
CollectionNameResolver resolver(col->_vocbase);
|
||||
SingleCollectionWriteTransaction<EmbeddableTransaction<V8TransactionContext>, 1> trx(col->_vocbase, resolver, col->_cid);
|
||||
|
||||
res = trx.begin();
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
VocbaseManager::manager.unlockCreation();
|
||||
TRI_V8_EXCEPTION(scope, res);
|
||||
}
|
||||
|
||||
trx.deleteDocument(name.c_str(), TRI_DOC_UPDATE_LAST_WRITE, false, 0, 0);
|
||||
|
||||
res = trx.finish(res);
|
||||
}
|
||||
|
||||
VocbaseManager::manager.unlockCreation();
|
||||
|
||||
// exclusive lock end
|
||||
// ---------------------------------------------------------
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_V8_EXCEPTION(scope, res);
|
||||
}
|
||||
*/
|
||||
|
||||
return scope.Close(v8::True());
|
||||
}
|
||||
|
@ -8567,14 +8532,26 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context,
|
|||
TRI_AddMethodVocbase(rt, "_createEdgeCollection", JS_CreateEdgeCollectionVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_document", JS_DocumentVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_exists", JS_ExistsVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_isSystem", JS_IsSystemVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_name", JS_NameVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_path", JS_PathVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_remove", JS_RemoveVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_replace", JS_ReplaceVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_update", JS_UpdateVocbase);
|
||||
TRI_AddMethodVocbase(rt, "_version", JS_VersionVocbase);
|
||||
|
||||
TRI_AddMethodVocbase(rt, "_version", JS_VersionServer);
|
||||
|
||||
TRI_AddMethodVocbase(rt, "_isSystem", JS_IsSystemDatabase);
|
||||
TRI_AddMethodVocbase(rt, "_name", JS_NameDatabase);
|
||||
TRI_AddMethodVocbase(rt, "_path", JS_PathDatabase);
|
||||
TRI_AddMethodVocbase(rt, "_createDatabase", JS_CreateDatabase);
|
||||
TRI_AddMethodVocbase(rt, "_dropDatabase", JS_DropDatabase);
|
||||
TRI_AddMethodVocbase(rt, "_listDatabases", JS_ListDatabases);
|
||||
TRI_AddMethodVocbase(rt, "_useDatabase", JS_UseDatabase);
|
||||
/* TODO: FIXME
|
||||
TRI_AddGlobalFunctionVocbase(context, "USE_DATABASE", JS_UseVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "LIST_DATABASES", JS_ListVocbases, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "CREATE_DATABASE", JS_CreateUserVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "DROP_DATABASE", JS_DropUserVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "ADD_ENDPOINT", JS_AddEndpoint, true);
|
||||
*/
|
||||
v8g->VocbaseTempl = v8::Persistent<v8::ObjectTemplate>::New(isolate, rt);
|
||||
TRI_AddGlobalFunctionVocbase(context, "ArangoDatabase", ft->GetFunction());
|
||||
|
||||
|
@ -8737,12 +8714,6 @@ void TRI_InitV8VocBridge (v8::Handle<v8::Context> context,
|
|||
TRI_AddGlobalFunctionVocbase(context, "RELOAD_AUTH", JS_ReloadAuth, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "TRANSACTION", JS_Transaction, true);
|
||||
|
||||
TRI_AddGlobalFunctionVocbase(context, "USE_DATABASE", JS_UseVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "LIST_DATABASES", JS_ListVocbases, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "CREATE_DATABASE", JS_CreateUserVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "DROP_DATABASE", JS_DropUserVocbase, true);
|
||||
TRI_AddGlobalFunctionVocbase(context, "ADD_ENDPOINT", JS_AddEndpoint, true);
|
||||
|
||||
// .............................................................................
|
||||
// create global variables
|
||||
// .............................................................................
|
||||
|
|
|
@ -499,6 +499,8 @@ static int OpenDatabases (TRI_server_t* server) {
|
|||
TRI_json_t* json;
|
||||
TRI_json_t const* deletedJson;
|
||||
TRI_json_t const* nameJson;
|
||||
TRI_json_t const* idJson;
|
||||
TRI_voc_tick_t id;
|
||||
TRI_vocbase_defaults_t defaults;
|
||||
char const* name;
|
||||
char* databaseDirectory;
|
||||
|
@ -598,6 +600,20 @@ static int OpenDatabases (TRI_server_t* server) {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
idJson = TRI_LookupArrayJson(json, "id");
|
||||
|
||||
if (! TRI_IsStringJson(idJson)) {
|
||||
LOG_ERROR("database directory '%s' does not contain a valid parameters file",
|
||||
databaseDirectory);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, databaseDirectory);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
// skip this database
|
||||
continue;
|
||||
}
|
||||
|
||||
id = (TRI_voc_tick_t) TRI_UInt64String(idJson->_value._string.data);
|
||||
|
||||
nameJson = TRI_LookupArrayJson(json, "name");
|
||||
|
||||
|
@ -635,7 +651,7 @@ static int OpenDatabases (TRI_server_t* server) {
|
|||
// .............................................................................
|
||||
|
||||
// try to open this database
|
||||
vocbase = TRI_OpenVocBase(databaseDirectory, databaseName, &defaults, server->_wasShutdownCleanly);
|
||||
vocbase = TRI_OpenVocBase(databaseDirectory, id, databaseName, &defaults, server->_wasShutdownCleanly);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, databaseName);
|
||||
|
||||
|
@ -934,20 +950,19 @@ static int SaveDatabaseParameters (TRI_voc_tick_t id,
|
|||
/// @brief create a new database directory and return its name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int CreateDatabaseDirectory (TRI_server_t* server,
|
||||
static int CreateDatabaseDirectory (TRI_server_t* server,
|
||||
TRI_voc_tick_t tick,
|
||||
char const* databaseName,
|
||||
TRI_vocbase_defaults_t const* defaults,
|
||||
char** name) {
|
||||
char* tickString;
|
||||
char* dname;
|
||||
char* file;
|
||||
TRI_voc_tick_t tick;
|
||||
int res;
|
||||
|
||||
assert(server != NULL);
|
||||
assert(databaseName != NULL);
|
||||
|
||||
tick = TRI_NewTickServer();
|
||||
tickString = TRI_StringUInt64(tick);
|
||||
|
||||
if (tickString == NULL) {
|
||||
|
@ -1122,7 +1137,7 @@ static int InitDatabases (TRI_server_t* server) {
|
|||
|
||||
// no databases found, i.e. there is no system database!
|
||||
// create a database for the system database
|
||||
res = CreateDatabaseDirectory(server, TRI_VOC_SYSTEM_DATABASE, &server->_defaults, &name);
|
||||
res = CreateDatabaseDirectory(server, TRI_NewTickServer(), TRI_VOC_SYSTEM_DATABASE, &server->_defaults, &name);
|
||||
|
||||
if (res == TRI_ERROR_NO_ERROR) {
|
||||
if (TRI_PushBackVectorString(&names, name) != TRI_ERROR_NO_ERROR) {
|
||||
|
@ -1505,6 +1520,7 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
TRI_vocbase_defaults_t const* defaults,
|
||||
TRI_vocbase_t** database) {
|
||||
TRI_vocbase_t* vocbase;
|
||||
TRI_voc_tick_t tick;
|
||||
char* file;
|
||||
char* path;
|
||||
int res;
|
||||
|
@ -1528,7 +1544,7 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
TRI_ReadUnlockReadWriteLock(&server->_lock);
|
||||
TRI_UnlockMutex(&server->_createLock);
|
||||
|
||||
return TRI_ERROR_ARANGO_DATABASE_NAME_USED;
|
||||
return TRI_ERROR_ARANGO_DUPLICATE_NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1536,9 +1552,9 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
// name not yet in use, release the read lock
|
||||
TRI_ReadUnlockReadWriteLock(&server->_lock);
|
||||
|
||||
|
||||
// create the database directory
|
||||
res = CreateDatabaseDirectory(server, name, defaults, &file);
|
||||
tick = TRI_NewTickServer();
|
||||
res = CreateDatabaseDirectory(server, tick, name, defaults, &file);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_UnlockMutex(&server->_createLock);
|
||||
|
@ -1549,7 +1565,7 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
path = TRI_Concatenate2File(server->_databasePath, file);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
|
||||
|
||||
vocbase = TRI_OpenVocBase(path, name, defaults, false);
|
||||
vocbase = TRI_OpenVocBase(path, tick, name, defaults, false);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, path);
|
||||
|
||||
if (vocbase == NULL) {
|
||||
|
@ -1583,6 +1599,37 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief drops an existing database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_DropDatabaseServer (TRI_server_t* server,
|
||||
char const* name) {
|
||||
TRI_vocbase_t* vocbase;
|
||||
int res;
|
||||
|
||||
if (TRI_EqualString(name, TRI_VOC_SYSTEM_DATABASE)) {
|
||||
return TRI_ERROR_FORBIDDEN;
|
||||
}
|
||||
|
||||
TRI_WriteLockReadWriteLock(&server->_lock);
|
||||
|
||||
vocbase = TRI_RemoveKeyAssociativePointer(&server->_databases, name);
|
||||
if (vocbase == NULL) {
|
||||
res = TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
|
||||
}
|
||||
else {
|
||||
assert(! vocbase->_isSystem);
|
||||
|
||||
res = SaveDatabaseParameters(vocbase->_id, name, true, &server->_defaults, vocbase->_path);
|
||||
// TODO FIXME: perform actual drop
|
||||
}
|
||||
|
||||
TRI_WriteUnlockReadWriteLock(&server->_lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get a database by its name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -167,6 +167,13 @@ int TRI_CreateDatabaseServer (TRI_server_t*,
|
|||
TRI_vocbase_defaults_t const*,
|
||||
struct TRI_vocbase_s**);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief drops an existing database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_DropDatabaseServer (TRI_server_t*,
|
||||
char const*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get a database by its name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1205,6 +1205,7 @@ void TRI_SetupReplicationVocBase (bool disableLogger,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vocbase_t* TRI_OpenVocBase (char const* path,
|
||||
TRI_voc_tick_t id,
|
||||
char const* name,
|
||||
TRI_vocbase_defaults_t const* defaults,
|
||||
bool iterateMarkers) {
|
||||
|
@ -1228,6 +1229,7 @@ TRI_vocbase_t* TRI_OpenVocBase (char const* path,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
vocbase->_id = id;
|
||||
vocbase->_path = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, path);
|
||||
vocbase->_name = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, name);
|
||||
vocbase->_isSystem = TRI_EqualString(name, TRI_VOC_SYSTEM_DATABASE);
|
||||
|
|
|
@ -318,6 +318,7 @@ struct TRI_vocbase_defaults_s;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_vocbase_s {
|
||||
TRI_voc_tick_t _id;
|
||||
char* _path; // path to the data directory
|
||||
|
||||
TRI_voc_size_t _defaultMaximalSize;
|
||||
|
@ -493,7 +494,8 @@ void TRI_SetupReplicationVocBase (bool,
|
|||
/// @brief opens an existing database, loads all collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vocbase_t* TRI_OpenVocBase (char const*,
|
||||
TRI_vocbase_t* TRI_OpenVocBase (char const*,
|
||||
TRI_voc_tick_t,
|
||||
char const*,
|
||||
struct TRI_vocbase_defaults_s const*,
|
||||
bool);
|
||||
|
|
|
@ -88,11 +88,10 @@
|
|||
"ERROR_ARANGO_DOCUMENT_KEY_MISSING" : { "code" : 1226, "message" : "missing document key" },
|
||||
"ERROR_ARANGO_DOCUMENT_TYPE_INVALID" : { "code" : 1227, "message" : "invalid document type" },
|
||||
"ERROR_ARANGO_DATABASE_NOT_FOUND" : { "code" : 1228, "message" : "database not found" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_USED" : { "code" : 1229, "message" : "database name already used" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_INVALID" : { "code" : 1230, "message" : "database name invalid" },
|
||||
"ERROR_ARANGO_USE_SYSTEM_DATABASE" : { "code" : 1231, "message" : "operation only allowed in system database" },
|
||||
"ERROR_ARANGO_DATADIR_LOCKED" : { "code" : 1232, "message" : "database directory is locked" },
|
||||
"ERROR_ARANGO_DATADIR_UNLOCKABLE" : { "code" : 1233, "message" : "cannot lock database directory" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_INVALID" : { "code" : 1229, "message" : "database name invalid" },
|
||||
"ERROR_ARANGO_USE_SYSTEM_DATABASE" : { "code" : 1230, "message" : "operation only allowed in system database" },
|
||||
"ERROR_ARANGO_DATADIR_LOCKED" : { "code" : 1231, "message" : "database directory is locked" },
|
||||
"ERROR_ARANGO_DATADIR_UNLOCKABLE" : { "code" : 1232, "message" : "cannot lock database directory" },
|
||||
"ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" },
|
||||
"ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" },
|
||||
"ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" },
|
||||
|
|
|
@ -88,11 +88,10 @@
|
|||
"ERROR_ARANGO_DOCUMENT_KEY_MISSING" : { "code" : 1226, "message" : "missing document key" },
|
||||
"ERROR_ARANGO_DOCUMENT_TYPE_INVALID" : { "code" : 1227, "message" : "invalid document type" },
|
||||
"ERROR_ARANGO_DATABASE_NOT_FOUND" : { "code" : 1228, "message" : "database not found" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_USED" : { "code" : 1229, "message" : "database name already used" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_INVALID" : { "code" : 1230, "message" : "database name invalid" },
|
||||
"ERROR_ARANGO_USE_SYSTEM_DATABASE" : { "code" : 1231, "message" : "operation only allowed in system database" },
|
||||
"ERROR_ARANGO_DATADIR_LOCKED" : { "code" : 1232, "message" : "database directory is locked" },
|
||||
"ERROR_ARANGO_DATADIR_UNLOCKABLE" : { "code" : 1233, "message" : "cannot lock database directory" },
|
||||
"ERROR_ARANGO_DATABASE_NAME_INVALID" : { "code" : 1229, "message" : "database name invalid" },
|
||||
"ERROR_ARANGO_USE_SYSTEM_DATABASE" : { "code" : 1230, "message" : "operation only allowed in system database" },
|
||||
"ERROR_ARANGO_DATADIR_LOCKED" : { "code" : 1231, "message" : "database directory is locked" },
|
||||
"ERROR_ARANGO_DATADIR_UNLOCKABLE" : { "code" : 1232, "message" : "cannot lock database directory" },
|
||||
"ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" },
|
||||
"ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" },
|
||||
"ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" },
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true */
|
||||
/*global require, exports, TRANSACTION, CREATE_DATABASE, DROP_DATABASE, USE_DATABASE,
|
||||
LIST_DATABASES */
|
||||
/*global require, exports, TRANSACTION */
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief ArangoDatabase
|
||||
|
@ -127,51 +126,6 @@ ArangoDatabase.prototype._query = function (query, bindVars, cursorOptions, opti
|
|||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- database functions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @addtogroup ArangoShell
|
||||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief create a new database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._createDatabase = function (name, options) {
|
||||
return CREATE_DATABASE(name, options);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete an existing database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._dropDatabase = function (name) {
|
||||
return DROP_DATABASE(name);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief lists all existing databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._listDatabases = function () {
|
||||
return LIST_DATABASES();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief use a different database
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoDatabase.prototype._useDatabase = function (name) {
|
||||
return USE_DATABASE(name);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- transactions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -106,11 +106,10 @@ ERROR_ARANGO_OUT_OF_KEYS,1225,"out of keys","Will be raised when a key generator
|
|||
ERROR_ARANGO_DOCUMENT_KEY_MISSING,1226,"missing document key","Will be raised when a document key is missing."
|
||||
ERROR_ARANGO_DOCUMENT_TYPE_INVALID,1227,"invalid document type","Will be raised when there is an attempt to create a document with an invalid type."
|
||||
ERROR_ARANGO_DATABASE_NOT_FOUND,1228,"database not found","Will be raised when a non-existing database is accessed."
|
||||
ERROR_ARANGO_DATABASE_NAME_USED,1229,"database name already used","Will be raised when a duplicate database name is used."
|
||||
ERROR_ARANGO_DATABASE_NAME_INVALID,1230,"database name invalid","Will be raised when an invalid database name is used."
|
||||
ERROR_ARANGO_USE_SYSTEM_DATABASE,1231,"operation only allowed in system database","Will be raised when an operation is requested in a database other than the system database."
|
||||
ERROR_ARANGO_DATADIR_LOCKED,1232,"database directory is locked","Will be raised when the server's database directory is locked (mainly because another ArangoDB instance is already running)."
|
||||
ERROR_ARANGO_DATADIR_UNLOCKABLE,1233,"cannot lock database directory","Will be raised when the server cannot lock the database directory on startup."
|
||||
ERROR_ARANGO_DATABASE_NAME_INVALID,1229,"database name invalid","Will be raised when an invalid database name is used."
|
||||
ERROR_ARANGO_USE_SYSTEM_DATABASE,1230,"operation only allowed in system database","Will be raised when an operation is requested in a database other than the system database."
|
||||
ERROR_ARANGO_DATADIR_LOCKED,1231,"database directory is locked","Will be raised when the server's database directory is locked (mainly because another ArangoDB instance is already running)."
|
||||
ERROR_ARANGO_DATADIR_UNLOCKABLE,1232,"cannot lock database directory","Will be raised when the server cannot lock the database directory on startup."
|
||||
|
||||
################################################################################
|
||||
## ArangoDB storage errors
|
||||
|
|
|
@ -84,7 +84,6 @@ void TRI_InitialiseErrorMessages (void) {
|
|||
REG_ERROR(ERROR_ARANGO_DOCUMENT_KEY_MISSING, "missing document key");
|
||||
REG_ERROR(ERROR_ARANGO_DOCUMENT_TYPE_INVALID, "invalid document type");
|
||||
REG_ERROR(ERROR_ARANGO_DATABASE_NOT_FOUND, "database not found");
|
||||
REG_ERROR(ERROR_ARANGO_DATABASE_NAME_USED, "database name already used");
|
||||
REG_ERROR(ERROR_ARANGO_DATABASE_NAME_INVALID, "database name invalid");
|
||||
REG_ERROR(ERROR_ARANGO_USE_SYSTEM_DATABASE, "operation only allowed in system database");
|
||||
REG_ERROR(ERROR_ARANGO_DATADIR_LOCKED, "database directory is locked");
|
||||
|
|
|
@ -173,17 +173,15 @@ extern "C" {
|
|||
/// invalid type.
|
||||
/// - 1228: @LIT{database not found}
|
||||
/// Will be raised when a non-existing database is accessed.
|
||||
/// - 1229: @LIT{database name already used}
|
||||
/// Will be raised when a duplicate database name is used.
|
||||
/// - 1230: @LIT{database name invalid}
|
||||
/// - 1229: @LIT{database name invalid}
|
||||
/// Will be raised when an invalid database name is used.
|
||||
/// - 1231: @LIT{operation only allowed in system database}
|
||||
/// - 1230: @LIT{operation only allowed in system database}
|
||||
/// Will be raised when an operation is requested in a database other than
|
||||
/// the system database.
|
||||
/// - 1232: @LIT{database directory is locked}
|
||||
/// - 1231: @LIT{database directory is locked}
|
||||
/// Will be raised when the server's database directory is locked (mainly
|
||||
/// because another ArangoDB instance is already running).
|
||||
/// - 1233: @LIT{cannot lock database directory}
|
||||
/// - 1232: @LIT{cannot lock database directory}
|
||||
/// Will be raised when the server cannot lock the database directory on
|
||||
/// startup.
|
||||
/// - 1300: @LIT{datafile full}
|
||||
|
@ -1230,27 +1228,17 @@ void TRI_InitialiseErrorMessages (void);
|
|||
#define TRI_ERROR_ARANGO_DATABASE_NOT_FOUND (1228)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1229: ERROR_ARANGO_DATABASE_NAME_USED
|
||||
///
|
||||
/// database name already used
|
||||
///
|
||||
/// Will be raised when a duplicate database name is used.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_ARANGO_DATABASE_NAME_USED (1229)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1230: ERROR_ARANGO_DATABASE_NAME_INVALID
|
||||
/// @brief 1229: ERROR_ARANGO_DATABASE_NAME_INVALID
|
||||
///
|
||||
/// database name invalid
|
||||
///
|
||||
/// Will be raised when an invalid database name is used.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_ARANGO_DATABASE_NAME_INVALID (1230)
|
||||
#define TRI_ERROR_ARANGO_DATABASE_NAME_INVALID (1229)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1231: ERROR_ARANGO_USE_SYSTEM_DATABASE
|
||||
/// @brief 1230: ERROR_ARANGO_USE_SYSTEM_DATABASE
|
||||
///
|
||||
/// operation only allowed in system database
|
||||
///
|
||||
|
@ -1258,10 +1246,10 @@ void TRI_InitialiseErrorMessages (void);
|
|||
/// system database.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_ARANGO_USE_SYSTEM_DATABASE (1231)
|
||||
#define TRI_ERROR_ARANGO_USE_SYSTEM_DATABASE (1230)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1232: ERROR_ARANGO_DATADIR_LOCKED
|
||||
/// @brief 1231: ERROR_ARANGO_DATADIR_LOCKED
|
||||
///
|
||||
/// database directory is locked
|
||||
///
|
||||
|
@ -1269,10 +1257,10 @@ void TRI_InitialiseErrorMessages (void);
|
|||
/// because another ArangoDB instance is already running).
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_ARANGO_DATADIR_LOCKED (1232)
|
||||
#define TRI_ERROR_ARANGO_DATADIR_LOCKED (1231)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1233: ERROR_ARANGO_DATADIR_UNLOCKABLE
|
||||
/// @brief 1232: ERROR_ARANGO_DATADIR_UNLOCKABLE
|
||||
///
|
||||
/// cannot lock database directory
|
||||
///
|
||||
|
@ -1280,7 +1268,7 @@ void TRI_InitialiseErrorMessages (void);
|
|||
/// startup.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TRI_ERROR_ARANGO_DATADIR_UNLOCKABLE (1233)
|
||||
#define TRI_ERROR_ARANGO_DATADIR_UNLOCKABLE (1232)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief 1300: ERROR_ARANGO_DATAFILE_FULL
|
||||
|
|
|
@ -81,15 +81,15 @@ ApplicationEndpointServer::ApplicationEndpointServer (ApplicationServer* applica
|
|||
ApplicationScheduler* applicationScheduler,
|
||||
ApplicationDispatcher* applicationDispatcher,
|
||||
std::string const& authenticationRealm,
|
||||
HttpHandlerFactory::flush_fptr flushAuthentication,
|
||||
HttpHandlerFactory::context_fptr setContext)
|
||||
HttpHandlerFactory::context_fptr setContext,
|
||||
void* setContextData)
|
||||
: ApplicationFeature("EndpointServer"),
|
||||
_applicationServer(applicationServer),
|
||||
_applicationScheduler(applicationScheduler),
|
||||
_applicationDispatcher(applicationDispatcher),
|
||||
_authenticationRealm(authenticationRealm),
|
||||
_setContext(setContext),
|
||||
_flushAuthentication(flushAuthentication),
|
||||
_setContextData(setContextData),
|
||||
_handlerFactory(0),
|
||||
_servers(),
|
||||
_endpointList(),
|
||||
|
@ -317,8 +317,8 @@ bool ApplicationEndpointServer::prepare () {
|
|||
_endpointList.dump();
|
||||
|
||||
_handlerFactory = new HttpHandlerFactory(_authenticationRealm,
|
||||
_flushAuthentication,
|
||||
_setContext);
|
||||
_setContext,
|
||||
_setContextData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -86,8 +86,8 @@ namespace triagens {
|
|||
ApplicationScheduler*,
|
||||
ApplicationDispatcher*,
|
||||
std::string const&,
|
||||
HttpHandlerFactory::flush_fptr,
|
||||
HttpHandlerFactory::context_fptr);
|
||||
HttpHandlerFactory::context_fptr,
|
||||
void*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
|
@ -252,10 +252,10 @@ namespace triagens {
|
|||
HttpHandlerFactory::context_fptr _setContext;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief authentication cache flush callback function
|
||||
/// @brief database passed to callback functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpHandlerFactory::flush_fptr _flushAuthentication;
|
||||
|
||||
void* _setContextData;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the handler factory
|
||||
|
|
|
@ -56,11 +56,11 @@ using namespace std;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpHandlerFactory::HttpHandlerFactory (std::string const& authenticationRealm,
|
||||
flush_fptr flushAuthentication,
|
||||
context_fptr setContext)
|
||||
context_fptr setContext,
|
||||
void* setContextData)
|
||||
: _authenticationRealm(authenticationRealm),
|
||||
_setContext(setContext),
|
||||
_flushAuthentication(flushAuthentication),
|
||||
_setContextData(setContextData),
|
||||
_notFound(0) {
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ HttpHandlerFactory::HttpHandlerFactory (std::string const& authenticationRealm,
|
|||
HttpHandlerFactory::HttpHandlerFactory (HttpHandlerFactory const& that)
|
||||
: _authenticationRealm(that._authenticationRealm),
|
||||
_setContext(that._setContext),
|
||||
_flushAuthentication(that._flushAuthentication),
|
||||
_setContextData(that._setContextData),
|
||||
_constructors(that._constructors),
|
||||
_datas(that._datas),
|
||||
_prefixes(that._prefixes),
|
||||
|
@ -86,7 +86,7 @@ HttpHandlerFactory& HttpHandlerFactory::operator= (HttpHandlerFactory const& tha
|
|||
if (this != &that) {
|
||||
_authenticationRealm = that._authenticationRealm,
|
||||
_setContext = that._setContext,
|
||||
_flushAuthentication = that._flushAuthentication,
|
||||
_setContextData = that._setContextData,
|
||||
_constructors = that._constructors;
|
||||
_datas = that._datas;
|
||||
_prefixes = that._prefixes;
|
||||
|
@ -146,15 +146,15 @@ pair<size_t, size_t> HttpHandlerFactory::sizeRestrictions () const {
|
|||
HttpResponse::HttpResponseCode HttpHandlerFactory::authenticateRequest (HttpRequest* request) {
|
||||
RequestContext* rc = request->getRequestContext();
|
||||
|
||||
if (! rc) {
|
||||
if (rc == 0) {
|
||||
if (! setRequestContext(request)) {
|
||||
return HttpResponse::NOT_FOUND;
|
||||
}
|
||||
|
||||
rc = request->getRequestContext();
|
||||
}
|
||||
|
||||
if (! rc) {
|
||||
return HttpResponse::NOT_FOUND;
|
||||
}
|
||||
assert(rc != 0);
|
||||
|
||||
return rc->authenticate();
|
||||
}
|
||||
|
@ -163,8 +163,8 @@ HttpResponse::HttpResponseCode HttpHandlerFactory::authenticateRequest (HttpRequ
|
|||
/// @brief set request context, wrapper method
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool HttpHandlerFactory::setRequestContext (HttpRequest * request) {
|
||||
return _setContext(request);
|
||||
bool HttpHandlerFactory::setRequestContext (HttpRequest* request) {
|
||||
return _setContext(request, _setContextData);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -102,15 +102,9 @@ namespace triagens {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief context handler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef bool (*context_fptr) (HttpRequest*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief authentication cache invalidation handler
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef bool (*flush_fptr) ();
|
||||
typedef bool (*context_fptr) (HttpRequest*, void*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
|
@ -132,8 +126,8 @@ namespace triagens {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpHandlerFactory (std::string const&,
|
||||
flush_fptr,
|
||||
context_fptr);
|
||||
context_fptr,
|
||||
void*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clones a handler factory
|
||||
|
@ -184,26 +178,27 @@ namespace triagens {
|
|||
/// @brief authenticates a new request, wrapper method
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual HttpResponse::HttpResponseCode authenticateRequest (HttpRequest * request);
|
||||
virtual HttpResponse::HttpResponseCode authenticateRequest (HttpRequest*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set request context, wrapper method
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual bool setRequestContext (HttpRequest * request);
|
||||
virtual bool setRequestContext (HttpRequest*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the authentication realm
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::string const& authenticationRealm (HttpRequest * request) const;
|
||||
virtual std::string const& authenticationRealm (HttpRequest*) const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new request
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual HttpRequest* createRequest (ConnectionInfo const& info,
|
||||
char const* ptr, size_t length);
|
||||
virtual HttpRequest* createRequest (ConnectionInfo const&,
|
||||
char const*,
|
||||
size_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a new handler
|
||||
|
@ -265,10 +260,10 @@ namespace triagens {
|
|||
context_fptr _setContext;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief authentication cache flush callback
|
||||
/// @brief set context data
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
flush_fptr _flushAuthentication;
|
||||
void* _setContextData;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief authentication lock for cache
|
||||
|
|
Loading…
Reference in New Issue