|
34 | 34 | #include "Logger/Logger.h"
|
35 | 35 | #include "ProgramOptions/ProgramOptions.h"
|
36 | 36 | #include "ProgramOptions/Section.h"
|
37 |
| -#include "Rest/Version.h" |
38 | 37 | #include "RestServer/DatabaseFeature.h"
|
39 | 38 | #include "Scheduler/Scheduler.h"
|
40 | 39 | #include "Scheduler/SchedulerFeature.h"
|
41 |
| -#include "StorageEngine/EngineSelectorFeature.h" |
42 | 40 |
|
43 | 41 | using namespace arangodb;
|
44 | 42 | using namespace arangodb::application_features;
|
@@ -242,7 +240,8 @@ void ClusterFeature::prepare() {
|
242 | 240 | if (_enableCluster &&
|
243 | 241 | _requirePersistedId &&
|
244 | 242 | !ServerState::instance()->hasPersistedId()) {
|
245 |
| - LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "required persisted UUID file '" << ServerState::instance()->getUuidFilename() << "' not found. Please make sure this instance is started using an already existing database directory"; |
| 243 | + LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "required persisted UUID file '" << ServerState::instance()->getUuidFilename() |
| 244 | + << "' not found. Please make sure this instance is started using an already existing database directory"; |
246 | 245 | FATAL_ERROR_EXIT();
|
247 | 246 | }
|
248 | 247 |
|
@@ -416,34 +415,6 @@ void ClusterFeature::start() {
|
416 | 415 |
|
417 | 416 | startHeartbeatThread(_agencyCallbackRegistry.get(), _heartbeatInterval, 5, endpoints);
|
418 | 417 |
|
419 |
| - while (true) { |
420 |
| - VPackBuilder builder; |
421 |
| - try { |
422 |
| - VPackObjectBuilder b(&builder); |
423 |
| - builder.add("endpoint", VPackValue(_myEndpoint)); |
424 |
| - builder.add("advertisedEndpoint", VPackValue(_myAdvertisedEndpoint)); |
425 |
| - builder.add("host", VPackValue(ServerState::instance()->getHost())); |
426 |
| - builder.add("version", VPackValue(rest::Version::getNumericServerVersion())); |
427 |
| - builder.add("engine", VPackValue(EngineSelectorFeature::engineName())); |
428 |
| - } catch (...) { |
429 |
| - LOG_TOPIC(FATAL, arangodb::Logger::CLUSTER) << "out of memory"; |
430 |
| - FATAL_ERROR_EXIT(); |
431 |
| - } |
432 |
| - |
433 |
| - result = comm.setValue("Current/ServersRegistered/" + myId, |
434 |
| - builder.slice(), 0.0); |
435 |
| - |
436 |
| - if (result.successful()) { |
437 |
| - break; |
438 |
| - } else { |
439 |
| - LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) |
440 |
| - << "failed to register server in agency: http code: " |
441 |
| - << result.httpCode() << ", body: '" << result.body() << "', retrying ..."; |
442 |
| - } |
443 |
| - |
444 |
| - std::this_thread::sleep_for(std::chrono::seconds(1)); |
445 |
| - } |
446 |
| - |
447 | 418 | comm.increment("Current/Version");
|
448 | 419 |
|
449 | 420 | ServerState::instance()->setState(ServerState::STATE_SERVING);
|
@@ -473,44 +444,38 @@ void ClusterFeature::stop() {
|
473 | 444 |
|
474 | 445 |
|
475 | 446 | void ClusterFeature::unprepare() {
|
476 |
| - if (_enableCluster) { |
477 |
| - if (_heartbeatThread != nullptr) { |
478 |
| - _heartbeatThread->beginShutdown(); |
479 |
| - } |
480 |
| - |
481 |
| - // change into shutdown state |
482 |
| - ServerState::instance()->setState(ServerState::STATE_SHUTDOWN); |
483 |
| - |
484 |
| - AgencyComm comm; |
485 |
| - comm.sendServerState(0.0); |
486 |
| - |
487 |
| - if (_heartbeatThread != nullptr) { |
488 |
| - int counter = 0; |
489 |
| - while (_heartbeatThread->isRunning()) { |
490 |
| - std::this_thread::sleep_for(std::chrono::microseconds(100000)); |
491 |
| - // emit warning after 5 seconds |
492 |
| - if (++counter == 10 * 5) { |
493 |
| - LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish"; |
494 |
| - } |
495 |
| - } |
496 |
| - } |
497 |
| - |
498 |
| - if (_unregisterOnShutdown) { |
499 |
| - ServerState::instance()->unregister(); |
500 |
| - } |
501 |
| - } |
502 |
| - |
503 | 447 | if (!_enableCluster) {
|
504 | 448 | ClusterComm::cleanup();
|
505 | 449 | return;
|
506 | 450 | }
|
| 451 | + |
| 452 | + if (_heartbeatThread != nullptr) { |
| 453 | + _heartbeatThread->beginShutdown(); |
| 454 | + } |
507 | 455 |
|
508 | 456 | // change into shutdown state
|
509 | 457 | ServerState::instance()->setState(ServerState::STATE_SHUTDOWN);
|
510 | 458 |
|
511 | 459 | AgencyComm comm;
|
512 | 460 | comm.sendServerState(0.0);
|
513 | 461 |
|
| 462 | + if (_heartbeatThread != nullptr) { |
| 463 | + int counter = 0; |
| 464 | + while (_heartbeatThread->isRunning()) { |
| 465 | + std::this_thread::sleep_for(std::chrono::microseconds(100000)); |
| 466 | + // emit warning after 5 seconds |
| 467 | + if (++counter == 10 * 5) { |
| 468 | + LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish"; |
| 469 | + } |
| 470 | + } |
| 471 | + } |
| 472 | + |
| 473 | + if (_unregisterOnShutdown) { |
| 474 | + ServerState::instance()->unregister(); |
| 475 | + } |
| 476 | + |
| 477 | + comm.sendServerState(0.0); |
| 478 | + |
514 | 479 | // Try only once to unregister because maybe the agencycomm
|
515 | 480 | // is shutting down as well...
|
516 | 481 |
|
|
0 commit comments