mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'generic-col-types' of https://github.com/arangodb/arangodb into generic-col-types
This commit is contained in:
commit
a6697636ed
|
@ -657,7 +657,6 @@ std::shared_ptr<LogicalCollection> ClusterInfo::getCollection(
|
||||||
}
|
}
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
|
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
|
||||||
"Collection not found: " + collectionID);
|
"Collection not found: " + collectionID);
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -563,12 +563,13 @@ int revisionOnCoordinator(std::string const& dbname,
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
if (collinfo == nullptr) {
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
rid = 0;
|
rid = 0;
|
||||||
|
|
||||||
|
@ -634,12 +635,13 @@ int figuresOnCoordinator(std::string const& dbname, std::string const& collname,
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
if (collinfo == nullptr) {
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
// If we get here, the sharding attributes are not only _key, therefore
|
// If we get here, the sharding attributes are not only _key, therefore
|
||||||
// we have to contact everybody:
|
// we have to contact everybody:
|
||||||
|
@ -700,12 +702,13 @@ int countOnCoordinator(std::string const& dbname, std::string const& collname,
|
||||||
result = 0;
|
result = 0;
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
if (collinfo == nullptr) {
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
auto shards = collinfo->shardIds();
|
auto shards = collinfo->shardIds();
|
||||||
std::vector<ClusterCommRequest> requests;
|
std::vector<ClusterCommRequest> requests;
|
||||||
|
@ -768,12 +771,13 @@ int createDocumentOnCoordinator(
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
if (collinfo == nullptr) {
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
std::string const collid = collinfo->cid_as_string();
|
std::string const collid = collinfo->cid_as_string();
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
|
@ -902,11 +906,13 @@ int deleteDocumentOnCoordinator(
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
if (collinfo == nullptr) {
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
bool useDefaultSharding = collinfo->usesDefaultShardKeys();
|
bool useDefaultSharding = collinfo->usesDefaultShardKeys();
|
||||||
std::string collid = collinfo->cid_as_string();
|
std::string collid = collinfo->cid_as_string();
|
||||||
bool useMultiple = slice.isArray();
|
bool useMultiple = slice.isArray();
|
||||||
|
@ -1128,12 +1134,13 @@ int truncateCollectionOnCoordinator(std::string const& dbname,
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
if (collinfo == nullptr) {
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
// Some stuff to prepare cluster-intern requests:
|
// Some stuff to prepare cluster-intern requests:
|
||||||
// We have to contact everybody:
|
// We have to contact everybody:
|
||||||
|
@ -1183,11 +1190,14 @@ int getDocumentOnCoordinator(
|
||||||
ClusterComm* cc = ClusterComm::instance();
|
ClusterComm* cc = ClusterComm::instance();
|
||||||
|
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo;
|
||||||
ci->getCollection(dbname, collname);
|
try {
|
||||||
if (collinfo == nullptr) {
|
collinfo = ci->getCollection(dbname, collname);
|
||||||
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(collinfo != nullptr);
|
||||||
|
|
||||||
std::string collid = collinfo->cid_as_string();
|
std::string collid = collinfo->cid_as_string();
|
||||||
|
|
||||||
// If _key is the one and only sharding attribute, we can do this quickly,
|
// If _key is the one and only sharding attribute, we can do this quickly,
|
||||||
|
@ -1436,10 +1446,7 @@ static void insertIntoShardMap(
|
||||||
// First determine the collection ID from the name:
|
// First determine the collection ID from the name:
|
||||||
std::shared_ptr<LogicalCollection> collinfo =
|
std::shared_ptr<LogicalCollection> collinfo =
|
||||||
ci->getCollection(dbname, splitId[0]);
|
ci->getCollection(dbname, splitId[0]);
|
||||||
if (collinfo == nullptr) {
|
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND,
|
|
||||||
"Collection not found: " + splitId[0]);
|
|
||||||
}
|
|
||||||
std::string collid = collinfo->cid_as_string();
|
std::string collid = collinfo->cid_as_string();
|
||||||
if (collinfo->usesDefaultShardKeys()) {
|
if (collinfo->usesDefaultShardKeys()) {
|
||||||
// We only need add one resp. shard
|
// We only need add one resp. shard
|
||||||
|
|
|
@ -676,9 +676,7 @@ static void JS_GetCollectionInfoClusterInfo(
|
||||||
|
|
||||||
std::shared_ptr<LogicalCollection> ci = ClusterInfo::instance()->getCollection(
|
std::shared_ptr<LogicalCollection> ci = ClusterInfo::instance()->getCollection(
|
||||||
TRI_ObjectToString(args[0]), TRI_ObjectToString(args[1]));
|
TRI_ObjectToString(args[0]), TRI_ObjectToString(args[1]));
|
||||||
if (ci == nullptr) {
|
TRI_ASSERT(ci != nullptr);
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
||||||
std::string const cid = ci->cid_as_string();
|
std::string const cid = ci->cid_as_string();
|
||||||
|
|
|
@ -1653,12 +1653,13 @@ int RestReplicationHandler::processRestoreCollectionCoordinator(
|
||||||
|
|
||||||
std::string dbName = _vocbase->name();
|
std::string dbName = _vocbase->name();
|
||||||
|
|
||||||
// in a cluster, we only look up by name:
|
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
|
|
||||||
|
try {
|
||||||
|
// in a cluster, we only look up by name:
|
||||||
std::shared_ptr<LogicalCollection> col = ci->getCollection(dbName, name);
|
std::shared_ptr<LogicalCollection> col = ci->getCollection(dbName, name);
|
||||||
|
|
||||||
// drop an existing collection if it exists
|
// drop an existing collection if it exists
|
||||||
if (col != nullptr) {
|
|
||||||
if (dropExisting) {
|
if (dropExisting) {
|
||||||
int res = ci->dropCollectionCoordinator(dbName, col->cid_as_string(),
|
int res = ci->dropCollectionCoordinator(dbName, col->cid_as_string(),
|
||||||
errorMsg, 0.0);
|
errorMsg, 0.0);
|
||||||
|
@ -1686,6 +1687,7 @@ int RestReplicationHandler::processRestoreCollectionCoordinator(
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// now re-create the collection
|
// now re-create the collection
|
||||||
|
@ -1975,12 +1977,14 @@ int RestReplicationHandler::processRestoreIndexesCoordinator(
|
||||||
|
|
||||||
// in a cluster, we only look up by name:
|
// in a cluster, we only look up by name:
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
std::shared_ptr<LogicalCollection> col = ci->getCollection(dbName, name);
|
std::shared_ptr<LogicalCollection> col;
|
||||||
|
try {
|
||||||
if (col == nullptr) {
|
col = ci->getCollection(dbName, name);
|
||||||
|
} catch (...) {
|
||||||
errorMsg = "could not find collection '" + name + "'";
|
errorMsg = "could not find collection '" + name + "'";
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
TRI_ASSERT(col != nullptr);
|
||||||
|
|
||||||
int res = TRI_ERROR_NO_ERROR;
|
int res = TRI_ERROR_NO_ERROR;
|
||||||
for (VPackSlice const& idxDef : VPackArrayIterator(indexes)) {
|
for (VPackSlice const& idxDef : VPackArrayIterator(indexes)) {
|
||||||
|
@ -2484,9 +2488,10 @@ void RestReplicationHandler::handleCommandRestoreDataCoordinator() {
|
||||||
|
|
||||||
// in a cluster, we only look up by name:
|
// in a cluster, we only look up by name:
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
std::shared_ptr<LogicalCollection> col = ci->getCollection(dbName, name);
|
std::shared_ptr<LogicalCollection> col;
|
||||||
|
try {
|
||||||
if (col == nullptr) {
|
col = ci->getCollection(dbName, name);
|
||||||
|
} catch (...) {
|
||||||
generateError(rest::ResponseCode::BAD,
|
generateError(rest::ResponseCode::BAD,
|
||||||
TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -77,11 +77,13 @@ TRI_voc_cid_t CollectionNameResolver::getCollectionIdCluster(
|
||||||
return cid;
|
return cid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// We have to look up the collection info:
|
// We have to look up the collection info:
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
auto cinfo = ci->getCollection(_vocbase->name(), name);
|
auto cinfo = ci->getCollection(_vocbase->name(), name);
|
||||||
if (cinfo != nullptr) {
|
TRI_ASSERT(cinfo != nullptr);
|
||||||
return cinfo->cid();
|
return cinfo->cid();
|
||||||
|
} catch (...) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -162,11 +164,13 @@ TRI_col_type_e CollectionNameResolver::getCollectionTypeCluster(
|
||||||
arangodb::basics::StringUtils::uint64(name))));
|
arangodb::basics::StringUtils::uint64(name))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// We have to look up the collection info:
|
// We have to look up the collection info:
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
auto cinfo = ci->getCollection(_vocbase->name(), name);
|
auto cinfo = ci->getCollection(_vocbase->name(), name);
|
||||||
if (cinfo != nullptr) {
|
TRI_ASSERT(cinfo != nullptr);
|
||||||
return cinfo->type();
|
return cinfo->type();
|
||||||
|
} catch(...) {
|
||||||
}
|
}
|
||||||
return TRI_COL_TYPE_UNKNOWN;
|
return TRI_COL_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,13 +173,13 @@ static int ParseDocumentOrDocumentHandle(v8::Isolate* isolate,
|
||||||
// name
|
// name
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
ClusterInfo* ci = ClusterInfo::instance();
|
ClusterInfo* ci = ClusterInfo::instance();
|
||||||
|
try {
|
||||||
std::shared_ptr<LogicalCollection> col =
|
std::shared_ptr<LogicalCollection> col =
|
||||||
ci->getCollection(vocbase->name(), collectionName);
|
ci->getCollection(vocbase->name(), collectionName);
|
||||||
if (col == nullptr) {
|
collection = new LogicalCollection(col);
|
||||||
// collection not found
|
} catch (...) {
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
|
||||||
}
|
}
|
||||||
collection = new LogicalCollection(col);
|
|
||||||
} else {
|
} else {
|
||||||
collection = resolver->getCollectionStruct(collectionName);
|
collection = resolver->getCollectionStruct(collectionName);
|
||||||
}
|
}
|
||||||
|
@ -2200,14 +2200,14 @@ static void JS_StatusVocbaseCol(
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
std::string const databaseName(collection->dbName());
|
std::string const databaseName(collection->dbName());
|
||||||
|
|
||||||
|
try {
|
||||||
std::shared_ptr<LogicalCollection> const ci =
|
std::shared_ptr<LogicalCollection> const ci =
|
||||||
ClusterInfo::instance()->getCollection(databaseName,
|
ClusterInfo::instance()->getCollection(databaseName,
|
||||||
collection->cid_as_string());
|
collection->cid_as_string());
|
||||||
|
TRI_V8_RETURN(v8::Number::New(isolate, (int)ci->getStatusLocked()));
|
||||||
if (ci == nullptr) {
|
} catch (...) {
|
||||||
TRI_V8_RETURN(v8::Number::New(isolate, (int)TRI_VOC_COL_STATUS_DELETED));
|
TRI_V8_RETURN(v8::Number::New(isolate, (int)TRI_VOC_COL_STATUS_DELETED));
|
||||||
}
|
}
|
||||||
TRI_V8_RETURN(v8::Number::New(isolate, (int)ci->getStatusLocked()));
|
|
||||||
}
|
}
|
||||||
// fallthru intentional
|
// fallthru intentional
|
||||||
|
|
||||||
|
@ -2362,14 +2362,13 @@ static void JS_TypeVocbaseCol(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
std::string const databaseName = collection->dbName();
|
std::string const databaseName = collection->dbName();
|
||||||
|
|
||||||
|
try {
|
||||||
std::shared_ptr<LogicalCollection> const ci =
|
std::shared_ptr<LogicalCollection> const ci =
|
||||||
ClusterInfo::instance()->getCollection(databaseName,
|
ClusterInfo::instance()->getCollection(databaseName,
|
||||||
collection->cid_as_string());
|
collection->cid_as_string());
|
||||||
|
|
||||||
if (ci == nullptr) {
|
|
||||||
TRI_V8_RETURN(v8::Number::New(isolate, (int)collection->type()));
|
|
||||||
} else {
|
|
||||||
TRI_V8_RETURN(v8::Number::New(isolate, (int)ci->type()));
|
TRI_V8_RETURN(v8::Number::New(isolate, (int)ci->type()));
|
||||||
|
} catch (...) {
|
||||||
|
TRI_V8_RETURN(v8::Number::New(isolate, (int)collection->type()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fallthru intentional
|
// fallthru intentional
|
||||||
|
@ -2521,15 +2520,14 @@ static void JS_CollectionVocbase(
|
||||||
|
|
||||||
if (ServerState::instance()->isCoordinator()) {
|
if (ServerState::instance()->isCoordinator()) {
|
||||||
std::string const name = TRI_ObjectToString(val);
|
std::string const name = TRI_ObjectToString(val);
|
||||||
|
try {
|
||||||
std::shared_ptr<LogicalCollection> const ci =
|
std::shared_ptr<LogicalCollection> const ci =
|
||||||
ClusterInfo::instance()->getCollection(vocbase->name(), name);
|
ClusterInfo::instance()->getCollection(vocbase->name(), name);
|
||||||
|
collection = new LogicalCollection(ci);
|
||||||
if (ci == nullptr) {
|
} catch (...) {
|
||||||
// not found
|
// not found
|
||||||
TRI_V8_RETURN_NULL();
|
TRI_V8_RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
collection = new LogicalCollection(ci);
|
|
||||||
} else {
|
} else {
|
||||||
collection = GetCollectionFromArgument(vocbase, val);
|
collection = GetCollectionFromArgument(vocbase, val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1890,6 +1890,7 @@ static void MapGetVocBase(v8::Local<v8::String> const name,
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// do not propagate exception from here
|
// do not propagate exception from here
|
||||||
|
TRI_V8_RETURN(v8::Handle<v8::Value>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collection == nullptr) {
|
if (collection == nullptr) {
|
||||||
|
|
|
@ -764,9 +764,9 @@ static void CreateCollectionCoordinator(
|
||||||
if (otherCid != 0) {
|
if (otherCid != 0) {
|
||||||
std::string otherCidString
|
std::string otherCidString
|
||||||
= arangodb::basics::StringUtils::itoa(otherCid);
|
= arangodb::basics::StringUtils::itoa(otherCid);
|
||||||
|
try {
|
||||||
std::shared_ptr<LogicalCollection> collInfo =
|
std::shared_ptr<LogicalCollection> collInfo =
|
||||||
ci->getCollection(databaseName, otherCidString);
|
ci->getCollection(databaseName, otherCidString);
|
||||||
if (collInfo != nullptr) {
|
|
||||||
auto shards = collInfo->shardIds();
|
auto shards = collInfo->shardIds();
|
||||||
auto shardList = ci->getShardList(otherCidString);
|
auto shardList = ci->getShardList(otherCidString);
|
||||||
for (auto const& s : *shardList) {
|
for (auto const& s : *shardList) {
|
||||||
|
@ -777,6 +777,7 @@ static void CreateCollectionCoordinator(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue