diff --git a/arangod/RestServer/ArangoServer.cpp b/arangod/RestServer/ArangoServer.cpp index a031acc622..0aca5b147e 100644 --- a/arangod/RestServer/ArangoServer.cpp +++ b/arangod/RestServer/ArangoServer.cpp @@ -42,6 +42,7 @@ #include "BasicsC/init.h" #include "BasicsC/logging.h" #include "BasicsC/strings.h" +#include "Dispatcher/ApplicationDispatcher.h" #include "Dispatcher/Dispatcher.h" #include "HttpServer/HttpHandlerFactory.h" #include "HttpServer/RedirectHandler.h" @@ -52,6 +53,7 @@ #include "RestHandler/RestImportHandler.h" #include "RestServer/ArangoHttpServer.h" #include "RestServer/JavascriptDispatcherThread.h" +#include "Scheduler/ApplicationScheduler.h" #include "UserManager/ApplicationUserManager.h" #include "V8/JSLoader.h" #include "V8/V8LineEditor.h" @@ -315,8 +317,12 @@ ArangoServer::ArangoServer (int argc, char** argv) : _argc(argc), _argv(argv), _binaryPath(), - _applicationAdminServer(0), + _applicationScheduler(0), + _applicationDispatcher(0), _applicationHttpServer(0), + _applicationHttpsServer(0), + _applicationAdminServer(0), + _applicationUserManager(0), _httpServer(0), _adminHttpServer(0), _httpPort("127.0.0.1:8529"), @@ -435,15 +441,17 @@ ArangoServer::ArangoServer (int argc, char** argv) //////////////////////////////////////////////////////////////////////////////// void ArangoServer::buildApplicationServer () { - _applicationServer = ApplicationServerDispatcher::create("[] ", TRIAGENS_VERSION); - + _applicationServer = new ApplicationServer("[] ", TRIAGENS_VERSION); _applicationServer->setUserConfigFile(".arango/arango.conf"); // ............................................................................. - // allow multi-threading scheduler + // allow multi-threading scheduler and dispatcher // ............................................................................. - _applicationServer->allowMultiScheduler(true); + _applicationScheduler = new ApplicationScheduler(_applicationServer); + _applicationScheduler->allowMultiScheduler(true); + + _applicationDispatcher = new ApplicationDispatcher(_applicationScheduler); // ............................................................................. // and start a simple admin server @@ -530,7 +538,7 @@ void ArangoServer::buildApplicationServer () { // a http server // ............................................................................. - _applicationHttpServer = ApplicationHttpServer::create(_applicationServer); + _applicationHttpServer = ApplicationHttpServer::create(_applicationScheduler, _applicationDispatcher); _applicationServer->addFeature(_applicationHttpServer); // ............................................................................. @@ -784,15 +792,15 @@ int ArangoServer::startupServer () { // create the various parts of the Arango server // ............................................................................. - _applicationServer->buildScheduler(); - _applicationServer->buildSchedulerReporter(); - _applicationServer->buildControlCHandler(); + _applicationScheduler->buildScheduler(); + _applicationScheduler->buildSchedulerReporter(); + _applicationScheduler->buildControlCHandler(); - safe_cast(_applicationServer)->buildDispatcher(); - safe_cast(_applicationServer)->buildDispatcherReporter(); - safe_cast(_applicationServer)->buildStandardQueue(_dispatcherThreads); + _applicationDispatcher->buildDispatcher(); + _applicationDispatcher->buildDispatcherReporter(); + _applicationDispatcher->buildStandardQueue(_dispatcherThreads); - Dispatcher* dispatcher = safe_cast(_applicationServer)->dispatcher(); + Dispatcher* dispatcher = _applicationDispatcher->dispatcher(); if (_actionThreadsJS < 1) { _actionThreadsJS = 1; @@ -800,22 +808,22 @@ int ArangoServer::startupServer () { // if we share a the server port for admin and client, only create a CLIENT queue if (0 < _actionThreadsJS) { - safe_cast(dispatcher)->addQueue("CLIENT-JAVASCRIPT", ClientActionDispatcherThreadCreatorJS, _actionThreadsJS); + dispatcher->addQueue("CLIENT-JAVASCRIPT", ClientActionDispatcherThreadCreatorJS, _actionThreadsJS); } #if TRI_ENABLE_MRUBY if (0 < _actionThreadsMR) { - safe_cast(dispatcher)->addQueue("CLIENT-RUBY", ClientActionDispatcherThreadCreatorMR, _actionThreadsMR); + dispatcher->addQueue("CLIENT-RUBY", ClientActionDispatcherThreadCreatorMR, _actionThreadsMR); } #endif // use a separate queue for administrator requests if (! shareAdminPort) { if (useAdminPort) { - safe_cast(dispatcher)->addQueue("SYSTEM-JAVASCRIPT", SystemActionDispatcherThreadCreatorJS, 2); + dispatcher->addQueue("SYSTEM-JAVASCRIPT", SystemActionDispatcherThreadCreatorJS, 2); #if TRI_ENABLE_MRUBY - safe_cast(dispatcher)->addQueue("SYSTEM-RUBY", SystemActionDispatcherThreadCreatorMR, 2); + dispatcher->addQueue("SYSTEM-RUBY", SystemActionDispatcherThreadCreatorMR, 2); #endif } } @@ -824,7 +832,7 @@ int ArangoServer::startupServer () { // create a http server and http handler factory // ............................................................................. - Scheduler* scheduler = _applicationServer->scheduler(); + Scheduler* scheduler = _applicationScheduler->scheduler(); // we pass the options be reference, so keep them until shutdown RestActionHandler::action_options_t httpOptions; diff --git a/arangod/RestServer/ArangoServer.h b/arangod/RestServer/ArangoServer.h index 81c87d54de..55e30d9b5f 100644 --- a/arangod/RestServer/ArangoServer.h +++ b/arangod/RestServer/ArangoServer.h @@ -39,6 +39,13 @@ // ----------------------------------------------------------------------------- namespace triagens { + namespace rest { + class ApplicationDispatcher; + class ApplicationHttpServer; + class ApplicationHttpsServer; + class ApplicationScheduler; + } + namespace admin { class ApplicationUserManager; } @@ -199,18 +206,36 @@ namespace triagens { std::string _binaryPath; +//////////////////////////////////////////////////////////////////////////////// +/// @brief application scheduler +//////////////////////////////////////////////////////////////////////////////// + + rest::ApplicationScheduler* _applicationScheduler; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief application dispatcher +//////////////////////////////////////////////////////////////////////////////// + + rest::ApplicationDispatcher* _applicationDispatcher; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief application http server +//////////////////////////////////////////////////////////////////////////////// + + rest::ApplicationHttpServer* _applicationHttpServer; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief application https server +//////////////////////////////////////////////////////////////////////////////// + + rest::ApplicationHttpsServer* _applicationHttpsServer; + //////////////////////////////////////////////////////////////////////////////// /// @brief constructed admin server application //////////////////////////////////////////////////////////////////////////////// admin::ApplicationAdminServer* _applicationAdminServer; -//////////////////////////////////////////////////////////////////////////////// -/// @brief constructed http server application -//////////////////////////////////////////////////////////////////////////////// - - rest::ApplicationHttpServer* _applicationHttpServer; - //////////////////////////////////////////////////////////////////////////////// /// @brief constructed user server application //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/ApplicationServer/ApplicationFeature.cpp b/lib/ApplicationServer/ApplicationFeature.cpp index 16330b306d..6857cfacd7 100644 --- a/lib/ApplicationServer/ApplicationFeature.cpp +++ b/lib/ApplicationServer/ApplicationFeature.cpp @@ -89,6 +89,36 @@ bool ApplicationFeature::parsePhase2 (basics::ProgramOptions&) { return true; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief starts the feature +//////////////////////////////////////////////////////////////////////////////// + +bool ApplicationFeature::start () { + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief checks if the feature is still running +//////////////////////////////////////////////////////////////////////////////// + +bool ApplicationFeature::isRunning () { + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief begins the shut down sequence +//////////////////////////////////////////////////////////////////////////////// + +void ApplicationFeature::beginShutdown () { +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief shuts down everything +//////////////////////////////////////////////////////////////////////////////// + +void ApplicationFeature::shutdown () { +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Dispatcher/ApplicationDispatcher.h b/lib/Dispatcher/ApplicationDispatcher.h index 86725ea08f..3eac56da6b 100644 --- a/lib/Dispatcher/ApplicationDispatcher.h +++ b/lib/Dispatcher/ApplicationDispatcher.h @@ -73,6 +73,8 @@ namespace triagens { /// @{ //////////////////////////////////////////////////////////////////////////////// + public: + //////////////////////////////////////////////////////////////////////////////// /// @brief constructor //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Rest/AnyServer.cpp b/lib/Rest/AnyServer.cpp index a440309306..7d920d823c 100644 --- a/lib/Rest/AnyServer.cpp +++ b/lib/Rest/AnyServer.cpp @@ -233,9 +233,7 @@ AnyServer::AnyServer () _supervisorMode(false), _pidFile(""), _workingDirectory(""), - _applicationServer(0), - _applicationHttpServer(0), - _applicationHttpsServer(0) { + _applicationServer(0) { } //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Rest/AnyServer.h b/lib/Rest/AnyServer.h index ee9f7b9e63..c20de94919 100644 --- a/lib/Rest/AnyServer.h +++ b/lib/Rest/AnyServer.h @@ -38,8 +38,6 @@ namespace triagens { namespace rest { class ApplicationServer; - class ApplicationHttpServer; - class ApplicationHttpsServer; // ----------------------------------------------------------------------------- // --SECTION-- class AnyServer @@ -191,24 +189,12 @@ namespace triagens { ApplicationServer* _applicationServer; -//////////////////////////////////////////////////////////////////////////////// -/// @brief application http server -//////////////////////////////////////////////////////////////////////////////// - - ApplicationHttpServer* _applicationHttpServer; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief application https server -//////////////////////////////////////////////////////////////////////////////// - - ApplicationHttpsServer* _applicationHttpsServer; - //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- -// --SECTION-- private variables +// --SECTION-- private methods // ----------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////