mirror of https://gitee.com/bigwinds/arangodb
no clientId anymore in send/sendWithFailOver SPIs (#3819)
This commit is contained in:
parent
514374440c
commit
f7b4150b64
|
@ -351,8 +351,7 @@ AgencyCommResult::AgencyCommResult()
|
||||||
_values(),
|
_values(),
|
||||||
_statusCode(0),
|
_statusCode(0),
|
||||||
_connected(false),
|
_connected(false),
|
||||||
_sent(false),
|
_sent(false) {}
|
||||||
_clientId("") {}
|
|
||||||
|
|
||||||
AgencyCommResult::AgencyCommResult(
|
AgencyCommResult::AgencyCommResult(
|
||||||
int code, std::string const& message, std::string const& clientId)
|
int code, std::string const& message, std::string const& clientId)
|
||||||
|
@ -362,23 +361,18 @@ AgencyCommResult::AgencyCommResult(
|
||||||
_values(),
|
_values(),
|
||||||
_statusCode(code),
|
_statusCode(code),
|
||||||
_connected(false),
|
_connected(false),
|
||||||
_sent(false),
|
_sent(false) {}
|
||||||
_clientId(clientId) {}
|
|
||||||
|
|
||||||
void AgencyCommResult::set(int code, std::string const& message,
|
void AgencyCommResult::set(int code, std::string const& message) {
|
||||||
std::string const& clientId) {
|
|
||||||
_location.clear();
|
_location.clear();
|
||||||
_message = message;
|
_message = message;
|
||||||
_body.clear();
|
_body.clear();
|
||||||
_values.clear();
|
_values.clear();
|
||||||
_statusCode = code;
|
_statusCode = code;
|
||||||
_clientId = clientId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AgencyCommResult::connected() const { return _connected; }
|
bool AgencyCommResult::connected() const { return _connected; }
|
||||||
|
|
||||||
std::string AgencyCommResult::clientId() const { return _clientId; }
|
|
||||||
|
|
||||||
int AgencyCommResult::httpCode() const { return _statusCode; }
|
int AgencyCommResult::httpCode() const { return _statusCode; }
|
||||||
|
|
||||||
bool AgencyCommResult::sent() const { return _sent; }
|
bool AgencyCommResult::sent() const { return _sent; }
|
||||||
|
@ -1134,7 +1128,7 @@ AgencyCommResult AgencyComm::sendTransactionWithFailover(
|
||||||
arangodb::rest::RequestType::POST,
|
arangodb::rest::RequestType::POST,
|
||||||
(timeout == 0.0) ?
|
(timeout == 0.0) ?
|
||||||
AgencyCommManager::CONNECTION_OPTIONS._requestTimeout : timeout,
|
AgencyCommManager::CONNECTION_OPTIONS._requestTimeout : timeout,
|
||||||
url, builder.slice(), transaction.getClientId());
|
url, builder.slice());
|
||||||
|
|
||||||
if (!result.successful() && result.httpCode() !=
|
if (!result.successful() && result.httpCode() !=
|
||||||
(int)arangodb::rest::ResponseCode::PRECONDITION_FAILED) {
|
(int)arangodb::rest::ResponseCode::PRECONDITION_FAILED) {
|
||||||
|
@ -1334,28 +1328,19 @@ void AgencyComm::updateEndpoints(arangodb::velocypack::Slice const& current) {
|
||||||
|
|
||||||
AgencyCommResult AgencyComm::sendWithFailover(
|
AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
arangodb::rest::RequestType method, double const timeout,
|
arangodb::rest::RequestType method, double const timeout,
|
||||||
std::string const& initialUrl, VPackSlice inBody,
|
std::string const& initialUrl, VPackSlice inBody) {
|
||||||
std::string clientId) {
|
|
||||||
|
|
||||||
std::string endpoint;
|
std::string endpoint;
|
||||||
std::unique_ptr<GeneralClientConnection> connection =
|
std::unique_ptr<GeneralClientConnection> connection =
|
||||||
AgencyCommManager::MANAGER->acquire(endpoint);
|
AgencyCommManager::MANAGER->acquire(endpoint);
|
||||||
|
|
||||||
std::vector<std::string> clientIds;
|
std::vector<std::string> clientIds;
|
||||||
clientId = "";
|
|
||||||
VPackSlice body = inBody.resolveExternals();
|
VPackSlice body = inBody.resolveExternals();
|
||||||
|
|
||||||
if (body.isArray()) {
|
if (body.isArray()) {
|
||||||
for (auto const& query : VPackArrayIterator(body)) {
|
for (auto const& query : VPackArrayIterator(body)) {
|
||||||
if (query.length() == 3 && query[0].isObject() && query[2].isString()) {
|
if (query.length() == 3 && query[0].isObject() && query[2].isString()) {
|
||||||
auto const id = query[2].copyString();
|
clientIds.push_back(query[2].copyString());
|
||||||
if (!id.empty()) {
|
|
||||||
if (!clientIds.empty()) {
|
|
||||||
clientId += " ";
|
|
||||||
}
|
|
||||||
clientIds.push_back(id);
|
|
||||||
clientId +=id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1387,7 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
// If for some reason we did not find an agency endpoint, we bail out:
|
// If for some reason we did not find an agency endpoint, we bail out:
|
||||||
if (connection == nullptr) {
|
if (connection == nullptr) {
|
||||||
LOG_TOPIC(ERR, Logger::AGENCYCOMM) << "No agency endpoints.";
|
LOG_TOPIC(ERR, Logger::AGENCYCOMM) << "No agency endpoints.";
|
||||||
result.set(400, "No endpoints for agency found.", clientId);
|
result.set(400, "No endpoints for agency found.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,7 +1400,7 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
|
|
||||||
// timeout exit strategy:
|
// timeout exit strategy:
|
||||||
if (std::chrono::steady_clock::now() > timeOut) {
|
if (std::chrono::steady_clock::now() > timeOut) {
|
||||||
result.set(0, "timeout in AgencyComm operation", clientId);
|
result.set(0, "timeout in AgencyComm operation");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1446,8 +1431,7 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
bodyString = body.toJson();
|
bodyString = body.toJson();
|
||||||
}
|
}
|
||||||
url = initialUrl; // Attention: overwritten by redirect below!
|
url = initialUrl; // Attention: overwritten by redirect below!
|
||||||
result = send(connection.get(), method, conTimeout, url, bodyString,
|
result = send(connection.get(), method, conTimeout, url, bodyString);
|
||||||
clientId);
|
|
||||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
if (!clientIds.empty()) {
|
if (!clientIds.empty()) {
|
||||||
if (clientIds[0] == "INTEGRATION_TEST_INQUIRY_ERROR_0") {
|
if (clientIds[0] == "INTEGRATION_TEST_INQUIRY_ERROR_0") {
|
||||||
|
@ -1502,11 +1486,11 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::AGENCYCOMM) <<
|
LOG_TOPIC(DEBUG, Logger::AGENCYCOMM) <<
|
||||||
"Failed agency comm (" << result._statusCode << ")! " <<
|
"Failed agency comm (" << result._statusCode << ")! " <<
|
||||||
"Inquiring about clientIds " << clientId << ".";
|
"Inquiring about clientIds " << clientIds << ".";
|
||||||
|
|
||||||
url = "/_api/agency/inquire"; // attention: overwritten by redirect!
|
url = "/_api/agency/inquire"; // attention: overwritten by redirect!
|
||||||
result = send(
|
result = send(
|
||||||
connection.get(), method, conTimeout, url, b.toJson(), "");
|
connection.get(), method, conTimeout, url, b.toJson());
|
||||||
|
|
||||||
// Inquire returns a body like write or if the write is still ongoing
|
// Inquire returns a body like write or if the write is still ongoing
|
||||||
// We check, if the operation is still ongoing then body is {"ongoing:true"}
|
// We check, if the operation is still ongoing then body is {"ongoing:true"}
|
||||||
|
@ -1594,7 +1578,7 @@ AgencyCommResult AgencyComm::sendWithFailover(
|
||||||
AgencyCommResult AgencyComm::send(
|
AgencyCommResult AgencyComm::send(
|
||||||
arangodb::httpclient::GeneralClientConnection* connection,
|
arangodb::httpclient::GeneralClientConnection* connection,
|
||||||
arangodb::rest::RequestType method, double timeout, std::string const& url,
|
arangodb::rest::RequestType method, double timeout, std::string const& url,
|
||||||
std::string const& body, std::string const& clientId) {
|
std::string const& body) {
|
||||||
TRI_ASSERT(connection != nullptr);
|
TRI_ASSERT(connection != nullptr);
|
||||||
|
|
||||||
if (method == arangodb::rest::RequestType::GET ||
|
if (method == arangodb::rest::RequestType::GET ||
|
||||||
|
@ -1607,10 +1591,6 @@ AgencyCommResult AgencyComm::send(
|
||||||
|
|
||||||
AgencyCommResult result;
|
AgencyCommResult result;
|
||||||
|
|
||||||
if (!clientId.empty()) {
|
|
||||||
result._clientId = clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
<< "sending " << arangodb::HttpRequest::translateMethod(method)
|
<< "sending " << arangodb::HttpRequest::translateMethod(method)
|
||||||
<< " request to agency at endpoint '"
|
<< " request to agency at endpoint '"
|
||||||
|
|
|
@ -226,8 +226,7 @@ class AgencyCommResult {
|
||||||
~AgencyCommResult() = default;
|
~AgencyCommResult() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set(int code, std::string const& message,
|
void set(int code, std::string const& message);
|
||||||
std::string const& clientId);
|
|
||||||
|
|
||||||
bool successful() const { return (_statusCode >= 200 && _statusCode <= 299); }
|
bool successful() const { return (_statusCode >= 200 && _statusCode <= 299); }
|
||||||
|
|
||||||
|
@ -237,8 +236,6 @@ class AgencyCommResult {
|
||||||
|
|
||||||
int errorCode() const;
|
int errorCode() const;
|
||||||
|
|
||||||
std::string clientId() const;
|
|
||||||
|
|
||||||
std::string errorMessage() const;
|
std::string errorMessage() const;
|
||||||
|
|
||||||
std::string errorDetails() const;
|
std::string errorDetails() const;
|
||||||
|
@ -269,8 +266,6 @@ class AgencyCommResult {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<velocypack::Builder> _vpack;
|
std::shared_ptr<velocypack::Builder> _vpack;
|
||||||
|
|
||||||
public:
|
|
||||||
std::string _clientId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -684,8 +679,7 @@ class AgencyComm {
|
||||||
bool ensureStructureInitialized();
|
bool ensureStructureInitialized();
|
||||||
|
|
||||||
AgencyCommResult sendWithFailover(arangodb::rest::RequestType, double,
|
AgencyCommResult sendWithFailover(arangodb::rest::RequestType, double,
|
||||||
std::string const&, VPackSlice,
|
std::string const&, VPackSlice);
|
||||||
std::string clientId = std::string());
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool lock(std::string const&, double, double,
|
bool lock(std::string const&, double, double,
|
||||||
|
@ -694,8 +688,7 @@ class AgencyComm {
|
||||||
bool unlock(std::string const&, arangodb::velocypack::Slice const&, double);
|
bool unlock(std::string const&, arangodb::velocypack::Slice const&, double);
|
||||||
|
|
||||||
AgencyCommResult send(httpclient::GeneralClientConnection*, rest::RequestType,
|
AgencyCommResult send(httpclient::GeneralClientConnection*, rest::RequestType,
|
||||||
double, std::string const&, std::string const&,
|
double, std::string const&, std::string const&);
|
||||||
std::string const& clientId = std::string());
|
|
||||||
|
|
||||||
bool tryInitializeStructure();
|
bool tryInitializeStructure();
|
||||||
|
|
||||||
|
|
|
@ -988,8 +988,8 @@ int ClusterInfo::createDatabaseCoordinator(std::string const& name,
|
||||||
(int)arangodb::rest::ResponseCode::PRECONDITION_FAILED) {
|
(int)arangodb::rest::ResponseCode::PRECONDITION_FAILED) {
|
||||||
return setErrormsg(TRI_ERROR_ARANGO_DUPLICATE_NAME, errorMsg);
|
return setErrormsg(TRI_ERROR_ARANGO_DUPLICATE_NAME, errorMsg);
|
||||||
}
|
}
|
||||||
errorMsg = std::string("Failed to create database with ") +
|
errorMsg = std::string("Failed to create database at ") +
|
||||||
res._clientId + " at " + __FILE__ + ":" + std::to_string(__LINE__);
|
__FILE__ + ":" + std::to_string(__LINE__);
|
||||||
return setErrormsg(TRI_ERROR_CLUSTER_COULD_NOT_CREATE_DATABASE_IN_PLAN,
|
return setErrormsg(TRI_ERROR_CLUSTER_COULD_NOT_CREATE_DATABASE_IN_PLAN,
|
||||||
errorMsg);
|
errorMsg);
|
||||||
}
|
}
|
||||||
|
@ -1323,7 +1323,6 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER) << "Could not get agency dump!";
|
LOG_TOPIC(ERR, Logger::CLUSTER) << "Could not get agency dump!";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorMsg += std::string("\nClientId ") + res._clientId;
|
|
||||||
errorMsg += std::string("\n") + __FILE__ + std::to_string(__LINE__);
|
errorMsg += std::string("\n") + __FILE__ + std::to_string(__LINE__);
|
||||||
errorMsg += std::string("\n") + res.errorMessage();
|
errorMsg += std::string("\n") + res.errorMessage();
|
||||||
errorMsg += std::string("\n") + res.errorDetails();
|
errorMsg += std::string("\n") + res.errorDetails();
|
||||||
|
@ -1491,7 +1490,6 @@ int ClusterInfo::dropCollectionCoordinator(
|
||||||
if (!res.successful()) {
|
if (!res.successful()) {
|
||||||
AgencyCommResult ag = ac.getValues("");
|
AgencyCommResult ag = ac.getValues("");
|
||||||
if (ag.successful()) {
|
if (ag.successful()) {
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER) << "ClientId: " << res._clientId;
|
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER) << "Agency dump:\n"
|
LOG_TOPIC(ERR, Logger::CLUSTER) << "Agency dump:\n"
|
||||||
<< ag.slice().toJson();
|
<< ag.slice().toJson();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2023,7 +2021,6 @@ int ClusterInfo::ensureIndexCoordinatorWithoutRollback(
|
||||||
} else {
|
} else {
|
||||||
errorMsg += " Failed to execute ";
|
errorMsg += " Failed to execute ";
|
||||||
errorMsg += trx.toJson();
|
errorMsg += trx.toJson();
|
||||||
errorMsg += "ClientId: " + result._clientId + " ";
|
|
||||||
errorMsg += " ResultCode: " + std::to_string(result.errorCode()) + " ";
|
errorMsg += " ResultCode: " + std::to_string(result.errorCode()) + " ";
|
||||||
errorMsg += " HttpCode: " + std::to_string(result.httpCode()) + " ";
|
errorMsg += " HttpCode: " + std::to_string(result.httpCode()) + " ";
|
||||||
errorMsg += std::string(__FILE__) + ":" + std::to_string(__LINE__);
|
errorMsg += std::string(__FILE__) + ":" + std::to_string(__LINE__);
|
||||||
|
@ -2267,7 +2264,6 @@ int ClusterInfo::dropIndexCoordinator(std::string const& databaseName,
|
||||||
if (!result.successful()) {
|
if (!result.successful()) {
|
||||||
errorMsg += " Failed to execute ";
|
errorMsg += " Failed to execute ";
|
||||||
errorMsg += trx.toJson();
|
errorMsg += trx.toJson();
|
||||||
errorMsg += " ClientId: " + result._clientId + " ";
|
|
||||||
errorMsg += " ResultCode: " + std::to_string(result.errorCode()) + " ";
|
errorMsg += " ResultCode: " + std::to_string(result.errorCode()) + " ";
|
||||||
|
|
||||||
events::DropIndex(collectionID, idString,
|
events::DropIndex(collectionID, idString,
|
||||||
|
|
Loading…
Reference in New Issue