1
0
Fork 0

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

This commit is contained in:
Michael Hackstein 2014-03-01 17:33:39 +01:00
commit 5b093918e6
20 changed files with 361 additions and 242 deletions

16
README
View File

@ -3,7 +3,6 @@ ArangoDB
ArangoDB is a multi-purpose open-source database with flexible data models for
documents, graphs, and key-values. Build high performance applications using a
convenient SQL-like query language or JavaScript/Ruby extensions.
Key features include:
* Schema-free schemata let you combine the space efficiency of MySQL with the
@ -13,7 +12,7 @@ Key features include:
* JavaScript for all: no language zoo, you can use one language from your
browser to your back-end
* ArangoDB is multi-threaded - exploit the power of all your cores
* Flexible data modeling: model your data as combination of key-value pairs,
* Flexible data modelling: model your data as combination of key-value pairs,
documents or graphs - perfect for social relations
* Free index choice: use the correct index for your problem, be it a skip list
or a fulltext search
@ -24,7 +23,8 @@ Key features include:
* Powerful query language (AQL) to retrieve data
* Transactions: run queries on multiple documents or collections with optional
transactional consistency and isolation
* Replication: set up the database in a master-slave configuration
* Replication and Sharding: set up the database in a master-slave configuration
or spread bigger datasets across multiple servers
* It is open source (Apache Licence 2.0)
For more in-depth information
@ -59,13 +59,13 @@ local/sbin. Point your browser to
and select the tab Shell. You can now use the Arango shell from within your
browser. Alternative, it is available as command-line tool arangosh.
arangosh> db._create("hallo");
arangosh> db.hallo.save({ world: "earth" });
arangosh> db._create("hello");
arangosh> db.hello.save({ world: "earth" });
Congratulations! You have created your first collection called hallo and your
first document. To verify your achievements
Congratulations! You have created your first collection called hello and your
first document. To verify your achievements, type:
arangosh> db.hallo.toArray();
arangosh> db.hello.toArray();
More Information

View File

@ -102,6 +102,7 @@ add_executable(
RestHandler/RestDocumentHandler.cpp
RestHandler/RestEdgeHandler.cpp
RestHandler/RestImportHandler.cpp
RestHandler/RestPleaseUpgradeHandler.cpp
RestHandler/RestReplicationHandler.cpp
RestHandler/RestUploadHandler.cpp
RestHandler/RestVocbaseBaseHandler.cpp

View File

@ -68,6 +68,7 @@ bin_arangod_SOURCES = \
arangod/RestHandler/RestDocumentHandler.cpp \
arangod/RestHandler/RestEdgeHandler.cpp \
arangod/RestHandler/RestImportHandler.cpp \
arangod/RestHandler/RestPleaseUpgradeHandler.cpp \
arangod/RestHandler/RestReplicationHandler.cpp \
arangod/RestHandler/RestUploadHandler.cpp \
arangod/RestHandler/RestVocbaseBaseHandler.cpp \
@ -109,7 +110,7 @@ bin_arangod_SOURCES = \
arangod/VocBase/voc-shaper.c \
arangod/VocBase/vocbase.c \
arangod/VocBase/vocbase-defaults.c
if ENABLE_CLUSTER
bin_arangod_SOURCES += \

View File

@ -0,0 +1,94 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief please upgrade handler
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 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.
/// 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 triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "RestPleaseUpgradeHandler.h"
using namespace triagens::basics;
using namespace triagens::rest;
using namespace triagens::arango;
using namespace std;
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
RestPleaseUpgradeHandler::RestPleaseUpgradeHandler (HttpRequest* request)
: HttpHandler(request) {
}
// -----------------------------------------------------------------------------
// --SECTION-- Handler methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
bool RestPleaseUpgradeHandler::isDirect () {
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
HttpHandler::status_t RestPleaseUpgradeHandler::execute () {
_response = createResponse(HttpResponse::OK);
_response->setContentType("text/plain; charset=utf-8");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), "Database: ");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), _request->databaseName().c_str());
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), "\r\n\r\n");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), "It appears that your database must be upgrade. ");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), "Normally this can be done using\r\n\r\n");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), " /etc/init.d/arangodb stop\r\n");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), " /etc/init.d/arangodb upgrade\r\n");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), " /etc/init.d/arangodb start\r\n\r\n");
TRI_AppendStringStringBuffer(_response->body().stringBuffer(), "Please check the log file for details.\r\n");
return status_t(HANDLER_DONE);
}
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
void RestPleaseUpgradeHandler::handleError (basics::TriagensError const&) {
}
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
// End:

View File

@ -0,0 +1,94 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief please upgrade handler
///
/// @file
///
/// DISCLAIMER
///
/// 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.
/// 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 triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2010-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_REST_HANDLER_REST_PLEASE_UPGRADE_HANDLER_H
#define TRIAGENS_REST_HANDLER_REST_PLEASE_UPGRADE_HANDLER_H 1
#include "HttpServer/HttpHandler.h"
// -----------------------------------------------------------------------------
// --SECTION-- class RestDocumentHandler
// -----------------------------------------------------------------------------
namespace triagens {
namespace arango {
////////////////////////////////////////////////////////////////////////////////
/// @brief document request handler
////////////////////////////////////////////////////////////////////////////////
class RestPleaseUpgradeHandler : public rest::HttpHandler {
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
RestPleaseUpgradeHandler (rest::HttpRequest*);
// -----------------------------------------------------------------------------
// --SECTION-- Handler methods
// -----------------------------------------------------------------------------
public:
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
bool isDirect ();
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
status_t execute ();
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
void handleError (basics::TriagensError const&);
};
}
}
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
// End:

View File

@ -52,22 +52,17 @@ using namespace triagens::arango;
// --SECTION-- public constants
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief batch path
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::BATCH_PATH = "/_api/batch";
const string RestVocbaseBaseHandler::BATCH_PATH = "/_api/batch";
////////////////////////////////////////////////////////////////////////////////
/// @brief document path
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::DOCUMENT_PATH = "/_api/document";
const string RestVocbaseBaseHandler::DOCUMENT_PATH = "/_api/document";
////////////////////////////////////////////////////////////////////////////////
/// @brief documents import path
@ -79,39 +74,30 @@ const string RestVocbaseBaseHandler::DOCUMENT_IMPORT_PATH = "/_api/import";
/// @brief document path
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::EDGE_PATH = "/_api/edge";
const string RestVocbaseBaseHandler::EDGE_PATH = "/_api/edge";
////////////////////////////////////////////////////////////////////////////////
/// @brief replication path
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::REPLICATION_PATH = "/_api/replication";
const string RestVocbaseBaseHandler::REPLICATION_PATH = "/_api/replication";
////////////////////////////////////////////////////////////////////////////////
/// @brief upload path
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::UPLOAD_PATH = "/_api/upload";
const string RestVocbaseBaseHandler::UPLOAD_PATH = "/_api/upload";
////////////////////////////////////////////////////////////////////////////////
/// @brief name of the queue
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::QUEUE_NAME = "STANDARD";
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
const string RestVocbaseBaseHandler::QUEUE_NAME = "STANDARD";
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
@ -130,19 +116,10 @@ RestVocbaseBaseHandler::RestVocbaseBaseHandler (HttpRequest* request)
RestVocbaseBaseHandler::~RestVocbaseBaseHandler () {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- protected methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief check if a collection needs to be created on the fly
///
@ -611,10 +588,6 @@ TRI_json_t* RestVocbaseBaseHandler::parseJsonBody () {
return json;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- HANDLER
// -----------------------------------------------------------------------------
@ -624,11 +597,10 @@ TRI_json_t* RestVocbaseBaseHandler::parseJsonBody () {
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoDB
/// @{
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
std::string const& RestVocbaseBaseHandler::queue () const {
string const& RestVocbaseBaseHandler::queue () const {
return QUEUE_NAME;
}
@ -690,10 +662,6 @@ int RestVocbaseBaseHandler::parseDocumentId (string const& handle,
return TRI_ERROR_NO_ERROR;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"

View File

@ -67,6 +67,7 @@
#include "RestHandler/RestDocumentHandler.h"
#include "RestHandler/RestEdgeHandler.h"
#include "RestHandler/RestImportHandler.h"
#include "RestHandler/RestPleaseUpgradeHandler.h"
#include "RestHandler/RestReplicationHandler.h"
#include "RestHandler/RestUploadHandler.h"
#include "RestServer/ConsoleThread.h"
@ -117,6 +118,10 @@ static void DefineApiHandlers (HttpHandlerFactory* factory,
// add "/version" handler
admin->addBasicHandlers(factory, "/_api", (void*) jobManager);
// add a upgrade warning
factory->addPrefixHandler("/_msg/please-upgrade",
RestHandlerCreator<RestPleaseUpgradeHandler>::createNoData);
// add "/batch" handler
factory->addPrefixHandler(RestVocbaseBaseHandler::BATCH_PATH,
RestHandlerCreator<RestBatchHandler>::createNoData);
@ -249,6 +254,12 @@ static bool SetRequestContext (triagens::rest::HttpRequest* request,
return false;
}
// database needs upgrade
if (vocbase->_state == (sig_atomic_t) TRI_VOCBASE_STATE_FAILED_VERSION) {
request->setRequestPath("/_msg/please-upgrade");
return false;
}
VocbaseContext* ctx = new triagens::arango::VocbaseContext(request, server, vocbase);
if (ctx == 0) {

View File

@ -9541,10 +9541,6 @@ static v8::Handle<v8::Value> JS_CreateDatabase (v8::Arguments const& argv) {
// version check ok
TRI_V8InitialiseFoxx(database, v8::Context::GetCurrent());
}
else {
// version check failed
// TODO: report an error
}
// populate the authentication cache. otherwise no one can access the new database
TRI_ReloadAuthInfo(database);
@ -10395,10 +10391,15 @@ bool TRI_V8RunVersionCheck (void* vocbase,
v8g->_vocbase = vocbase;
v8::Handle<v8::Value> result = startupLoader->executeGlobalScript(context, "server/version-check.js");
bool ok = TRI_ObjectToBoolean(result);
if (! ok) {
((TRI_vocbase_t*) vocbase)->_state = (sig_atomic_t) TRI_VOCBASE_STATE_FAILED_VERSION;
}
v8g->_vocbase = orig;
return TRI_ObjectToBoolean(result);
return ok;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -1410,14 +1410,13 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
return NULL;
}
TRI_ReloadAuthInfo(vocbase);
// .............................................................................
// vocbase is now active
// .............................................................................
vocbase->_state = 1;
vocbase->_state = (sig_atomic_t) TRI_VOCBASE_STATE_NORMAL;
// .............................................................................
// start helper threads
@ -1516,7 +1515,7 @@ void TRI_DestroyVocBase (TRI_vocbase_t* vocbase) {
TRI_DestroyVectorPointer(&collections);
// this will signal the synchroniser and the compactor threads to do one last iteration
vocbase->_state = 2;
vocbase->_state = (sig_atomic_t) TRI_VOCBASE_STATE_SHUTDOWN_COMPACTOR;
// wait until synchroniser and compactor are finished
@ -1537,7 +1536,7 @@ void TRI_DestroyVocBase (TRI_vocbase_t* vocbase) {
}
// this will signal the cleanup thread to do one last iteration
vocbase->_state = 3;
vocbase->_state = (sig_atomic_t) TRI_VOCBASE_STATE_SHUTDOWN_CLEANUP;
TRI_LockCondition(&vocbase->_cleanupCondition);
TRI_SignalCondition(&vocbase->_cleanupCondition);

View File

@ -60,11 +60,6 @@ struct TRI_vocbase_defaults_s;
// --SECTION-- public macros
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief read locks the collections structure
////////////////////////////////////////////////////////////////////////////////
@ -184,19 +179,10 @@ struct TRI_vocbase_defaults_s;
TRI_BroadcastCondition(&(a)->_syncWaitersCondition); \
TRI_UnlockCondition(&(a)->_syncWaitersCondition)
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public constants
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief name of the _from attribute
////////////////////////////////////////////////////////////////////////////////
@ -302,19 +288,23 @@ struct TRI_vocbase_defaults_s;
#define TRI_QRY_NO_SKIP ((TRI_voc_ssize_t) 0)
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
/// @brief database state
////////////////////////////////////////////////////////////////////////////////
typedef enum {
TRI_VOCBASE_STATE_INACTIVE = 0,
TRI_VOCBASE_STATE_NORMAL = 1,
TRI_VOCBASE_STATE_SHUTDOWN_COMPACTOR = 2,
TRI_VOCBASE_STATE_SHUTDOWN_CLEANUP = 3,
TRI_VOCBASE_STATE_FAILED_VERSION = 4
}
TRI_vocbase_state_e;
////////////////////////////////////////////////////////////////////////////////
/// @brief database type
////////////////////////////////////////////////////////////////////////////////
@ -367,6 +357,8 @@ typedef struct TRI_vocbase_s {
// 1 = normal operation/running
// 2 = shutdown in progress/waiting for compactor/synchroniser thread to finish
// 3 = shutdown in progress/waiting for cleanup thread to finish
// 4 = version check failed
sig_atomic_t _state;
TRI_thread_t _synchroniser;
@ -437,19 +429,10 @@ typedef struct TRI_vocbase_col_s {
}
TRI_vocbase_col_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup VocBase
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief free the memory associated with a collection
////////////////////////////////////////////////////////////////////////////////
@ -681,10 +664,6 @@ bool TRI_IsSystemVocBase (TRI_vocbase_t*);
bool TRI_IsAllowedNameVocBase (bool,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
}
#endif

View File

@ -736,6 +736,15 @@ actions.defineHttp({
description: "Number of seconds elapsed since server start.",
type: "current",
units: "seconds"
},
{
group: "server",
identifier: "physicalMemory",
name: "Physical Memory",
description: "Physical memory in bytes.",
type: "current",
units: "bytes"
}
]

View File

@ -40,6 +40,8 @@
////////////////////////////////////////////////////////////////////////////////
(function(args) {
delete UPGRADE_ARGS;
var internal = require("internal");
var fs = require("fs");
var console = require("console");
@ -708,7 +710,6 @@
return true;
}
var lastVersion = null;
var currentServerVersion = internal.db._version().match(/^(\d+\.\d+).*$/);
@ -777,9 +778,17 @@
logger.error("Database directory version (" + lastVersion
+ ") is lower than server version (" + currentVersion + ").");
logger.error("It seems like you have upgraded the ArangoDB binary. If this is"
+" what you wanted to do, please restart with the --upgrade option"
+" to upgrade the data in the database directory.");
logger.error("----------------------------------------------------------------------");
logger.error("It seems like you have upgraded the ArangoDB binary.");
logger.error("If this is what you wanted to do, please restart with the");
logger.error(" --upgrade");
logger.error("option to upgrade the data in the database directory.");
logger.error("Normally you can use the control script to upgrade your database")
logger.error(" /etc/init.d/arangodb stop")
logger.error(" /etc/init.d/arangodb upgrade")
logger.error(" /etc/init.d/arangodb start")
logger.error("----------------------------------------------------------------------");
// do not start unless started with --upgrade
return false;
@ -789,8 +798,6 @@
return true;
}(UPGRADE_ARGS));
delete UPGRADE_ARGS;
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -162,6 +162,10 @@ HttpHandler::status_t RestVersionHandler::execute () {
return status_t(HANDLER_DONE);
}
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"

View File

@ -85,12 +85,12 @@ namespace triagens {
// --SECTION-- private variables
// -----------------------------------------------------------------------------
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief name of the queue
////////////////////////////////////////////////////////////////////////////////
private:
static const std::string QUEUE_NAME;
};
@ -99,6 +99,10 @@ namespace triagens {
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"

View File

@ -111,6 +111,7 @@
#define TRI_HAVE_POSIX 1
#define TRI_HAVE_MACOS_MEM_STATS 1
#define TRI_HAVE_LINUX_SOCKETS 1
#define TRI_HAVE_MACH 1
#define TRI_HAVE_MACOS_SPIN 1
@ -419,6 +420,7 @@
#define TRI_HAVE_POSIX 1
#define TRI_HAVE_SC_PHYS_PAGES 1
#define TRI_HAVE_LINUX_PROC 1
#define TRI_HAVE_LINUX_SOCKETS 1
#define TRI_HAVE_POSIX_SPIN 1
@ -545,6 +547,8 @@
#define TRI_HAVE_STRTOI64 1
#define TRI_HAVE_STRTOUI64 1
#define TRI_HAVE_WIN32_GLOBAL_MEMORY_STATUS 1
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define snprintf _snprintf

View File

@ -685,6 +685,14 @@ void HttpRequest::setUser (string const& user) {
_user = user;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the path of the request
////////////////////////////////////////////////////////////////////////////////
void HttpRequest::setRequestPath (char const* path) {
_requestPath = path;
}
// -----------------------------------------------------------------------------
// --SECTION-- private methods
// -----------------------------------------------------------------------------
@ -898,7 +906,9 @@ void HttpRequest::parseHeader (char* ptr, size_t length) {
if (pathEnd - pathBegin >= 5) {
char* q = pathBegin;
// check if the prefix is "_db"
if (q[0] == '/' && q[1] == '_' && q[2] == 'd' && q[3] == 'b' && q[4] == '/') {
// request contains database name
q += 5;
pathBegin = q;
@ -1097,14 +1107,6 @@ void HttpRequest::setFullUrl (char const* begin, char const* end) {
_fullUrl = string(begin, end - begin);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the path of the request
////////////////////////////////////////////////////////////////////////////////
void HttpRequest::setRequestPath (char const* path) {
_requestPath = path;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the header values
////////////////////////////////////////////////////////////////////////////////

View File

@ -236,6 +236,15 @@ namespace triagens {
void setUser (std::string const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the path of the request
///
/// @note The @FA{path} must exists as long as the instance is alive and it
/// must be garbage collected by the caller.
////////////////////////////////////////////////////////////////////////////////
void setRequestPath (char const* path);
// -----------------------------------------------------------------------------
// --SECTION-- public prefix/suffix methods
// -----------------------------------------------------------------------------
@ -522,15 +531,6 @@ namespace triagens {
void setFullUrl (char const* begin, char const* end);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the path of the request
///
/// @note The @FA{path} must exists as long as the instance is alive and it
/// must be garbage collected by the caller.
////////////////////////////////////////////////////////////////////////////////
void setRequestPath (char const* path);
////////////////////////////////////////////////////////////////////////////////
/// @brief sets a key/value pair
////////////////////////////////////////////////////////////////////////////////

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,13 +22,18 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2012-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "statistics.h"
#include "BasicsC/locks.h"
#ifdef TRI_HAVE_MACOS_MEM_STATS
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
using namespace triagens::basics;
using namespace std;
@ -50,11 +55,6 @@ using namespace std;
// --SECTION-- private request statistics variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief lock for lists
////////////////////////////////////////////////////////////////////////////////
@ -67,19 +67,10 @@ static STATISTICS_TYPE RequestListLock;
static TRI_statistics_list_t RequestFreeList;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public request statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets a new statistics block
////////////////////////////////////////////////////////////////////////////////
@ -168,19 +159,10 @@ void TRI_FillRequestStatistics (StatisticsDistribution& totalTime,
STATISTICS_UNLOCK(&RequestListLock);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- private connection statistics variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief lock for lists
////////////////////////////////////////////////////////////////////////////////
@ -193,19 +175,10 @@ static STATISTICS_TYPE ConnectionListLock;
static TRI_statistics_list_t ConnectionFreeList;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public connection statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets a new statistics block
////////////////////////////////////////////////////////////////////////////////
@ -283,19 +256,10 @@ void TRI_FillConnectionStatistics (StatisticsCounter& httpConnections,
STATISTICS_UNLOCK(&ConnectionListLock);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public server statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the global server statistics
////////////////////////////////////////////////////////////////////////////////
@ -310,18 +274,60 @@ TRI_server_statistics_t TRI_GetServerStatistics () {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
/// @brief gets the physical memory
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_HAVE_MACOS_MEM_STATS
uint64_t TRI_GetPhysicalMemory () {
int mib[2];
int64_t physicalMemory;
size_t length;
// Get the Physical memory size
mib[0] = CTL_HW;
mib[1] = HW_MEMSIZE;
length = sizeof(int64_t);
sysctl(mib, 2, &physicalMemory, &length, NULL, 0);
return (uint64_t) physicalMemory;
}
#else
#ifdef TRI_HAVE_SC_PHYS_PAGES
uint64_t TRI_GetPhysicalMemory () {
long pages = sysconf(_SC_PHYS_PAGES);
long page_size = sysconf(_SC_PAGE_SIZE);
return (uint64_t)(pages * page_size);
}
#else
#ifdef TRI_HAVE_WIN32_GLOBAL_MEMORY_STATUS
uint64_t getTotalSystemMemory() {
MEMORYSTATUSEX status;
status.dwLength = sizeof(status);
GlobalMemoryStatusEx(&status);
return (uint64_t) status.ullTotalPhys;
}
#else
uint64_t TRI_GetPhysicalMemory () {
return 0;
}
#endif
#endif
#endif
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief fills a linked list
////////////////////////////////////////////////////////////////////////////////
@ -358,19 +364,10 @@ void TRI_DestroyStatisticsList (TRI_statistics_list_t* list) {
list->_first = list->_last = NULL;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public variable
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics enabled flags
////////////////////////////////////////////////////////////////////////////////
@ -467,19 +464,10 @@ StatisticsDistribution* BytesReceivedDistribution;
TRI_server_statistics_t ServerStatistics;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the current wallclock time
////////////////////////////////////////////////////////////////////////////////
@ -497,11 +485,15 @@ double TRI_StatisticsTime () {
#else
double TRI_StatisticsTime () {
return TRI_microtime();
return TRI_microtime();
}
#endif
// -----------------------------------------------------------------------------
// --SECTION-- module initialisation
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief module init function
////////////////////////////////////////////////////////////////////////////////
@ -583,10 +575,6 @@ void TRI_ShutdownStatistics (void) {
#endif
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --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 2012-2013, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2012-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_STATISTICS_STATISTICS_H
@ -41,11 +41,6 @@
// --SECTION-- public types
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics list entry
////////////////////////////////////////////////////////////////////////////////
@ -117,19 +112,10 @@ typedef struct TRI_server_statistics_s {
}
TRI_server_statistics_t;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public request statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets a new statistics block
////////////////////////////////////////////////////////////////////////////////
@ -152,19 +138,10 @@ void TRI_FillRequestStatistics (triagens::basics::StatisticsDistribution& totalT
triagens::basics::StatisticsDistribution& bytesSent,
triagens::basics::StatisticsDistribution& bytesReceived);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public connection statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets a new statistics block
////////////////////////////////////////////////////////////////////////////////
@ -187,19 +164,10 @@ void TRI_FillConnectionStatistics (triagens::basics::StatisticsCounter& httpConn
triagens::basics::StatisticsCounter& asyncRequests,
triagens::basics::StatisticsDistribution& connectionTime);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public server statistics functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the server statistics
////////////////////////////////////////////////////////////////////////////////
@ -207,18 +175,15 @@ void TRI_FillConnectionStatistics (triagens::basics::StatisticsCounter& httpConn
TRI_server_statistics_t TRI_GetServerStatistics ();
////////////////////////////////////////////////////////////////////////////////
/// @}
/// @brief gets the physical memory
////////////////////////////////////////////////////////////////////////////////
uint64_t TRI_GetPhysicalMemory ();
// -----------------------------------------------------------------------------
// --SECTION-- public variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief statistics enabled flags
////////////////////////////////////////////////////////////////////////////////
@ -315,19 +280,10 @@ extern triagens::basics::StatisticsDistribution* BytesReceivedDistribution;
extern TRI_server_statistics_t ServerStatistics;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Statistics
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the current wallclock time
////////////////////////////////////////////////////////////////////////////////
@ -346,10 +302,6 @@ void TRI_InitialiseStatistics (void);
void TRI_ShutdownStatistics (void);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------

View File

@ -2034,6 +2034,7 @@ static v8::Handle<v8::Value> JS_ServerStatistics (v8::Arguments const& argv) {
v8::Handle<v8::Object> result = v8::Object::New();
result->Set(v8::String::New("uptime"), v8::Number::New((double) info._uptime));
result->Set(v8::String::New("physicalMemory"), v8::Number::New((double) TRI_GetPhysicalMemory()));
return scope.Close(result);
}