1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-06-04 11:49:33 +02:00
commit 7e511ddaa9
16 changed files with 264 additions and 266 deletions

View File

@ -35,6 +35,8 @@ v2.2.0 (XXXX-XX-XX)
v2.1.1 (2014-06-06)
-------------------
* fixed dfdb: should not start any other V8 threads
* signature for collection functions was modified
The basic change was the substitution of the input parameter of the

View File

@ -247,7 +247,7 @@ pack-winXX-cmake:
cd Build$(BITS) && cpack -G NSIS
./installer-generator.sh $(BITS)
./Installation/Windows/installer-generator.sh $(BITS) $(shell pwd)
################################################################################
### @brief Windows Vista 64-bit bundle

View File

@ -1,7 +1,10 @@
#!/bin/bash
NSIS_PATH="/cygdrive/c/Program Files (x86)/NSIS"
#shell parameter:
#1 the bits (64 or 32)
#2 the parent directory which contains the Build64 or Build32 directory
cd $2
bits=$1
INSTALLERNAME=`grep CPACK_PACKAGE_FILE_NAME Build$bits/CPackConfig.cmake | grep -o '".*"' | awk -F\" '{print $2}'`
if [ ! -f Build$bits/$INSTALLERNAME-internal.exe ]; then

View File

@ -491,6 +491,7 @@ void ArangoServer::buildApplicationServer () {
additional[ApplicationServer::OPTIONS_HIDDEN]
("no-upgrade", "skip a database upgrade")
("start-service", "used to start as windows service")
("no-server", "do not start the server, if console is requested")
;
// .............................................................................
@ -763,6 +764,11 @@ void ArangoServer::buildApplicationServer () {
int ArangoServer::startupServer () {
OperationMode::server_operation_mode_e mode = OperationMode::determineMode(_applicationServer->programOptions());
bool startServer = true;
if (_applicationServer->programOptions().has("no-server")) {
startServer = false;
}
// .............................................................................
// prepare the various parts of the Arango server
@ -789,7 +795,9 @@ int ArangoServer::startupServer () {
if (mode == OperationMode::MODE_CONSOLE) {
// one V8 instance is taken by the console
++concurrency;
if (startServer) {
++concurrency;
}
}
else if (mode == OperationMode::MODE_UNITTESTS || mode == OperationMode::MODE_SCRIPT) {
if (concurrency == 1) {
@ -823,11 +831,21 @@ int ArangoServer::startupServer () {
// prepare everything
// .............................................................................
if (! startServer) {
_applicationScheduler->disable();
_applicationDispatcher->disable();
_applicationEndpointServer->disable();
_applicationV8->disableActions();
_applicationV8->setStartupFile("");
}
// prepare scheduler and dispatcher
_applicationServer->prepare();
// now we can create the queues
_applicationDispatcher->buildStandardQueue(_dispatcherThreads, (int) _dispatcherQueueSize);
if (startServer) {
_applicationDispatcher->buildStandardQueue(_dispatcherThreads, (int) _dispatcherQueueSize);
}
// and finish prepare
_applicationServer->prepare2();
@ -840,7 +858,9 @@ int ArangoServer::startupServer () {
_applicationV8->runVersionCheck(skipUpgrade, performUpgrade);
// setup the V8 actions
_applicationV8->prepareActions();
if (startServer) {
_applicationV8->prepareActions();
}
// .............................................................................
// create endpoints and handlers
@ -851,24 +871,27 @@ int ArangoServer::startupServer () {
httpOptions._vocbase = vocbase;
httpOptions._queue = "STANDARD";
// create the handlers
httpOptions._contexts.insert("user");
httpOptions._contexts.insert("api");
httpOptions._contexts.insert("admin");
if (startServer) {
// create the server
_applicationEndpointServer->buildServers();
// create the handlers
httpOptions._contexts.insert("user");
httpOptions._contexts.insert("api");
httpOptions._contexts.insert("admin");
HttpHandlerFactory* handlerFactory = _applicationEndpointServer->getHandlerFactory();
// create the server
_applicationEndpointServer->buildServers();
DefineApiHandlers(handlerFactory, _applicationAdminServer, _applicationDispatcher, _jobManager);
DefineAdminHandlers(handlerFactory, _applicationAdminServer, _applicationDispatcher, _jobManager, _applicationServer);
HttpHandlerFactory* handlerFactory = _applicationEndpointServer->getHandlerFactory();
// add action handler
handlerFactory->addPrefixHandler(
"/",
RestHandlerCreator<RestActionHandler>::createData<RestActionHandler::action_options_t*>,
(void*) &httpOptions);
DefineApiHandlers(handlerFactory, _applicationAdminServer, _applicationDispatcher, _jobManager);
DefineAdminHandlers(handlerFactory, _applicationAdminServer, _applicationDispatcher, _jobManager, _applicationServer);
// add action handler
handlerFactory->addPrefixHandler(
"/",
RestHandlerCreator<RestActionHandler>::createData<RestActionHandler::action_options_t*>,
(void*) &httpOptions);
}
// .............................................................................
// start the main event loop

View File

@ -249,7 +249,9 @@ ApplicationV8::ApplicationV8 (TRI_server_t* server,
_stopping(0),
_gcThread(0),
_scheduler(scheduler),
_dispatcher(dispatcher) {
_dispatcher(dispatcher),
_definedBooleans(),
_startupFile("server/server.js") {
assert(_server != 0);
}
@ -784,6 +786,14 @@ void ApplicationV8::prepareActions () {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief sets an alternate init file
////////////////////////////////////////////////////////////////////////////////
void ApplicationV8::setStartupFile (const string& file) {
_startupFile = file;
}
// -----------------------------------------------------------------------------
// --SECTION-- ApplicationFeature methods
// -----------------------------------------------------------------------------
@ -927,7 +937,7 @@ void ApplicationV8::close () {
_contextCondition.broadcast();
// unregister all tasks
if (_scheduler != nullptr) {
if (_scheduler != nullptr && _scheduler->scheduler() != nullptr) {
_scheduler->scheduler()->unregisterUserTasks();
}
@ -1006,7 +1016,10 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
files.push_back("common/bootstrap/monkeypatches.js");
files.push_back("server/bootstrap/module-internal.js");
files.push_back("server/server.js"); // needs internal
if (! _startupFile.empty()) {
files.push_back(_startupFile); // needs internal
}
LOG_TRACE("initialising V8 context #%d", (int) i);

View File

@ -334,6 +334,14 @@ namespace triagens {
void prepareActions ();
////////////////////////////////////////////////////////////////////////////////
/// @brief sets an alternate init file
///
/// Normally "server.js" will be used. Pass empty string to disable.
////////////////////////////////////////////////////////////////////////////////
void setStartupFile (const string&);
// -----------------------------------------------------------------------------
// --SECTION-- ApplicationFeature methods
// -----------------------------------------------------------------------------
@ -625,6 +633,12 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
std::map<std::string, bool> _definedBooleans;
////////////////////////////////////////////////////////////////////////////////
/// @brief startup file
////////////////////////////////////////////////////////////////////////////////
std::string _startupFile;
};
}
}

View File

@ -1,4 +1,5 @@
no-upgrade = true
no-server = true
[database]
directory= @LOCALSTATEDIR@/lib/arangodb

View File

@ -1,4 +1,5 @@
no-upgrade = true
no-server = true
[database]
# directory= /var/arangodb

View File

@ -861,32 +861,32 @@ ArangoCollection.prototype.iterate = function (iterator, options) {
////////////////////////////////////////////////////////////////////////////////
/// @brief removes documents matching an example
///
/// @FUN{@FA{collection}.removeByExample(@FA{example})}
/// @startDocuBlock documents_collectionRemoveByExample
/// `collection.removeByExample(example)`
///
/// Removes all documents matching an example.
///
/// @FUN{@FA{collection}.removeByExample(@FA{document}, @FA{waitForSync})}
/// `collection.removeByExample(document, waitForSync)`
///
/// The optional @FA{waitForSync} parameter can be used to force synchronisation
/// The optional *waitForSync* parameter can be used to force synchronisation
/// of the document deletion operation to disk even in case that the
/// @LIT{waitForSync} flag had been disabled for the entire collection. Thus,
/// the @FA{waitForSync} parameter can be used to force synchronisation of just
/// specific operations. To use this, set the @FA{waitForSync} parameter to
/// @LIT{true}. If the @FA{waitForSync} parameter is not specified or set to
/// @LIT{false}, then the collection's default @LIT{waitForSync} behavior is
/// applied. The @FA{waitForSync} parameter cannot be used to disable
/// synchronisation for collections that have a default @LIT{waitForSync} value
/// of @LIT{true}.
/// *waitForSync* flag had been disabled for the entire collection. Thus,
/// the *waitForSync* parameter can be used to force synchronisation of just
/// specific operations. To use this, set the *waitForSync* parameter to
/// *true*. If the *waitForSync* parameter is not specified or set to
/// *false*, then the collection's default *waitForSync* behavior is
/// applied. The *waitForSync* parameter cannot be used to disable
/// synchronisation for collections that have a default *waitForSync* value
/// of *true*.
///
/// @FUN{@FA{collection}.removeByExample(@FA{document}, @FA{waitForSync}, @FA{limit})}
/// `collection.removeByExample(document, waitForSync, limit)`
///
/// The optional @FA{limit} parameter can be used to restrict the number of
/// removals to the specified value. If @FA{limit} is specified but less than the
/// The optional *limit* parameter can be used to restrict the number of
/// removals to the specified value. If *limit* is specified but less than the
/// number of documents in the collection, it is undefined which documents are
/// removed.
///
/// @EXAMPLES
/// *Examples*
///
/// @code
/// arangod> db.content.removeByExample({ "domain": "de.celler" })
@ -899,35 +899,35 @@ ArangoCollection.prototype.removeByExample = function (example, waitForSync, lim
////////////////////////////////////////////////////////////////////////////////
/// @brief replaces documents matching an example
///
/// @FUN{@FA{collection}.replaceByExample(@FA{example}, @FA{newValue})}
/// @startDocuBlock documents_collectionReplaceByExample
/// `collection.replaceByExample(example, newValue)`
///
/// Replaces all documents matching an example with a new document body.
/// The entire document body of each document matching the @FA{example} will be
/// replaced with @FA{newValue}. The document meta-attributes such as @LIT{_id},
/// @LIT{_key}, @LIT{_from}, @LIT{_to} will not be replaced.
/// The entire document body of each document matching the *example* will be
/// replaced with *newValue*. The document meta-attributes such as *_id*,
/// *_key*, *_from*, *_to* will not be replaced.
///
/// @FUN{@FA{collection}.replaceByExample(@FA{document}, @FA{newValue}, @FA{waitForSync})}
/// `collection.replaceByExample(document, newValue, waitForSync)`
///
/// The optional @FA{waitForSync} parameter can be used to force synchronisation
/// The optional *waitForSync* parameter can be used to force synchronisation
/// of the document replacement operation to disk even in case that the
/// @LIT{waitForSync} flag had been disabled for the entire collection. Thus,
/// the @FA{waitForSync} parameter can be used to force synchronisation of just
/// specific operations. To use this, set the @FA{waitForSync} parameter to
/// @LIT{true}. If the @FA{waitForSync} parameter is not specified or set to
/// @LIT{false}, then the collection's default @LIT{waitForSync} behavior is
/// applied. The @FA{waitForSync} parameter cannot be used to disable
/// synchronisation for collections that have a default @LIT{waitForSync} value
/// of @LIT{true}.
/// *waitForSync* flag had been disabled for the entire collection. Thus,
/// the *waitForSync* parameter can be used to force synchronisation of just
/// specific operations. To use this, set the *waitForSync* parameter to
/// *true*. If the *waitForSync* parameter is not specified or set to
/// *false*, then the collection's default *waitForSync* behavior is
/// applied. The *waitForSync* parameter cannot be used to disable
/// synchronisation for collections that have a default *waitForSync* value
/// of *true*.
///
/// @FUN{@FA{collection}.replaceByExample(@FA{document}, @FA{newValue}, @FA{waitForSync}, @FA{limit})}
/// `collection.replaceByExample(document, newValue, waitForSync, limit)`
///
/// The optional @FA{limit} parameter can be used to restrict the number of
/// replacements to the specified value. If @FA{limit} is specified but less than
/// The optional *limit* parameter can be used to restrict the number of
/// replacements to the specified value. If *limit* is specified but less than
/// the number of documents in the collection, it is undefined which documents are
/// replaced.
///
/// @EXAMPLES
/// *Examples*
///
/// @code
/// arangod> db.content.replaceByExample({ "domain": "de.celler" }, { "foo": "someValue }, false, 5)
@ -940,42 +940,42 @@ ArangoCollection.prototype.replaceByExample = function (example, newValue, waitF
////////////////////////////////////////////////////////////////////////////////
/// @brief partially updates documents matching an example
///
/// @FUN{@FA{collection}.updateByExample(@FA{example}, @FA{newValue})}
/// @startDocuBlock documents_collectionUpdateByExample
/// `collection.updateByExample(example, newValue`
///
/// Partially updates all documents matching an example with a new document body.
/// Specific attributes in the document body of each document matching the
/// @FA{example} will be updated with the values from @FA{newValue}.
/// The document meta-attributes such as @LIT{_id}, @LIT{_key}, @LIT{_from},
/// @LIT{_to} cannot be updated.
/// *example* will be updated with the values from *newValue*.
/// The document meta-attributes such as *_id*, *_key*, *_from*,
/// *_to* cannot be updated.
///
/// @FUN{@FA{collection}.updateByExample(@FA{document}, @FA{newValue}, @FA{keepNull}, @FA{waitForSync})}
/// `collection.updateByExample(document, newValue, keepNull, waitForSync)`
///
/// The optional @FA{keepNull} parameter can be used to modify the behavior when
/// handling @LIT{null} values. Normally, @LIT{null} values are stored in the
/// database. By setting the @FA{keepNull} parameter to @LIT{false}, this behavior
/// can be changed so that all attributes in @FA{data} with @LIT{null} values will
/// The optional *keepNull* parameter can be used to modify the behavior when
/// handling *null* values. Normally, *null* values are stored in the
/// database. By setting the *keepNull* parameter to *false*, this behavior
/// can be changed so that all attributes in *data* with *null* values will
/// be removed from the target document.
///
/// The optional @FA{waitForSync} parameter can be used to force synchronisation
/// The optional *waitForSync* parameter can be used to force synchronization
/// of the document replacement operation to disk even in case that the
/// @LIT{waitForSync} flag had been disabled for the entire collection. Thus,
/// the @FA{waitForSync} parameter can be used to force synchronisation of just
/// specific operations. To use this, set the @FA{waitForSync} parameter to
/// @LIT{true}. If the @FA{waitForSync} parameter is not specified or set to
/// @LIT{false}, then the collection's default @LIT{waitForSync} behavior is
/// applied. The @FA{waitForSync} parameter cannot be used to disable
/// synchronisation for collections that have a default @LIT{waitForSync} value
/// of @LIT{true}.
/// *waitForSync* flag had been disabled for the entire collection. Thus,
/// the *waitForSync* parameter can be used to force synchronisation of just
/// specific operations. To use this, set the *waitForSync* parameter to
/// *true*. If the *waitForSync* parameter is not specified or set to
/// *false*, then the collection's default *waitForSync* behavior is
/// applied. The *waitForSync* parameter cannot be used to disable
/// synchronisation for collections that have a default *waitForSync* value
/// of *true*.
///
/// @FUN{@FA{collection}.updateByExample(@FA{document}, @FA{newValue}, @FA{keepNull}, @FA{waitForSync}, @FA{limit})}
/// `collection.updateByExample(document, newValue, keepNull, waitForSync, limit)`
///
/// The optional @FA{limit} parameter can be used to restrict the number of
/// updates to the specified value. If @FA{limit} is specified but less than
/// The optional *limit* parameter can be used to restrict the number of
/// updates to the specified value. If *limit* is specified but less than
/// the number of documents in the collection, it is undefined which documents are
/// updated.
///
/// @EXAMPLES
/// *Examples*
///
/// @code
/// arangod> db.content.updateByExample({ "domain": "de.celler" }, { "foo": "someValue, "domain": null }, false)

View File

@ -31,10 +31,9 @@ var fs = require("fs");
var printf = internal.printf;
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief unload a collection
@ -589,9 +588,9 @@ function main (argv) {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor

View File

@ -5,7 +5,7 @@
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS 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.
@ -22,7 +22,7 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "ApplicationFeature.h"
@ -35,17 +35,12 @@ using namespace std;
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
ApplicationFeature::ApplicationFeature (string const& name)
: _name(name) {
: _disabled(false), _name(name) {
}
////////////////////////////////////////////////////////////////////////////////
@ -55,19 +50,10 @@ ApplicationFeature::ApplicationFeature (string const& name)
ApplicationFeature::~ApplicationFeature () {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the name
////////////////////////////////////////////////////////////////////////////////
@ -146,9 +132,17 @@ void ApplicationFeature::stop () {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
/// @brief disable feature
////////////////////////////////////////////////////////////////////////////////
void ApplicationFeature::disable () {
_disabled = true;
}
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"

View File

@ -5,7 +5,7 @@
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS 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.
@ -22,7 +22,7 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_APPLICATION_SERVER_APPLICATION_FEATURE_H
@ -45,11 +45,6 @@ namespace triagens {
// --SECTION-- class ApplicationFeature
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
namespace rest {
////////////////////////////////////////////////////////////////////////////////
@ -61,19 +56,10 @@ namespace triagens {
ApplicationFeature (ApplicationFeature const&);
ApplicationFeature& operator= (ApplicationFeature const&);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
@ -88,19 +74,10 @@ namespace triagens {
virtual ~ApplicationFeature ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
@ -169,18 +146,27 @@ namespace triagens {
virtual void stop ();
////////////////////////////////////////////////////////////////////////////////
/// @}
/// @brief disable feature
////////////////////////////////////////////////////////////////////////////////
void disable ();
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// --SECTION-- protected variables
// -----------------------------------------------------------------------------
protected:
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
/// @brief feature is disabled
////////////////////////////////////////////////////////////////////////////////
bool _disabled;
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
private:
////////////////////////////////////////////////////////////////////////////////
@ -192,10 +178,6 @@ namespace triagens {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------

View File

@ -172,6 +172,10 @@ void ApplicationDispatcher::setupOptions (map<string, ProgramOptionsDescription>
////////////////////////////////////////////////////////////////////////////////
bool ApplicationDispatcher::prepare () {
if (_disabled) {
return true;
}
buildDispatcher(_applicationScheduler->scheduler());
return true;
@ -182,6 +186,10 @@ bool ApplicationDispatcher::prepare () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationDispatcher::start () {
if (_disabled) {
return true;
}
buildDispatcherReporter();
bool ok = _dispatcher->start();
@ -203,6 +211,10 @@ bool ApplicationDispatcher::start () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationDispatcher::open () {
if (_disabled) {
return true;
}
if (_dispatcher != 0) {
return _dispatcher->open();
}
@ -215,6 +227,10 @@ bool ApplicationDispatcher::open () {
////////////////////////////////////////////////////////////////////////////////
void ApplicationDispatcher::close () {
if (_disabled) {
return;
}
if (_dispatcher != 0) {
_dispatcher->beginShutdown();
}
@ -225,6 +241,10 @@ void ApplicationDispatcher::close () {
////////////////////////////////////////////////////////////////////////////////
void ApplicationDispatcher::stop () {
if (_disabled) {
return;
}
if (_dispatcherReporterTask != 0) {
_dispatcherReporterTask = 0;
}

View File

@ -5,7 +5,7 @@
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS 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.
@ -22,7 +22,7 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "ApplicationEndpointServer.h"
@ -70,11 +70,6 @@ namespace {
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Scheduler
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
@ -137,19 +132,10 @@ ApplicationEndpointServer::~ApplicationEndpointServer () {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Scheduler
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief builds the endpoint servers
////////////////////////////////////////////////////////////////////////////////
@ -189,23 +175,14 @@ bool ApplicationEndpointServer::buildServers () {
server->setEndpointList(&_endpointList);
_servers.push_back(server);
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- ApplicationFeature methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
@ -249,7 +226,7 @@ bool ApplicationEndpointServer::parsePhase2 (ProgramOptions& options) {
if (! ok) {
return false;
}
if (_backlogSize <= 0 || _backlogSize > SOMAXCONN) {
LOG_FATAL_AND_EXIT("invalid value for --server.backlog-size. maximum allowed value is %d", (int) SOMAXCONN);
}
@ -337,7 +314,7 @@ bool ApplicationEndpointServer::addEndpoint (std::string const& newEndpoint,
if (save) {
saveEndpoints();
}
LOG_DEBUG("reconfigured endpoint '%s'", newEndpoint.c_str());
// in this case, we updated an existing endpoint and are done
return true;
@ -353,7 +330,7 @@ bool ApplicationEndpointServer::addEndpoint (std::string const& newEndpoint,
LOG_DEBUG("bound to endpoint '%s'", newEndpoint.c_str());
return true;
}
LOG_WARNING("failed to bind to endpoint '%s'", newEndpoint.c_str());
return false;
}
@ -374,7 +351,7 @@ bool ApplicationEndpointServer::removeEndpoint (std::string const& oldEndpoint)
// invalid endpoint
return false;
}
Endpoint::EncryptionType encryption;
if (unified.substr(0, 6) == "ssl://") {
encryption = Endpoint::ENCRYPTION_SSL;
@ -390,7 +367,7 @@ bool ApplicationEndpointServer::removeEndpoint (std::string const& oldEndpoint)
WRITE_LOCKER(_endpointsLock);
Endpoint* endpoint;
bool ok = _endpointList.remove(unified, &endpoint);
bool ok = _endpointList.remove(unified, &endpoint);
if (! ok) {
LOG_WARNING("could not remove endpoint '%s'", oldEndpoint.c_str());
@ -415,7 +392,7 @@ bool ApplicationEndpointServer::removeEndpoint (std::string const& oldEndpoint)
return false;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief restores the endpoint list
////////////////////////////////////////////////////////////////////////////////
@ -434,7 +411,7 @@ bool ApplicationEndpointServer::loadEndpoints () {
if (json == 0) {
return false;
}
std::map<std::string, std::vector<std::string> > endpoints;
if (! TRI_IsArrayJson(json)) {
@ -451,7 +428,7 @@ bool ApplicationEndpointServer::loadEndpoints () {
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
return false;
}
const string endpoint = string(e->_value._string.data, e->_value._string.length - 1);
vector<string> dbNames;
@ -475,7 +452,7 @@ bool ApplicationEndpointServer::loadEndpoints () {
std::map<std::string, std::vector<std::string> >::const_iterator it;
for (it = endpoints.begin(); it != endpoints.end(); ++it) {
bool ok = _endpointList.add((*it).first, (*it).second, _backlogSize, _reuseAddress);
if (! ok) {
@ -493,7 +470,7 @@ bool ApplicationEndpointServer::loadEndpoints () {
bool ApplicationEndpointServer::saveEndpoints () {
const std::map<std::string, std::vector<std::string> > endpoints = _endpointList.getAll();
TRI_json_t* json = TRI_CreateArrayJson(TRI_CORE_MEM_ZONE);
if (json == 0) {
@ -501,7 +478,7 @@ bool ApplicationEndpointServer::saveEndpoints () {
}
std::map<std::string, std::vector<std::string> >::const_iterator it;
for (it = endpoints.begin(); it != endpoints.end(); ++it) {
TRI_json_t* list = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
@ -518,10 +495,10 @@ bool ApplicationEndpointServer::saveEndpoints () {
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, json, (*it).first.c_str(), list);
}
const string filename = getEndpointsFilename();
LOG_TRACE("saving endpoint list in file '%s'", filename.c_str());
bool ok = TRI_SaveJson(filename.c_str(), json, true);
bool ok = TRI_SaveJson(filename.c_str(), json, true);
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
@ -537,15 +514,19 @@ const std::vector<std::string> ApplicationEndpointServer::getEndpointMapping (st
return _endpointList.getMapping(endpoint);
}
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
bool ApplicationEndpointServer::prepare () {
if (_disabled) {
return true;
}
loadEndpoints();
if (_endpointList.empty()) {
if (_endpointList.empty()) {
LOG_INFO("please use the '--server.endpoint' option");
LOG_FATAL_AND_EXIT("no endpoints have been specified, giving up");
}
@ -558,7 +539,7 @@ bool ApplicationEndpointServer::prepare () {
_allowMethodOverride,
_setContext,
_contextData);
LOG_INFO("using default API compatibility: %ld", (long int) _defaultApiCompatibility);
return true;
@ -569,6 +550,10 @@ bool ApplicationEndpointServer::prepare () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationEndpointServer::prepare2 () {
if (_disabled) {
return true;
}
// scheduler might be created after prepare(), so we need to use prepare2()!!
Scheduler* scheduler = _applicationScheduler->scheduler();
@ -586,6 +571,10 @@ bool ApplicationEndpointServer::prepare2 () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationEndpointServer::open () {
if (_disabled) {
return true;
}
for (vector<EndpointServer*>::iterator i = _servers.begin(); i != _servers.end(); ++i) {
EndpointServer* server = *i;
@ -600,6 +589,10 @@ bool ApplicationEndpointServer::open () {
////////////////////////////////////////////////////////////////////////////////
void ApplicationEndpointServer::close () {
if (_disabled) {
return;
}
// close all open connections
for (vector<EndpointServer*>::iterator i = _servers.begin(); i != _servers.end(); ++i) {
EndpointServer* server = *i;
@ -620,6 +613,10 @@ void ApplicationEndpointServer::close () {
////////////////////////////////////////////////////////////////////////////////
void ApplicationEndpointServer::stop () {
if (_disabled) {
return;
}
for (vector<EndpointServer*>::iterator i = _servers.begin(); i != _servers.end(); ++i) {
EndpointServer* server = *i;
@ -627,19 +624,10 @@ void ApplicationEndpointServer::stop () {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief creates an ssl context
////////////////////////////////////////////////////////////////////////////////
@ -656,7 +644,7 @@ bool ApplicationEndpointServer::createSslContext () {
return false;
}
LOG_DEBUG("using SSL protocol version '%s'",
LOG_DEBUG("using SSL protocol version '%s'",
HttpsServer::protocolName((HttpsServer::protocol_e) _sslProtocol).c_str());
if (! FileUtils::exists(_httpsKeyfile)) {
@ -748,10 +736,6 @@ bool ApplicationEndpointServer::createSslContext () {
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -5,7 +5,7 @@
///
/// DISCLAIMER
///
/// Copyright 2004-2013 triAGENS GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS 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.
@ -22,7 +22,7 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_HTTP_SERVER_APPLICATION_ENDPOINT_SERVER_H
@ -52,11 +52,6 @@ namespace triagens {
// --SECTION-- class ApplicationEndpointServer
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief application http server feature
////////////////////////////////////////////////////////////////////////////////
@ -66,19 +61,10 @@ namespace triagens {
ApplicationEndpointServer (ApplicationEndpointServer const&);
ApplicationEndpointServer& operator= (ApplicationEndpointServer const&);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
@ -99,19 +85,10 @@ namespace triagens {
~ApplicationEndpointServer ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
@ -136,19 +113,10 @@ namespace triagens {
_basePath = basePath;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- ApplicationFeature methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ApplicationServer
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
@ -166,11 +134,11 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
std::map<std::string, std::vector<std::string> > getEndpoints ();
////////////////////////////////////////////////////////////////////////////////
/// @brief adds a new endpoint at runtime, and connects to it
////////////////////////////////////////////////////////////////////////////////
bool addEndpoint (std::string const&,
std::vector<std::string> const&,
bool);
@ -178,7 +146,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an existing endpoint and disconnects from it
////////////////////////////////////////////////////////////////////////////////
bool removeEndpoint (std::string const&);
////////////////////////////////////////////////////////////////////////////////
@ -230,19 +198,10 @@ namespace triagens {
void stop ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
private:
////////////////////////////////////////////////////////////////////////////////
@ -257,19 +216,10 @@ namespace triagens {
bool createSslContext ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- protected variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup HttpServer
/// @{
////////////////////////////////////////////////////////////////////////////////
protected:
////////////////////////////////////////////////////////////////////////////////
@ -311,7 +261,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
/// @brief context data passed to callback functions
////////////////////////////////////////////////////////////////////////////////
void* _contextData;
////////////////////////////////////////////////////////////////////////////////
@ -395,7 +345,7 @@ namespace triagens {
///
/// @CMDOPT{\--server.reuse-address}
///
/// If this boolean option is set to `true` then the socket option
/// If this boolean option is set to `true` then the socket option
/// SO_REUSEADDR is set on all server endpoints, which is the default.
/// If this option is set to `false` it is possible that it takes up
/// to a minute after a server has terminated until it is possible for
@ -427,24 +377,24 @@ namespace triagens {
double _keepAliveTimeout;
////////////////////////////////////////////////////////////////////////////////
/// @brief default API compatibility
/// @brief default API compatibility
///
/// @CMDOPT{\--server.default-api-compatibility}
///
/// This option can be used to determine the API compatibility of the ArangoDB
/// server. It expects an ArangoDB version number as an integer, calculated as
/// follows:
///
///
/// `10000 * major + 100 * minor` (example: `10400` for ArangoDB 1.4)
///
/// The value of this option will have an influence on some API return values
/// The value of this option will have an influence on some API return values
/// when the HTTP client used does not send any compatibility information.
///
/// In most cases it will be sufficient to not set this option explicitly but to
/// keep the default value. However, in case an "old" ArangoDB client is used
/// that does not send any compatibility information and that cannot handle the
/// responses of the current version of ArangoDB, it might be reasonable to set
/// the option to an old version number to improve compatibility with older
/// In most cases it will be sufficient to not set this option explicitly but to
/// keep the default value. However, in case an "old" ArangoDB client is used
/// that does not send any compatibility information and that cannot handle the
/// responses of the current version of ArangoDB, it might be reasonable to set
/// the option to an old version number to improve compatibility with older
/// clients.
////////////////////////////////////////////////////////////////////////////////
@ -456,7 +406,7 @@ namespace triagens {
/// @CMDOPT{\--server.allow-method-override}
///
/// When this option is set to `true`, the HTTP request method will optionally
/// be fetched from one of the following HTTP request headers if present in
/// be fetched from one of the following HTTP request headers if present in
/// the request:
///
/// - `x-http-method`
@ -466,7 +416,7 @@ namespace triagens {
/// If the option is set to `true` and any of these headers is set, the
/// request method will be overriden by the value of the header. For example,
/// this allows issuing an HTTP DELETE request which to the outside world will
/// look like an HTTP GET request. This allows bypassing proxies and tools that
/// look like an HTTP GET request. This allows bypassing proxies and tools that
/// will only let certain request types pass.
///
/// Setting this option to `true` may impose a security risk so it should only
@ -630,10 +580,6 @@ namespace triagens {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------

View File

@ -461,6 +461,10 @@ bool ApplicationScheduler::parsePhase2 (triagens::basics::ProgramOptions& option
////////////////////////////////////////////////////////////////////////////////
bool ApplicationScheduler::prepare () {
if (_disabled) {
return true;
}
buildScheduler();
return true;
@ -471,6 +475,10 @@ bool ApplicationScheduler::prepare () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationScheduler::start () {
if (_disabled) {
return true;
}
buildSchedulerReporter();
buildControlCHandler();
@ -498,6 +506,10 @@ bool ApplicationScheduler::start () {
////////////////////////////////////////////////////////////////////////////////
bool ApplicationScheduler::open () {
if (_disabled) {
return true;
}
if (_scheduler != 0) {
return _scheduler->open();
}
@ -510,6 +522,10 @@ bool ApplicationScheduler::open () {
////////////////////////////////////////////////////////////////////////////////
void ApplicationScheduler::stop () {
if (_disabled) {
return;
}
if (_scheduler != 0) {
static size_t const MAX_TRIES = 10;