mirror of https://gitee.com/bigwinds/arangodb
replication API documentation
This commit is contained in:
parent
fcd1637261
commit
e08d840b47
|
@ -61,9 +61,9 @@ using namespace triagens::arango;
|
||||||
// --SECTION-- initialize static variables
|
// --SECTION-- initialize static variables
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
const uint64_t RestReplicationHandler::defaultChunkSize = 128 * 1024;
|
uint64_t const RestReplicationHandler::defaultChunkSize = 128 * 1024;
|
||||||
|
|
||||||
const uint64_t RestReplicationHandler::maxChunkSize = 128 * 1024 * 1024;
|
uint64_t const RestReplicationHandler::maxChunkSize = 128 * 1024 * 1024;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- constructors and destructors
|
// --SECTION-- constructors and destructors
|
||||||
|
@ -94,7 +94,7 @@ RestReplicationHandler::~RestReplicationHandler () {
|
||||||
|
|
||||||
HttpHandler::status_t RestReplicationHandler::execute () {
|
HttpHandler::status_t RestReplicationHandler::execute () {
|
||||||
// extract the request type
|
// extract the request type
|
||||||
const HttpRequest::HttpRequestType type = _request->requestType();
|
HttpRequest::HttpRequestType const type = _request->requestType();
|
||||||
|
|
||||||
vector<string> const& suffix = _request->suffix();
|
vector<string> const& suffix = _request->suffix();
|
||||||
|
|
||||||
|
@ -909,7 +909,7 @@ void RestReplicationHandler::handleCommandBatch () {
|
||||||
int res = TRI_InsertBlockerCompactorVocBase(_vocbase, expires, &id);
|
int res = TRI_InsertBlockerCompactorVocBase(_vocbase, expires, &id);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::BAD, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,7 +948,7 @@ void RestReplicationHandler::handleCommandBatch () {
|
||||||
_response = createResponse(HttpResponse::NO_CONTENT);
|
_response = createResponse(HttpResponse::NO_CONTENT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
generateError(HttpResponse::BAD, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -963,7 +963,7 @@ void RestReplicationHandler::handleCommandBatch () {
|
||||||
_response = createResponse(HttpResponse::NO_CONTENT);
|
_response = createResponse(HttpResponse::NO_CONTENT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
generateError(HttpResponse::BAD, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1386,7 +1386,7 @@ void RestReplicationHandler::handleCommandLoggerFollow () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,7 +1466,7 @@ void RestReplicationHandler::handleCommandDetermineOpenTransactions () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1956,7 +1956,7 @@ void RestReplicationHandler::handleCommandRestoreCollection () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRI_json_t result;
|
TRI_json_t result;
|
||||||
|
@ -2003,7 +2003,7 @@ void RestReplicationHandler::handleCommandRestoreIndexes () {
|
||||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRI_json_t result;
|
TRI_json_t result;
|
||||||
|
@ -2773,7 +2773,7 @@ void RestReplicationHandler::handleCommandRestoreData () {
|
||||||
int res = processRestoreData(resolver, cid, recycleIds, force, errorMsg);
|
int res = processRestoreData(resolver, cid, recycleIds, force, errorMsg);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TRI_json_t result;
|
TRI_json_t result;
|
||||||
|
@ -3063,7 +3063,7 @@ void RestReplicationHandler::handleCommandRestoreDataCoordinator () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::BAD, res, errorMsg);
|
generateError(HttpResponse::responseCode(res), res, errorMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3157,7 +3157,7 @@ void RestReplicationHandler::handleCommandCreateKeys () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3249,7 +3249,7 @@ void RestReplicationHandler::handleCommandGetKeys () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3353,7 +3353,7 @@ void RestReplicationHandler::handleCommandFetchKeys () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3662,7 +3662,7 @@ void RestReplicationHandler::handleCommandDump () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3913,7 +3913,7 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_DestroyConfigurationReplicationApplier(&config);
|
TRI_DestroyConfigurationReplicationApplier(&config);
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3939,7 +3939,7 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_DestroyConfigurationReplicationApplier(&config);
|
TRI_DestroyConfigurationReplicationApplier(&config);
|
||||||
generateError(HttpResponse::SERVER_ERROR, res, errorMsg);
|
generateError(HttpResponse::responseCode(res), res, errorMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3947,7 +3947,7 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
TRI_DestroyConfigurationReplicationApplier(&config);
|
TRI_DestroyConfigurationReplicationApplier(&config);
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3956,7 +3956,7 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
res =_vocbase->_replicationApplier->start(lastLogTick, true);
|
res =_vocbase->_replicationApplier->start(lastLogTick, true);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3990,9 +3990,17 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
/// @RESTBODYPARAM{password,string,required,string}
|
/// @RESTBODYPARAM{password,string,required,string}
|
||||||
/// the password to use when connecting to the endpoint.
|
/// the password to use when connecting to the endpoint.
|
||||||
///
|
///
|
||||||
/// @RESTBODYPARAM{includeSystem,boolean,required,}
|
/// @RESTBODYPARAM{includeSystem,boolean,optional,}
|
||||||
/// whether or not system collection operations will be applied
|
/// whether or not system collection operations will be applied
|
||||||
///
|
///
|
||||||
|
/// @RESTBODYPARAM{incremental,boolean,optional,}
|
||||||
|
/// if set to *true*, then an incremental synchronization method will be used
|
||||||
|
/// for synchronizing data in collections. This method is useful when
|
||||||
|
/// collections already exist locally, and only the remaining differences need
|
||||||
|
/// to be transferred from the remote endpoint. The default value is *false*,
|
||||||
|
/// meaning that the complete data from the remote collection will be
|
||||||
|
/// transferred.
|
||||||
|
///
|
||||||
/// @RESTBODYPARAM{restrictType,string,optional,string}
|
/// @RESTBODYPARAM{restrictType,string,optional,string}
|
||||||
/// an optional string value for collection filtering. When
|
/// an optional string value for collection filtering. When
|
||||||
/// specified, the allowed values are *include* or *exclude*.
|
/// specified, the allowed values are *include* or *exclude*.
|
||||||
|
@ -4027,7 +4035,7 @@ void RestReplicationHandler::handleCommandMakeSlave () {
|
||||||
/// was started. Use this value as the *from* value when starting the continuous
|
/// was started. Use this value as the *from* value when starting the continuous
|
||||||
/// synchronization later.
|
/// synchronization later.
|
||||||
///
|
///
|
||||||
/// WARNING: calling this method will sychronise data from the collections found
|
/// WARNING: calling this method will sychronize data from the collections found
|
||||||
/// on the remote endpoint to the local ArangoDB database. All data in the local
|
/// on the remote endpoint to the local ArangoDB database. All data in the local
|
||||||
/// collections will be purged and replaced with data from the endpoint.
|
/// collections will be purged and replaced with data from the endpoint.
|
||||||
///
|
///
|
||||||
|
@ -4062,11 +4070,10 @@ void RestReplicationHandler::handleCommandSync () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string endpoint = JsonHelper::getStringValue(json.get(), "endpoint", "");
|
std::string const endpoint = JsonHelper::getStringValue(json.get(), "endpoint", "");
|
||||||
const string database = JsonHelper::getStringValue(json.get(), "database", _vocbase->_name);
|
std::string const database = JsonHelper::getStringValue(json.get(), "database", _vocbase->_name);
|
||||||
const string username = JsonHelper::getStringValue(json.get(), "username", "");
|
std::string const username = JsonHelper::getStringValue(json.get(), "username", "");
|
||||||
const string password = JsonHelper::getStringValue(json.get(), "password", "");
|
std::string const password = JsonHelper::getStringValue(json.get(), "password", "");
|
||||||
|
|
||||||
|
|
||||||
if (endpoint.empty()) {
|
if (endpoint.empty()) {
|
||||||
generateError(HttpResponse::BAD, TRI_ERROR_HTTP_BAD_PARAMETER, "<endpoint> must be a valid endpoint");
|
generateError(HttpResponse::BAD, TRI_ERROR_HTTP_BAD_PARAMETER, "<endpoint> must be a valid endpoint");
|
||||||
|
@ -4099,6 +4106,8 @@ void RestReplicationHandler::handleCommandSync () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool incremental = JsonHelper::getBooleanValue(json.get(), "incremental", false);
|
||||||
|
|
||||||
TRI_replication_applier_configuration_t config;
|
TRI_replication_applier_configuration_t config;
|
||||||
TRI_InitConfigurationReplicationApplier(&config);
|
TRI_InitConfigurationReplicationApplier(&config);
|
||||||
config._endpoint = TRI_DuplicateString2Z(TRI_CORE_MEM_ZONE, endpoint.c_str(), endpoint.size());
|
config._endpoint = TRI_DuplicateString2Z(TRI_CORE_MEM_ZONE, endpoint.c_str(), endpoint.size());
|
||||||
|
@ -4114,7 +4123,7 @@ void RestReplicationHandler::handleCommandSync () {
|
||||||
string errorMsg = "";
|
string errorMsg = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
res = syncer.run(errorMsg, false);
|
res = syncer.run(errorMsg, incremental);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
errorMsg = "caught an exception";
|
errorMsg = "caught an exception";
|
||||||
|
@ -4122,22 +4131,21 @@ void RestReplicationHandler::handleCommandSync () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
generateError(HttpResponse::SERVER_ERROR, res, errorMsg);
|
generateError(HttpResponse::responseCode(res), res, errorMsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_json_t result;
|
TRI_json_t result;
|
||||||
|
|
||||||
TRI_InitObjectJson(TRI_CORE_MEM_ZONE, &result);
|
TRI_InitObjectJson(TRI_CORE_MEM_ZONE, &result);
|
||||||
|
|
||||||
TRI_json_t* jsonCollections = TRI_CreateArrayJson(TRI_CORE_MEM_ZONE);
|
TRI_json_t* jsonCollections = TRI_CreateArrayJson(TRI_CORE_MEM_ZONE);
|
||||||
|
|
||||||
if (jsonCollections != nullptr) {
|
if (jsonCollections != nullptr) {
|
||||||
map<TRI_voc_cid_t, string>::const_iterator it;
|
std::map<TRI_voc_cid_t, std::string>::const_iterator it;
|
||||||
const map<TRI_voc_cid_t, string>& c = syncer.getProcessedCollections();
|
std::map<TRI_voc_cid_t, std::string> const& c = syncer.getProcessedCollections();
|
||||||
|
|
||||||
for (it = c.begin(); it != c.end(); ++it) {
|
for (it = c.begin(); it != c.end(); ++it) {
|
||||||
const string cidString = StringUtils::itoa((*it).first);
|
std::string const cidString = StringUtils::itoa((*it).first);
|
||||||
|
|
||||||
TRI_json_t* ci = TRI_CreateObjectJson(TRI_CORE_MEM_ZONE, 2);
|
TRI_json_t* ci = TRI_CreateObjectJson(TRI_CORE_MEM_ZONE, 2);
|
||||||
|
|
||||||
|
@ -4531,13 +4539,7 @@ void RestReplicationHandler::handleCommandApplierSetConfig () {
|
||||||
TRI_DestroyConfigurationReplicationApplier(&config);
|
TRI_DestroyConfigurationReplicationApplier(&config);
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
if (res == TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION ||
|
generateError(HttpResponse::responseCode(res), res);
|
||||||
res == TRI_ERROR_REPLICATION_RUNNING) {
|
|
||||||
generateError(HttpResponse::BAD, res);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
generateError(HttpResponse::SERVER_ERROR, res);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,8 @@ HttpResponse::HttpResponseCode HttpResponse::responseCode (int code) {
|
||||||
case TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY:
|
case TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY:
|
||||||
case TRI_ERROR_TYPE_ERROR:
|
case TRI_ERROR_TYPE_ERROR:
|
||||||
case TRI_ERROR_QUERY_NUMBER_OUT_OF_RANGE:
|
case TRI_ERROR_QUERY_NUMBER_OUT_OF_RANGE:
|
||||||
|
case TRI_ERROR_REPLICATION_INVALID_APPLIER_CONFIGURATION:
|
||||||
|
case TRI_ERROR_REPLICATION_RUNNING:
|
||||||
return BAD;
|
return BAD;
|
||||||
|
|
||||||
case TRI_ERROR_ARANGO_READ_ONLY:
|
case TRI_ERROR_ARANGO_READ_ONLY:
|
||||||
|
|
Loading…
Reference in New Issue