1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/arangodb into devel

This commit is contained in:
Willi Goesgens 2015-07-20 14:11:49 +02:00
commit b5ff2f8f4f
45 changed files with 563 additions and 545 deletions

View File

@ -0,0 +1,142 @@
# coding: utf-8
require 'rspec'
require 'arangodb.rb'
describe ArangoDB do
api = "/_api/cursor"
prefix = "api-cursor"
################################################################################
## query cache
################################################################################
context "testing the query cache:" do
before do
doc = ArangoDB.get("/_api/query-cache/properties")
@mode = doc.parsed_response['mode']
ArangoDB.put("/_api/query-cache/properties", :body => "{ \"mode\" : \"demand\" }")
ArangoDB.delete("/_api/query-cache")
end
after do
ArangoDB.put("/_api/query-cache/properties", :body => "{ \"mode\" : \"#{@mode}\" }")
end
it "testing without cache attribute set" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\" }"
doc = ArangoDB.log_post("#{prefix}-query-cache-disabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but not from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
end
it "testing explicitly disable cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : false }"
doc = ArangoDB.log_post("#{prefix}-query-cache-disabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but not from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
end
it "testing enabled cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : true }"
doc = ArangoDB.log_post("#{prefix}-query-cache-enabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but now from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
end
it "testing clearing the cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : true }"
doc = ArangoDB.log_post("#{prefix}-query-cache-enabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but now from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
# now clear cache
ArangoDB.delete("/_api/query-cache")
# query again. now response should not come from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
end
end
end

View File

@ -604,138 +604,5 @@ describe ArangoDB do
end
end
################################################################################
## query cache
################################################################################
context "testing the query cache:" do
before do
doc = ArangoDB.get("/_api/query-cache/properties")
@mode = doc.parsed_response['mode']
ArangoDB.put("/_api/query-cache/properties", :body => "{ \"mode\" : \"demand\" }")
ArangoDB.delete("/_api/query-cache")
end
after do
ArangoDB.put("/_api/query-cache/properties", :body => "{ \"mode\" : \"#{@mode}\" }")
end
it "testing without cache attribute set" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\" }"
doc = ArangoDB.log_post("#{prefix}-query-cache-disabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but not from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
end
it "testing explicitly disable cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : false }"
doc = ArangoDB.log_post("#{prefix}-query-cache-disabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but not from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
end
it "testing enabled cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : true }"
doc = ArangoDB.log_post("#{prefix}-query-cache-enabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but now from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
end
it "testing clearing the cache" do
cmd = api
body = "{ \"query\" : \"FOR i IN 1..5 RETURN i\", \"cache\" : true }"
doc = ArangoDB.log_post("#{prefix}-query-cache-enabled", cmd, :body => body)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['id'].should be_nil
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
# should see same result, but now from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
# now clear cache
ArangoDB.delete("/_api/query-cache")
# query again. now response should not come from cache
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(false)
doc.parsed_response['extra'].should have_key('stats')
doc = ArangoDB.log_post("#{prefix}-query-cache", cmd, :body => body)
doc.code.should eq(201)
result = doc.parsed_response['result']
result.should eq([ 1, 2, 3, 4, 5 ])
doc.parsed_response['cached'].should eq(true)
doc.parsed_response['extra'].should_not have_key('stats')
end
end
end
end

View File

@ -622,7 +622,7 @@ SHELL_SERVER_AQL = @top_srcdir@/js/server/tests/aql-arithmetic.js \
@top_srcdir@/js/server/tests/aql-queries-optimiser-sort-noncluster.js \
@top_srcdir@/js/server/tests/aql-queries-simple.js \
@top_srcdir@/js/server/tests/aql-queries-variables.js \
@top_srcdir@/js/server/tests/aql-query-cache.js \
@top_srcdir@/js/server/tests/aql-query-cache-noncluster.js \
@top_srcdir@/js/server/tests/aql-range.js \
@top_srcdir@/js/server/tests/aql-ranges.js \
@top_srcdir@/js/server/tests/aql-refaccess-attribute.js \

View File

@ -37,7 +37,7 @@
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace rest {
@ -98,7 +98,7 @@ class TRI_action_t {
virtual ~TRI_action_t () {}
virtual TRI_action_result_t execute (struct TRI_vocbase_s*,
virtual TRI_action_result_t execute (TRI_vocbase_t*,
triagens::rest::HttpRequest*,
triagens::basics::Mutex* dataLock,
void** data) = 0;

View File

@ -49,7 +49,7 @@ using namespace triagens::aql;
////////////////////////////////////////////////////////////////////////////////
Collection::Collection (std::string const& name,
struct TRI_vocbase_s* vocbase,
TRI_vocbase_t* vocbase,
TRI_transaction_type_e accessType)
: collection(nullptr),
currentShard(),
@ -271,9 +271,23 @@ void Collection::fillIndexesCoordinator () const {
for (size_t i = 0; i < n; ++i) {
TRI_json_t const* v = TRI_LookupArrayJson(json, i);
if (v != nullptr) {
indexes.emplace_back(new triagens::aql::Index(v));
if (! TRI_IsObjectJson(v)) {
continue;
}
TRI_json_t const* type = TRI_LookupObjectJson(v, "type");
if (! TRI_IsStringJson(type)) {
// no "type" attribute. this is invalid
continue;
}
if (strcmp(type->_value._string.data, "cap") == 0) {
// ignore cap constraints
continue;
}
indexes.emplace_back(new triagens::aql::Index(v));
}
}
}
@ -311,6 +325,19 @@ void Collection::fillIndexesDBServer () const {
TRI_json_t const* id = TRI_LookupObjectJson(v, "id");
if (! TRI_IsStringJson(id)) {
// no "id" attribute. this is invalid
continue;
}
TRI_json_t const* type = TRI_LookupObjectJson(v, "type");
if (! TRI_IsStringJson(type)) {
// no "type" attribute. this is invalid
continue;
}
if (strcmp(type->_value._string.data, "cap") == 0) {
// ignore cap constraints
continue;
}
@ -330,9 +357,6 @@ void Collection::fillIndexesDBServer () const {
data = localIndex;
break;
}
else if (localIndex->type() == triagens::arango::Index::TRI_IDX_TYPE_PRIMARY_INDEX ||
localIndex->type() == triagens::arango::Index::TRI_IDX_TYPE_EDGE_INDEX) {
}
}
auto idx = new triagens::aql::Index(v);
@ -362,6 +386,11 @@ void Collection::fillIndexesLocal () const {
indexes.reserve(n);
for (size_t i = 0; i < n; ++i) {
if (allIndexes[i]->type() == triagens::arango::Index::TRI_IDX_TYPE_CAP_CONSTRAINT) {
// ignore this type of index
continue;
}
indexes.emplace_back(new triagens::aql::Index(allIndexes[i]));
}
}

View File

@ -54,7 +54,7 @@ namespace triagens {
Collection () = delete;
Collection (std::string const&,
struct TRI_vocbase_s*,
TRI_vocbase_t*,
TRI_transaction_type_e);
~Collection ();

View File

@ -34,7 +34,7 @@
#include "Basics/Exceptions.h"
#include "Aql/Collection.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace aql {
@ -49,7 +49,7 @@ namespace triagens {
Collections& operator= (Collections const& other) = delete;
Collections (struct TRI_vocbase_s* vocbase)
Collections (TRI_vocbase_t* vocbase)
: _vocbase(vocbase),
_collections() {
}
@ -123,7 +123,7 @@ namespace triagens {
private:
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
std::map<std::string, Collection*> _collections;

View File

@ -82,7 +82,7 @@ namespace triagens {
Index (TRI_json_t const* json)
: id(triagens::basics::StringUtils::uint64(triagens::basics::JsonHelper::checkAndGetStringValue(json, "id"))),
type(triagens::arango::Index::type(triagens::basics::JsonHelper::checkAndGetStringValue(json, "type").c_str())),
unique(triagens::basics::JsonHelper::checkAndGetBooleanValue(json, "unique")),
unique(triagens::basics::JsonHelper::getBooleanValue(json, "unique", false)),
sparse(triagens::basics::JsonHelper::getBooleanValue(json, "sparse", false)),
fields(),
internals(nullptr) {

View File

@ -1282,14 +1282,14 @@ bool Query::canUseQueryCache () const {
// setting `cache` attribute to false.
// cannot use query cache on a coordinator at the moment
return ! triagens::arango::ServerState::instance()->isCoordinator();
return ! triagens::arango::ServerState::instance()->isRunningInCluster();
}
else if (queryCacheMode == CACHE_ON_DEMAND && getBooleanOption("cache", false)) {
// cache mode is set to demand... query will only be cached if `cache`
// attribute is set to false
// cannot use query cache on a coordinator at the moment
return ! triagens::arango::ServerState::instance()->isCoordinator();
return ! triagens::arango::ServerState::instance()->isRunningInCluster();
}
return false;

View File

@ -43,7 +43,7 @@
#include "V8Server/ApplicationV8.h"
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -145,7 +145,7 @@ namespace triagens {
Query (triagens::arango::ApplicationV8*,
bool,
struct TRI_vocbase_s*,
TRI_vocbase_t*,
char const*,
size_t,
struct TRI_json_t*,
@ -154,7 +154,7 @@ namespace triagens {
Query (triagens::arango::ApplicationV8*,
bool,
struct TRI_vocbase_s*,
TRI_vocbase_t*,
triagens::basics::Json queryStruct,
struct TRI_json_t*,
QueryPart);
@ -203,7 +203,7 @@ namespace triagens {
/// @brief get the vocbase
////////////////////////////////////////////////////////////////////////////////
inline struct TRI_vocbase_s* vocbase () const {
inline TRI_vocbase_t* vocbase () const {
return _vocbase;
}
@ -590,7 +590,7 @@ namespace triagens {
/// @brief pointer to vocbase the query runs in
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief V8 code executor

View File

@ -36,7 +36,7 @@
#include "Basics/ReadWriteLock.h"
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace aql {
@ -336,7 +336,7 @@ namespace triagens {
/// @brief lookup a query result in the cache
////////////////////////////////////////////////////////////////////////////////
QueryCacheResultEntry* lookup (struct TRI_vocbase_s*,
QueryCacheResultEntry* lookup (TRI_vocbase_t*,
uint64_t,
char const*,
size_t);
@ -347,7 +347,7 @@ namespace triagens {
/// query result!
////////////////////////////////////////////////////////////////////////////////
QueryCacheResultEntry* store (struct TRI_vocbase_s*,
QueryCacheResultEntry* store (TRI_vocbase_t*,
uint64_t,
char const*,
size_t,
@ -358,21 +358,21 @@ namespace triagens {
/// @brief invalidate all queries for the given collections
////////////////////////////////////////////////////////////////////////////////
void invalidate (struct TRI_vocbase_s*,
void invalidate (TRI_vocbase_t*,
std::vector<char const*> const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief invalidate all queries for a particular collection
////////////////////////////////////////////////////////////////////////////////
void invalidate (struct TRI_vocbase_s*,
void invalidate (TRI_vocbase_t*,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief invalidate all queries for a particular database
////////////////////////////////////////////////////////////////////////////////
void invalidate (struct TRI_vocbase_s*);
void invalidate (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief invalidate all queries
@ -407,7 +407,7 @@ namespace triagens {
/// @brief determine which part of the cache to use for the cache entries
////////////////////////////////////////////////////////////////////////////////
unsigned int getPart (struct TRI_vocbase_s const*) const;
unsigned int getPart (TRI_vocbase_t const*) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief invalidate all entries in the cache part
@ -462,7 +462,7 @@ namespace triagens {
/// @brief cached query entries, organized per database
////////////////////////////////////////////////////////////////////////////////
std::unordered_map<struct TRI_vocbase_s*, QueryCacheDatabaseEntry*> _entries[NumberOfParts];
std::unordered_map<TRI_vocbase_t*, QueryCacheDatabaseEntry*> _entries[NumberOfParts];
};

View File

@ -34,7 +34,7 @@
#include "Basics/ReadWriteLock.h"
#include "VocBase/voc-types.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace aql {
@ -85,7 +85,7 @@ namespace triagens {
/// @brief create a query list
////////////////////////////////////////////////////////////////////////////////
explicit QueryList (struct TRI_vocbase_s*);
explicit QueryList (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy a query list

View File

@ -44,7 +44,7 @@
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- i class RestAqlHandler
@ -226,7 +226,7 @@ namespace triagens {
/// @brief the vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief our query registry

View File

@ -38,7 +38,7 @@
#include "Cluster/AgencyComm.h"
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace rest {
@ -193,7 +193,7 @@ namespace triagens {
/// @brief fetch users for a database (run on coordinator only)
////////////////////////////////////////////////////////////////////////////////
bool fetchUsers (struct TRI_vocbase_s*);
bool fetchUsers (TRI_vocbase_t*);
// -----------------------------------------------------------------------------
// --SECTION-- private variables
@ -242,7 +242,7 @@ namespace triagens {
/// heartbeat thread runs
////////////////////////////////////////////////////////////////////////////////
std::unordered_set<struct TRI_vocbase_s*> _refetchUsers;
std::unordered_set<TRI_vocbase_t*> _refetchUsers;
////////////////////////////////////////////////////////////////////////////////
/// @brief this server's id

View File

@ -42,7 +42,7 @@
struct TRI_json_t;
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
@ -75,7 +75,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
ContinuousSyncer (struct TRI_server_s*,
struct TRI_vocbase_s*,
TRI_vocbase_t*,
struct TRI_replication_applier_configuration_s const*,
TRI_voc_tick_t,
bool);

View File

@ -31,7 +31,6 @@
#define ARANGODB_REPLICATION_INITIAL_SYNCER_H 1
#include "Basics/Common.h"
#include "Replication/Syncer.h"
// -----------------------------------------------------------------------------
@ -41,7 +40,7 @@
struct TRI_json_t;
struct TRI_replication_applier_configuration_s;
struct TRI_transaction_collection_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
@ -87,7 +86,7 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
InitialSyncer (struct TRI_vocbase_s*,
InitialSyncer (TRI_vocbase_t*,
struct TRI_replication_applier_configuration_s const*,
std::unordered_map<std::string, bool> const&,
std::string const&,

View File

@ -45,7 +45,7 @@
struct TRI_json_t;
struct TRI_replication_applier_configuration_s;
struct TRI_transaction_collection_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
struct TRI_vocbase_col_s;
namespace triagens {
@ -78,7 +78,7 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
Syncer (struct TRI_vocbase_s*,
Syncer (TRI_vocbase_t*,
struct TRI_replication_applier_configuration_s const*);
////////////////////////////////////////////////////////////////////////////////
@ -169,7 +169,7 @@ namespace triagens {
/// @brief vocbase base pointer
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief configuration

View File

@ -46,7 +46,7 @@
struct TRI_document_collection_t;
struct TRI_vocbase_col_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- class RestVocbaseBaseHandler
@ -404,7 +404,7 @@ namespace triagens {
/// @brief the vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
// -----------------------------------------------------------------------------
// --SECTION-- Handler methods

View File

@ -140,25 +140,25 @@ namespace triagens {
/// @brief runs in server mode
////////////////////////////////////////////////////////////////////////////////
int runServer (struct TRI_vocbase_s*);
int runServer (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief runs in console mode
////////////////////////////////////////////////////////////////////////////////
int runConsole (struct TRI_vocbase_s*);
int runConsole (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief runs unit tests
////////////////////////////////////////////////////////////////////////////////
int runUnitTests (struct TRI_vocbase_s*);
int runUnitTests (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief runs script
////////////////////////////////////////////////////////////////////////////////
int runScript (struct TRI_vocbase_s*);
int runScript (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief opens all system databases

View File

@ -35,7 +35,7 @@
#include "V8/V8LineEditor.h"
#include "V8Server/ApplicationV8.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace rest {
@ -76,7 +76,7 @@ namespace triagens {
ConsoleThread (triagens::rest::ApplicationServer*,
ApplicationV8*,
struct TRI_vocbase_s*);
TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
@ -144,7 +144,7 @@ namespace triagens {
ApplicationV8::V8Context* _context;
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
sig_atomic_t _done;

View File

@ -41,7 +41,7 @@
// -----------------------------------------------------------------------------
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- class VocbaseContext
@ -102,7 +102,7 @@ namespace triagens {
VocbaseContext (rest::HttpRequest*,
struct TRI_server_s*,
struct TRI_vocbase_s*);
TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
@ -120,7 +120,7 @@ namespace triagens {
/// @brief get vocbase of context
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* getVocbase () const {
TRI_vocbase_t* getVocbase () const {
return _vocbase;
}
@ -178,7 +178,7 @@ namespace triagens {
/// @brief the vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
};
}

View File

@ -35,7 +35,7 @@
#include "VocBase/voc-types.h"
struct TRI_document_collection_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -74,7 +74,7 @@ namespace triagens {
CollectionExport (CollectionExport const&) = delete;
CollectionExport& operator= (CollectionExport const&) = delete;
CollectionExport (TRI_vocbase_s*,
CollectionExport (TRI_vocbase_t*,
std::string const&,
Restrictions const&);

View File

@ -35,7 +35,7 @@
#include "VocBase/voc-types.h"
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -149,7 +149,7 @@ namespace triagens {
class JsonCursor : public Cursor {
public:
JsonCursor (struct TRI_vocbase_s*,
JsonCursor (TRI_vocbase_t*,
CursorId,
struct TRI_json_t*,
size_t,
@ -188,7 +188,7 @@ namespace triagens {
private:
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
struct TRI_json_t* _json;
size_t const _size;
bool _cached;
@ -201,7 +201,7 @@ namespace triagens {
class ExportCursor : public Cursor {
public:
ExportCursor (struct TRI_vocbase_s*,
ExportCursor (TRI_vocbase_t*,
CursorId,
triagens::arango::CollectionExport*,
size_t,
@ -230,7 +230,7 @@ namespace triagens {
private:
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
triagens::arango::CollectionExport* _ex;
size_t const _size;
};

View File

@ -36,7 +36,7 @@
#include "VocBase/voc-types.h"
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -59,7 +59,7 @@ namespace triagens {
/// @brief create a cursors repository
////////////////////////////////////////////////////////////////////////////////
explicit CursorRepository (struct TRI_vocbase_s*);
explicit CursorRepository (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy a cursors repository
@ -139,7 +139,7 @@ namespace triagens {
/// @brief vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief mutex for the cursors repository

View File

@ -34,7 +34,7 @@
#include "Basics/Exceptions.h"
#include "VocBase/server.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -106,7 +106,7 @@ namespace triagens {
/// @brief return the database pointer
////////////////////////////////////////////////////////////////////////////////
inline struct TRI_vocbase_s* database () const {
inline TRI_vocbase_t* database () const {
return _database;
}
@ -126,7 +126,7 @@ namespace triagens {
/// @brief pointer to database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _database;
TRI_vocbase_t* _database;
};
}

View File

@ -37,7 +37,7 @@
#include "VocBase/server.h"
#include "VocBase/transaction.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -58,7 +58,7 @@ namespace triagens {
/// @brief create the transaction
////////////////////////////////////////////////////////////////////////////////
ExplicitTransaction (struct TRI_vocbase_s* vocbase,
ExplicitTransaction (TRI_vocbase_t* vocbase,
std::vector<std::string> const& readCollections,
std::vector<std::string> const& writeCollections,
double lockTimeout,
@ -89,7 +89,7 @@ namespace triagens {
/// @brief create the transaction with cids
////////////////////////////////////////////////////////////////////////////////
ExplicitTransaction (struct TRI_vocbase_s* vocbase,
ExplicitTransaction (TRI_vocbase_t* vocbase,
std::vector<TRI_voc_cid_t> const& readCollections,
std::vector<TRI_voc_cid_t> const& writeCollections,
double lockTimeout,

View File

@ -37,7 +37,7 @@
#include "VocBase/server.h"
#include "VocBase/transaction.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -59,7 +59,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
ReplicationTransaction (TRI_server_t* server,
struct TRI_vocbase_s* vocbase,
TRI_vocbase_t* vocbase,
TRI_voc_tid_t externalId)
: Transaction(new StandaloneTransactionContext(), vocbase, externalId),
_server(server),

View File

@ -37,7 +37,7 @@
#include "VocBase/transaction.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -62,7 +62,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
SingleCollectionReadOnlyTransaction (TransactionContext* transactionContext,
struct TRI_vocbase_s* vocbase,
TRI_vocbase_t* vocbase,
TRI_voc_cid_t cid)
: SingleCollectionTransaction(transactionContext, vocbase, cid, TRI_TRANSACTION_READ) {
}
@ -72,7 +72,7 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
SingleCollectionReadOnlyTransaction (TransactionContext* transactionContext,
struct TRI_vocbase_s* vocbase,
TRI_vocbase_t* vocbase,
std::string const& name)
: SingleCollectionTransaction(transactionContext, vocbase, name, TRI_TRANSACTION_READ) {
}

View File

@ -44,7 +44,7 @@
// -----------------------------------------------------------------------------
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace aql {
@ -306,14 +306,14 @@ namespace triagens {
/// @brief sets the database
////////////////////////////////////////////////////////////////////////////////
void setVocbase (struct TRI_vocbase_s*);
void setVocbase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief enters an context
////////////////////////////////////////////////////////////////////////////////
V8Context* enterContext (std::string const& name,
TRI_vocbase_s*,
TRI_vocbase_t*,
bool useDatabase);
////////////////////////////////////////////////////////////////////////////////
@ -592,7 +592,7 @@ namespace triagens {
/// @brief system database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief number of instances to create

View File

@ -33,7 +33,7 @@
#include "Basics/json.h"
#include "Dispatcher/Job.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- class V8Job
@ -58,7 +58,7 @@ namespace triagens {
/// @brief constructs a new V8 job
////////////////////////////////////////////////////////////////////////////////
V8Job (struct TRI_vocbase_s*,
V8Job (TRI_vocbase_t*,
ApplicationV8*,
std::string const&,
TRI_json_t const*,
@ -130,7 +130,7 @@ namespace triagens {
/// @brief vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief V8 dealer

View File

@ -48,7 +48,7 @@ using namespace triagens::arango;
/// @brief constructs a new V8 job
////////////////////////////////////////////////////////////////////////////////
V8QueueJob::V8QueueJob (const string& queue,
V8QueueJob::V8QueueJob (std::string const& queue,
TRI_vocbase_t* vocbase,
ApplicationV8* v8Dealer,
TRI_json_t const* parameters)

View File

@ -31,7 +31,7 @@
#include "Dispatcher/Job.h"
#include "Basics/json.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- class V8Job
@ -56,8 +56,8 @@ namespace triagens {
/// @brief constructs a new V8 queue job
////////////////////////////////////////////////////////////////////////////////
V8QueueJob (const std::string& queue,
struct TRI_vocbase_s*,
V8QueueJob (std::string const& queue,
TRI_vocbase_t*,
ApplicationV8*,
const TRI_json_t*);
@ -131,7 +131,7 @@ namespace triagens {
/// @brief vocbase
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief V8 dealer

View File

@ -34,7 +34,7 @@
#include "V8/v8-globals.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- public functions
@ -44,13 +44,13 @@ struct TRI_vocbase_s;
/// @brief creates the user structures for a database
////////////////////////////////////////////////////////////////////////////////
void TRI_CreateUserStructuresVocBase (struct TRI_vocbase_s*);
void TRI_CreateUserStructuresVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys the user structures for a database
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeUserStructuresVocBase (struct TRI_vocbase_s*);
void TRI_FreeUserStructuresVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates the user structures functions

View File

@ -37,7 +37,7 @@
#include "VocBase/document-collection.h"
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace aql {
@ -102,7 +102,7 @@ void TRI_InitV8VocBridge (v8::Isolate* isolate,
v8::Handle<v8::Context>,
triagens::aql::QueryRegistry*,
struct TRI_server_s*,
struct TRI_vocbase_s*,
TRI_vocbase_t*,
triagens::arango::JSLoader*,
size_t);

View File

@ -37,7 +37,7 @@
// -----------------------------------------------------------------------------
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- public types
@ -76,31 +76,31 @@ TRI_vocbase_auth_cache_t;
/// @brief initialises the authentication info
////////////////////////////////////////////////////////////////////////////////
int TRI_InitAuthInfo (struct TRI_vocbase_s*);
int TRI_InitAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys the authentication info
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroyAuthInfo (struct TRI_vocbase_s*);
void TRI_DestroyAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief insert initial authentication info
////////////////////////////////////////////////////////////////////////////////
bool TRI_InsertInitialAuthInfo (struct TRI_vocbase_s*);
bool TRI_InsertInitialAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief loads the authentication info
////////////////////////////////////////////////////////////////////////////////
bool TRI_LoadAuthInfo (struct TRI_vocbase_s*);
bool TRI_LoadAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief populate the authentication info cache
////////////////////////////////////////////////////////////////////////////////
bool TRI_PopulateAuthInfo (struct TRI_vocbase_s*,
bool TRI_PopulateAuthInfo (TRI_vocbase_t*,
struct TRI_json_t const*);
////////////////////////////////////////////////////////////////////////////////
@ -108,19 +108,19 @@ bool TRI_PopulateAuthInfo (struct TRI_vocbase_s*,
/// this must be executed after the underlying _users collection is modified
////////////////////////////////////////////////////////////////////////////////
bool TRI_ReloadAuthInfo (struct TRI_vocbase_s*);
bool TRI_ReloadAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief clears the authentication info
////////////////////////////////////////////////////////////////////////////////
void TRI_ClearAuthInfo (struct TRI_vocbase_s*);
void TRI_ClearAuthInfo (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief looks up authentication data in the cache
////////////////////////////////////////////////////////////////////////////////
char* TRI_CheckCacheAuthInfo (struct TRI_vocbase_s*,
char* TRI_CheckCacheAuthInfo (TRI_vocbase_t*,
char const* hash,
bool* mustChange);
@ -128,14 +128,14 @@ char* TRI_CheckCacheAuthInfo (struct TRI_vocbase_s*,
/// @brief checks the authentication - note: only checks whether the user exists
////////////////////////////////////////////////////////////////////////////////
bool TRI_ExistsAuthenticationAuthInfo (struct TRI_vocbase_s*,
bool TRI_ExistsAuthenticationAuthInfo (TRI_vocbase_t*,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief checks the authentication
////////////////////////////////////////////////////////////////////////////////
bool TRI_CheckAuthenticationAuthInfo (struct TRI_vocbase_s*,
bool TRI_CheckAuthenticationAuthInfo (TRI_vocbase_t*,
char const* hash,
char const* username,
char const* password,

View File

@ -34,7 +34,7 @@
#include "VocBase/voc-types.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- public functions
@ -44,25 +44,25 @@ struct TRI_vocbase_s;
/// @brief initialise the compaction blockers structure
////////////////////////////////////////////////////////////////////////////////
int TRI_InitCompactorVocBase (struct TRI_vocbase_s*);
int TRI_InitCompactorVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy the compaction blockers structure
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroyCompactorVocBase (struct TRI_vocbase_s*);
void TRI_DestroyCompactorVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief remove data of expired compaction blockers
////////////////////////////////////////////////////////////////////////////////
bool TRI_CleanupCompactorVocBase (struct TRI_vocbase_s*);
bool TRI_CleanupCompactorVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief insert a compaction blocker
////////////////////////////////////////////////////////////////////////////////
int TRI_InsertBlockerCompactorVocBase (struct TRI_vocbase_s*,
int TRI_InsertBlockerCompactorVocBase (TRI_vocbase_t*,
double,
TRI_voc_tick_t*);
@ -70,7 +70,7 @@ int TRI_InsertBlockerCompactorVocBase (struct TRI_vocbase_s*,
/// @brief touch an existing compaction blocker
////////////////////////////////////////////////////////////////////////////////
int TRI_TouchBlockerCompactorVocBase (struct TRI_vocbase_s*,
int TRI_TouchBlockerCompactorVocBase (TRI_vocbase_t*,
TRI_voc_tick_t,
double);
@ -78,7 +78,7 @@ int TRI_TouchBlockerCompactorVocBase (struct TRI_vocbase_s*,
/// @brief remove an existing compaction blocker
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveBlockerCompactorVocBase (struct TRI_vocbase_s*,
int TRI_RemoveBlockerCompactorVocBase (TRI_vocbase_t*,
TRI_voc_tick_t);
////////////////////////////////////////////////////////////////////////////////
@ -87,13 +87,13 @@ int TRI_RemoveBlockerCompactorVocBase (struct TRI_vocbase_s*,
/// acquired, which must eventually be freed by the caller
////////////////////////////////////////////////////////////////////////////////
bool TRI_CheckAndLockCompactorVocBase (struct TRI_vocbase_s*);
bool TRI_CheckAndLockCompactorVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief unlock the compactor
////////////////////////////////////////////////////////////////////////////////
void TRI_UnlockCompactorVocBase (struct TRI_vocbase_s*);
void TRI_UnlockCompactorVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief compactor event loop

View File

@ -43,7 +43,7 @@
struct TRI_json_t;
struct TRI_server_s;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- REPLICATION APPLIER
@ -159,7 +159,7 @@ struct TRI_replication_applier_t {
}
struct TRI_server_s* _server;
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
TRI_read_write_lock_t _statusLock;
TRI_spin_t _threadLock;
TRI_condition_t _runStateChangeCondition;
@ -180,7 +180,7 @@ struct TRI_replication_applier_t {
////////////////////////////////////////////////////////////////////////////////
TRI_replication_applier_t* TRI_CreateReplicationApplier (struct TRI_server_s*,
struct TRI_vocbase_s*);
TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy a replication applier
@ -284,7 +284,7 @@ void TRI_DestroyStateReplicationApplier (TRI_replication_applier_state_t*);
/// @brief save the replication application state to a file
////////////////////////////////////////////////////////////////////////////////
int TRI_SaveStateReplicationApplier (struct TRI_vocbase_s*,
int TRI_SaveStateReplicationApplier (TRI_vocbase_t*,
TRI_replication_applier_state_t const*,
bool);
@ -292,13 +292,13 @@ int TRI_SaveStateReplicationApplier (struct TRI_vocbase_s*,
/// @brief remove the replication application state file
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveStateReplicationApplier (struct TRI_vocbase_s*);
int TRI_RemoveStateReplicationApplier (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief load the replication application state from a file
////////////////////////////////////////////////////////////////////////////////
int TRI_LoadStateReplicationApplier (struct TRI_vocbase_s*,
int TRI_LoadStateReplicationApplier (TRI_vocbase_t*,
TRI_replication_applier_state_t*);
////////////////////////////////////////////////////////////////////////////////
@ -324,13 +324,13 @@ void TRI_CopyConfigurationReplicationApplier (TRI_replication_applier_configurat
/// @brief remove the replication application configuration file
////////////////////////////////////////////////////////////////////////////////
int TRI_RemoveConfigurationReplicationApplier (struct TRI_vocbase_s*);
int TRI_RemoveConfigurationReplicationApplier (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief save the replication application configuration to a file
////////////////////////////////////////////////////////////////////////////////
int TRI_SaveConfigurationReplicationApplier (struct TRI_vocbase_s*,
int TRI_SaveConfigurationReplicationApplier (TRI_vocbase_t*,
TRI_replication_applier_configuration_t const*,
bool);

View File

@ -38,16 +38,17 @@
#include "Aql/QueryCache.h"
#include "Aql/QueryRegistry.h"
#include "Basics/conversions.h"
#include "Basics/Exceptions.h"
#include "Basics/files.h"
#include "Basics/hashes.h"
#include "Basics/json.h"
#include "Basics/JsonHelper.h"
#include "Basics/locks.h"
#include "Basics/logging.h"
#include "Basics/memory-map.h"
#include "Basics/MutexLocker.h"
#include "Basics/random.h"
#include "Basics/tri-strings.h"
#include "Basics/JsonHelper.h"
#include "Basics/Exceptions.h"
#include "Cluster/ServerState.h"
#include "Utils/CursorRepository.h"
#include "VocBase/auth.h"
@ -126,6 +127,18 @@ class DatabaseWriteLocker {
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief lock for serializing the creation of database
////////////////////////////////////////////////////////////////////////////////
static triagens::basics::Mutex DatabaseCreateLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief variable protecting the server shutdown
////////////////////////////////////////////////////////////////////////////////
static std::atomic<bool> ServerShutdown;
////////////////////////////////////////////////////////////////////////////////
/// @brief server operation mode (e.g. read-only, normal etc).
////////////////////////////////////////////////////////////////////////////////
@ -842,7 +855,8 @@ static int CloseDatabases (TRI_server_t* server) {
TRI_ASSERT(vocbase->_type == TRI_VOCBASE_TYPE_NORMAL);
TRI_DestroyVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
delete vocbase;
// clear to avoid potential double freeing
server->_databases._table[i] = nullptr;
@ -857,8 +871,7 @@ static int CloseDatabases (TRI_server_t* server) {
if (vocbase != nullptr) {
TRI_ASSERT(vocbase->_type == TRI_VOCBASE_TYPE_COORDINATOR);
TRI_DestroyInitialVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
delete vocbase;
// clear to avoid potential double freeing
server->_coordinatorDatabases._table[i] = nullptr;
@ -883,14 +896,13 @@ static int CloseDroppedDatabases (TRI_server_t* server) {
if (vocbase != nullptr) {
if (vocbase->_type == TRI_VOCBASE_TYPE_NORMAL) {
TRI_DestroyVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
delete vocbase;
// clear to avoid potential double freeing
server->_droppedDatabases._buffer[i] = nullptr;
}
else if (vocbase->_type == TRI_VOCBASE_TYPE_COORDINATOR) {
TRI_DestroyInitialVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
delete vocbase;
// clear to avoid potential double freeing
server->_droppedDatabases._buffer[i] = nullptr;
}
@ -1578,9 +1590,7 @@ static void DatabaseManager (void* data) {
int cleanupCycles = 0;
while (true) {
TRI_LockMutex(&server->_createLock);
bool shutdown = server->_shutdown;
TRI_UnlockMutex(&server->_createLock);
bool shutdown = ServerShutdown.load(std::memory_order_relaxed);
// check if we have to drop some database
TRI_vocbase_t* database = nullptr;
@ -1604,13 +1614,7 @@ static void DatabaseManager (void* data) {
}
if (database != nullptr) {
if (database->_type == TRI_VOCBASE_TYPE_COORDINATOR) {
// coordinator database
// ---------------------------
TRI_DestroyInitialVocBase(database);
}
else {
if (database->_type != TRI_VOCBASE_TYPE_COORDINATOR) {
// regular database
// ---------------------------
@ -1647,9 +1651,9 @@ static void DatabaseManager (void* data) {
TRI_RemoveDirectory(path);
TRI_FreeString(TRI_CORE_MEM_ZONE, path);
}
TRI_Free(TRI_UNKNOWN_MEM_ZONE, database);
}
delete database;
// directly start next iteration
}
@ -1811,8 +1815,6 @@ int TRI_InitServer (TRI_server_t* server,
TRI_InitVectorPointer(&server->_droppedDatabases, TRI_UNKNOWN_MEM_ZONE, 64);
TRI_InitMutex(&server->_createLock);
server->_disableReplicationAppliers = disableAppliers;
server->_queryRegistry = nullptr; // will be filled in later
@ -1830,7 +1832,6 @@ void TRI_DestroyServer (TRI_server_t* server) {
if (server->_initialised) {
CloseDatabases(server);
TRI_DestroyMutex(&server->_createLock);
TRI_DestroyVectorPointer(&server->_droppedDatabases);
TRI_DestroyReadWriteLock(&server->_databasesLock);
TRI_DestroyAssociativePointer(&server->_coordinatorDatabases);
@ -2064,12 +2065,6 @@ int TRI_StartServer (TRI_server_t* server,
return res;
}
// we don't yet need the lock here as this is called during startup and no races
// are possible. however, this may be changed in the future
TRI_LockMutex(&server->_createLock);
server->_shutdown = false;
TRI_UnlockMutex(&server->_createLock);
// start dbm thread
TRI_InitThread(&server->_databaseManager);
TRI_StartThread(&server->_databaseManager, nullptr, "[databases]", DatabaseManager, server);
@ -2128,9 +2123,7 @@ int TRI_InitDatabasesServer (TRI_server_t* server) {
int TRI_StopServer (TRI_server_t* server) {
// set shutdown flag
TRI_LockMutex(&server->_createLock);
server->_shutdown = true;
TRI_UnlockMutex(&server->_createLock);
ServerShutdown.store(true);
// stop dbm thread
int res = TRI_JoinThread(&server->_databaseManager);
@ -2163,7 +2156,7 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
return TRI_ERROR_ARANGO_DATABASE_NAME_INVALID;
}
TRI_LockMutex(&server->_createLock);
MUTEX_LOCKER(DatabaseCreateLock);
{
DatabaseReadLocker locker(&server->_databasesLock);
@ -2172,8 +2165,6 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
if (vocbase != nullptr) {
// name already in use
TRI_UnlockMutex(&server->_createLock);
return TRI_ERROR_ARANGO_DUPLICATE_NAME;
}
}
@ -2183,8 +2174,6 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
TRI_vocbase_t* vocbase = TRI_CreateInitialVocBase(server, TRI_VOCBASE_TYPE_COORDINATOR, "none", tick, name, defaults);
if (vocbase == nullptr) {
TRI_UnlockMutex(&server->_createLock);
// grab last error
int res = TRI_errno();
@ -2205,9 +2194,7 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
vocbase->_replicationApplier = TRI_CreateReplicationApplier(server, vocbase);
if (vocbase->_replicationApplier == nullptr) {
TRI_DestroyInitialVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
TRI_UnlockMutex(&server->_createLock);
delete vocbase;
return TRI_ERROR_OUT_OF_MEMORY;
}
@ -2228,8 +2215,6 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t* server,
}
}
TRI_UnlockMutex(&server->_createLock);
*database = vocbase;
return TRI_ERROR_NO_ERROR;
@ -2250,124 +2235,124 @@ int TRI_CreateDatabaseServer (TRI_server_t* server,
return TRI_ERROR_ARANGO_DATABASE_NAME_INVALID;
}
TRI_vocbase_t* vocbase = nullptr;
TRI_json_t* json = nullptr;
int res;
// the create lock makes sure no one else is creating a database while we're inside
// this function
TRI_LockMutex(&server->_createLock);
MUTEX_LOCKER(DatabaseCreateLock);
{
DatabaseReadLocker locker(&server->_databasesLock);
TRI_vocbase_t* vocbase = static_cast<TRI_vocbase_t*>(TRI_LookupByKeyAssociativePointer(&server->_databases, name));
{
DatabaseReadLocker locker(&server->_databasesLock);
if (vocbase != nullptr) {
// name already in use
TRI_UnlockMutex(&server->_createLock);
vocbase = static_cast<TRI_vocbase_t*>(TRI_LookupByKeyAssociativePointer(&server->_databases, name));
return TRI_ERROR_ARANGO_DUPLICATE_NAME;
if (vocbase != nullptr) {
// name already in use
return TRI_ERROR_ARANGO_DUPLICATE_NAME;
}
}
}
// name not yet in use
TRI_json_t* json = TRI_JsonVocBaseDefaults(TRI_UNKNOWN_MEM_ZONE, defaults);
// name not yet in use
json = TRI_JsonVocBaseDefaults(TRI_UNKNOWN_MEM_ZONE, defaults);
if (json == nullptr) {
TRI_UnlockMutex(&server->_createLock);
return TRI_ERROR_OUT_OF_MEMORY;
}
if (json == nullptr) {
return TRI_ERROR_OUT_OF_MEMORY;
}
// create the database directory
char* file;
// create the database directory
char* file;
if (databaseId == 0) {
databaseId = TRI_NewTickServer();
}
if (databaseId == 0) {
databaseId = TRI_NewTickServer();
}
int res = CreateDatabaseDirectory(server, databaseId, name, defaults, &file);
if (res != TRI_ERROR_NO_ERROR) {
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
TRI_UnlockMutex(&server->_createLock);
return res;
}
char* path = TRI_Concatenate2File(server->_databasePath, file);
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
if (triagens::wal::LogfileManager::instance()->isInRecovery()) {
LOG_TRACE("creating database '%s', directory '%s'",
name,
path);
}
else {
LOG_INFO("creating database '%s', directory '%s'",
name,
path);
}
TRI_vocbase_t* vocbase = TRI_OpenVocBase(server, path, databaseId, name, defaults, false, false);
TRI_FreeString(TRI_CORE_MEM_ZONE, path);
if (vocbase == nullptr) {
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
TRI_UnlockMutex(&server->_createLock);
// grab last error
res = TRI_errno();
res = CreateDatabaseDirectory(server, databaseId, name, defaults, &file);
if (res != TRI_ERROR_NO_ERROR) {
// but we must have an error...
res = TRI_ERROR_INTERNAL;
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
return res;
}
LOG_ERROR("could not create database '%s': %s",
char* path = TRI_Concatenate2File(server->_databasePath, file);
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
if (triagens::wal::LogfileManager::instance()->isInRecovery()) {
LOG_TRACE("creating database '%s', directory '%s'",
name,
path);
}
else {
LOG_INFO("creating database '%s', directory '%s'",
name,
TRI_errno_string(res));
path);
}
return res;
}
vocbase = TRI_OpenVocBase(server, path, databaseId, name, defaults, false, false);
TRI_FreeString(TRI_CORE_MEM_ZONE, path);
TRI_ASSERT(vocbase != nullptr);
char* tickString = TRI_StringUInt64(databaseId);
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, json, "id", TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, tickString, strlen(tickString)));
TRI_FreeString(TRI_CORE_MEM_ZONE, tickString);
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, json, "name", TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, name, strlen(name)));
if (vocbase == nullptr) {
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
// grab last error
res = TRI_errno();
// create application directories
CreateApplicationDirectory(vocbase->_name, server->_appPath);
if (! triagens::wal::LogfileManager::instance()->isInRecovery()) {
TRI_ReloadAuthInfo(vocbase);
TRI_StartCompactorVocBase(vocbase);
// start the replication applier
if (vocbase->_replicationApplier->_configuration._autoStart) {
if (server->_disableReplicationAppliers) {
LOG_INFO("replication applier explicitly deactivated for database '%s'", name);
if (res != TRI_ERROR_NO_ERROR) {
// but we must have an error...
res = TRI_ERROR_INTERNAL;
}
else {
res = TRI_StartReplicationApplier(vocbase->_replicationApplier, 0, false);
if (res != TRI_ERROR_NO_ERROR) {
LOG_WARNING("unable to start replication applier for database '%s': %s",
name,
TRI_errno_string(res));
LOG_ERROR("could not create database '%s': %s",
name,
TRI_errno_string(res));
return res;
}
TRI_ASSERT(vocbase != nullptr);
char* tickString = TRI_StringUInt64(databaseId);
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, json, "id", TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, tickString, strlen(tickString)));
TRI_FreeString(TRI_CORE_MEM_ZONE, tickString);
TRI_Insert3ObjectJson(TRI_UNKNOWN_MEM_ZONE, json, "name", TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, name, strlen(name)));
// create application directories
CreateApplicationDirectory(vocbase->_name, server->_appPath);
if (! triagens::wal::LogfileManager::instance()->isInRecovery()) {
TRI_ReloadAuthInfo(vocbase);
TRI_StartCompactorVocBase(vocbase);
// start the replication applier
if (vocbase->_replicationApplier->_configuration._autoStart) {
if (server->_disableReplicationAppliers) {
LOG_INFO("replication applier explicitly deactivated for database '%s'", name);
}
else {
res = TRI_StartReplicationApplier(vocbase->_replicationApplier, 0, false);
if (res != TRI_ERROR_NO_ERROR) {
LOG_WARNING("unable to start replication applier for database '%s': %s",
name,
TRI_errno_string(res));
}
}
}
// increase reference counter
TRI_UseVocBase(vocbase);
}
// increase reference counter
TRI_UseVocBase(vocbase);
}
{
DatabaseWriteLocker locker(&server->_databasesLock);
TRI_InsertKeyAssociativePointer(&server->_databases, vocbase->_name, vocbase, false);
}
{
DatabaseWriteLocker locker(&server->_databasesLock);
TRI_InsertKeyAssociativePointer(&server->_databases, vocbase->_name, vocbase, false);
}
TRI_UnlockMutex(&server->_createLock);
} // release DatabaseCreateLock
// write marker into log
if (writeMarker) {

View File

@ -38,7 +38,7 @@
#include "VocBase/voc-types.h"
#include "VocBase/vocbase-defaults.h"
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- public types
@ -53,10 +53,8 @@ typedef struct TRI_server_s {
TRI_associative_pointer_t _coordinatorDatabases;
TRI_read_write_lock_t _databasesLock;
TRI_mutex_t _createLock;
TRI_thread_t _databaseManager;
TRI_vector_pointer_t _droppedDatabases;
bool _shutdown;
TRI_vocbase_defaults_t _defaults;
void* _applicationEndpointServer; // ptr to C++ object
@ -175,7 +173,7 @@ int TRI_CreateCoordinatorDatabaseServer (TRI_server_t*,
TRI_voc_tick_t,
char const*,
TRI_vocbase_defaults_t const*,
struct TRI_vocbase_s**);
TRI_vocbase_t**);
////////////////////////////////////////////////////////////////////////////////
/// @brief create a new database
@ -185,7 +183,7 @@ int TRI_CreateDatabaseServer (TRI_server_t*,
TRI_voc_tick_t,
char const*,
TRI_vocbase_defaults_t const*,
struct TRI_vocbase_s**,
TRI_vocbase_t**,
bool);
////////////////////////////////////////////////////////////////////////////////
@ -233,46 +231,46 @@ int TRI_DropByIdDatabaseServer (TRI_server_t*,
/// this will increase the reference-counter for the database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_UseByIdCoordinatorDatabaseServer (TRI_server_t*,
TRI_voc_tick_t);
TRI_vocbase_t* TRI_UseByIdCoordinatorDatabaseServer (TRI_server_t*,
TRI_voc_tick_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief use a coordinator database by its name
/// this will increase the reference-counter for the database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_UseCoordinatorDatabaseServer (TRI_server_t*,
char const*);
TRI_vocbase_t* TRI_UseCoordinatorDatabaseServer (TRI_server_t*,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief use a database by its name
/// this will increase the reference-counter for the database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_UseDatabaseServer (TRI_server_t*,
char const*);
TRI_vocbase_t* TRI_UseDatabaseServer (TRI_server_t*,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookup a database by its id
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_LookupDatabaseByIdServer (TRI_server_t*,
TRI_voc_tick_t);
TRI_vocbase_t* TRI_LookupDatabaseByIdServer (TRI_server_t*,
TRI_voc_tick_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief lookup a database by its name
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_LookupDatabaseByNameServer (TRI_server_t*,
char const*);
TRI_vocbase_t* TRI_LookupDatabaseByNameServer (TRI_server_t*,
char const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief use a database by its id
/// this will increase the reference-counter for the database
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* TRI_UseDatabaseByIdServer (TRI_server_t*,
TRI_voc_tick_t);
TRI_vocbase_t* TRI_UseDatabaseByIdServer (TRI_server_t*,
TRI_voc_tick_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief release a previously used database
@ -280,7 +278,7 @@ struct TRI_vocbase_s* TRI_UseDatabaseByIdServer (TRI_server_t*,
////////////////////////////////////////////////////////////////////////////////
void TRI_ReleaseDatabaseServer (TRI_server_t*,
struct TRI_vocbase_s*);
TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief checks whether a database exists

View File

@ -52,7 +52,7 @@ namespace triagens {
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
struct TRI_vocbase_s;
struct TRI_vocbase_t;
struct TRI_vocbase_col_s;
// -----------------------------------------------------------------------------
@ -143,7 +143,7 @@ TRI_transaction_hint_e;
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_transaction_s {
struct TRI_vocbase_s* _vocbase; // vocbase
TRI_vocbase_t* _vocbase; // vocbase
TRI_voc_tid_t _id; // local trx id
TRI_voc_tid_t _externalId; // external trx id (used in replication)
TRI_transaction_type_e _type; // access type (read|write)
@ -185,7 +185,7 @@ TRI_transaction_collection_t;
/// @brief create a new transaction
////////////////////////////////////////////////////////////////////////////////
TRI_transaction_t* TRI_CreateTransaction (struct TRI_vocbase_s*,
TRI_transaction_t* TRI_CreateTransaction (TRI_vocbase_t*,
TRI_voc_tid_t,
double,
bool);

View File

@ -34,7 +34,7 @@
#include "VocBase/voc-types.h"
struct TRI_json_t;
struct TRI_vocbase_s;
struct TRI_vocbase_t;
// -----------------------------------------------------------------------------
// --SECTION-- public types
@ -62,7 +62,7 @@ TRI_vocbase_defaults_t;
/// @brief apply default settings
////////////////////////////////////////////////////////////////////////////////
void TRI_ApplyVocBaseDefaults (struct TRI_vocbase_s*,
void TRI_ApplyVocBaseDefaults (TRI_vocbase_t*,
TRI_vocbase_defaults_t const*);
////////////////////////////////////////////////////////////////////////////////

View File

@ -1360,133 +1360,16 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_server_t* server,
TRI_voc_tick_t id,
char const* name,
TRI_vocbase_defaults_t const* defaults) {
TRI_vocbase_t* vocbase = static_cast<TRI_vocbase_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vocbase_t), false));
if (vocbase == nullptr) {
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
return nullptr;
}
vocbase->_server = server;
vocbase->_type = type;
vocbase->_id = id;
vocbase->_path = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, path);
vocbase->_name = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, name);
vocbase->_authInfoLoaded = false;
vocbase->_hasCompactor = false;
vocbase->_isOwnAppsDirectory = true;
vocbase->_replicationApplier = nullptr;
vocbase->_userStructures = nullptr;
vocbase->_cursorRepository = nullptr;
vocbase->_queries = nullptr;
vocbase->_oldTransactions = nullptr;
try {
vocbase->_queries = new triagens::aql::QueryList(vocbase);
std::unique_ptr<TRI_vocbase_t> vocbase(new TRI_vocbase_t(server, type, path, id, name, defaults));
return vocbase.release();
}
catch (...) {
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_name);
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_path);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
return nullptr;
}
try {
vocbase->_cursorRepository = new triagens::arango::CursorRepository(vocbase);
}
catch (...) {
delete static_cast<triagens::aql::QueryList*>(vocbase->_queries);
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_name);
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_path);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
return nullptr;
}
// use the defaults provided
TRI_ApplyVocBaseDefaults(vocbase, defaults);
// init usage info
TRI_InitSpin(&vocbase->_usage._lock);
vocbase->_usage._refCount = 0;
vocbase->_usage._isDeleted = false;
// init collections
TRI_InitVectorPointer(&vocbase->_collections, TRI_UNKNOWN_MEM_ZONE);
TRI_InitVectorPointer(&vocbase->_deadCollections, TRI_UNKNOWN_MEM_ZONE);
TRI_InitAssociativePointer(&vocbase->_collectionsById,
TRI_UNKNOWN_MEM_ZONE,
HashKeyCid,
HashElementCid,
EqualKeyCid,
nullptr);
TRI_InitAssociativePointer(&vocbase->_collectionsByName,
TRI_UNKNOWN_MEM_ZONE,
HashKeyCollectionName,
HashElementCollectionName,
EqualKeyCollectionName,
nullptr);
TRI_InitAuthInfo(vocbase);
TRI_InitReadWriteLock(&vocbase->_inventoryLock);
TRI_InitReadWriteLock(&vocbase->_lock);
TRI_InitCondition(&vocbase->_compactorCondition);
TRI_InitCondition(&vocbase->_cleanupCondition);
TRI_CreateUserStructuresVocBase(vocbase);
return vocbase;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy the central parts of a vocbase
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroyInitialVocBase (TRI_vocbase_t* vocbase) {
if (vocbase->_userStructures != nullptr) {
TRI_FreeUserStructuresVocBase(vocbase);
}
// free replication
if (vocbase->_replicationApplier != nullptr) {
TRI_FreeReplicationApplier(vocbase->_replicationApplier);
vocbase->_replicationApplier = nullptr;
}
if (vocbase->_oldTransactions == nullptr) {
delete vocbase->_oldTransactions;
}
TRI_DestroyCondition(&vocbase->_cleanupCondition);
TRI_DestroyCondition(&vocbase->_compactorCondition);
TRI_DestroyReadWriteLock(&vocbase->_lock);
TRI_DestroyReadWriteLock(&vocbase->_inventoryLock);
TRI_DestroyAuthInfo(vocbase);
TRI_DestroyAssociativePointer(&vocbase->_collectionsByName);
TRI_DestroyAssociativePointer(&vocbase->_collectionsById);
TRI_DestroyVectorPointer(&vocbase->_collections);
TRI_DestroyVectorPointer(&vocbase->_deadCollections);
delete static_cast<triagens::arango::CursorRepository*>(vocbase->_cursorRepository);
delete static_cast<triagens::aql::QueryList*>(vocbase->_queries);
TRI_DestroySpin(&vocbase->_usage._lock);
// free name and path
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_path);
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_name);
}
////////////////////////////////////////////////////////////////////////////////
@ -1524,8 +1407,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
if (res != TRI_ERROR_NO_ERROR) {
TRI_DestroyCompactorVocBase(vocbase);
TRI_DestroyInitialVocBase(vocbase);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
delete vocbase;
TRI_set_errno(res);
return nullptr;
@ -1637,7 +1519,6 @@ void TRI_DestroyVocBase (TRI_vocbase_t* vocbase) {
}
TRI_DestroyCompactorVocBase(vocbase);
TRI_DestroyInitialVocBase(vocbase);
}
////////////////////////////////////////////////////////////////////////////////
@ -2536,6 +2417,121 @@ TRI_voc_tick_t TRI_NextQueryIdVocBase (TRI_vocbase_t* vocbase) {
return QueryId.fetch_add(1, std::memory_order_seq_cst);
}
// -----------------------------------------------------------------------------
// --SECTION-- TRI_vocbase_t
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief create a vocbase object
////////////////////////////////////////////////////////////////////////////////
TRI_vocbase_t::TRI_vocbase_t (TRI_server_t* server,
TRI_vocbase_type_e type,
char const* path,
TRI_voc_tick_t id,
char const* name,
TRI_vocbase_defaults_t const* defaults)
: _id(id),
_path(nullptr),
_name(nullptr),
_type(type),
_server(server),
_userStructures(nullptr),
_queries(nullptr),
_cursorRepository(nullptr),
_authInfoLoaded(false),
_hasCompactor(false),
_isOwnAppsDirectory(true),
_oldTransactions(nullptr),
_replicationApplier(nullptr) {
_queries = new triagens::aql::QueryList(this);
_cursorRepository = new triagens::arango::CursorRepository(this);
_path = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, path);
_name = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, name);
// init usage info
TRI_InitSpin(&_usage._lock);
_usage._refCount = 0;
_usage._isDeleted = false;
// use the defaults provided
TRI_ApplyVocBaseDefaults(this, defaults);
// init collections
TRI_InitVectorPointer(&_collections, TRI_UNKNOWN_MEM_ZONE);
TRI_InitVectorPointer(&_deadCollections, TRI_UNKNOWN_MEM_ZONE);
TRI_InitAssociativePointer(&_collectionsById,
TRI_UNKNOWN_MEM_ZONE,
HashKeyCid,
HashElementCid,
EqualKeyCid,
nullptr);
TRI_InitAssociativePointer(&_collectionsByName,
TRI_UNKNOWN_MEM_ZONE,
HashKeyCollectionName,
HashElementCollectionName,
EqualKeyCollectionName,
nullptr);
TRI_InitAuthInfo(this);
TRI_InitReadWriteLock(&_inventoryLock);
TRI_InitReadWriteLock(&_lock);
TRI_CreateUserStructuresVocBase(this);
TRI_InitCondition(&_compactorCondition);
TRI_InitCondition(&_cleanupCondition);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destroy a vocbase object
////////////////////////////////////////////////////////////////////////////////
TRI_vocbase_t::~TRI_vocbase_t () {
if (_userStructures != nullptr) {
TRI_FreeUserStructuresVocBase(this);
}
// free replication
if (_replicationApplier != nullptr) {
TRI_FreeReplicationApplier(_replicationApplier);
}
delete _oldTransactions;
TRI_DestroyCondition(&_cleanupCondition);
TRI_DestroyCondition(&_compactorCondition);
TRI_DestroyReadWriteLock(&_lock);
TRI_DestroyReadWriteLock(&_inventoryLock);
TRI_DestroyAuthInfo(this);
TRI_DestroyAssociativePointer(&_collectionsByName);
TRI_DestroyAssociativePointer(&_collectionsById);
TRI_DestroyVectorPointer(&_collections);
TRI_DestroyVectorPointer(&_deadCollections);
delete static_cast<triagens::arango::CursorRepository*>(_cursorRepository);
delete static_cast<triagens::aql::QueryList*>(_queries);
TRI_DestroySpin(&_usage._lock);
// free name and path
if (_path != nullptr) {
TRI_Free(TRI_CORE_MEM_ZONE, _path);
}
if (_name != nullptr) {
TRI_Free(TRI_CORE_MEM_ZONE, _name);
}
}
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -286,7 +286,16 @@ TRI_vocbase_type_e;
/// For the lock handling, see the document "LOCKS.md".
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_vocbase_s {
struct TRI_vocbase_t {
TRI_vocbase_t (struct TRI_server_s*,
TRI_vocbase_type_e,
char const*,
TRI_voc_tick_t,
char const*,
struct TRI_vocbase_defaults_s const*);
~TRI_vocbase_t ();
TRI_voc_tick_t _id; // internal database id
char* _path; // path to the data directory
char* _name; // database name
@ -346,8 +355,7 @@ typedef struct TRI_vocbase_s {
TRI_condition_t _compactorCondition;
TRI_condition_t _cleanupCondition;
}
TRI_vocbase_t;
};
////////////////////////////////////////////////////////////////////////////////
/// @brief status of a collection
@ -426,12 +434,6 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (struct TRI_server_s*,
char const*,
struct TRI_vocbase_defaults_s const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys an initial, not fully constructed vocbase
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroyInitialVocBase (TRI_vocbase_t*);
////////////////////////////////////////////////////////////////////////////////
/// @brief opens an existing database, loads all collections
////////////////////////////////////////////////////////////////////////////////

View File

@ -38,7 +38,7 @@
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
struct TRI_vocbase_s;
struct TRI_vocbase_t;
namespace triagens {
namespace arango {
@ -1068,7 +1068,7 @@ typedef struct TRI_v8_global_s {
/// @brief pointer to the vocbase (TRI_vocbase_t*)
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
TRI_vocbase_t* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief number of v8 externals used in the context