1
0
Fork 0

dirty yet

This commit is contained in:
Kaveh Vahedipour 2016-04-22 19:04:59 +02:00
parent 04fbad730a
commit d2a95f2022
4 changed files with 28 additions and 7 deletions

View File

@ -43,8 +43,6 @@ using namespace arangodb::consensus;
/// @brief ArangoDB server /// @brief ArangoDB server
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
extern ArangoServer* ArangoInstance;
RestAgencyHandler::RestAgencyHandler(HttpRequest* request, Agent* agent) RestAgencyHandler::RestAgencyHandler(HttpRequest* request, Agent* agent)
: RestBaseHandler(request), _agent(agent) {} : RestBaseHandler(request), _agent(agent) {}

View File

@ -35,7 +35,7 @@ namespace arangodb {
class RestAgencyHandler : public RestBaseHandler { class RestAgencyHandler : public RestBaseHandler {
public: public:
explicit RestAgencyHandler(HttpRequest*, consensus::Agent*); RestAgencyHandler(HttpRequest*, consensus::Agent*);
bool isDirect() const override; bool isDirect() const override;

View File

@ -396,7 +396,6 @@ void ClusterFeature::start() {
"default value '" "default value '"
<< _heartbeatInterval << " ms'"; << _heartbeatInterval << " ms'";
} }
// start heartbeat thread // start heartbeat thread
_heartbeatThread = new HeartbeatThread(DatabaseFeature::DATABASE->server(), _heartbeatThread = new HeartbeatThread(DatabaseFeature::DATABASE->server(),
_agencyCallbackRegistry.get(), _agencyCallbackRegistry.get(),

View File

@ -41,7 +41,7 @@
#include "VocBase/server.h" #include "VocBase/server.h"
#include "VocBase/vocbase.h" #include "VocBase/vocbase.h"
#include <functional> #include <functional>
#include <iostream>
using namespace arangodb; using namespace arangodb;
volatile sig_atomic_t HeartbeatThread::HasRunOnce = 0; volatile sig_atomic_t HeartbeatThread::HasRunOnce = 0;
@ -105,6 +105,7 @@ void HeartbeatThread::run() {
void HeartbeatThread::runDBServer() { void HeartbeatThread::runDBServer() {
LOG(TRACE) << "starting heartbeat thread (DBServer version)"; LOG(TRACE) << "starting heartbeat thread (DBServer version)";
std::cout << __FILE__ << __LINE__ << std::endl;
// convert timeout to seconds // convert timeout to seconds
double const interval = (double)_interval / 1000.0 / 1000.0; double const interval = (double)_interval / 1000.0 / 1000.0;
@ -217,6 +218,7 @@ void HeartbeatThread::runDBServer() {
void HeartbeatThread::runCoordinator() { void HeartbeatThread::runCoordinator() {
LOG(TRACE) << "starting heartbeat thread (coordinator version)"; LOG(TRACE) << "starting heartbeat thread (coordinator version)";
std::cout << __FILE__ << __LINE__ << std::endl;
uint64_t oldUserVersion = 0; uint64_t oldUserVersion = 0;
// convert timeout to seconds // convert timeout to seconds
@ -236,7 +238,7 @@ void HeartbeatThread::runCoordinator() {
LOG(TRACE) << "sending heartbeat to agency"; LOG(TRACE) << "sending heartbeat to agency";
double const start = TRI_microtime(); double const start = TRI_microtime();
std::cout << __FILE__ << __LINE__ << std::endl;
// send our state to the agency. // send our state to the agency.
// we don't care if this fails // we don't care if this fails
sendState(); sendState();
@ -258,6 +260,7 @@ void HeartbeatThread::runCoordinator() {
if (isStopping()) { if (isStopping()) {
break; break;
} }
std::cout << __FILE__ << __LINE__ << std::endl;
bool shouldSleep = true; bool shouldSleep = true;
@ -267,25 +270,31 @@ void HeartbeatThread::runCoordinator() {
if (result.successful()) { if (result.successful()) {
result.parse("", false); result.parse("", false);
std::cout << __FILE__ << __LINE__ << std::endl;
std::map<std::string, AgencyCommResultEntry>::iterator it = std::map<std::string, AgencyCommResultEntry>::iterator it =
result._values.begin(); result._values.begin();
if (it != result._values.end()) { if (it != result._values.end()) {
// there is a plan version // there is a plan version
std::cout << __FILE__ << __LINE__ << std::endl;
uint64_t planVersion = arangodb::basics::VelocyPackHelper::stringUInt64( uint64_t planVersion = arangodb::basics::VelocyPackHelper::stringUInt64(
it->second._vpack->slice()); it->second._vpack->slice());
std::cout << __FILE__ << __LINE__ << std::endl;
if (planVersion > lastPlanVersionNoticed) { if (planVersion > lastPlanVersionNoticed) {
if (handlePlanChangeCoordinator(planVersion)) { if (handlePlanChangeCoordinator(planVersion)) {
lastPlanVersionNoticed = planVersion; lastPlanVersionNoticed = planVersion;
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
result.clear(); result.clear();
std::cout << __FILE__ << __LINE__ << std::endl;
result = _agency.getValues("Sync/UserVersion", false); result = _agency.getValues("Sync/UserVersion", false);
if (result.successful()) { if (result.successful()) {
result.parse("", false); result.parse("", false);
@ -327,6 +336,7 @@ void HeartbeatThread::runCoordinator() {
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
result = _agency.getValues("Current/Version", false); result = _agency.getValues("Current/Version", false);
if (result.successful()) { if (result.successful()) {
result.parse("", false); result.parse("", false);
@ -348,6 +358,7 @@ void HeartbeatThread::runCoordinator() {
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
if (shouldSleep) { if (shouldSleep) {
double remain = interval - (TRI_microtime() - start); double remain = interval - (TRI_microtime() - start);
@ -363,6 +374,8 @@ void HeartbeatThread::runCoordinator() {
} }
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
} }
LOG(TRACE) << "stopped heartbeat thread"; LOG(TRACE) << "stopped heartbeat thread";
@ -456,8 +469,10 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
} }
} }
std::cout << result._body << std::endl;
if (result.successful()) { if (result.successful()) {
result.parse(prefixPlanChangeCoordinator + "/", false); result.parse(prefixPlanChangeCoordinator + "/", true);
std::vector<TRI_voc_tick_t> ids; std::vector<TRI_voc_tick_t> ids;
@ -470,6 +485,9 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
names.push_back(it->first); names.push_back(it->first);
} }
std::sort(names.begin(), names.end(), &myDBnamesComparer); std::sort(names.begin(), names.end(), &myDBnamesComparer);
for (auto const& a : names) {
std::cout << "++++++" << a << "+++" << std::endl;
}
// loop over all database names we got and create a local database // loop over all database names we got and create a local database
// instance if not yet present: // instance if not yet present:
@ -478,17 +496,22 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
VPackSlice const options = it->second._vpack->slice(); VPackSlice const options = it->second._vpack->slice();
TRI_voc_tick_t id = 0; TRI_voc_tick_t id = 0;
std::cout << options.toJson() << std::endl;
if (options.hasKey("id")) { if (options.hasKey("id")) {
std::cout << __FILE__ << __LINE__ << std::endl;
VPackSlice const v = options.get("id"); VPackSlice const v = options.get("id");
if (v.isString()) { if (v.isString()) {
std::cout << __FILE__ << __LINE__ << std::endl;
id = arangodb::basics::StringUtils::uint64(v.copyString()); id = arangodb::basics::StringUtils::uint64(v.copyString());
} }
} }
std::cout << __FILE__ << __LINE__ << std::endl;
if (id > 0) { if (id > 0) {
ids.push_back(id); ids.push_back(id);
} }
std::cout << __FILE__ << __LINE__ << std::endl;
TRI_vocbase_t* vocbase = TRI_vocbase_t* vocbase =
TRI_UseCoordinatorDatabaseServer(_server, name.c_str()); TRI_UseCoordinatorDatabaseServer(_server, name.c_str());
@ -527,6 +550,7 @@ bool HeartbeatThread::handlePlanChangeCoordinator(uint64_t currentPlanVersion) {
TRI_ReleaseVocBase(vocbase); TRI_ReleaseVocBase(vocbase);
} }
std::cout << __FILE__ << __LINE__ << std::endl;
++it; ++it;
} }