1
0
Fork 0

Give the server state in the agency a time to live.

This commit is contained in:
Max Neunhoeffer 2014-02-28 18:47:46 +01:00
parent b3a7173808
commit cb8f0257a7
4 changed files with 8 additions and 7 deletions

View File

@ -919,7 +919,7 @@ AgencyEndpoint* AgencyComm::createAgencyEndpoint (std::string const& endpointSpe
/// @brief sends the current server state to the agency /// @brief sends the current server state to the agency
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AgencyCommResult AgencyComm::sendServerState () { AgencyCommResult AgencyComm::sendServerState (double ttl) {
// construct JSON value { "status": "...", "time": "..." } // construct JSON value { "status": "...", "time": "..." }
TRI_json_t* json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE); TRI_json_t* json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE);
@ -933,7 +933,7 @@ AgencyCommResult AgencyComm::sendServerState () {
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "status", TRI_CreateString2CopyJson(TRI_UNKNOWN_MEM_ZONE, status.c_str(), status.size())); TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "status", TRI_CreateString2CopyJson(TRI_UNKNOWN_MEM_ZONE, status.c_str(), status.size()));
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "time", TRI_CreateString2CopyJson(TRI_UNKNOWN_MEM_ZONE, stamp.c_str(), stamp.size())); TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "time", TRI_CreateString2CopyJson(TRI_UNKNOWN_MEM_ZONE, stamp.c_str(), stamp.size()));
AgencyCommResult result(setValue("Sync/ServerStates/" + ServerState::instance()->getId(), json, 0.0)); AgencyCommResult result(setValue("Sync/ServerStates/" + ServerState::instance()->getId(), json, ttl));
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json); TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
return result; return result;

View File

@ -439,7 +439,7 @@ namespace triagens {
/// @brief sends the current server state to the agency /// @brief sends the current server state to the agency
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
AgencyCommResult sendServerState (); AgencyCommResult sendServerState (double ttl);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief gets the backend version /// @brief gets the backend version

View File

@ -262,7 +262,7 @@ bool ApplicationCluster::start () {
// the agency about our state // the agency about our state
AgencyComm comm; AgencyComm comm;
comm.sendServerState(); comm.sendServerState(0.0);
const std::string version = comm.getVersion(); const std::string version = comm.getVersion();
@ -430,7 +430,7 @@ void ApplicationCluster::close () {
ServerState::instance()->setState(ServerState::STATE_SHUTDOWN); ServerState::instance()->setState(ServerState::STATE_SHUTDOWN);
AgencyComm comm; AgencyComm comm;
comm.sendServerState(); comm.sendServerState(0.0);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -446,7 +446,7 @@ void ApplicationCluster::stop () {
ServerState::instance()->setState(ServerState::STATE_SHUTDOWN); ServerState::instance()->setState(ServerState::STATE_SHUTDOWN);
AgencyComm comm; AgencyComm comm;
comm.sendServerState(); comm.sendServerState(0.0);
if (_heartbeat != 0) { if (_heartbeat != 0) {
_heartbeat->stop(); _heartbeat->stop();

View File

@ -461,7 +461,8 @@ bool HeartbeatThread::handleStateChange (AgencyCommResult& result,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool HeartbeatThread::sendState () { bool HeartbeatThread::sendState () {
const AgencyCommResult result = _agency.sendServerState(); const AgencyCommResult result = _agency.sendServerState(
3.0 * static_cast<double>(_interval) / 1000.0 / 1000.0);
if (result.successful()) { if (result.successful()) {
_numFails = 0; _numFails = 0;