diff --git a/arangod/Cluster/ClusterInfo.cpp b/arangod/Cluster/ClusterInfo.cpp index 2ef3647ec4..d032dd84cd 100644 --- a/arangod/Cluster/ClusterInfo.cpp +++ b/arangod/Cluster/ClusterInfo.cpp @@ -1687,7 +1687,12 @@ int ClusterInfo::ensureIndexCoordinator( loadPlan(); - TRI_ASSERT(*numberOfShards > 0); + if (*numberOfShards == 0) { + errorMsg = *errMsg; + resultBuilder = *resBuilder; + loadCurrent(); + return TRI_ERROR_NO_ERROR; + } { CONDITION_LOCKER(locker, agencyCallback->_cv); @@ -1902,6 +1907,10 @@ int ClusterInfo::dropIndexCoordinator(std::string const& databaseName, // load our own cache: loadPlan(); + if (*numberOfShards == 0) { + loadCurrent(); + return TRI_ERROR_NO_ERROR; + } { MUTEX_LOCKER(guard, *numberOfShardsMutex); diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index 6fe6ec2e45..d9523266e3 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -794,11 +794,24 @@ static void JS_DocumentVocbaseCol( } +#ifndef USE_ENTERPRISE +//////////////////////////////////////////////////////////////////////////////// +/// @brief unloads a collection, case of a coordinator in a cluster +//////////////////////////////////////////////////////////////////////////////// + +static int ULVocbaseColCoordinator(std::string const& databaseName, + std::string const& collectionCID, + TRI_vocbase_col_status_e status) { + + return ClusterInfo::instance()->setCollectionStatusCoordinator( + databaseName, collectionCID, s); + +} + //////////////////////////////////////////////////////////////////////////////// /// @brief drops a collection, case of a coordinator in a cluster //////////////////////////////////////////////////////////////////////////////// -#ifndef USE_ENTERPRISE static void DropVocbaseColCoordinator( v8::FunctionCallbackInfo const& args, arangodb::LogicalCollection* collection) { @@ -988,37 +1001,41 @@ static void JS_LoadVocbaseCol(v8::FunctionCallbackInfo const& args) { } if (ServerState::instance()->isCoordinator()) { - std::string const databaseName(collection->dbName()); - std::string const cid = collection->cid_as_string(); - - int res = ClusterInfo::instance()->setCollectionStatusCoordinator( - databaseName, cid, TRI_VOC_COL_STATUS_LOADED); - + int res = +#ifdef USE_ENTERPRISE + ULVocbaseColCoordinatorEnterprise( + collection->dbName(), collection->cid_as_string(), + TRI_VOC_COL_STATUS_LOADED); +#else + ULVocbaseColCoordinator( + collection->dbName(), collection->cid_as_string(), + TRI_VOC_COL_STATUS_LOADED); +#endif if (res != TRI_ERROR_NO_ERROR) { TRI_V8_THROW_EXCEPTION(res); } - TRI_V8_RETURN_UNDEFINED(); } SingleCollectionTransaction trx( - V8TransactionContext::Create(collection->vocbase(), true), - collection->cid(), TRI_TRANSACTION_READ); - + V8TransactionContext::Create(collection->vocbase(), true), + collection->cid(), TRI_TRANSACTION_READ); + int res = trx.begin(); - + if (res != TRI_ERROR_NO_ERROR) { TRI_V8_THROW_EXCEPTION(res); } - + res = trx.finish(res); if (res != TRI_ERROR_NO_ERROR) { TRI_V8_THROW_EXCEPTION(res); } - + TRI_V8_RETURN_UNDEFINED(); TRI_V8_TRY_CATCH_END + } //////////////////////////////////////////////////////////////////////////////// @@ -2415,11 +2432,18 @@ static void JS_UnloadVocbaseCol( int res; if (ServerState::instance()->isCoordinator()) { - std::string const databaseName(collection->dbName()); - - res = ClusterInfo::instance()->setCollectionStatusCoordinator( - databaseName, collection->cid_as_string(), + + res = +#ifdef USE_ENTERPRISE + ULVocbaseColCoordinatorEnterprise( + collection->dbName(), collection->cid_as_string(), TRI_VOC_COL_STATUS_UNLOADED); +#else + ULVocbaseColCoordinator( + collection->dbName(), collection->cid_as_string(), + TRI_VOC_COL_STATUS_UNLOADED); +#endif + } else { res = collection->vocbase()->unloadCollection(collection, false); } diff --git a/arangod/V8Server/v8-collection.h b/arangod/V8Server/v8-collection.h index f3750ff280..024a9c3cae 100644 --- a/arangod/V8Server/v8-collection.h +++ b/arangod/V8Server/v8-collection.h @@ -27,6 +27,7 @@ #include "Basics/Common.h" #include "Utils/CollectionNameResolver.h" #include "V8Server/v8-vocbase.h" +#include "VocBase/vocbase.h" namespace arangodb { class LogicalCollection; @@ -65,5 +66,11 @@ void TRI_InitV8Collection(v8::Handle context, void DropVocbaseColCoordinatorEnterprise( v8::FunctionCallbackInfo const& args, arangodb::LogicalCollection* collection); + +int ULVocbaseColCoordinatorEnterprise(std::string const& databaseName, + std::string const& collectionCID, + TRI_vocbase_col_status_e status); + #endif + #endif diff --git a/arangod/V8Server/v8-vocindex.cpp b/arangod/V8Server/v8-vocindex.cpp index 7f970044d1..fbbb211b77 100644 --- a/arangod/V8Server/v8-vocindex.cpp +++ b/arangod/V8Server/v8-vocindex.cpp @@ -448,15 +448,11 @@ static int EnhanceIndexJson(v8::FunctionCallbackInfo const& args, /// @brief ensures an index, coordinator case //////////////////////////////////////////////////////////////////////////////// -int EnsureIndexCoordinator( - LogicalCollection const* collection, VPackSlice const slice, bool create, - VPackBuilder& resultBuilder, std::string& errorMsg) { - TRI_ASSERT(collection != nullptr); +int EnsureIndexCoordinator(std::string const& databaseName, + std::string const& cid, + VPackSlice const slice, bool create, + VPackBuilder& resultBuilder, std::string& errorMsg) { TRI_ASSERT(!slice.isNone()); - - std::string const databaseName(collection->dbName()); - std::string const cid = collection->cid_as_string(); - return ClusterInfo::instance()->ensureIndexCoordinator( databaseName, cid, slice, create, &arangodb::Index::Compare, resultBuilder, errorMsg, 360.0); @@ -604,9 +600,13 @@ static void EnsureIndex(v8::FunctionCallbackInfo const& args, VPackBuilder resultBuilder; std::string errorMsg; #ifdef USE_ENTERPRISE - int res = EnsureIndexCoordinatorEnterprise(collection, slice, create, resultBuilder, errorMsg); + int res = EnsureIndexCoordinatorEnterprise(collection, slice, create, + resultBuilder, errorMsg); #else - int res = EnsureIndexCoordinator(collection, slice, create, resultBuilder, errorMsg); + std::string const databaseName(collection->dbName()); + std::string const cid = collection->cid_as_string(); + int res = EnsureIndexCoordinator(databaseName, cid, slice, create, + resultBuilder, errorMsg); #endif if (res != TRI_ERROR_NO_ERROR) { TRI_V8_THROW_EXCEPTION_MESSAGE(res, errorMsg); @@ -728,54 +728,15 @@ static void JS_LookupIndexVocbaseCol( /// @brief drops an index, coordinator case //////////////////////////////////////////////////////////////////////////////// -static void DropIndexCoordinator( - v8::FunctionCallbackInfo const& args, - arangodb::LogicalCollection const* collection, v8::Handle const val) { - v8::Isolate* isolate = args.GetIsolate(); - v8::HandleScope scope(isolate); - - std::string collectionName; - TRI_idx_iid_t iid = 0; - - // extract the index identifier from a string - if (val->IsString() || val->IsStringObject() || val->IsNumber()) { - if (!IsIndexHandle(val, collectionName, iid)) { - TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_INDEX_HANDLE_BAD); - } - } - - // extract the index identifier from an object - else if (val->IsObject()) { - TRI_GET_GLOBALS(); - - v8::Handle obj = val->ToObject(); - TRI_GET_GLOBAL_STRING(IdKey); - v8::Handle iidVal = obj->Get(IdKey); - - if (!IsIndexHandle(iidVal, collectionName, iid)) { - TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_INDEX_HANDLE_BAD); - } - } - - if (!collectionName.empty()) { - CollectionNameResolver resolver(collection->vocbase()); - - if (!EqualCollection(&resolver, collectionName, collection)) { - TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_CROSS_COLLECTION_REQUEST); - } - } - - std::string const databaseName(collection->dbName()); - std::string const cid = collection->cid_as_string(); +int DropIndexCoordinator( + std::string const& databaseName, + std::string const& cid, + TRI_idx_iid_t const iid) { std::string errorMsg; - int res = ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid, - iid, errorMsg, 0.0); + return ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid, + iid, errorMsg, 0.0); - if (res == TRI_ERROR_NO_ERROR) { - TRI_V8_RETURN_TRUE(); - } - TRI_V8_RETURN_FALSE(); } //////////////////////////////////////////////////////////////////////////////// @@ -801,8 +762,49 @@ static void JS_DropIndexVocbaseCol( } if (ServerState::instance()->isCoordinator()) { - DropIndexCoordinator(args, collection, args[0]); - return; + std::string collectionName; + TRI_idx_iid_t iid = 0; + v8::Handle const val = args[0]; + + // extract the index identifier from a string + if (val->IsString() || val->IsStringObject() || val->IsNumber()) { + if (!IsIndexHandle(val, collectionName, iid)) { + TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_INDEX_HANDLE_BAD); + } + } + + // extract the index identifier from an object + else if (val->IsObject()) { + TRI_GET_GLOBALS(); + + v8::Handle obj = val->ToObject(); + TRI_GET_GLOBAL_STRING(IdKey); + v8::Handle iidVal = obj->Get(IdKey); + + if (!IsIndexHandle(iidVal, collectionName, iid)) { + TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_INDEX_HANDLE_BAD); + } + } + + if (!collectionName.empty()) { + CollectionNameResolver resolver(collection->vocbase()); + + if (!EqualCollection(&resolver, collectionName, collection)) { + TRI_V8_THROW_EXCEPTION(TRI_ERROR_ARANGO_CROSS_COLLECTION_REQUEST); + } + } + +#ifdef USE_ENTERPRISE + int res = DropIndexCoordinatorEnterprise(collection, iid); +#else + std::string const databaseName(collection->dbName()); + std::string const cid = collection->cid_as_string(); + int res = DropIndexCoordinator(databaseName, cid, iid); +#endif + if (res == TRI_ERROR_NO_ERROR) { + TRI_V8_RETURN_TRUE(); + } + TRI_V8_RETURN_FALSE(); } READ_LOCKER(readLocker, collection->vocbase()->_inventoryLock); diff --git a/arangod/V8Server/v8-vocindex.h b/arangod/V8Server/v8-vocindex.h index 3b9adeea39..426dfc82b5 100644 --- a/arangod/V8Server/v8-vocindex.h +++ b/arangod/V8Server/v8-vocindex.h @@ -61,7 +61,7 @@ std::unique_ptr CreateCollectionCoordinatorEnterpri arangodb::velocypack::Slice parameters); #endif -int EnsureIndexCoordinator(arangodb::LogicalCollection const* collection, +int EnsureIndexCoordinator(std::string const& dbName, std::string const& cid, arangodb::velocypack::Slice const slice, bool create, arangodb::velocypack::Builder& resultBuilder, std::string& errorMessage); @@ -73,4 +73,14 @@ int EnsureIndexCoordinatorEnterprise( arangodb::velocypack::Builder& resultBuilder, std::string& errorMessage); #endif +int DropIndexCoordinator( + std::string const& databaseName, + std::string const& cid, + TRI_idx_iid_t const iid); + +#ifdef USE_ENTERPRISE +int DropIndexCoordinatorEnterprise( + arangodb::LogicalCollection const* collection, TRI_idx_iid_t const iid); +#endif + #endif diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js index b86b2ba945..0cc5a57253 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/graphViewer.js @@ -289,11 +289,11 @@ var tmpNodes = {}; var tmpEdges = {}; - _.each(this.graphData.modified.nodes, function (node) { + _.each(this.currentGraph.graph.nodes(), function (node) { tmpNodes[node.id] = undefined; }); - _.each(this.graphData.modified.edges, function (edge) { + _.each(self.currentGraph.graph.edges(), function (edge) { tmpEdges[edge.id] = undefined; }); @@ -358,7 +358,7 @@ self.nodeEdgesCount = {}; var handledEdges = {}; - _.each(this.graphData.modified.edges, function (edge) { + _.each(this.currentGraph.graph.edges(), function (edge) { if (handledEdges[edge.id] === undefined) { handledEdges[edge.id] = true; @@ -394,13 +394,25 @@ }, switchEdgeType: function (edgeType) { + var data = { + nodes: this.currentGraph.graph.nodes(), + edges: this.currentGraph.graph.edges(), + settings: {} + }; + this.killCurrentGraph(); - this.renderGraph(this.graphData.modified, null, false, null, null, edgeType); + this.renderGraph(data, null, false, null, null, edgeType); }, switchLayout: function (layout) { + var data = { + nodes: this.currentGraph.graph.nodes(), + edges: this.currentGraph.graph.edges(), + settings: {} + }; + this.killCurrentGraph(); - this.renderGraph(this.graphData.modified, null, false, layout); + this.renderGraph(data, null, false, layout); if ($('#g_nodeColorByCollection').val() === 'true') { this.switchNodeColorByCollection(true); @@ -1696,12 +1708,6 @@ renderGraph: function (graph, toFocus, aqlMode, layout, renderer, edgeType) { var self = this; - - if (this.graphData === undefined) { - this.graphData = {}; - this.graphData.modified = graph; - } - this.graphSettings = graph.settings; var color = '#2ecc71'; @@ -2114,7 +2120,7 @@ // allow draggin nodes } else if (self.algorithm === 'force') { // add buttons for start/stopping calculation - var style2 = 'color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; bottom: 40px;'; + var style2 = 'color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; bottom: 40px; z-index: 9999;'; if (self.aqlMode) { style2 = 'color: rgb(64, 74, 83); cursor: pointer; position: absolute; right: 30px; margin-top: -30px;'; diff --git a/js/apps/system/_admin/aardvark/APP/frontend/js/views/queryView.js b/js/apps/system/_admin/aardvark/APP/frontend/js/views/queryView.js index cafcac6d05..f4bb0f4dd7 100644 --- a/js/apps/system/_admin/aardvark/APP/frontend/js/views/queryView.js +++ b/js/apps/system/_admin/aardvark/APP/frontend/js/views/queryView.js @@ -1517,7 +1517,7 @@ }); data.bindVars = this.bindParamTableObj; } - if (Object.keys(data.bindVars).length > 0) { + if (Object.keys(bindVars).length > 0) { data.bindVars = bindVars; } diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index ee0342ed79..3ab22357f4 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -258,6 +258,7 @@ "ERROR_SERVICE_MOUNTPOINT_CONFLICT" : { "code" : 3011, "message" : "mountpoint already in use" }, "ERROR_MODULE_NOT_FOUND" : { "code" : 3100, "message" : "cannot locate module" }, "ERROR_MODULE_FAILURE" : { "code" : 3103, "message" : "failed to invoke module" }, + "ERROR_NO_SMART_COLLECTION" : { "code" : 4000, "message" : "collection is not smart" }, "ERROR_DISPATCHER_IS_STOPPING" : { "code" : 21001, "message" : "dispatcher stopped" }, "ERROR_QUEUE_UNKNOWN" : { "code" : 21002, "message" : "named queue does not exist" }, "ERROR_QUEUE_FULL" : { "code" : 21003, "message" : "named queue is full" } diff --git a/lib/Basics/errors.dat b/lib/Basics/errors.dat index e5ac1b0189..9d72efd678 100755 --- a/lib/Basics/errors.dat +++ b/lib/Basics/errors.dat @@ -360,6 +360,13 @@ ERROR_SERVICE_MOUNTPOINT_CONFLICT,3011,"mountpoint already in use","A service ha ERROR_MODULE_NOT_FOUND,3100,"cannot locate module","The module path could not be resolved." ERROR_MODULE_FAILURE,3103,"failed to invoke module","Failed to invoke the module in its context." + +################################################################################ +## Enterprise errors +################################################################################ + +ERROR_NO_SMART_COLLECTION,4000,"collection is not smart","The requested collection needs to be smart, but it ain't" + ################################################################################ ## Dispatcher errors ################################################################################ diff --git a/lib/Basics/voc-errors.cpp b/lib/Basics/voc-errors.cpp index d242393100..d4b16d8076 100644 --- a/lib/Basics/voc-errors.cpp +++ b/lib/Basics/voc-errors.cpp @@ -254,6 +254,7 @@ void TRI_InitializeErrorMessages () { REG_ERROR(ERROR_SERVICE_MOUNTPOINT_CONFLICT, "mountpoint already in use"); REG_ERROR(ERROR_MODULE_NOT_FOUND, "cannot locate module"); REG_ERROR(ERROR_MODULE_FAILURE, "failed to invoke module"); + REG_ERROR(ERROR_NO_SMART_COLLECTION, "collection is not smart"); REG_ERROR(ERROR_DISPATCHER_IS_STOPPING, "dispatcher stopped"); REG_ERROR(ERROR_QUEUE_UNKNOWN, "named queue does not exist"); REG_ERROR(ERROR_QUEUE_FULL, "named queue is full"); diff --git a/lib/Basics/voc-errors.h b/lib/Basics/voc-errors.h index 6a7031c068..691bcba22f 100644 --- a/lib/Basics/voc-errors.h +++ b/lib/Basics/voc-errors.h @@ -605,6 +605,8 @@ /// The module path could not be resolved. /// - 3103: @LIT{failed to invoke module} /// Failed to invoke the module in its context. +/// - 4000: @LIT{collection is not smart} +/// The requested collection needs to be smart, but it ain't /// - 21001: @LIT{dispatcher stopped} /// Will be returned if a shutdown is in progress. /// - 21002: @LIT{named queue does not exist} @@ -3195,6 +3197,16 @@ void TRI_InitializeErrorMessages (); #define TRI_ERROR_MODULE_FAILURE (3103) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 4000: ERROR_NO_SMART_COLLECTION +/// +/// collection is not smart +/// +/// The requested collection needs to be smart, but it ain't +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_NO_SMART_COLLECTION (4000) + //////////////////////////////////////////////////////////////////////////////// /// @brief 21001: ERROR_DISPATCHER_IS_STOPPING ///