mirror of https://gitee.com/bigwinds/arangodb
WIP
This commit is contained in:
parent
3f9dd62d4c
commit
0fa6435731
|
@ -234,6 +234,7 @@ add_executable(${BIN_ARANGOD}
|
||||||
Scheduler/Task.cpp
|
Scheduler/Task.cpp
|
||||||
Scheduler/TaskManager.cpp
|
Scheduler/TaskManager.cpp
|
||||||
Scheduler/TimerTask.cpp
|
Scheduler/TimerTask.cpp
|
||||||
|
Statistics/StatisticsFeature.cpp
|
||||||
Statistics/statistics.cpp
|
Statistics/statistics.cpp
|
||||||
Storage/Marker.cpp
|
Storage/Marker.cpp
|
||||||
Storage/Options.cpp
|
Storage/Options.cpp
|
||||||
|
|
|
@ -31,10 +31,8 @@
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
RestShardHandler::RestShardHandler(arangodb::HttpRequest* request,
|
RestShardHandler::RestShardHandler(arangodb::HttpRequest* request)
|
||||||
Dispatcher* data)
|
: RestBaseHandler(request) {
|
||||||
: RestBaseHandler(request), _dispatcher(data) {
|
|
||||||
TRI_ASSERT(_dispatcher != nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RestShardHandler::isDirect() const { return true; }
|
bool RestShardHandler::isDirect() const { return true; }
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Dispatcher;
|
||||||
|
|
||||||
class RestShardHandler : public RestBaseHandler {
|
class RestShardHandler : public RestBaseHandler {
|
||||||
public:
|
public:
|
||||||
RestShardHandler(HttpRequest* request, rest::Dispatcher*);
|
RestShardHandler(HttpRequest* request);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isDirect() const override;
|
bool isDirect() const override;
|
||||||
|
@ -48,13 +48,6 @@ class RestShardHandler : public RestBaseHandler {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
status_t execute() override;
|
status_t execute() override;
|
||||||
|
|
||||||
private:
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief dispatcher
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
rest::Dispatcher* TRI_UNUSED _dispatcher;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "Basics/conversions.h"
|
#include "Basics/conversions.h"
|
||||||
#include "Basics/StringUtils.h"
|
#include "Basics/StringUtils.h"
|
||||||
#include "Dispatcher/Dispatcher.h"
|
#include "Dispatcher/Dispatcher.h"
|
||||||
|
#include "Dispatcher/DispatcherFeature.h"
|
||||||
#include "HttpServer/AsyncJobManager.h"
|
#include "HttpServer/AsyncJobManager.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "Rest/HttpResponse.h"
|
#include "Rest/HttpResponse.h"
|
||||||
|
@ -37,10 +38,8 @@ using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
RestJobHandler::RestJobHandler(HttpRequest* request,
|
RestJobHandler::RestJobHandler(HttpRequest* request,
|
||||||
std::pair<Dispatcher*, AsyncJobManager*>* data)
|
AsyncJobManager* jobManager)
|
||||||
: RestBaseHandler(request),
|
: RestBaseHandler(request), _jobManager(jobManager) {}
|
||||||
_dispatcher(data->first),
|
|
||||||
_jobManager(data->second) {}
|
|
||||||
|
|
||||||
bool RestJobHandler::isDirect() const { return true; }
|
bool RestJobHandler::isDirect() const { return true; }
|
||||||
|
|
||||||
|
@ -58,7 +57,8 @@ HttpHandler::status_t RestJobHandler::execute() {
|
||||||
} else if (suffix.size() == 2) {
|
} else if (suffix.size() == 2) {
|
||||||
putJobMethod();
|
putJobMethod();
|
||||||
} else {
|
} else {
|
||||||
generateError(GeneralResponse::ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER);
|
generateError(GeneralResponse::ResponseCode::BAD,
|
||||||
|
TRI_ERROR_HTTP_BAD_PARAMETER);
|
||||||
}
|
}
|
||||||
} else if (type == GeneralRequest::RequestType::DELETE_REQ) {
|
} else if (type == GeneralRequest::RequestType::DELETE_REQ) {
|
||||||
deleteJob();
|
deleteJob();
|
||||||
|
@ -122,7 +122,7 @@ void RestJobHandler::putJobMethod() {
|
||||||
uint64_t jobId = StringUtils::uint64(value);
|
uint64_t jobId = StringUtils::uint64(value);
|
||||||
|
|
||||||
if (method == "cancel") {
|
if (method == "cancel") {
|
||||||
bool status = _dispatcher->cancelJob(jobId);
|
bool status = DispatcherFeature::DISPATCHER->cancelJob(jobId);
|
||||||
|
|
||||||
// unknown or already fetched job
|
// unknown or already fetched job
|
||||||
if (!status) {
|
if (!status) {
|
||||||
|
|
|
@ -40,8 +40,7 @@ class Dispatcher;
|
||||||
|
|
||||||
class RestJobHandler : public RestBaseHandler {
|
class RestJobHandler : public RestBaseHandler {
|
||||||
public:
|
public:
|
||||||
RestJobHandler(HttpRequest* request,
|
RestJobHandler(HttpRequest* request, rest::AsyncJobManager*);
|
||||||
std::pair<rest::Dispatcher*, rest::AsyncJobManager*>*);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isDirect() const override;
|
bool isDirect() const override;
|
||||||
|
@ -89,12 +88,6 @@ class RestJobHandler : public RestBaseHandler {
|
||||||
void deleteJob();
|
void deleteJob();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief dispatcher
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
rest::Dispatcher* _dispatcher;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief async job manager
|
/// @brief async job manager
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -32,11 +32,8 @@ using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
RestShutdownHandler::RestShutdownHandler(HttpRequest* request,
|
RestShutdownHandler::RestShutdownHandler(HttpRequest* request)
|
||||||
void* applicationServer)
|
: RestBaseHandler(request) {}
|
||||||
: RestBaseHandler(request),
|
|
||||||
_applicationServer(
|
|
||||||
static_cast<ApplicationServer*>(applicationServer)) {}
|
|
||||||
|
|
||||||
bool RestShutdownHandler::isDirect() const { return true; }
|
bool RestShutdownHandler::isDirect() const { return true; }
|
||||||
|
|
||||||
|
@ -45,7 +42,7 @@ bool RestShutdownHandler::isDirect() const { return true; }
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HttpHandler::status_t RestShutdownHandler::execute() {
|
HttpHandler::status_t RestShutdownHandler::execute() {
|
||||||
_applicationServer->beginShutdown();
|
ApplicationServer::server->beginShutdown();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
VPackBuilder json;
|
VPackBuilder json;
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace arangodb {
|
||||||
|
|
||||||
class RestShutdownHandler : public RestBaseHandler {
|
class RestShutdownHandler : public RestBaseHandler {
|
||||||
public:
|
public:
|
||||||
RestShutdownHandler(HttpRequest*, void* applicationServer);
|
RestShutdownHandler(HttpRequest*);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isDirect() const override;
|
bool isDirect() const override;
|
||||||
|
@ -47,13 +47,6 @@ class RestShutdownHandler : public RestBaseHandler {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
status_t execute() override;
|
status_t execute() override;
|
||||||
|
|
||||||
private:
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief application server
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
application_features::ApplicationServer* _applicationServer;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
#include "Rest/Version.h"
|
#include "Rest/Version.h"
|
||||||
|
#include "RestServer/RestServerFeature.h"
|
||||||
#include "V8Server/V8DealerFeature.h"
|
#include "V8Server/V8DealerFeature.h"
|
||||||
#include "V8Server/v8-query.h"
|
#include "V8Server/v8-query.h"
|
||||||
#include "V8Server/v8-vocbase.h"
|
#include "V8Server/v8-vocbase.h"
|
||||||
|
@ -309,13 +310,19 @@ void DatabaseFeature::openDatabases() {
|
||||||
defaults.defaultWaitForSync = _defaultWaitForSync;
|
defaults.defaultWaitForSync = _defaultWaitForSync;
|
||||||
defaults.forceSyncProperties = _forceSyncProperties;
|
defaults.forceSyncProperties = _forceSyncProperties;
|
||||||
|
|
||||||
#warning TODO
|
// get authentication (if available)
|
||||||
#if 0
|
RestServerFeature* rest = dynamic_cast<RestServerFeature*>(
|
||||||
defaults.requireAuthentication = !_disableAuthentication;
|
ApplicationServer::lookupFeature("RestServer"));
|
||||||
defaults.requireAuthenticationUnixSockets =
|
|
||||||
!_disableAuthenticationUnixSockets;
|
if (rest != nullptr) {
|
||||||
defaults.authenticateSystemOnly = _authenticateSystemOnly;
|
defaults.requireAuthentication = rest->authentication();
|
||||||
#endif
|
defaults.requireAuthenticationUnixSockets = rest->authenticationUnixSockets();
|
||||||
|
defaults.authenticateSystemOnly = rest->authenticationSystemOnly();
|
||||||
|
} else {
|
||||||
|
defaults.requireAuthentication = true;
|
||||||
|
defaults.requireAuthenticationUnixSockets = true;
|
||||||
|
defaults.authenticateSystemOnly = false;
|
||||||
|
}
|
||||||
|
|
||||||
TRI_ASSERT(_server != nullptr);
|
TRI_ASSERT(_server != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ class DatabaseFeature final : public application_features::ApplicationFeature {
|
||||||
public:
|
public:
|
||||||
TRI_vocbase_t* vocbase() const { return _vocbase; }
|
TRI_vocbase_t* vocbase() const { return _vocbase; }
|
||||||
TRI_server_t* server() const { return _server.get(); }
|
TRI_server_t* server() const { return _server.get(); }
|
||||||
|
aql::QueryRegistry* queryRegistry() const { return _queryRegistry.get(); }
|
||||||
|
|
||||||
bool ignoreDatafileErrors() const { return _ignoreDatafileErrors; }
|
bool ignoreDatafileErrors() const { return _ignoreDatafileErrors; }
|
||||||
bool isInitiallyEmpty() const { return _isInitiallyEmpty; }
|
bool isInitiallyEmpty() const { return _isInitiallyEmpty; }
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
|
|
||||||
#include "EndpointFeature.h"
|
#include "EndpointFeature.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/SslFeature.h"
|
|
||||||
#include "Dispatcher/DispatcherFeature.h"
|
|
||||||
#include "HttpServer/HttpServer.h"
|
|
||||||
#include "HttpServer/HttpsServer.h"
|
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
#include "RestServer/ServerFeature.h"
|
#include "RestServer/ServerFeature.h"
|
||||||
|
@ -41,8 +37,7 @@ EndpointFeature::EndpointFeature(
|
||||||
application_features::ApplicationServer* server)
|
application_features::ApplicationServer* server)
|
||||||
: ApplicationFeature(server, "Endpoint"),
|
: ApplicationFeature(server, "Endpoint"),
|
||||||
_reuseAddress(true),
|
_reuseAddress(true),
|
||||||
_backlogSize(64),
|
_backlogSize(64) {
|
||||||
_keepAliveTimeout(300.0) {
|
|
||||||
setOptional(true);
|
setOptional(true);
|
||||||
requiresElevatedPrivileges(true);
|
requiresElevatedPrivileges(true);
|
||||||
startsAfter("Ssl");
|
startsAfter("Ssl");
|
||||||
|
@ -73,12 +68,6 @@ void EndpointFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
|
||||||
options->addHiddenOption("--tcp.backlog-size", "listen backlog size",
|
options->addHiddenOption("--tcp.backlog-size", "listen backlog size",
|
||||||
new UInt64Parameter(&_backlogSize));
|
new UInt64Parameter(&_backlogSize));
|
||||||
|
|
||||||
options->addSection("http", "HttpServer features");
|
|
||||||
|
|
||||||
options->addOption("--http.keep-alive-timeout",
|
|
||||||
"keep-alive timeout in seconds",
|
|
||||||
new DoubleParameter(&_keepAliveTimeout));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
void EndpointFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||||
|
@ -109,6 +98,11 @@ void EndpointFeature::start() {
|
||||||
_endpointList.dump();
|
_endpointList.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> EndpointFeature::httpEndpoints() {
|
||||||
|
#warning TODO
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void EndpointFeature::buildEndpointLists() {
|
void EndpointFeature::buildEndpointLists() {
|
||||||
for (std::vector<std::string>::const_iterator i = _endpoints.begin();
|
for (std::vector<std::string>::const_iterator i = _endpoints.begin();
|
||||||
i != _endpoints.end(); ++i) {
|
i != _endpoints.end(); ++i) {
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
#ifndef ARANGOD_HTTP_SERVER_ENDPOINT_FEATURE_H
|
#ifndef ARANGOD_HTTP_SERVER_ENDPOINT_FEATURE_H
|
||||||
#define ARANGOD_HTTP_SERVER_ENDPOINT_FEATURE_H 1
|
#define ARANGOD_HTTP_SERVER_ENDPOINT_FEATURE_H 1
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
|
||||||
|
|
||||||
#include "ApplicationFeatures/ApplicationFeature.h"
|
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||||
|
#include "ApplicationFeatures/HttpEndpointProvider.h"
|
||||||
|
|
||||||
#include "Endpoint/EndpointList.h"
|
#include "Endpoint/EndpointList.h"
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
@ -35,7 +35,8 @@ class HttpServer;
|
||||||
class HttpsServer;
|
class HttpsServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndpointFeature final : public application_features::ApplicationFeature {
|
class EndpointFeature final : public application_features::ApplicationFeature,
|
||||||
|
public HttpEndpointProvider {
|
||||||
public:
|
public:
|
||||||
explicit EndpointFeature(application_features::ApplicationServer* server);
|
explicit EndpointFeature(application_features::ApplicationServer* server);
|
||||||
|
|
||||||
|
@ -45,14 +46,17 @@ class EndpointFeature final : public application_features::ApplicationFeature {
|
||||||
void prepare() override final;
|
void prepare() override final;
|
||||||
void start() override final;
|
void start() override final;
|
||||||
|
|
||||||
private:
|
|
||||||
void buildEndpointLists();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> _endpoints;
|
std::vector<std::string> _endpoints;
|
||||||
bool _reuseAddress;
|
bool _reuseAddress;
|
||||||
uint64_t _backlogSize;
|
uint64_t _backlogSize;
|
||||||
double _keepAliveTimeout;
|
|
||||||
|
public:
|
||||||
|
std::vector<std::string> httpEndpoints() override;
|
||||||
|
EndpointList const& endpointList() const { return _endpointList; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void buildEndpointLists();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EndpointList _endpointList;
|
EndpointList _endpointList;
|
||||||
|
|
|
@ -22,148 +22,101 @@
|
||||||
|
|
||||||
#include "RestServerFeature.h"
|
#include "RestServerFeature.h"
|
||||||
|
|
||||||
|
#include "ApplicationFeatures/SslFeature.h"
|
||||||
|
#include "Aql/RestAqlHandler.h"
|
||||||
|
#include "Cluster/ClusterComm.h"
|
||||||
|
#include "Cluster/RestShardHandler.h"
|
||||||
|
#include "Dispatcher/DispatcherFeature.h"
|
||||||
|
#include "HttpServer/HttpHandlerFactory.h"
|
||||||
|
#include "HttpServer/HttpServer.h"
|
||||||
|
#include "HttpServer/HttpsServer.h"
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
|
#include "Rest/Version.h"
|
||||||
|
#include "RestHandler/RestAdminLogHandler.h"
|
||||||
|
#include "RestHandler/RestBatchHandler.h"
|
||||||
|
#include "RestHandler/RestCursorHandler.h"
|
||||||
|
#include "RestHandler/RestDebugHandler.h"
|
||||||
|
#include "RestHandler/RestDocumentHandler.h"
|
||||||
|
#include "RestHandler/RestEdgeHandler.h"
|
||||||
|
#include "RestHandler/RestEdgesHandler.h"
|
||||||
|
#include "RestHandler/RestExportHandler.h"
|
||||||
|
#include "RestHandler/RestHandlerCreator.h"
|
||||||
|
#include "RestHandler/RestImportHandler.h"
|
||||||
|
#include "RestHandler/RestJobHandler.h"
|
||||||
|
#include "RestHandler/RestPleaseUpgradeHandler.h"
|
||||||
|
#include "RestHandler/RestQueryCacheHandler.h"
|
||||||
|
#include "RestHandler/RestQueryHandler.h"
|
||||||
|
#include "RestHandler/RestReplicationHandler.h"
|
||||||
|
#include "RestHandler/RestShutdownHandler.h"
|
||||||
|
#include "RestHandler/RestSimpleHandler.h"
|
||||||
|
#include "RestHandler/RestSimpleQueryHandler.h"
|
||||||
|
#include "RestHandler/RestUploadHandler.h"
|
||||||
|
#include "RestHandler/RestVersionHandler.h"
|
||||||
|
#include "RestHandler/WorkMonitorHandler.h"
|
||||||
#include "RestServer/DatabaseFeature.h"
|
#include "RestServer/DatabaseFeature.h"
|
||||||
|
#include "RestServer/EndpointFeature.h"
|
||||||
#include "RestServer/ServerFeature.h"
|
#include "RestServer/ServerFeature.h"
|
||||||
|
#include "Scheduler/SchedulerFeature.h"
|
||||||
|
#include "V8Server/V8DealerFeature.h"
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
using namespace arangodb::rest;
|
||||||
using namespace arangodb::options;
|
using namespace arangodb::options;
|
||||||
|
|
||||||
RestServerFeature::RestServerFeature(application_features::ApplicationServer* server)
|
RestServerFeature::RestServerFeature(
|
||||||
: ApplicationFeature(server, "RestServer") {
|
application_features::ApplicationServer* server,
|
||||||
|
std::string const& authenticationRealm)
|
||||||
|
: ApplicationFeature(server, "RestServer"),
|
||||||
|
_keepAliveTimeout(300.0),
|
||||||
|
_authenticationRealm(authenticationRealm),
|
||||||
|
_defaultApiCompatibility(Version::getNumericServerVersion()),
|
||||||
|
_allowMethodOverride(false),
|
||||||
|
_handlerFactory(nullptr),
|
||||||
|
_jobManager(nullptr) {
|
||||||
|
setOptional(true);
|
||||||
|
requiresElevatedPrivileges(false);
|
||||||
|
startsAfter("Dispatcher");
|
||||||
|
startsAfter("Endpoint");
|
||||||
|
startsAfter("Scheduler");
|
||||||
startsAfter("Server");
|
startsAfter("Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestServerFeature::start() {
|
void RestServerFeature::collectOptions(
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
|
std::shared_ptr<ProgramOptions> options) {
|
||||||
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
|
||||||
|
|
||||||
|
options->addSection("server", "Server features");
|
||||||
|
|
||||||
|
options->addHiddenOption("--server.default-api-compatibility",
|
||||||
|
"default API compatibility version",
|
||||||
|
new Int32Parameter(&_defaultApiCompatibility));
|
||||||
|
|
||||||
|
options->addSection("http", "HttpServer features");
|
||||||
|
|
||||||
|
options->addSection("http", "HttpServer features");
|
||||||
|
|
||||||
|
options->addHiddenOption("--http.allow-method-override",
|
||||||
|
"allow HTTP method override using special headers",
|
||||||
|
new BooleanParameter(&_allowMethodOverride));
|
||||||
|
|
||||||
|
options->addOption("--http.keep-alive-timeout",
|
||||||
|
"keep-alive timeout in seconds",
|
||||||
|
new DoubleParameter(&_keepAliveTimeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestServerFeature::stop() {
|
void RestServerFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
|
||||||
|
|
||||||
}
|
if (_defaultApiCompatibility < HttpRequest::MIN_COMPATIBILITY) {
|
||||||
|
LOG(FATAL) << "invalid value for --server.default-api-compatibility. "
|
||||||
|
"minimum allowed value is "
|
||||||
#if 0
|
<< HttpRequest::MIN_COMPATIBILITY;
|
||||||
_jobManager(nullptr),
|
|
||||||
|
|
||||||
rest::AsyncJobManager* jobManager() const { return _jobManager; }
|
|
||||||
|
|
||||||
_handlerFactory(nullptr),
|
|
||||||
rest::AsyncJobManager* _jobManager;
|
|
||||||
|
|
||||||
|
|
||||||
defineHandlers();
|
|
||||||
|
|
||||||
// disabled maintenance mode
|
|
||||||
HttpHandlerFactory::setMaintenance(false);
|
|
||||||
|
|
||||||
|
|
||||||
void buildServers();
|
|
||||||
|
|
||||||
std::vector<rest::HttpServer*> _servers;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
prepare:
|
|
||||||
buildHandlerFactory();
|
|
||||||
HttpHandlerFactory::setMaintenance(true);
|
|
||||||
|
|
||||||
|
|
||||||
start:
|
|
||||||
buildServers();
|
|
||||||
|
|
||||||
for (auto& server : _servers) {
|
|
||||||
server->startListening();
|
|
||||||
}
|
|
||||||
|
|
||||||
#warning TODO
|
|
||||||
#if 0
|
|
||||||
_jobManager = new AsyncJobManager(ClusterCommRestCallback);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stop:
|
|
||||||
|
|
||||||
for (auto& server : _servers) {
|
|
||||||
server->stopListening();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& server : _servers) {
|
|
||||||
server->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& server : _servers) {
|
|
||||||
delete server;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EndpointFeature::buildServers() {
|
|
||||||
ServerFeature* server = dynamic_cast<ServerFeature*>(
|
|
||||||
application_features::ApplicationServer::lookupFeature("Server"));
|
|
||||||
|
|
||||||
TRI_ASSERT(server != nullptr);
|
|
||||||
|
|
||||||
HttpHandlerFactory* handlerFactory = server->httpHandlerFactory();
|
|
||||||
AsyncJobManager* jobManager = server->jobManager();
|
|
||||||
|
|
||||||
#warning TODO filter list
|
|
||||||
HttpServer* httpServer;
|
|
||||||
|
|
||||||
// unencrypted HTTP endpoints
|
|
||||||
httpServer =
|
|
||||||
new HttpServer(SchedulerFeature::SCHEDULER, DispatcherFeature::DISPATCHER,
|
|
||||||
handlerFactory, jobManager, _keepAliveTimeout);
|
|
||||||
|
|
||||||
httpServer->setEndpointList(&_endpointList);
|
|
||||||
_servers.push_back(httpServer);
|
|
||||||
|
|
||||||
// ssl endpoints
|
|
||||||
if (_endpointList.hasSsl()) {
|
|
||||||
SslFeature* ssl = dynamic_cast<SslFeature*>(
|
|
||||||
application_features::ApplicationServer::lookupFeature("Ssl"));
|
|
||||||
|
|
||||||
// check the ssl context
|
|
||||||
if (ssl == nullptr || ssl->sslContext() == nullptr) {
|
|
||||||
LOG(FATAL) << "no ssl context is known, cannot create https server, "
|
|
||||||
"please use the '--ssl.keyfile' option";
|
|
||||||
FATAL_ERROR_EXIT();
|
FATAL_ERROR_EXIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_CTX* sslContext = ssl->sslContext();
|
|
||||||
|
|
||||||
// https
|
|
||||||
httpServer = new HttpsServer(SchedulerFeature::SCHEDULER,
|
|
||||||
DispatcherFeature::DISPATCHER, handlerFactory,
|
|
||||||
jobManager, _keepAliveTimeout, sslContext);
|
|
||||||
|
|
||||||
httpServer->setEndpointList(&_endpointList);
|
|
||||||
_servers.push_back(httpServer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::unique_ptr<rest::HttpHandlerFactory> _handlerFactory;
|
|
||||||
|
|
||||||
void buildHandlerFactory();
|
|
||||||
void defineHandlers();
|
|
||||||
|
|
||||||
rest::HttpHandlerFactory* httpHandlerFactory() const {
|
|
||||||
return _handlerFactory.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
static TRI_vocbase_t* LookupDatabaseFromRequest(HttpRequest* request,
|
static TRI_vocbase_t* LookupDatabaseFromRequest(HttpRequest* request,
|
||||||
TRI_server_t* server) {
|
TRI_server_t* server) {
|
||||||
// get database name from request
|
// get database name from request
|
||||||
|
@ -205,15 +158,102 @@ static bool SetRequestContext(HttpRequest* request, void* data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerFeature::buildHandlerFactory() {
|
void RestServerFeature::prepare() {
|
||||||
_handlerFactory.reset(new HttpHandlerFactory(
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::prepare";
|
||||||
_authenticationRealm, _defaultApiCompatibility, _allowMethodOverride,
|
|
||||||
&SetRequestContext, nullptr));
|
HttpHandlerFactory::setMaintenance(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerFeature::defineHandlers() {
|
void RestServerFeature::start() {
|
||||||
#warning TODO
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
|
||||||
#if 0
|
|
||||||
|
LOG(DEBUG) << "using default API compatibility: "
|
||||||
|
<< (long int)_defaultApiCompatibility;
|
||||||
|
|
||||||
|
_jobManager.reset(new AsyncJobManager(ClusterCommRestCallback));
|
||||||
|
|
||||||
|
auto vocbase = DatabaseFeature::DATABASE->vocbase();
|
||||||
|
V8DealerFeature::DEALER->loadJavascript(vocbase, "server/server.js");
|
||||||
|
_httpOptions._vocbase = vocbase;
|
||||||
|
|
||||||
|
auto server = DatabaseFeature::DATABASE->server();
|
||||||
|
_handlerFactory.reset(new HttpHandlerFactory(
|
||||||
|
_authenticationRealm, _defaultApiCompatibility, _allowMethodOverride,
|
||||||
|
&SetRequestContext, server));
|
||||||
|
|
||||||
|
defineHandlers();
|
||||||
|
buildServers();
|
||||||
|
|
||||||
|
for (auto& server : _servers) {
|
||||||
|
server->startListening();
|
||||||
|
}
|
||||||
|
|
||||||
|
// disabled maintenance mode
|
||||||
|
HttpHandlerFactory::setMaintenance(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RestServerFeature::stop() {
|
||||||
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
||||||
|
|
||||||
|
for (auto& server : _servers) {
|
||||||
|
server->stopListening();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& server : _servers) {
|
||||||
|
server->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& server : _servers) {
|
||||||
|
delete server;
|
||||||
|
}
|
||||||
|
|
||||||
|
_httpOptions._vocbase = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RestServerFeature::buildServers() {
|
||||||
|
EndpointFeature* endpoint = dynamic_cast<EndpointFeature*>(
|
||||||
|
application_features::ApplicationServer::lookupFeature("Endpoint"));
|
||||||
|
|
||||||
|
HttpServer* httpServer;
|
||||||
|
|
||||||
|
// unencrypted HTTP endpoints
|
||||||
|
httpServer = new HttpServer(
|
||||||
|
SchedulerFeature::SCHEDULER, DispatcherFeature::DISPATCHER,
|
||||||
|
_handlerFactory.get(), _jobManager.get(), _keepAliveTimeout);
|
||||||
|
|
||||||
|
#warning TODO filter list
|
||||||
|
auto const& endpointList = endpoint->endpointList();
|
||||||
|
httpServer->setEndpointList(&endpointList);
|
||||||
|
_servers.push_back(httpServer);
|
||||||
|
|
||||||
|
// ssl endpoints
|
||||||
|
if (endpointList.hasSsl()) {
|
||||||
|
SslFeature* ssl = dynamic_cast<SslFeature*>(
|
||||||
|
application_features::ApplicationServer::lookupFeature("Ssl"));
|
||||||
|
|
||||||
|
// check the ssl context
|
||||||
|
if (ssl == nullptr || ssl->sslContext() == nullptr) {
|
||||||
|
LOG(FATAL) << "no ssl context is known, cannot create https server, "
|
||||||
|
"please use the '--ssl.keyfile' option";
|
||||||
|
FATAL_ERROR_EXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
SSL_CTX* sslContext = ssl->sslContext();
|
||||||
|
|
||||||
|
// https
|
||||||
|
httpServer =
|
||||||
|
new HttpsServer(SchedulerFeature::SCHEDULER,
|
||||||
|
DispatcherFeature::DISPATCHER, _handlerFactory.get(),
|
||||||
|
_jobManager.get(), _keepAliveTimeout, sslContext);
|
||||||
|
|
||||||
|
httpServer->setEndpointList(&endpointList);
|
||||||
|
_servers.push_back(httpServer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RestServerFeature::defineHandlers() {
|
||||||
|
auto queryRegistry = DatabaseFeature::DATABASE->queryRegistry();
|
||||||
|
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
// /_msg
|
// /_msg
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
|
@ -232,9 +272,8 @@ void ServerFeature::defineHandlers() {
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::CURSOR_PATH,
|
RestVocbaseBaseHandler::CURSOR_PATH,
|
||||||
RestHandlerCreator<RestCursorHandler>::createData<
|
RestHandlerCreator<RestCursorHandler>::createData<aql::QueryRegistry*>,
|
||||||
std::pair<ApplicationV8*, aql::QueryRegistry*>*>,
|
queryRegistry);
|
||||||
_pairForAqlHandler);
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::DOCUMENT_PATH,
|
RestVocbaseBaseHandler::DOCUMENT_PATH,
|
||||||
|
@ -248,62 +287,48 @@ void ServerFeature::defineHandlers() {
|
||||||
RestVocbaseBaseHandler::EDGES_PATH,
|
RestVocbaseBaseHandler::EDGES_PATH,
|
||||||
RestHandlerCreator<RestEdgesHandler>::createNoData);
|
RestHandlerCreator<RestEdgesHandler>::createNoData);
|
||||||
|
|
||||||
#warning TODO
|
|
||||||
#if 0
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::EXPORT_PATH,
|
RestVocbaseBaseHandler::EXPORT_PATH,
|
||||||
RestHandlerCreator<RestExportHandler>::createNoData);
|
RestHandlerCreator<RestExportHandler>::createNoData);
|
||||||
#endif
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::IMPORT_PATH,
|
RestVocbaseBaseHandler::IMPORT_PATH,
|
||||||
RestHandlerCreator<RestImportHandler>::createNoData);
|
RestHandlerCreator<RestImportHandler>::createNoData);
|
||||||
|
|
||||||
#warning TODO
|
|
||||||
#if 0
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::REPLICATION_PATH,
|
RestVocbaseBaseHandler::REPLICATION_PATH,
|
||||||
RestHandlerCreator<RestReplicationHandler>::createNoData);
|
RestHandlerCreator<RestReplicationHandler>::createNoData);
|
||||||
#endif
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::SIMPLE_QUERY_ALL_PATH,
|
RestVocbaseBaseHandler::SIMPLE_QUERY_ALL_PATH,
|
||||||
RestHandlerCreator<RestSimpleQueryHandler>::createData<
|
RestHandlerCreator<RestSimpleQueryHandler>::createData<
|
||||||
std::pair<ApplicationV8*, aql::QueryRegistry*>*>,
|
aql::QueryRegistry*>,
|
||||||
_pairForAqlHandler);
|
queryRegistry);
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::SIMPLE_LOOKUP_PATH,
|
RestVocbaseBaseHandler::SIMPLE_LOOKUP_PATH,
|
||||||
RestHandlerCreator<RestSimpleHandler>::createData<
|
RestHandlerCreator<RestSimpleHandler>::createData<aql::QueryRegistry*>,
|
||||||
std::pair<ApplicationV8*, aql::QueryRegistry*>*>,
|
queryRegistry);
|
||||||
_pairForAqlHandler);
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::SIMPLE_REMOVE_PATH,
|
RestVocbaseBaseHandler::SIMPLE_REMOVE_PATH,
|
||||||
RestHandlerCreator<RestSimpleHandler>::createData<
|
RestHandlerCreator<RestSimpleHandler>::createData<aql::QueryRegistry*>,
|
||||||
std::pair<ApplicationV8*, aql::QueryRegistry*>*>,
|
queryRegistry);
|
||||||
_pairForAqlHandler);
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
RestVocbaseBaseHandler::UPLOAD_PATH,
|
RestVocbaseBaseHandler::UPLOAD_PATH,
|
||||||
RestHandlerCreator<RestUploadHandler>::createNoData);
|
RestHandlerCreator<RestUploadHandler>::createNoData);
|
||||||
|
|
||||||
#warning TODO
|
|
||||||
#if 0
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_api/shard-comm",
|
"/_api/shard-comm", RestHandlerCreator<RestShardHandler>::createNoData);
|
||||||
RestHandlerCreator<RestShardHandler>::createNoData);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_api/aql", RestHandlerCreator<aql::RestAqlHandler>::createData<
|
"/_api/aql",
|
||||||
std::pair<ApplicationV8*, aql::QueryRegistry*>*>,
|
RestHandlerCreator<aql::RestAqlHandler>::createData<aql::QueryRegistry*>,
|
||||||
_pairForAqlHandler);
|
queryRegistry);
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_api/query",
|
"/_api/query", RestHandlerCreator<RestQueryHandler>::createNoData);
|
||||||
RestHandlerCreator<RestQueryHandler>::createData<ApplicationV8*>,
|
|
||||||
_applicationV8);
|
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_api/query-cache",
|
"/_api/query-cache",
|
||||||
|
@ -312,12 +337,11 @@ void ServerFeature::defineHandlers() {
|
||||||
// And now some handlers which are registered in both /_api and /_admin
|
// And now some handlers which are registered in both /_api and /_admin
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_api/job", RestHandlerCreator<arangodb::RestJobHandler>::createData<
|
"/_api/job", RestHandlerCreator<arangodb::RestJobHandler>::createData<
|
||||||
std::pair<Dispatcher*, AsyncJobManager*>*>,
|
AsyncJobManager*>,
|
||||||
_pairForJobHandler);
|
_jobManager.get());
|
||||||
|
|
||||||
_handlerFactory->addHandler(
|
_handlerFactory->addHandler(
|
||||||
"/_api/version", RestHandlerCreator<RestVersionHandler>::createNoData,
|
"/_api/version", RestHandlerCreator<RestVersionHandler>::createNoData);
|
||||||
nullptr);
|
|
||||||
|
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
// /_admin
|
// /_admin
|
||||||
|
@ -325,36 +349,30 @@ void ServerFeature::defineHandlers() {
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_admin/job", RestHandlerCreator<arangodb::RestJobHandler>::createData<
|
"/_admin/job", RestHandlerCreator<arangodb::RestJobHandler>::createData<
|
||||||
std::pair<Dispatcher*, AsyncJobManager*>*>,
|
AsyncJobManager*>,
|
||||||
_pairForJobHandler);
|
_jobManager.get());
|
||||||
|
|
||||||
_handlerFactory->addHandler(
|
_handlerFactory->addHandler(
|
||||||
"/_admin/version", RestHandlerCreator<RestVersionHandler>::createNoData,
|
"/_admin/version", RestHandlerCreator<RestVersionHandler>::createNoData);
|
||||||
nullptr);
|
|
||||||
|
|
||||||
// further admin handlers
|
// further admin handlers
|
||||||
_handlerFactory->addHandler(
|
_handlerFactory->addHandler(
|
||||||
"/_admin/log",
|
"/_admin/log",
|
||||||
RestHandlerCreator<arangodb::RestAdminLogHandler>::createNoData, nullptr);
|
RestHandlerCreator<arangodb::RestAdminLogHandler>::createNoData);
|
||||||
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_admin/work-monitor",
|
"/_admin/work-monitor",
|
||||||
RestHandlerCreator<WorkMonitorHandler>::createNoData, nullptr);
|
RestHandlerCreator<WorkMonitorHandler>::createNoData);
|
||||||
|
|
||||||
// This handler is to activate SYS_DEBUG_FAILAT on DB servers
|
|
||||||
#ifdef ARANGODB_ENABLE_FAILURE_TESTS
|
#ifdef ARANGODB_ENABLE_FAILURE_TESTS
|
||||||
|
// This handler is to activate SYS_DEBUG_FAILAT on DB servers
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_admin/debug", RestHandlerCreator<RestDebugHandler>::createNoData,
|
"/_admin/debug", RestHandlerCreator<RestDebugHandler>::createNoData);
|
||||||
nullptr);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#warning TODO
|
|
||||||
#if 0
|
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/_admin/shutdown",
|
"/_admin/shutdown",
|
||||||
RestHandlerCreator<arangodb::RestShutdownHandler>::createData<void*>,
|
RestHandlerCreator<arangodb::RestShutdownHandler>::createNoData);
|
||||||
static_cast<void*>(_applicationServer));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
// /_admin
|
// /_admin
|
||||||
|
@ -363,8 +381,5 @@ void ServerFeature::defineHandlers() {
|
||||||
_handlerFactory->addPrefixHandler(
|
_handlerFactory->addPrefixHandler(
|
||||||
"/", RestHandlerCreator<RestActionHandler>::createData<
|
"/", RestHandlerCreator<RestActionHandler>::createData<
|
||||||
RestActionHandler::action_options_t*>,
|
RestActionHandler::action_options_t*>,
|
||||||
(void*)&httpOptions);
|
(void*)&_httpOptions);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -25,16 +25,51 @@
|
||||||
|
|
||||||
#include "ApplicationFeatures/ApplicationFeature.h"
|
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||||
|
|
||||||
|
#include "Actions/RestActionHandler.h"
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
namespace rest {
|
||||||
|
class AsyncJobManager;
|
||||||
|
class HttpHandlerFactory;
|
||||||
|
class HttpServer;
|
||||||
|
}
|
||||||
|
|
||||||
class RestServerThread;
|
class RestServerThread;
|
||||||
|
|
||||||
class RestServerFeature final : public application_features::ApplicationFeature {
|
class RestServerFeature final
|
||||||
|
: public application_features::ApplicationFeature {
|
||||||
public:
|
public:
|
||||||
explicit RestServerFeature(application_features::ApplicationServer* server);
|
RestServerFeature(application_features::ApplicationServer*,
|
||||||
|
std::string const&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
|
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
|
void prepare() override final;
|
||||||
void start() override final;
|
void start() override final;
|
||||||
void stop() override final;
|
void stop() override final;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _keepAliveTimeout;
|
||||||
|
std::string const _authenticationRealm;
|
||||||
|
int32_t _defaultApiCompatibility;
|
||||||
|
bool _allowMethodOverride;
|
||||||
|
|
||||||
|
public:
|
||||||
|
#warning TODO
|
||||||
|
bool authentication() const { return false; }
|
||||||
|
bool authenticationUnixSockets() const { return false; }
|
||||||
|
bool authenticationSystemOnly() const { return false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void buildServers();
|
||||||
|
void defineHandlers();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<rest::HttpHandlerFactory> _handlerFactory;
|
||||||
|
std::unique_ptr<rest::AsyncJobManager> _jobManager;
|
||||||
|
std::vector<rest::HttpServer*> _servers;
|
||||||
|
RestActionHandler::action_options_t _httpOptions;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,43 +22,22 @@
|
||||||
|
|
||||||
#include "ServerFeature.h"
|
#include "ServerFeature.h"
|
||||||
|
|
||||||
#include "Aql/RestAqlHandler.h"
|
|
||||||
#include "Basics/ArangoGlobalContext.h"
|
#include "Basics/ArangoGlobalContext.h"
|
||||||
#include "Basics/process-utils.h"
|
#include "Basics/process-utils.h"
|
||||||
#include "Cluster/HeartbeatThread.h"
|
#include "Cluster/HeartbeatThread.h"
|
||||||
#include "Cluster/RestShardHandler.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "HttpServer/HttpHandlerFactory.h"
|
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "Rest/Version.h"
|
#include "Rest/Version.h"
|
||||||
#include "RestHandler/RestAdminLogHandler.h"
|
|
||||||
#include "RestHandler/RestBatchHandler.h"
|
|
||||||
#include "RestHandler/RestCursorHandler.h"
|
|
||||||
#include "RestHandler/RestDebugHandler.h"
|
|
||||||
#include "RestHandler/RestDocumentHandler.h"
|
|
||||||
#include "RestHandler/RestEdgeHandler.h"
|
|
||||||
#include "RestHandler/RestEdgesHandler.h"
|
|
||||||
#include "RestHandler/RestExportHandler.h"
|
|
||||||
#include "RestHandler/RestHandlerCreator.h"
|
|
||||||
#include "RestHandler/RestImportHandler.h"
|
|
||||||
#include "RestHandler/RestJobHandler.h"
|
|
||||||
#include "RestHandler/RestPleaseUpgradeHandler.h"
|
|
||||||
#include "RestHandler/RestQueryCacheHandler.h"
|
|
||||||
#include "RestHandler/RestQueryHandler.h"
|
|
||||||
#include "RestHandler/RestReplicationHandler.h"
|
|
||||||
#include "RestHandler/RestShutdownHandler.h"
|
|
||||||
#include "RestHandler/RestSimpleHandler.h"
|
|
||||||
#include "RestHandler/RestSimpleQueryHandler.h"
|
|
||||||
#include "RestHandler/RestUploadHandler.h"
|
|
||||||
#include "RestHandler/RestVersionHandler.h"
|
|
||||||
#include "RestHandler/WorkMonitorHandler.h"
|
|
||||||
#include "RestServer/DatabaseFeature.h"
|
#include "RestServer/DatabaseFeature.h"
|
||||||
#include "Scheduler/SchedulerFeature.h"
|
#include "Scheduler/SchedulerFeature.h"
|
||||||
|
#include "Statistics/StatisticsFeature.h"
|
||||||
#include "V8/v8-conv.h"
|
#include "V8/v8-conv.h"
|
||||||
#include "V8/v8-globals.h"
|
#include "V8/v8-globals.h"
|
||||||
#include "V8/v8-utils.h"
|
#include "V8/v8-utils.h"
|
||||||
|
#include "V8Server/V8Context.h"
|
||||||
#include "V8Server/V8DealerFeature.h"
|
#include "V8Server/V8DealerFeature.h"
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
|
@ -66,15 +45,11 @@ using namespace arangodb::application_features;
|
||||||
using namespace arangodb::options;
|
using namespace arangodb::options;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
|
||||||
ServerFeature::ServerFeature(application_features::ApplicationServer* server,
|
ServerFeature::ServerFeature(application_features::ApplicationServer* server, int* res)
|
||||||
std::string const& authenticationRealm, int* res)
|
|
||||||
: ApplicationFeature(server, "Server"),
|
: ApplicationFeature(server, "Server"),
|
||||||
_defaultApiCompatibility(Version::getNumericServerVersion()),
|
|
||||||
_allowMethodOverride(false),
|
|
||||||
_console(false),
|
_console(false),
|
||||||
_restServer(true),
|
_restServer(true),
|
||||||
_authentication(false),
|
_authentication(false),
|
||||||
_authenticationRealm(authenticationRealm),
|
|
||||||
_result(res),
|
_result(res),
|
||||||
_operationMode(OperationMode::MODE_SERVER) {
|
_operationMode(OperationMode::MODE_SERVER) {
|
||||||
setOptional(true);
|
setOptional(true);
|
||||||
|
@ -83,8 +58,9 @@ ServerFeature::ServerFeature(application_features::ApplicationServer* server,
|
||||||
startsAfter("Database");
|
startsAfter("Database");
|
||||||
startsAfter("Dispatcher");
|
startsAfter("Dispatcher");
|
||||||
startsAfter("Scheduler");
|
startsAfter("Scheduler");
|
||||||
startsAfter("WorkMonitor");
|
startsAfter("Statistics");
|
||||||
startsAfter("V8Dealer");
|
startsAfter("V8Dealer");
|
||||||
|
startsAfter("WorkMonitor");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
void ServerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
@ -95,10 +71,6 @@ void ServerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
|
||||||
options->addSection("server", "Server features");
|
options->addSection("server", "Server features");
|
||||||
|
|
||||||
options->addHiddenOption("--server.default-api-compatibility",
|
|
||||||
"default API compatibility version",
|
|
||||||
new Int32Parameter(&_defaultApiCompatibility));
|
|
||||||
|
|
||||||
options->addHiddenOption("--server.rest-server", "start a rest-server",
|
options->addHiddenOption("--server.rest-server", "start a rest-server",
|
||||||
new BooleanParameter(&_restServer));
|
new BooleanParameter(&_restServer));
|
||||||
|
|
||||||
|
@ -134,12 +106,6 @@ void ServerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
options->addSection("http", "HttpServer features");
|
|
||||||
|
|
||||||
options->addHiddenOption("--http.allow-method-override",
|
|
||||||
"allow HTTP method override using special headers",
|
|
||||||
new BooleanParameter(&_allowMethodOverride));
|
|
||||||
|
|
||||||
options->addSection("javascript", "Configure the Javascript engine");
|
options->addSection("javascript", "Configure the Javascript engine");
|
||||||
|
|
||||||
options->addHiddenOption("--javascript.unit-tests", "run unit-tests and exit",
|
options->addHiddenOption("--javascript.unit-tests", "run unit-tests and exit",
|
||||||
|
@ -155,16 +121,6 @@ void ServerFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
void ServerFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
void ServerFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::validateOptions";
|
||||||
|
|
||||||
if (_defaultApiCompatibility < HttpRequest::MIN_COMPATIBILITY) {
|
|
||||||
LOG(FATAL) << "invalid value for --server.default-api-compatibility. "
|
|
||||||
"minimum allowed value is "
|
|
||||||
<< HttpRequest::MIN_COMPATIBILITY;
|
|
||||||
FATAL_ERROR_EXIT();
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(DEBUG) << "using default API compatibility: "
|
|
||||||
<< (long int)_defaultApiCompatibility;
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (_console) {
|
if (_console) {
|
||||||
|
@ -195,14 +151,17 @@ void ServerFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_restServer) {
|
if (!_restServer) {
|
||||||
ApplicationServer::disableFeatures(
|
ApplicationServer::disableFeatures({"Daemon", "Dispatcher", "Endpoint",
|
||||||
{"Daemon", "Dispatcher", "Endpoint", "Scheduler", "Ssl", "Supervisor"});
|
"RestServer", "Scheduler", "Ssl",
|
||||||
|
"Supervisor"});
|
||||||
|
|
||||||
DatabaseFeature* database = dynamic_cast<DatabaseFeature*>(
|
DatabaseFeature* database = dynamic_cast<DatabaseFeature*>(
|
||||||
ApplicationServer::lookupFeature("Database"));
|
ApplicationServer::lookupFeature("Database"));
|
||||||
database->disableReplicationApplier();
|
database->disableReplicationApplier();
|
||||||
|
|
||||||
TRI_ENABLE_STATISTICS = false;
|
StatisticsFeature* statistics = dynamic_cast<StatisticsFeature*>(
|
||||||
|
ApplicationServer::lookupFeature("Statistics"));
|
||||||
|
statistics->disableStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
V8DealerFeature* v8dealer = dynamic_cast<V8DealerFeature*>(
|
V8DealerFeature* v8dealer = dynamic_cast<V8DealerFeature*>(
|
||||||
|
@ -230,10 +189,6 @@ void ServerFeature::validateOptions(std::shared_ptr<ProgramOptions>) {
|
||||||
void ServerFeature::start() {
|
void ServerFeature::start() {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
|
||||||
|
|
||||||
auto vocbase = DatabaseFeature::DATABASE->vocbase();
|
|
||||||
V8DealerFeature::DEALER->loadJavascript(vocbase, "server/server.js");
|
|
||||||
_httpOptions._vocbase = vocbase;
|
|
||||||
|
|
||||||
if (_operationMode != OperationMode::MODE_CONSOLE) {
|
if (_operationMode != OperationMode::MODE_CONSOLE) {
|
||||||
auto scheduler = dynamic_cast<SchedulerFeature*>(
|
auto scheduler = dynamic_cast<SchedulerFeature*>(
|
||||||
ApplicationServer::lookupFeature("Scheduler"));
|
ApplicationServer::lookupFeature("Scheduler"));
|
||||||
|
@ -271,13 +226,6 @@ void ServerFeature::beginShutdown() {
|
||||||
|
|
||||||
void ServerFeature::stop() {
|
void ServerFeature::stop() {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
||||||
|
|
||||||
_httpOptions._vocbase = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> ServerFeature::httpEndpoints() {
|
|
||||||
#warning TODO
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerFeature::waitForHeartbeat() {
|
void ServerFeature::waitForHeartbeat() {
|
||||||
|
@ -436,4 +384,3 @@ int ServerFeature::runScript() {
|
||||||
|
|
||||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@
|
||||||
#define REST_SERVER_SERVER_FEATURE_H 1
|
#define REST_SERVER_SERVER_FEATURE_H 1
|
||||||
|
|
||||||
#include "ApplicationFeatures/ApplicationFeature.h"
|
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||||
#include "ApplicationFeatures/HttpEndpointProvider.h"
|
|
||||||
|
|
||||||
#include "Actions/RestActionHandler.h"
|
|
||||||
#include "Rest/OperationMode.h"
|
#include "Rest/OperationMode.h"
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
@ -35,11 +33,9 @@ class HttpHandlerFactory;
|
||||||
class AsyncJobManager;
|
class AsyncJobManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ServerFeature final : public application_features::ApplicationFeature,
|
class ServerFeature final : public application_features::ApplicationFeature {
|
||||||
public HttpEndpointProvider {
|
|
||||||
public:
|
public:
|
||||||
ServerFeature(application_features::ApplicationServer* server,
|
ServerFeature(application_features::ApplicationServer* server, int*);
|
||||||
std::string const&, int*);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
|
@ -50,11 +46,8 @@ class ServerFeature final : public application_features::ApplicationFeature,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OperationMode operationMode() const { return _operationMode; }
|
OperationMode operationMode() const { return _operationMode; }
|
||||||
std::vector<std::string> httpEndpoints() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t _defaultApiCompatibility;
|
|
||||||
bool _allowMethodOverride;
|
|
||||||
bool _console;
|
bool _console;
|
||||||
bool _restServer;
|
bool _restServer;
|
||||||
bool _authentication;
|
bool _authentication;
|
||||||
|
@ -68,10 +61,8 @@ class ServerFeature final : public application_features::ApplicationFeature,
|
||||||
int runScript();
|
int runScript();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string const _authenticationRealm;
|
|
||||||
int* _result;
|
int* _result;
|
||||||
OperationMode _operationMode;
|
OperationMode _operationMode;
|
||||||
RestActionHandler::action_options_t _httpOptions;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
bool disableStatistics = false;
|
|
||||||
|
|
||||||
additional["Server Options:help-admin"]("server.disable-statistics",
|
|
||||||
&disableStatistics,
|
|
||||||
"turn off statistics gathering");
|
|
||||||
|
|
||||||
if (disableStatistics) {
|
|
||||||
TRI_ENABLE_STATISTICS = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRI_InitializeStatistics();
|
|
||||||
|
|
||||||
TRI_ShutdownStatistics();
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include "RestServer/ServerFeature.h"
|
#include "RestServer/ServerFeature.h"
|
||||||
#include "RestServer/UpgradeFeature.h"
|
#include "RestServer/UpgradeFeature.h"
|
||||||
#include "Scheduler/SchedulerFeature.h"
|
#include "Scheduler/SchedulerFeature.h"
|
||||||
|
#include "Statistics/StatisticsFeature.h"
|
||||||
#include "V8Server/V8DealerFeature.h"
|
#include "V8Server/V8DealerFeature.h"
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
|
@ -120,11 +121,12 @@ int main(int argc, char* argv[]) {
|
||||||
server.addFeature(new LoggerFeature(&server, true));
|
server.addFeature(new LoggerFeature(&server, true));
|
||||||
server.addFeature(new NonceFeature(&server));
|
server.addFeature(new NonceFeature(&server));
|
||||||
server.addFeature(new RandomFeature(&server));
|
server.addFeature(new RandomFeature(&server));
|
||||||
server.addFeature(new RestServerFeature(&server));
|
server.addFeature(new RestServerFeature(&server, "arangodb"));
|
||||||
server.addFeature(new SchedulerFeature(&server));
|
server.addFeature(new SchedulerFeature(&server));
|
||||||
server.addFeature(new ServerFeature(&server, "arangod", &ret));
|
server.addFeature(new ServerFeature(&server, &ret));
|
||||||
server.addFeature(new ShutdownFeature(&server, "Server"));
|
server.addFeature(new ShutdownFeature(&server, "Server"));
|
||||||
server.addFeature(new SslFeature(&server));
|
server.addFeature(new SslFeature(&server));
|
||||||
|
server.addFeature(new StatisticsFeature(&server));
|
||||||
server.addFeature(new TempFeature(&server, name));
|
server.addFeature(new TempFeature(&server, name));
|
||||||
server.addFeature(new UpgradeFeature(&server, &ret, nonServerFeatures));
|
server.addFeature(new UpgradeFeature(&server, &ret, nonServerFeatures));
|
||||||
server.addFeature(new V8DealerFeature(&server));
|
server.addFeature(new V8DealerFeature(&server));
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
|
||||||
|
#include "Statistics/StatisticsFeature.h"
|
||||||
#include "Statistics/statistics.h"
|
#include "Statistics/statistics.h"
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
@ -173,7 +174,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetRequestType(GeneralRequest::RequestType b) {
|
void requestStatisticsAgentSetRequestType(GeneralRequest::RequestType b) {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_requestType = b;
|
_statistics->_requestType = b;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +186,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetAsync() {
|
void requestStatisticsAgentSetAsync() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_async = true;
|
_statistics->_async = true;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +198,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetReadStart() {
|
void requestStatisticsAgentSetReadStart() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr && _statistics->_readStart == 0.0) {
|
if (_statistics != nullptr && _statistics->_readStart == 0.0) {
|
||||||
_lastReadStart = _statistics->_readStart = TRI_StatisticsTime();
|
_lastReadStart = _statistics->_readStart = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -209,7 +210,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetReadEnd() {
|
void requestStatisticsAgentSetReadEnd() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_readEnd = TRI_StatisticsTime();
|
_statistics->_readEnd = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -221,7 +222,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetWriteStart() {
|
void requestStatisticsAgentSetWriteStart() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_writeStart = TRI_StatisticsTime();
|
_statistics->_writeStart = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -233,7 +234,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetWriteEnd() {
|
void requestStatisticsAgentSetWriteEnd() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_writeEnd = TRI_StatisticsTime();
|
_statistics->_writeEnd = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +246,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetQueueStart() {
|
void requestStatisticsAgentSetQueueStart() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_queueStart = TRI_StatisticsTime();
|
_statistics->_queueStart = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -257,7 +258,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetQueueEnd() {
|
void requestStatisticsAgentSetQueueEnd() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_queueEnd = TRI_StatisticsTime();
|
_statistics->_queueEnd = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -269,7 +270,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetRequestStart() {
|
void requestStatisticsAgentSetRequestStart() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_requestStart = TRI_StatisticsTime();
|
_statistics->_requestStart = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetRequestEnd() {
|
void requestStatisticsAgentSetRequestEnd() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_requestEnd = TRI_StatisticsTime();
|
_statistics->_requestEnd = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -293,7 +294,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetExecuteError() {
|
void requestStatisticsAgentSetExecuteError() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_executeError = true;
|
_statistics->_executeError = true;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +306,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentSetIgnore() {
|
void requestStatisticsAgentSetIgnore() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_ignore = true;
|
_statistics->_ignore = true;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +318,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentAddReceivedBytes(size_t b) {
|
void requestStatisticsAgentAddReceivedBytes(size_t b) {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_receivedBytes += b;
|
_statistics->_receivedBytes += b;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +330,7 @@ class RequestStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void requestStatisticsAgentAddSentBytes(size_t b) {
|
void requestStatisticsAgentAddSentBytes(size_t b) {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_sentBytes += b;
|
_statistics->_sentBytes += b;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +370,7 @@ class ConnectionStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void connectionStatisticsAgentSetHttp() {
|
void connectionStatisticsAgentSetHttp() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_http = true;
|
_statistics->_http = true;
|
||||||
}
|
}
|
||||||
|
@ -381,7 +382,7 @@ class ConnectionStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void connectionStatisticsAgentSetStart() {
|
void connectionStatisticsAgentSetStart() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_connStart = TRI_StatisticsTime();
|
_statistics->_connStart = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
@ -393,7 +394,7 @@ class ConnectionStatisticsAgent
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void connectionStatisticsAgentSetEnd() {
|
void connectionStatisticsAgentSetEnd() {
|
||||||
if (TRI_ENABLE_STATISTICS) {
|
if (StatisticsFeature::enabled()) {
|
||||||
if (_statistics != nullptr) {
|
if (_statistics != nullptr) {
|
||||||
_statistics->_connEnd = TRI_StatisticsTime();
|
_statistics->_connEnd = TRI_StatisticsTime();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Dr. Frank Celler
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "StatisticsFeature.h"
|
||||||
|
|
||||||
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
|
#include "ProgramOptions/Section.h"
|
||||||
|
#include "Statistics/statistics.h"
|
||||||
|
|
||||||
|
using namespace arangodb;
|
||||||
|
using namespace arangodb::application_features;
|
||||||
|
using namespace arangodb::options;
|
||||||
|
|
||||||
|
StatisticsFeature* StatisticsFeature::STATISTICS = nullptr;
|
||||||
|
|
||||||
|
StatisticsFeature::StatisticsFeature(application_features::ApplicationServer* server)
|
||||||
|
: ApplicationFeature(server, "Statistics"),
|
||||||
|
_statistics(true) {
|
||||||
|
startsAfter("Logger");
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatisticsFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
||||||
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::collectOptions";
|
||||||
|
|
||||||
|
options->addSection("server", "Server features");
|
||||||
|
|
||||||
|
options->addHiddenOption(
|
||||||
|
"--server.statistics",
|
||||||
|
"turn statistics gathering on or off",
|
||||||
|
new BooleanParameter(&_statistics));
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatisticsFeature::start() {
|
||||||
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::start";
|
||||||
|
|
||||||
|
STATISTICS = this;
|
||||||
|
TRI_InitializeStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatisticsFeature::stop() {
|
||||||
|
LOG_TOPIC(TRACE, Logger::STARTUP) << name() << "::stop";
|
||||||
|
|
||||||
|
TRI_ShutdownStatistics();
|
||||||
|
STATISTICS = nullptr;
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Dr. Frank Celler
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef APPLICATION_FEATURES_STATISTICS_FEATURE_H
|
||||||
|
#define APPLICATION_FEATURES_STATISTICS_FEATURE_H 1
|
||||||
|
|
||||||
|
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||||
|
|
||||||
|
namespace arangodb {
|
||||||
|
class StatisticsFeature final
|
||||||
|
: public application_features::ApplicationFeature {
|
||||||
|
public:
|
||||||
|
static bool enabled() {
|
||||||
|
return STATISTICS != nullptr && STATISTICS->_statistics;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static StatisticsFeature* STATISTICS;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit StatisticsFeature(application_features::ApplicationServer* server);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void collectOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
|
void start() override final;
|
||||||
|
void stop() override final;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void disableStatistics() { _statistics = false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _statistics;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -22,13 +22,16 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
|
|
||||||
|
#include <boost/lockfree/queue.hpp>
|
||||||
|
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "Basics/Mutex.h"
|
#include "Basics/Mutex.h"
|
||||||
#include "Basics/MutexLocker.h"
|
#include "Basics/MutexLocker.h"
|
||||||
#include "Basics/threads.h"
|
#include "Basics/threads.h"
|
||||||
|
#include "Statistics/StatisticsFeature.h"
|
||||||
|
|
||||||
#include <boost/lockfree/queue.hpp>
|
using namespace arangodb;
|
||||||
|
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
static size_t const QUEUE_SIZE = 1000;
|
static size_t const QUEUE_SIZE = 1000;
|
||||||
|
@ -135,7 +138,7 @@ static size_t ProcessAllRequestStatistics() {
|
||||||
TRI_request_statistics_t* TRI_AcquireRequestStatistics() {
|
TRI_request_statistics_t* TRI_AcquireRequestStatistics() {
|
||||||
TRI_request_statistics_t* statistics = nullptr;
|
TRI_request_statistics_t* statistics = nullptr;
|
||||||
|
|
||||||
if (TRI_ENABLE_STATISTICS && RequestFreeList.pop(statistics)) {
|
if (StatisticsFeature::enabled() && RequestFreeList.pop(statistics)) {
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +216,7 @@ static boost::lockfree::queue<TRI_connection_statistics_t*,
|
||||||
TRI_connection_statistics_t* TRI_AcquireConnectionStatistics() {
|
TRI_connection_statistics_t* TRI_AcquireConnectionStatistics() {
|
||||||
TRI_connection_statistics_t* statistics = nullptr;
|
TRI_connection_statistics_t* statistics = nullptr;
|
||||||
|
|
||||||
if (TRI_ENABLE_STATISTICS && ConnectionFreeList.pop(statistics)) {
|
if (StatisticsFeature::enabled() && ConnectionFreeList.pop(statistics)) {
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +312,7 @@ static void StatisticsQueueWorker(void* data) {
|
||||||
uint64_t const MaxSleepTime = 250 * 1000;
|
uint64_t const MaxSleepTime = 250 * 1000;
|
||||||
int nothingHappened = 0;
|
int nothingHappened = 0;
|
||||||
|
|
||||||
while (!Shutdown.load(std::memory_order_relaxed) && TRI_ENABLE_STATISTICS) {
|
while (!Shutdown.load(std::memory_order_relaxed) && StatisticsFeature::enabled()) {
|
||||||
size_t count = ProcessAllRequestStatistics();
|
size_t count = ProcessAllRequestStatistics();
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
@ -367,12 +370,6 @@ static void StatisticsQueueWorker(void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief statistics enabled flags
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool TRI_ENABLE_STATISTICS = true;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief number of http connections
|
/// @brief number of http connections
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -174,12 +174,6 @@ void TRI_FillConnectionStatistics(
|
||||||
|
|
||||||
TRI_server_statistics_t TRI_GetServerStatistics();
|
TRI_server_statistics_t TRI_GetServerStatistics();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief statistics enabled flags
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
extern bool TRI_ENABLE_STATISTICS;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief number of http connections
|
/// @brief number of http connections
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "Rest/Version.h"
|
#include "Rest/Version.h"
|
||||||
#include "RestServer/ConsoleThread.h"
|
#include "RestServer/ConsoleThread.h"
|
||||||
#include "RestServer/VocbaseContext.h"
|
#include "RestServer/VocbaseContext.h"
|
||||||
|
#include "Statistics/StatisticsFeature.h"
|
||||||
#include "Utils/V8ResolverGuard.h"
|
#include "Utils/V8ResolverGuard.h"
|
||||||
#include "Utils/transactions.h"
|
#include "Utils/transactions.h"
|
||||||
#include "V8/JSLoader.h"
|
#include "V8/JSLoader.h"
|
||||||
|
@ -72,8 +73,6 @@ using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
using namespace arangodb::traverser;
|
using namespace arangodb::traverser;
|
||||||
|
|
||||||
extern bool TRI_ENABLE_STATISTICS;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief wrapped class for TRI_vocbase_t
|
/// @brief wrapped class for TRI_vocbase_t
|
||||||
///
|
///
|
||||||
|
@ -3872,7 +3871,7 @@ void TRI_InitV8VocBridge(v8::Isolate* isolate, v8::Handle<v8::Context> context,
|
||||||
|
|
||||||
// whether or not statistics are enabled
|
// whether or not statistics are enabled
|
||||||
context->Global()->ForceSet(TRI_V8_ASCII_STRING("ENABLE_STATISTICS"),
|
context->Global()->ForceSet(TRI_V8_ASCII_STRING("ENABLE_STATISTICS"),
|
||||||
v8::Boolean::New(isolate, TRI_ENABLE_STATISTICS),
|
v8::Boolean::New(isolate, StatisticsFeature::enabled()),
|
||||||
v8::ReadOnly);
|
v8::ReadOnly);
|
||||||
|
|
||||||
// a thread-global variable that will is supposed to contain the AQL module
|
// a thread-global variable that will is supposed to contain the AQL module
|
||||||
|
|
|
@ -142,8 +142,8 @@ add_library(${LIB_ARANGO} STATIC
|
||||||
ApplicationFeatures/ConsoleFeature.cpp
|
ApplicationFeatures/ConsoleFeature.cpp
|
||||||
ApplicationFeatures/LanguageFeature.cpp
|
ApplicationFeatures/LanguageFeature.cpp
|
||||||
ApplicationFeatures/LoggerFeature.cpp
|
ApplicationFeatures/LoggerFeature.cpp
|
||||||
ApplicationFeatures/RandomFeature.cpp
|
|
||||||
ApplicationFeatures/NonceFeature.cpp
|
ApplicationFeatures/NonceFeature.cpp
|
||||||
|
ApplicationFeatures/RandomFeature.cpp
|
||||||
ApplicationFeatures/ShutdownFeature.cpp
|
ApplicationFeatures/ShutdownFeature.cpp
|
||||||
ApplicationFeatures/SslFeature.cpp
|
ApplicationFeatures/SslFeature.cpp
|
||||||
ApplicationFeatures/TempFeature.cpp
|
ApplicationFeatures/TempFeature.cpp
|
||||||
|
|
|
@ -551,7 +551,7 @@ static void JS_Download(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
|
|
||||||
// check if we are a server
|
// check if we are a server
|
||||||
HttpEndpointProvider* server = dynamic_cast<HttpEndpointProvider*>(
|
HttpEndpointProvider* server = dynamic_cast<HttpEndpointProvider*>(
|
||||||
ApplicationServer::lookupFeature("Server"));
|
ApplicationServer::lookupFeature("Endpoint"));
|
||||||
|
|
||||||
if (server != nullptr) {
|
if (server != nullptr) {
|
||||||
endpoints = server->httpEndpoints();
|
endpoints = server->httpEndpoints();
|
||||||
|
|
Loading…
Reference in New Issue