1
0
Fork 0

issue 504: return Result instead of int from all ClusterInfo functions (#7954)

This commit is contained in:
Vasiliy 2019-01-16 18:07:27 +03:00 committed by Andrey Abramov
parent d245e5c96d
commit 8b94be9bf1
13 changed files with 563 additions and 686 deletions

File diff suppressed because it is too large Load Diff

View File

@ -364,32 +364,39 @@ class ClusterInfo {
//////////////////////////////////////////////////////////////////////////////
/// @brief create database in coordinator
//////////////////////////////////////////////////////////////////////////////
int createDatabaseCoordinator(std::string const&, arangodb::velocypack::Slice const&,
std::string&, double);
Result createDatabaseCoordinator( // create database
std::string const& name, // database name
velocypack::Slice const& slice, // database definition
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief drop database in coordinator
//////////////////////////////////////////////////////////////////////////////
int dropDatabaseCoordinator(std::string const& name, std::string& errorMsg, double timeout);
Result dropDatabaseCoordinator( // drop database
std::string const& name, // database name
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief create collection in coordinator
//////////////////////////////////////////////////////////////////////////////
int createCollectionCoordinator(std::string const& databaseName,
Result createCollectionCoordinator( // create collection
std::string const& databaseName, // database name
std::string const& collectionID, uint64_t numberOfShards,
uint64_t replicationFactor, bool waitForReplication,
arangodb::velocypack::Slice const& json,
std::string& errorMsg, double timeout);
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief drop collection in coordinator
//////////////////////////////////////////////////////////////////////////////
int dropCollectionCoordinator(std::string const& databaseName, std::string const& collectionID,
std::string& errorMsg, double timeout);
Result dropCollectionCoordinator( // drop collection
std::string const& databaseName, // database name
std::string const& collectionID, // collection identifier
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief set collection properties in coordinator
@ -410,16 +417,19 @@ class ClusterInfo {
//////////////////////////////////////////////////////////////////////////////
/// @brief create view in coordinator
//////////////////////////////////////////////////////////////////////////////
int createViewCoordinator(std::string const& databaseName, std::string const& viewID,
arangodb::velocypack::Slice json, std::string& errorMsg);
Result createViewCoordinator( // create view
std::string const& databaseName, // database name
std::string const& viewID, // view identifier
velocypack::Slice json // view definition
);
//////////////////////////////////////////////////////////////////////////////
/// @brief drop view in coordinator
//////////////////////////////////////////////////////////////////////////////
int dropViewCoordinator(std::string const& databaseName,
std::string const& viewID, std::string& errorMsg);
Result dropViewCoordinator( // drop view
std::string const& databaseName, // database name
std::string const& viewID // view identifier
);
//////////////////////////////////////////////////////////////////////////////
/// @brief set view properties in coordinator
@ -431,18 +441,23 @@ class ClusterInfo {
//////////////////////////////////////////////////////////////////////////////
/// @brief ensure an index in coordinator.
//////////////////////////////////////////////////////////////////////////////
int ensureIndexCoordinator(std::string const& databaseName, std::string const& collectionID,
Result ensureIndexCoordinator( // create index
std::string const& databaseName, // database name
std::string const& collectionID, // collection identifier
arangodb::velocypack::Slice const& slice, bool create,
arangodb::velocypack::Builder& resultBuilder,
std::string& errorMsg, double timeout);
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief drop an index in coordinator.
//////////////////////////////////////////////////////////////////////////////
int dropIndexCoordinator(std::string const& databaseName, std::string const& collectionID,
TRI_idx_iid_t iid, std::string& errorMsg, double timeout);
Result dropIndexCoordinator( // drop index
std::string const& databaseName, // database name
std::string const& collectionID, // collection identifier
TRI_idx_iid_t iid, // index identifier
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief (re-)load the information about servers from the agency
@ -629,12 +644,13 @@ class ClusterInfo {
//////////////////////////////////////////////////////////////////////////////
/// @brief ensure an index in coordinator.
//////////////////////////////////////////////////////////////////////////////
int ensureIndexCoordinatorInner(std::string const& databaseName,
Result ensureIndexCoordinatorInner( // create index
std::string const& databaseName, // database name
std::string const& collectionID, std::string const& idSlice,
arangodb::velocypack::Slice const& slice, bool create,
arangodb::velocypack::Builder& resultBuilder,
std::string& errorMsg, double timeout);
double timeout // request timeout
);
//////////////////////////////////////////////////////////////////////////////
/// @brief object for agency communication
@ -780,4 +796,4 @@ class ClusterInfo {
} // end namespace arangodb
#endif
#endif

View File

@ -2596,21 +2596,21 @@ std::shared_ptr<LogicalCollection> ClusterMethods::persistCollectionInAgency(
std::unordered_set<std::string> const ignoreKeys{
"allowUserKeys", "cid", "globallyUniqueId", "count",
"planId", "version", "objectId"};
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
col->setStatus(TRI_VOC_COL_STATUS_LOADED);
VPackBuilder velocy = col->toVelocyPackIgnore(ignoreKeys, false, false);
auto& dbName = col->vocbase().name();
std::string errorMsg;
int myerrno = ci->createCollectionCoordinator(dbName, std::to_string(col->id()),
auto res = ci->createCollectionCoordinator( // create collection
dbName, std::to_string(col->id()),
col->numberOfShards(),
col->replicationFactor(), waitForSyncReplication,
velocy.slice(), errorMsg, 240.0);
velocy.slice(), // collection definition
240.0 // request timeout
);
if (myerrno != TRI_ERROR_NO_ERROR) {
if (errorMsg.empty()) {
errorMsg = TRI_errno_string(myerrno);
}
THROW_ARANGO_EXCEPTION_MESSAGE(myerrno, errorMsg);
if (!res.ok()) {
THROW_ARANGO_EXCEPTION(res);
}
ci->loadPlan();

View File

@ -1004,14 +1004,14 @@ Result RestReplicationHandler::processRestoreCollectionCoordinator(
// drop an existing collection if it exists
if (dropExisting) {
std::string errorMsg;
int res = ci->dropCollectionCoordinator(dbName, std::to_string(col->id()),
errorMsg, 0.0);
auto result =
ci->dropCollectionCoordinator(dbName, std::to_string(col->id()), 0.0);
if (res == TRI_ERROR_FORBIDDEN ||
res == TRI_ERROR_CLUSTER_MUST_NOT_DROP_COLL_OTHER_DISTRIBUTESHARDSLIKE) {
if (TRI_ERROR_FORBIDDEN == result.errorNumber() // forbidden
|| TRI_ERROR_CLUSTER_MUST_NOT_DROP_COLL_OTHER_DISTRIBUTESHARDSLIKE == result.errorNumber()) {
// some collections must not be dropped
res = truncateCollectionOnCoordinator(dbName, name);
auto res = truncateCollectionOnCoordinator(dbName, name);
if (res != TRI_ERROR_NO_ERROR) {
return Result(
res,
@ -1019,12 +1019,15 @@ Result RestReplicationHandler::processRestoreCollectionCoordinator(
"unable to truncate collection (dropping is forbidden): '") +
name + "'");
}
return Result(res);
}
if (res != TRI_ERROR_NO_ERROR) {
return Result(res, std::string("unable to drop collection '") + name +
"': " + TRI_errno_string(res));
if (!result.ok()) {
return Result( // result
result.errorNumber(), // code
std::string("unable to drop collection '") + name + "': " + result.errorMessage()
);
}
} else {
return Result(TRI_ERROR_ARANGO_DUPLICATE_NAME,
@ -1718,19 +1721,20 @@ Result RestReplicationHandler::processRestoreIndexesCoordinator(VPackSlice const
"Cluster");
Result res;
for (VPackSlice const& idxDef : VPackArrayIterator(indexes)) {
VPackSlice type = idxDef.get(StaticStrings::IndexType);
if (type.isString() && (type.copyString() == "primary" || type.copyString() == "edge")) {
// must ignore these types of indexes during restore
continue;
}
VPackBuilder tmp;
std::string errorMsg;
res = ci->ensureIndexCoordinator( // returns int that gets converted to
// result
dbName, std::to_string(col->id()), idxDef, true, tmp, errorMsg,
cluster->indexCreationTimeout());
res = ci->ensureIndexCoordinator( // result
dbName, std::to_string(col->id()), idxDef, true, tmp, cluster->indexCreationTimeout()
);
if (res.fail()) {
return res.reset(res.errorNumber(), "could not create index: " + res.errorMessage());

View File

@ -253,22 +253,12 @@ Result LogicalView::rename(std::string&& newName) {
}
builder.close();
res = engine->createViewCoordinator( // create view
vocbase.name(), std::to_string(impl->id()), builder.slice() // args
);
std::string error;
auto resNum =
engine->createViewCoordinator(vocbase.name(), std::to_string(impl->id()),
builder.slice(), error);
if (TRI_ERROR_NO_ERROR != resNum) {
if (error.empty()) {
error = TRI_errno_string(resNum);
}
return arangodb::Result(
resNum,
std::string("failure during ClusterInfo persistance of created view "
"while creating arangosearch View in database '") +
vocbase.name() + "', error: " + error);
if (!res.ok()) {
return res;
}
view = engine->getView(vocbase.name(),
@ -306,22 +296,9 @@ Result LogicalView::rename(std::string&& newName) {
view.name() + "' from database '" + view.vocbase().name() + "'");
}
std::string error;
auto res = engine->dropViewCoordinator(view.vocbase().name(),
std::to_string(view.id()), error);
if (TRI_ERROR_NO_ERROR == res) {
return Result();
}
if (error.empty()) {
error = TRI_errno_string(res);
}
return Result(res,
std::string("failure during ClusterInfo removal of view '") +
view.name() + "' from database '" +
view.vocbase().name() + "': " + error);
return engine->dropViewCoordinator( // drop view
view.vocbase().name(), std::to_string(view.id()) // args
);
} catch (basics::Exception const& e) {
return Result(e.code()); // noexcept constructor
} catch (...) {
@ -536,4 +513,4 @@ Result LogicalView::rename(std::string&& newName) {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -558,12 +558,12 @@ static Result DropVocbaseColCoordinator(arangodb::LogicalCollection* collection,
auto& databaseName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
ClusterInfo* ci = ClusterInfo::instance();
std::string errorMsg;
auto res = ci->dropCollectionCoordinator(databaseName, cid, 300.0);
int res = ci->dropCollectionCoordinator(databaseName, cid, errorMsg, 300.0);
if (res != TRI_ERROR_NO_ERROR) {
return Result(res, errorMsg);
if (!res.ok()) {
return res;
}
collection->setStatus(TRI_VOC_COL_STATUS_DELETED);
return TRI_ERROR_NO_ERROR;

View File

@ -212,12 +212,12 @@ arangodb::Result Databases::create(std::string const& dbName, VPackSlice const&
}
ClusterInfo* ci = ClusterInfo::instance();
std::string errorMsg;
auto res = ci->createDatabaseCoordinator(dbName, builder.slice(), 120.0);
int res = ci->createDatabaseCoordinator(dbName, builder.slice(), errorMsg, 120.0);
if (res != TRI_ERROR_NO_ERROR) {
return Result(res);
if (!res.ok()) {
return res;
}
// database was created successfully in agency
// now wait for heartbeat thread to create the database object
@ -311,24 +311,25 @@ int dropDBCoordinator(std::string const& dbName) {
// Arguments are already checked, there is exactly one argument
DatabaseFeature* databaseFeature = DatabaseFeature::DATABASE;
TRI_vocbase_t* vocbase = databaseFeature->useDatabase(dbName);
if (vocbase == nullptr) {
return TRI_ERROR_ARANGO_DATABASE_NOT_FOUND;
}
TRI_voc_tick_t const id = vocbase->id();
vocbase->release();
ClusterInfo* ci = ClusterInfo::instance();
std::string errorMsg;
auto res = ci->dropDatabaseCoordinator(dbName, 120.0);
int res = ci->dropDatabaseCoordinator(dbName, errorMsg, 120.0);
if (res != TRI_ERROR_NO_ERROR) {
return res;
if (!res.ok()) {
return res.errorNumber();
}
// now wait for heartbeat thread to drop the database object
int tries = 0;
while (++tries <= 6000) {
TRI_vocbase_t* vocbase = databaseFeature->useDatabase(id);

View File

@ -306,15 +306,11 @@ Result Indexes::ensureIndexCoordinator(arangodb::LogicalCollection const* collec
TRI_ASSERT(collection != nullptr);
auto& dbName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
std::string errorMsg;
auto cluster = application_features::ApplicationServer::getFeature<ClusterFeature>("Cluster");
auto cluster = application_features::ApplicationServer::getFeature<ClusterFeature>(
"Cluster");
int res =
ClusterInfo::instance()->ensureIndexCoordinator(dbName, cid, indexDef, create,
resultBuilder, errorMsg,
cluster->indexCreationTimeout());
return Result(res, errorMsg);
return ClusterInfo::instance()->ensureIndexCoordinator( // create index
dbName, cid, indexDef, create, resultBuilder, cluster->indexCreationTimeout() // args
);
}
Result Indexes::ensureIndex(LogicalCollection* collection, VPackSlice const& input,
@ -558,11 +554,10 @@ arangodb::Result Indexes::drop(LogicalCollection* collection, VPackSlice const&
#else
TRI_ASSERT(collection);
auto& databaseName = collection->vocbase().name();
auto cid = std::to_string(collection->id());
std::string errorMsg;
int r = ClusterInfo::instance()->dropIndexCoordinator(databaseName, cid,
iid, errorMsg, 0.0);
return Result(r, errorMsg);
return ClusterInfo::instance()->dropIndexCoordinator( // drop index
databaseName, std::to_string(collection->id()), iid, 0.0 // args
);
#endif
} else {
READ_LOCKER(readLocker, collection->vocbase()._inventoryLock);

View File

@ -97,9 +97,8 @@ struct ViewFactory: public arangodb::ViewFactory {
builder.close();
std::string error;
return ci->createViewCoordinator(
vocbase.name(), std::to_string(view->id()), builder.slice(), error
vocbase.name(), std::to_string(view->id()), builder.slice()
);
}
@ -234,11 +233,10 @@ SECTION("test_drop_databse") {
// test LogicalView dropped when database dropped
{
auto viewCreateJson = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testView\", \"type\": \"testViewType\" }");
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == database->createDatabase(1, "testDatabase", vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.0)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.0).ok()));
// initial view creation
{
@ -247,8 +245,8 @@ SECTION("test_drop_databse") {
REQUIRE((false == !logicalView));
}
CHECK((TRI_ERROR_NO_ERROR == ci->dropDatabaseCoordinator(vocbase->name(), error, 0.0)));
CHECK((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.0)));
CHECK((ci->dropDatabaseCoordinator(vocbase->name(), 0.0).ok()));
CHECK((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.0).ok()));
arangodb::LogicalView::ptr logicalView;
CHECK((s.viewFactory.create(logicalView, *vocbase, viewCreateJson->slice()).ok()));

View File

@ -426,19 +426,13 @@ SECTION("test_upgrade0_1") {
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE((nullptr != ci));
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
std::string error;
REQUIRE((TRI_ERROR_NO_ERROR == database->createDatabase(1, "testDatabase", vocbase)));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.0)));
CHECK((std::string("no error") == error));
error.clear();
REQUIRE((TRI_ERROR_NO_ERROR == ci->createCollectionCoordinator(vocbase->name(), collectionId, 0, 1, false, collectionJson->slice(), error, 0.0)));
CHECK((error.empty()));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.0).ok()));
REQUIRE((ci->createCollectionCoordinator(vocbase->name(), collectionId, 0, 1, false, collectionJson->slice(), 0.0).ok()));
auto logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((false == !logicalCollection));
error.clear();
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), viewId, viewJson->slice(), error)));
CHECK((error.empty()));
CHECK((ci->createViewCoordinator(vocbase->name(), viewId, viewJson->slice()).ok()));
auto logicalView0 = ci->getView(vocbase->name(), viewId);
REQUIRE((false == !logicalView0));
@ -1088,4 +1082,4 @@ SECTION("test_async") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

View File

@ -252,7 +252,6 @@ SECTION("test_create_drop") {
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE(nullptr != ci);
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
// create database
@ -265,10 +264,7 @@ SECTION("test_create_drop") {
CHECK(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_COORDINATOR == vocbase->type());
CHECK(1 == vocbase->id());
CHECK(TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(
vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0
));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
}
// create collection
@ -280,9 +276,7 @@ SECTION("test_create_drop") {
"{ \"name\": \"testCollection\", \"replicationFactor\":1, \"shards\":{} }"
);
CHECK(TRI_ERROR_NO_ERROR == ci->createCollectionCoordinator(
vocbase->name(), collectionId, 0, 1, false, collectionJson->slice(), error, 0.0
));
CHECK((ci->createCollectionCoordinator(vocbase->name(), collectionId, 0, 1, false, collectionJson->slice(), 0.0).ok()));
logicalCollection = ci->getCollection(vocbase->name(), collectionId);
REQUIRE((nullptr != logicalCollection));
@ -358,7 +352,7 @@ SECTION("test_create_drop") {
arangodb::iresearch::IResearchLinkMeta expectedMeta;
auto builder = index->toVelocyPack(arangodb::Index::makeFlags(arangodb::Index::Serialize::Figures));
error.clear();
std::string error;
CHECK(actualMeta.init(builder->slice(), error));
CHECK(error.empty());
CHECK(expectedMeta == actualMeta);
@ -511,4 +505,4 @@ SECTION("test_create_drop") {
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -205,7 +205,6 @@ SECTION("test_drop") {
REQUIRE(nullptr != database);
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE(nullptr != ci);
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
// create database
@ -218,10 +217,7 @@ SECTION("test_drop") {
CHECK(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL == vocbase->type());
CHECK(1 == vocbase->id());
CHECK(TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(
vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0
));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
}
// drop empty
@ -305,7 +301,6 @@ SECTION("test_drop_cid") {
REQUIRE((nullptr != database));
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE((nullptr != ci));
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
// create database
@ -318,10 +313,7 @@ SECTION("test_drop_cid") {
CHECK(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL == vocbase->type());
CHECK(1 == vocbase->id());
CHECK(TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(
vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0
));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
}
auto collectionJson = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testCollection\" }");
@ -356,7 +348,6 @@ SECTION("test_drop_database") {
REQUIRE((nullptr != ci));
auto* databaseFeature = arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabaseFeature>("Database");
REQUIRE((nullptr != databaseFeature));
std::string error;
auto collectionJson = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testCollection\" }");
auto viewCreateJson = arangodb::velocypack::Parser::fromJson("{ \"id\": \"42\", \"name\": \"testView\", \"type\": \"arangosearch\" }");
@ -370,10 +361,10 @@ SECTION("test_drop_database") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
REQUIRE((false == !logicalCollection));
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", viewCreateJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", viewCreateJson->slice()).ok()));
auto logicalWiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
REQUIRE((false == !logicalWiew));
auto* wiewImpl = dynamic_cast<arangodb::iresearch::IResearchView*>(logicalWiew.get());
@ -394,7 +385,6 @@ SECTION("test_ensure") {
REQUIRE((nullptr != database));
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE((nullptr != ci));
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
// create database
@ -407,10 +397,7 @@ SECTION("test_ensure") {
CHECK(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL == vocbase->type());
CHECK(1 == vocbase->id());
CHECK(TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(
vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0
));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
}
auto collectionJson = arangodb::velocypack::Parser::fromJson("{ \"name\": \"testCollection\" }");
@ -463,7 +450,6 @@ SECTION("test_make") {
SECTION("test_open") {
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE(nullptr != ci);
std::string error;
// open empty
{
@ -516,7 +502,6 @@ SECTION("test_query") {
REQUIRE((nullptr != ci));
auto* databaseFeature = arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabaseFeature>("Database");
REQUIRE((nullptr != databaseFeature));
std::string error;
auto createJson = arangodb::velocypack::Parser::fromJson("{ \
\"id\": \"42\", \
@ -535,8 +520,7 @@ SECTION("test_query") {
auto linkJson = arangodb::velocypack::Parser::fromJson("{ \"view\": \"testView\", \"type\": \"arangosearch\", \"includeAllFields\": true }");
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == database->createDatabase(1, "testDatabase0", vocbase)));
CHECK((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0)));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
REQUIRE(nullptr != logicalCollection);
arangodb::LogicalView::ptr logicalWiew;
@ -571,7 +555,7 @@ SECTION("test_query") {
auto linkJson = arangodb::velocypack::Parser::fromJson("{ \"view\": \"testView\", \"type\": \"arangosearch\", \"includeAllFields\": true }");
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == database->createDatabase(1, "testDatabase1", vocbase)));
CHECK((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0)));
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
REQUIRE(nullptr != logicalCollection);
arangodb::LogicalView::ptr logicalWiew;
@ -632,10 +616,10 @@ SECTION("test_query") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
std::vector<std::string> collections{ logicalCollection->name() };
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", createJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", createJson->slice()).ok()));
auto logicalWiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
CHECK((false == !logicalWiew));
auto* wiewImpl = dynamic_cast<arangodb::iresearch::IResearchView*>(logicalWiew.get());
@ -734,9 +718,9 @@ SECTION("test_query") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", createJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", createJson->slice()).ok()));
auto logicalWiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
REQUIRE((false == !logicalWiew));
auto* wiewImpl = dynamic_cast<arangodb::iresearch::IResearchView*>(logicalWiew.get());
@ -972,7 +956,6 @@ SECTION("test_transaction_snapshot") {
REQUIRE((nullptr != database));
auto* ci = arangodb::ClusterInfo::instance();
REQUIRE((nullptr != ci));
std::string error;
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
// create database
@ -985,10 +968,7 @@ SECTION("test_transaction_snapshot") {
CHECK(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL == vocbase->type());
CHECK(1 == vocbase->id());
CHECK(TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(
vocbase->name(), VPackSlice::emptyObjectSlice(), error, 0.0
));
CHECK("no error" == error);
CHECK((ci->createDatabaseCoordinator(vocbase->name(), VPackSlice::emptyObjectSlice(), 0.0).ok()));
}
static std::vector<std::string> const EMPTY;
@ -1105,7 +1085,6 @@ SECTION("test_updateProperties") {
REQUIRE((nullptr != ci));
auto* databaseFeature = arangodb::application_features::ApplicationServer::getFeature<arangodb::DatabaseFeature>("Database");
REQUIRE((nullptr != databaseFeature));
std::string error;
// update empty (partial)
{
@ -1114,10 +1093,10 @@ SECTION("test_updateProperties") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
CHECK((nullptr != logicalCollection));
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice()).ok()));
auto wiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
CHECK((false == !wiew));
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(wiew.get());
@ -1204,10 +1183,10 @@ SECTION("test_updateProperties") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
CHECK((nullptr != logicalCollection));
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice()).ok()));
auto wiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
CHECK((false == !wiew));
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(wiew.get());
@ -1294,10 +1273,10 @@ SECTION("test_updateProperties") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection = vocbase->createCollection(collectionJson->slice());
CHECK((nullptr != logicalCollection));
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice()).ok()));
auto wiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
CHECK((false == !wiew));
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(wiew.get());
@ -1389,12 +1368,12 @@ SECTION("test_updateProperties") {
TRI_vocbase_t* vocbase; // will be owned by DatabaseFeature
REQUIRE((TRI_ERROR_NO_ERROR == databaseFeature->createDatabase(0, "testDatabase" TOSTRING(__LINE__), vocbase)));
REQUIRE((nullptr != vocbase));
REQUIRE((TRI_ERROR_NO_ERROR == ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), error, 0.)));
REQUIRE((ci->createDatabaseCoordinator(vocbase->name(), arangodb::velocypack::Slice::emptyObjectSlice(), 0.).ok()));
auto logicalCollection0 = vocbase->createCollection(collection0Json->slice());
CHECK((nullptr != logicalCollection0));
auto logicalCollection1 = vocbase->createCollection(collection1Json->slice());
CHECK((nullptr != logicalCollection1));
CHECK((TRI_ERROR_NO_ERROR == ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice(), error)));
CHECK((ci->createViewCoordinator(vocbase->name(), "42", viewJson->slice()).ok()));
auto wiew = ci->getView(vocbase->name(), "42"); // link creation requires cluster-view to be in ClusterInfo instead of TRI_vocbase_t
CHECK((false == !wiew));
auto* impl = dynamic_cast<arangodb::iresearch::IResearchView*>(wiew.get());