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