1
0
Fork 0

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

This commit is contained in:
gschwab 2014-06-12 11:36:39 +02:00
commit d8bcfd3bbb
15 changed files with 3089 additions and 76 deletions

View File

@ -1,6 +1,8 @@
v2.2.0 (XXXX-XX-XX)
-------------------
* fixed check-version for empty directory
* moved try/catch block to the top of routing chain
* added mountedApp function for foxx-manager

File diff suppressed because it is too large Load Diff

View File

@ -39,11 +39,11 @@ start () {
fi
if [ "$1" = "--upgrade" ]; then
$DAEMON -c $CONF --uid arangodb --gid arangodb $@
$DAEMON -c $CONF --uid arangodb --gid arangodb --no-server $@
RETVAL=$?
log_end_msg $RETVAL
else
$DAEMON -c $CONF --uid arangodb --gid arangodb --check-version
$DAEMON -c $CONF --uid arangodb --gid arangodb --no-server --check-version
RETVAL=$?
if test $RETVAL -eq 0; then

View File

@ -770,6 +770,27 @@ int ArangoServer::startupServer () {
startServer = false;
}
// check version
bool checkVersion = false;
if (_applicationServer->programOptions().has("check-version")) {
checkVersion = true;
}
// run upgrade script
bool performUpgrade = false;
if (_applicationServer->programOptions().has("upgrade")) {
performUpgrade = true;
}
// skip an upgrade even if VERSION is missing
bool skipUpgrade = false;
if (_applicationServer->programOptions().has("no-upgrade")) {
skipUpgrade = true;
}
// .............................................................................
// prepare the various parts of the Arango server
// .............................................................................
@ -779,7 +800,7 @@ int ArangoServer::startupServer () {
}
// open all databases
openDatabases();
openDatabases(checkVersion, performUpgrade);
// fetch the system database
TRI_vocbase_t* vocbase = TRI_UseDatabaseServer(_server, TRI_VOC_SYSTEM_DATABASE);
@ -809,19 +830,6 @@ int ArangoServer::startupServer () {
_applicationV8->setVocbase(vocbase);
_applicationV8->setConcurrency(concurrency);
bool performUpgrade = false;
if (_applicationServer->programOptions().has("upgrade")) {
performUpgrade = true;
}
// skip an upgrade even if VERSION is missing
bool skipUpgrade = false;
if (_applicationServer->programOptions().has("no-upgrade")) {
skipUpgrade = true;
}
#ifdef TRI_ENABLE_MRUBY
_applicationMR->setVocbase(vocbase);
_applicationMR->setConcurrency(_dispatcherThreads);
@ -851,7 +859,7 @@ int ArangoServer::startupServer () {
_applicationServer->prepare2();
// run version check
if (_applicationServer->programOptions().has("check-version")) {
if (checkVersion) {
_applicationV8->runUpgradeCheck();
}
@ -1098,7 +1106,7 @@ int ArangoServer::runScript (TRI_vocbase_t* vocbase) {
/// @brief opens the database
////////////////////////////////////////////////////////////////////////////////
void ArangoServer::openDatabases () {
void ArangoServer::openDatabases (bool checkVersion, bool performUpgrade) {
TRI_vocbase_defaults_t defaults;
// override with command-line options
@ -1125,10 +1133,13 @@ void ArangoServer::openDatabases () {
LOG_FATAL_AND_EXIT("cannot create server instance: out of memory");
}
const bool isUpgrade = _applicationServer->programOptions().has("upgrade");
res = TRI_StartServer(_server, isUpgrade);
res = TRI_StartServer(_server, checkVersion, performUpgrade);
if (res != TRI_ERROR_NO_ERROR) {
if (checkVersion && res == TRI_ERROR_ARANGO_EMPTY_DATADIR) {
TRI_EXIT_FUNCTION(EXIT_SUCCESS, NULL);
}
LOG_FATAL_AND_EXIT("cannot start server: %s", TRI_errno_string(res));
}

View File

@ -158,7 +158,7 @@ namespace triagens {
/// @brief opens the system database
////////////////////////////////////////////////////////////////////////////////
void openDatabases ();
void openDatabases (bool checkVersion, bool performUpgrade);
////////////////////////////////////////////////////////////////////////////////
/// @brief closes the database

View File

@ -290,12 +290,16 @@ static int WriteServerId (char const* filename) {
/// @brief read / create the server id on startup
////////////////////////////////////////////////////////////////////////////////
static int DetermineServerId (TRI_server_t* server) {
static int DetermineServerId (TRI_server_t* server, bool checkVersion) {
int res;
res = ReadServerId(server->_serverIdFilename);
if (res == TRI_ERROR_FILE_NOT_FOUND) {
if (checkVersion) {
return TRI_ERROR_ARANGO_EMPTY_DATADIR;
}
// id file does not yet exist. now create it
res = GenerateServerId();
@ -1390,7 +1394,8 @@ static int Move14AlphaDatabases (TRI_server_t* server) {
////////////////////////////////////////////////////////////////////////////////
static int InitDatabases (TRI_server_t* server,
bool isUpgrade) {
bool checkVersion,
bool performUpgrade) {
TRI_vector_string_t names;
int res;
@ -1404,7 +1409,7 @@ static int InitDatabases (TRI_server_t* server,
if (names._length == 0) {
char* name;
if (! isUpgrade && HasOldCollections(server)) {
if (! performUpgrade && HasOldCollections(server)) {
LOG_ERROR("no databases found. Please start the server with the --upgrade option");
return TRI_ERROR_ARANGO_DATADIR_INVALID;
@ -1422,7 +1427,7 @@ static int InitDatabases (TRI_server_t* server,
}
}
if (res == TRI_ERROR_NO_ERROR && isUpgrade) {
if (res == TRI_ERROR_NO_ERROR && performUpgrade) {
char const* systemName;
assert(names._length > 0);
@ -1782,7 +1787,8 @@ TRI_server_id_t TRI_GetIdServer () {
////////////////////////////////////////////////////////////////////////////////
int TRI_StartServer (TRI_server_t* server,
bool isUpgrade) {
bool checkVersion,
bool performUpgrade) {
int res;
if (! TRI_IsDirectory(server->_basePath)) {
@ -1832,7 +1838,11 @@ int TRI_StartServer (TRI_server_t* server,
// read the server id
// .............................................................................
res = DetermineServerId(server);
res = DetermineServerId(server, checkVersion);
if (res == TRI_ERROR_ARANGO_EMPTY_DATADIR) {
return res;
}
if (res != TRI_ERROR_NO_ERROR) {
LOG_ERROR("reading/creating server file failed: %s",
@ -1894,7 +1904,11 @@ int TRI_StartServer (TRI_server_t* server,
// perform an eventual migration of the databases.
// .............................................................................
res = InitDatabases(server, isUpgrade);
res = InitDatabases(server, checkVersion, performUpgrade);
if (res == TRI_ERROR_ARANGO_EMPTY_DATADIR) {
return res;
}
if (res != TRI_ERROR_NO_ERROR) {
LOG_ERROR("unable to initialise databases: %s",
@ -1909,7 +1923,7 @@ int TRI_StartServer (TRI_server_t* server,
if (server->_appPath != NULL &&
strlen(server->_appPath) > 0 &&
! TRI_IsDirectory(server->_appPath)) {
if (! isUpgrade) {
if (! performUpgrade) {
LOG_ERROR("specified --javascript.app-path directory '%s' does not exist. "
"Please start again with --upgrade option to create it.",
server->_appPath);
@ -1929,7 +1943,7 @@ int TRI_StartServer (TRI_server_t* server,
if (server->_devAppPath != NULL &&
strlen(server->_devAppPath) > 0 &&
! TRI_IsDirectory(server->_devAppPath)) {
if (! isUpgrade) {
if (! performUpgrade) {
LOG_ERROR("specified --javascript.dev-app-path directory '%s' does not exist. "
"Please start again with --upgrade option to create it.",
server->_devAppPath);
@ -1979,7 +1993,7 @@ int TRI_StartServer (TRI_server_t* server,
// .............................................................................
// scan all databases
res = OpenDatabases(server, isUpgrade);
res = OpenDatabases(server, performUpgrade);
if (res != TRI_ERROR_NO_ERROR) {
LOG_ERROR("could not iterate over all databases: %s",
@ -2686,6 +2700,10 @@ bool TRI_MSync (int fd,
return true;
}
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"

View File

@ -151,7 +151,8 @@ TRI_server_id_t TRI_GetIdServer (void);
////////////////////////////////////////////////////////////////////////////////
int TRI_StartServer (TRI_server_t*,
bool);
bool checkVersion,
bool performUpgrade);
////////////////////////////////////////////////////////////////////////////////
/// @brief stop the server

View File

@ -104,6 +104,7 @@
"ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING" : { "code" : 1234, "message" : "index insertion warning - attribute missing in document" },
"ERROR_ARANGO_INDEX_CREATION_FAILED" : { "code" : 1235, "message" : "index creation failed" },
"ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" },
"ERROR_ARANGO_EMPTY_DATADIR" : { "code" : 1301, "message" : "server database directory is empty" },
"ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" },
"ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" },
"ERROR_REPLICATION_MASTER_ERROR" : { "code" : 1402, "message" : "master error" },

View File

@ -104,6 +104,7 @@
"ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING" : { "code" : 1234, "message" : "index insertion warning - attribute missing in document" },
"ERROR_ARANGO_INDEX_CREATION_FAILED" : { "code" : 1235, "message" : "index creation failed" },
"ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" },
"ERROR_ARANGO_EMPTY_DATADIR" : { "code" : 1301, "message" : "server database directory is empty" },
"ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" },
"ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" },
"ERROR_REPLICATION_MASTER_ERROR" : { "code" : 1402, "message" : "master error" },

View File

@ -1480,7 +1480,7 @@ var _create = function (graphName, edgeDefinitions) {
);
try {
g = gdb.document(graphName);
var g = gdb.document(graphName);
} catch (e) {
if (e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) {
throw e;

View File

@ -4970,7 +4970,7 @@ function IS_EXAMPLE_SET (example) {
/// @startDocuBlock JSF_ahuacatl_general_graph_shortest_paths
///
/// `GRAPH_SHORTEST_PATH (graphName, startVertexExample, endVertexExample, options)`
/// *The GRAPH\_SHORTEST\_PATH function returns all paths of a graph.*
/// *The GRAPH\_SHORTEST\_PATH function returns all shortest paths of a graph.*
///
/// This function determines all shortest paths in a graph identified by *graphName*.
/// The function accepts an id, an example, a list of examples
@ -4978,7 +4978,7 @@ function IS_EXAMPLE_SET (example) {
/// start and end vertex. If one wants to calls this function to receive nearly all
/// shortest paths for a graph the
/// option *algorithm* should be set to *Floyd-Warshall* to increase performance.
/// If no algorithm is given in the options the function chooses the appropriate
/// If no algorithm is provided in the options the function chooses the appropriate
/// one (either *Floyd-Warshall* or *Dijsktra*) according to its parameters.
/// The length of a path is by default the amount of edges from one start vertex to
/// an end vertex. The option weight allows the user to define an edge attribute
@ -5224,6 +5224,7 @@ function GRAPH_TRAVERSAL_TREE (vertexCollection,
/// *The GRAPH\_DISTANCE\_TO function returns all paths and there distance within a graph.*
///
/// This function is a wrapper of [GRAPH\_SHORTEST\_PATH](#SUBSECTION GRAPH_SHORTEST_PATH).
/// It does not return the actual path but only the distance between two vertices.
///
////////////////////////////////////////////////////////////////////////////////
function GENERAL_GRAPH_DISTANCE_TO (graphName,
@ -5529,7 +5530,7 @@ function GENERAL_GRAPH_NEIGHBORS (graphName,
}
////////////////////////////////////////////////////////////////////////////////
/// @startDocuBlock JSF_ahuacatl_general_graph_neighbors
/// @startDocuBlock JSF_ahuacatl_general_graph_edges
///
/// `GRAPH_EDGES (graphName, vertexExample, options)`
/// *The GRAPH\_EDGES function returns all edges of vertices.*
@ -5704,7 +5705,7 @@ function GENERAL_GRAPH_VERTICES (
function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
var ret = {};
result.forEach(function (r) {
var v = JSON.stringify(r.vertex)
var v = JSON.stringify(r.vertex);
if (! ret[v]) {
ret[v] = [];
}
@ -5718,7 +5719,8 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
////////////////////////////////////////////////////////////////////////////////
/// @startDocuBlock JSF_ahuacatl_general_graph_common_neighbors
///
/// `GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)`
/// `GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples,
/// optionsVertex1, optionsVertex2)`
/// *The GRAPH\_COMMON\_NEIGHBORS function returns all common neighbors of the vertices
/// defined by the examples.*
///
@ -5758,28 +5760,27 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
///
/// @EXAMPLES
///
/// A route planner example, all neighbors of locations with a distance of
/// either 700 or 600.:
/// A route planner example, all common neighbors of capitals.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices1}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS("
/// |+"'routeplanner', {}) RETURN e"
/// |+"'routeplanner', {isCapital : true}, {isCapital : true}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, all outbound neighbors of munich with a maximal
/// depth of 2 :
/// A route planner example, all common outbound neighbors of munich with any other location
/// which have a maximal depth of 2 :
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices2}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS("
/// |+"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" +
/// |" : 'city'}) RETURN e"
/// |+"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+
/// | "{direction : 'outbound', maxDepth : 2}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
@ -5797,8 +5798,8 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS (
var neighbors1 = TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT(
GENERAL_GRAPH_NEIGHBORS(graphName, vertex1Examples, options1)
), neighbors2;
if (vertex1Examples == vertex2Examples) {
neighbors2 == CLONE(neighbors1);
if (vertex1Examples === vertex2Examples) {
neighbors2 = CLONE(neighbors1);
} else {
neighbors2 = TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT(
GENERAL_GRAPH_NEIGHBORS(graphName, vertex2Examples, options2)
@ -5835,7 +5836,7 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS (
});
});
Object.keys(res2).forEach(function (r) {
var e = {}
var e = {};
e[r] = res2[r];
res3.push(e);
});
@ -5988,7 +5989,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES (
///
/// `GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)`
/// *The GRAPH\_ABSOLUTE\_ECCENTRICITY function returns the
/// [eccentricity](http://en.wikipedia.org/wiki/Distance_(graph_theory))
/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29)
/// of the vertices defined by the examples.
///
/// The function accepts an id, an example, a list of examples or even an empty
@ -6011,8 +6012,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES (
/// * String|Object|Array *edgeExamples* : A filter example for the
/// edges in the shortest paths (see below).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6100,7 +6100,7 @@ function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)
///
/// `GRAPH_ECCENTRICITY (graphName, options)`
/// *The GRAPH\_ECCENTRICITY function returns the normalized
/// [eccentricity](http://en.wikipedia.org/wiki/Distance_(graph_theory))
/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29)
/// of the graphs vertices
///
/// * String *graphName* : The name of the graph.
@ -6110,8 +6110,7 @@ function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6202,8 +6201,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) {
/// * String|Object|Array *edgeExamples* : A filter example for the
/// edges in the shortest paths (see below).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6300,8 +6298,7 @@ function GENERAL_GRAPH_ABSOLUTE_CLOSENESS (graphName, vertexExample, options) {
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6396,9 +6393,6 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) {
/// Possible options and there defaults:
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6507,9 +6501,6 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) {
/// Possible options and there defaults:
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is
/// used, otherwise the default is *Dijkstra*
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
@ -6582,7 +6573,68 @@ function GENERAL_GRAPH_BETWEENNESS (graphName, options) {
////////////////////////////////////////////////////////////////////////////////
/// @brief return the radius of the graph
/// @startDocuBlock JSF_ahuacatl_general_graph_radius
///
/// `GRAPH_RADIUS (graphName, options)`
/// *The GRAPH\_RADIUS function returns the
/// [radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29)
/// of a graph.
///
/// * String *graphName* : The name of the graph.
/// * Object *options* : Optional options, see below:
///
/// Possible options and there defaults:
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
/// If an edge does not have the attribute named as defined in option *weight* this default
/// is used as length.
/// If no default is supplied the default would be positive Infinity so the path and
/// hence the eccentricity can not be calculated.
///
/// @EXAMPLES
///
/// A route planner example, the radius of the graph.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius1}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_RADIUS("
/// |+"'routeplanner')"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the radius of the graph.
/// This considers the actual distances.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius2}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_RADIUS("
/// |+"'routeplanner', {weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the cradius of the graph regarding only
/// outbound pathes.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius3}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_RADIUS("
/// | + "'routeplanner', {direction : 'outbound', weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
//
////////////////////////////////////////////////////////////////////////////////
function GENERAL_GRAPH_RADIUS (graphName, options) {
@ -6613,7 +6665,68 @@ function GENERAL_GRAPH_RADIUS (graphName, options) {
////////////////////////////////////////////////////////////////////////////////
/// @brief return the diameter of the graph
/// @startDocuBlock JSF_ahuacatl_general_graph_diameter
///
/// `GRAPH_DIAMETER (graphName, options)`
/// *The GRAPH\_DIAMETER function returns the
/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29)
/// of a graph.
///
/// * String *graphName* : The name of the graph.
/// * Object *options* : Optional options, see below:
///
/// Possible options and there defaults:
/// * String *direction* : The direction of the edges.
/// Possible values are *outbound*, *inbound* and *any* (default).
/// * String *algorithm* : The algorithm to calculate
/// the shortest paths.
/// * String *weight* : The name of the attribute of
/// the edges containing the length.
/// * Number *defaultWeight* : Only used with the option *weight*.
/// If an edge does not have the attribute named as defined in option *weight* this default
/// is used as length.
/// If no default is supplied the default would be positive Infinity so the path and
/// hence the eccentricity can not be calculated.
///
/// @EXAMPLES
///
/// A route planner example, the diameter of the graph.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter1}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_DIAMETER("
/// |+"'routeplanner')"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, tthe diameter of the graph.
/// This considers the actual distances.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter2}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_DIAMETER("
/// |+"'routeplanner', {weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the diameter of the graph regarding only
/// outbound pathes.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter3}
/// ~ var db = require("internal").db;
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_DIAMETER("
/// | + "'routeplanner', {direction : 'outbound', weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// @endDocuBlock
//
////////////////////////////////////////////////////////////////////////////////
function GENERAL_GRAPH_DIAMETER (graphName, options) {

View File

@ -30,10 +30,9 @@
/// @author Copyright 2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var internal = require("internal");
var cluster = require("org/arangodb/cluster");
var fs = require("fs");
var db = internal.db;
var db = require("org/arangodb").db;
var console = require("console");
// -----------------------------------------------------------------------------
@ -124,7 +123,7 @@ exports.databaseVersion = function () {
}
// path to the VERSION file
var versionFile = internal.db._path() + "/VERSION";
var versionFile = db._path() + "/VERSION";
var lastVersion = null;
// VERSION file exists, read its contents
@ -152,11 +151,11 @@ exports.databaseVersion = function () {
}
// extract server version
var currentServerVersion = internal.db._version().match(/^(\d+\.\d+).*$/);
var currentServerVersion = db._version().match(/^(\d+\.\d+).*$/);
// server version is invalid for some reason
if (! currentServerVersion) {
logger.error("Unexpected ArangoDB server version: " + internal.db._version());
logger.error("Unexpected ArangoDB server version: " + db._version());
return { result: exports.NO_SERVER_VERSION };
}

View File

@ -129,6 +129,7 @@ ERROR_ARANGO_INDEX_CREATION_FAILED,1235,"index creation failed","Will be raised
################################################################################
ERROR_ARANGO_DATAFILE_FULL,1300,"datafile full","Will be raised when the datafile reaches its limit."
ERROR_ARANGO_EMPTY_DATADIR,1301,"server database directory is empty","Will be raised when encoutering an empty server database directory."
################################################################################
## ArangoDB replication errors

View File

@ -100,6 +100,7 @@ void TRI_InitialiseErrorMessages (void) {
REG_ERROR(ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING, "index insertion warning - attribute missing in document");
REG_ERROR(ERROR_ARANGO_INDEX_CREATION_FAILED, "index creation failed");
REG_ERROR(ERROR_ARANGO_DATAFILE_FULL, "datafile full");
REG_ERROR(ERROR_ARANGO_EMPTY_DATADIR, "server database directory is empty");
REG_ERROR(ERROR_REPLICATION_NO_RESPONSE, "no response");
REG_ERROR(ERROR_REPLICATION_INVALID_RESPONSE, "invalid response");
REG_ERROR(ERROR_REPLICATION_MASTER_ERROR, "master error");

View File

@ -213,6 +213,8 @@ extern "C" {
/// Will be raised when an attempt to create an index has failed.
/// - 1300: @LIT{datafile full}
/// Will be raised when the datafile reaches its limit.
/// - 1301: @LIT{server database directory is empty}
/// Will be raised when encoutering an empty server database directory.
/// - 1400: @LIT{no response}
/// Will be raised when the replication applier does not receive any or an
/// incomplete response from the master.
@ -1459,6 +1461,16 @@ void TRI_InitialiseErrorMessages (void);
#define TRI_ERROR_ARANGO_DATAFILE_FULL (1300)
////////////////////////////////////////////////////////////////////////////////
/// @brief 1301: ERROR_ARANGO_EMPTY_DATADIR
///
/// server database directory is empty
///
/// Will be raised when encoutering an empty server database directory.
////////////////////////////////////////////////////////////////////////////////
#define TRI_ERROR_ARANGO_EMPTY_DATADIR (1301)
////////////////////////////////////////////////////////////////////////////////
/// @brief 1400: ERROR_REPLICATION_NO_RESPONSE
///