1
0
Fork 0

trying to fix cleanup

This commit is contained in:
Frank Celler 2016-06-06 23:49:36 +02:00
parent d0693b8fc1
commit 69e254d28a
17 changed files with 38 additions and 32 deletions

View File

@ -189,7 +189,7 @@ void AgencyFeature::start() {
_agent->load();
}
void AgencyFeature::stop() {
void AgencyFeature::unprepare() {
if (!isEnabled()) {
return;

View File

@ -40,7 +40,7 @@ class AgencyFeature : virtual public application_features::ApplicationFeature {
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
void prepare() override final;
void start() override final;
void stop() override final;
void unprepare() override final;
private:
uint64_t _size; // agency size (default: 5)

View File

@ -461,7 +461,7 @@ void ClusterFeature::start() {
dispatcher->buildAqlQueue();
}
void ClusterFeature::stop() {
void ClusterFeature::unprepare() {
if (_enableCluster) {
if (_heartbeatThread != nullptr) {
_heartbeatThread->beginShutdown();

View File

@ -42,7 +42,7 @@ class ClusterFeature : public application_features::ApplicationFeature {
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
void prepare() override final;
void start() override final;
void stop() override final;
void unprepare() override final;
private:
std::vector<std::string> _agencyEndpoints;

View File

@ -24,10 +24,10 @@
#include "Dispatcher.h"
#include "Logger/Logger.h"
#include "Dispatcher/DispatcherQueue.h"
#include "Dispatcher/DispatcherThread.h"
#include "Dispatcher/Job.h"
#include "Logger/Logger.h"
using namespace arangodb::basics;
using namespace arangodb::rest;
@ -59,21 +59,22 @@ void Dispatcher::addStandardQueue(size_t nrThreads, size_t nrExtraThreads,
size_t maxSize) {
TRI_ASSERT(_queues[STANDARD_QUEUE] == nullptr);
_queues[STANDARD_QUEUE] =
new DispatcherQueue(_scheduler, this, STANDARD_QUEUE,
CreateDispatcherThread, nrThreads, nrExtraThreads, maxSize);
_queues[STANDARD_QUEUE] = new DispatcherQueue(
_scheduler, this, STANDARD_QUEUE, CreateDispatcherThread, nrThreads,
nrExtraThreads, maxSize);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief adds the AQL queue (used for the cluster)
////////////////////////////////////////////////////////////////////////////////
void Dispatcher::addAQLQueue(size_t nrThreads, size_t nrExtraThreads,
void Dispatcher::addAQLQueue(size_t nrThreads, size_t nrExtraThreads,
size_t maxSize) {
TRI_ASSERT(_queues[AQL_QUEUE] == nullptr);
_queues[AQL_QUEUE] = new DispatcherQueue(
_scheduler, this, AQL_QUEUE, CreateDispatcherThread, nrThreads, nrExtraThreads, maxSize);
_queues[AQL_QUEUE] =
new DispatcherQueue(_scheduler, this, AQL_QUEUE, CreateDispatcherThread,
nrThreads, nrExtraThreads, maxSize);
}
////////////////////////////////////////////////////////////////////////////////
@ -100,7 +101,8 @@ int Dispatcher::addJob(std::unique_ptr<Job>& job, bool startThread) {
// log success, but do this BEFORE the real add, because the addJob might
// execute
// and delete the job before we have a chance to log something
LOG(TRACE) << "added job " << (void*)(job.get()) << " to queue '" << qnr << "'";
LOG(TRACE) << "added job " << (void*)(job.get()) << " to queue '" << qnr
<< "'";
// add the job to the list of ready jobs
return queue->addJob(job, startThread);
@ -152,8 +154,6 @@ void Dispatcher::shutdown() {
LOG(DEBUG) << "shutting down the dispatcher";
for (auto queue : _queues) {
if (queue != nullptr) {
queue->shutdown();
}
@ -169,7 +169,11 @@ void Dispatcher::reportStatus() {
DispatcherQueue* queue = _queues[i];
if (queue != nullptr) {
LOG(INFO) << "dispatcher queue '" << i << "': initial = " << queue->_nrThreads << ", running = " << queue->_nrRunning.load() << ", waiting = " << queue->_nrWaiting.load() << ", blocked = " << queue->_nrBlocked.load();
LOG(INFO) << "dispatcher queue '" << i
<< "': initial = " << queue->_nrThreads
<< ", running = " << queue->_nrRunning.load()
<< ", waiting = " << queue->_nrWaiting.load()
<< ", blocked = " << queue->_nrBlocked.load();
}
}
}

View File

@ -57,7 +57,9 @@ DispatcherFeature::DispatcherFeature(
}
DispatcherFeature::~DispatcherFeature() {
delete _dispatcher;
if (_dispatcher != nullptr) {
delete _dispatcher;
}
}
void DispatcherFeature::collectOptions(

View File

@ -162,7 +162,7 @@ void BootstrapFeature::start() {
_isReady = true;
}
void BootstrapFeature::stop() {
void BootstrapFeature::unprepare() {
auto server = ApplicationServer::getFeature<DatabaseServerFeature>("DatabaseServer");
TRI_server_t* s = server->SERVER;

View File

@ -33,7 +33,7 @@ class BootstrapFeature final : public application_features::ApplicationFeature {
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void start() override final;
void stop() override final;
void unprepare() override final;
bool isReady() const {
return _isReady;

View File

@ -60,7 +60,7 @@ void ConsoleFeature::start() {
_consoleThread->start();
}
void ConsoleFeature::stop() {
void ConsoleFeature::unprepare() {
if (_operationMode != OperationMode::MODE_CONSOLE) {
return;
}
@ -73,8 +73,6 @@ void ConsoleFeature::stop() {
while (_consoleThread->isRunning() && ++iterations < 30) {
usleep(100 * 1000); // spin while console is still needed
}
}
void ConsoleFeature::unprepare() {
std::cout << std::endl << TRI_BYE_MESSAGE << std::endl;
}

View File

@ -36,7 +36,6 @@ class ConsoleFeature final : public application_features::ApplicationFeature {
public:
void start() override final;
void stop() override final;
void unprepare() override final;
private:

View File

@ -58,6 +58,12 @@ SchedulerFeature::SchedulerFeature(
startsAfter("WorkMonitor");
}
SchedulerFeature::~SchedulerFeature() {
if (_scheduler != nullptr) {
delete _scheduler;
}
}
void SchedulerFeature::collectOptions(
std::shared_ptr<options::ProgramOptions> options) {
options->addSection("scheduler", "Configure the I/O scheduler");
@ -145,11 +151,7 @@ void SchedulerFeature::stop() {
}
void SchedulerFeature::unprepare() {
if (_scheduler != nullptr) {
delete _scheduler;
_scheduler = nullptr;
SCHEDULER = nullptr;
}
SCHEDULER = nullptr;
}
#ifdef _WIN32

View File

@ -40,6 +40,7 @@ class SchedulerFeature final : public application_features::ApplicationFeature {
public:
explicit SchedulerFeature(application_features::ApplicationServer* server);
~SchedulerFeature();
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;

View File

@ -54,7 +54,7 @@ void StatisticsFeature::start() {
TRI_InitializeStatistics();
}
void StatisticsFeature::stop() {
void StatisticsFeature::unprepare() {
TRI_ShutdownStatistics();
STATISTICS = nullptr;
}

View File

@ -42,7 +42,7 @@ class StatisticsFeature final
public:
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
void start() override final;
void stop() override final;
void unprepare() override final;
public:
void disableStatistics() { _statistics = false; }

View File

@ -454,7 +454,7 @@ bool LogfileManager::open() {
return true;
}
void LogfileManager::stop() {
void LogfileManager::unprepare() {
_shutdown = 1;
LOG(TRACE) << "shutting down WAL";

View File

@ -116,7 +116,7 @@ class LogfileManager final : public application_features::ApplicationFeature {
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
void prepare() override final;
void start() override final;
void stop() override final;
void unprepare() override final;
public:
// run the recovery procedure

View File

@ -545,7 +545,7 @@ void ApplicationServer::stop() {
auto feature = *it;
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::stop";
// feature->stop();
feature->stop();
feature->state(FeatureState::STOPPED);
reportFeatureProgress(_state, feature->name());
}