1
0
Fork 0

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

This commit is contained in:
Kaveh Vahedipour 2016-10-05 13:06:58 +02:00
commit 0872e17f7f
7 changed files with 101 additions and 59 deletions

View File

@ -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);

View File

@ -448,15 +448,11 @@ static int EnhanceIndexJson(v8::FunctionCallbackInfo<v8::Value> 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<v8::Value> 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<v8::Value> const& args,
arangodb::LogicalCollection const* collection, v8::Handle<v8::Value> 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<v8::Object> obj = val->ToObject();
TRI_GET_GLOBAL_STRING(IdKey);
v8::Handle<v8::Value> 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<v8::Value> 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<v8::Object> obj = val->ToObject();
TRI_GET_GLOBAL_STRING(IdKey);
v8::Handle<v8::Value> 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);

View File

@ -61,7 +61,7 @@ std::unique_ptr<arangodb::LogicalCollection> 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

View File

@ -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" }

View File

@ -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
################################################################################

View File

@ -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");

View File

@ -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
///