mirror of https://gitee.com/bigwinds/arangodb
use X-Etcd-Index header
This commit is contained in:
parent
996be652f1
commit
a67ee89a9e
|
@ -86,6 +86,7 @@ AgencyEndpoint::~AgencyEndpoint () {
|
||||||
AgencyCommResult::AgencyCommResult ()
|
AgencyCommResult::AgencyCommResult ()
|
||||||
: _message(),
|
: _message(),
|
||||||
_body(),
|
_body(),
|
||||||
|
_index(0),
|
||||||
_statusCode(0) {
|
_statusCode(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,10 +883,17 @@ bool AgencyComm::send (triagens::httpclient::GeneralClientConnection* connection
|
||||||
delete response;
|
delete response;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result._statusCode = response->getHttpReturnCode();
|
|
||||||
result._message = response->getHttpReturnMessage();
|
result._message = response->getHttpReturnMessage();
|
||||||
result._body = response->getBody().str();
|
result._body = response->getBody().str();
|
||||||
|
result._index = 0;
|
||||||
|
result._statusCode = response->getHttpReturnCode();
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
std::string lastIndex = response->getHeaderField("x-etcd-index", found);
|
||||||
|
if (found) {
|
||||||
|
result._index = triagens::basics::StringUtils::uint64(lastIndex);
|
||||||
|
}
|
||||||
|
|
||||||
LOG_TRACE("request to agency returned status code %d, message: '%s', body: '%s'",
|
LOG_TRACE("request to agency returned status code %d, message: '%s', body: '%s'",
|
||||||
result._statusCode,
|
result._statusCode,
|
||||||
|
|
|
@ -130,7 +130,8 @@ namespace triagens {
|
||||||
|
|
||||||
std::string _message;
|
std::string _message;
|
||||||
std::string _body;
|
std::string _body;
|
||||||
int _statusCode;
|
uint64_t _index;
|
||||||
|
int _statusCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -115,6 +115,7 @@ void HeartbeatThread::run () {
|
||||||
|
|
||||||
if (result.successful()) {
|
if (result.successful()) {
|
||||||
// value has changed!
|
// value has changed!
|
||||||
|
|
||||||
handleStateChange(result, lastCommandIndex);
|
handleStateChange(result, lastCommandIndex);
|
||||||
|
|
||||||
// sleep a while
|
// sleep a while
|
||||||
|
@ -180,6 +181,11 @@ uint64_t HeartbeatThread::getLastCommandIndex () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result._index > 0) {
|
||||||
|
// use the value returned in header X-Etcd-Index
|
||||||
|
return result._index;
|
||||||
|
}
|
||||||
|
|
||||||
// nothing found. this is not an error
|
// nothing found. this is not an error
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue