1
0
Fork 0

merged experimental features

This commit is contained in:
Jan Steemann 2014-09-24 09:42:16 +02:00
parent c8efcda671
commit ddfb5c965d
9 changed files with 1876 additions and 14 deletions

View File

@ -135,16 +135,17 @@ add_executable(
V8Server/V8QueueJob.cpp
V8Server/V8TimerTask.cpp
V8Server/v8-actions.cpp
V8Server/v8-dispatcher.cpp
V8Server/v8-query.cpp
V8Server/v8-vocbase.cpp
V8Server/v8-wrapshapedjson.cpp
V8Server/v8-vocindex.cpp
V8Server/v8-voccursor.cpp
V8Server/v8-replication.cpp
V8Server/v8-collection.cpp
V8Server/v8-collection-util.cpp
V8Server/v8-dispatcher.cpp
V8Server/v8-query.cpp
V8Server/v8-replication.cpp
V8Server/v8-user-structures.cpp
V8Server/v8-util.cpp
V8Server/v8-vocbase.cpp
V8Server/v8-voccursor.cpp
V8Server/v8-vocindex.cpp
V8Server/v8-wrapshapedjson.cpp
VocBase/auth.cpp
VocBase/barrier.cpp
VocBase/cleanup.cpp

View File

@ -116,16 +116,17 @@ arangod_libarangod_a_SOURCES = \
arangod/V8Server/V8QueueJob.cpp \
arangod/V8Server/V8TimerTask.cpp \
arangod/V8Server/v8-actions.cpp \
arangod/V8Server/v8-dispatcher.cpp \
arangod/V8Server/v8-query.cpp \
arangod/V8Server/v8-vocbase.cpp \
arangod/V8Server/v8-wrapshapedjson.cpp \
arangod/V8Server/v8-vocindex.cpp \
arangod/V8Server/v8-voccursor.cpp \
arangod/V8Server/v8-replication.cpp \
arangod/V8Server/v8-collection.cpp \
arangod/V8Server/v8-collection-util.cpp \
arangod/V8Server/v8-dispatcher.cpp \
arangod/V8Server/v8-query.cpp \
arangod/V8Server/v8-replication.cpp \
arangod/V8Server/v8-vocbase.cpp \
arangod/V8Server/v8-vocindex.cpp \
arangod/V8Server/v8-voccursor.cpp \
arangod/V8Server/v8-user-structures.cpp \
arangod/V8Server/v8-util.cpp \
arangod/V8Server/v8-wrapshapedjson.cpp \
arangod/VocBase/auth.cpp \
arangod/VocBase/barrier.cpp \
arangod/VocBase/cleanup.cpp \

View File

@ -52,6 +52,7 @@
#include "V8Server/v8-actions.h"
#include "V8Server/v8-dispatcher.h"
#include "V8Server/v8-query.h"
#include "V8Server/v8-user-structures.h"
#include "V8Server/v8-vocbase.h"
#include "VocBase/server.h"
#include "Cluster/ServerState.h"
@ -1222,6 +1223,7 @@ bool ApplicationV8::prepareV8Instance (const string& name, size_t i, bool useAct
TRI_InitV8VocBridge(context->_context, _server, _vocbase, &_startupLoader, i);
TRI_InitV8Queries(context->_context);
TRI_InitV8UserStructures(context->_context);
TRI_InitV8Cluster(context->_context);
if (_dispatcher->dispatcher() != nullptr) {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,70 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief V8 user data structures
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2011-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_V8SERVER_V8__USER_STRUCTURES_H
#define ARANGODB_V8SERVER_V8__USER_STRUCTURES_H 1
#include "Basics/Common.h"
#include "V8/v8-globals.h"
struct TRI_vocbase_s;
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief creates the user structures for a database
////////////////////////////////////////////////////////////////////////////////
void TRI_CreateUserStructuresVocBase (struct TRI_vocbase_s*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys the user structures for a database
////////////////////////////////////////////////////////////////////////////////
void TRI_FreeUserStructuresVocBase (struct TRI_vocbase_s*);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates the user structures functions
////////////////////////////////////////////////////////////////////////////////
void TRI_InitV8UserStructures (v8::Handle<v8::Context>);
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
// End:

View File

@ -57,6 +57,7 @@
#include "VocBase/server.h"
#include "VocBase/transaction.h"
#include "VocBase/vocbase-defaults.h"
#include "V8Server/v8-user-structures.h"
#include "Wal/LogfileManager.h"
#include "Ahuacatl/ahuacatl-functions.h"
@ -1342,6 +1343,7 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_server_t* server,
vocbase->_hasCompactor = false;
vocbase->_isOwnAppsDirectory = true;
vocbase->_replicationApplier = nullptr;
vocbase->_userStructures = nullptr;
vocbase->_oldTransactions = nullptr;
@ -1403,6 +1405,8 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_server_t* server,
TRI_InitCondition(&vocbase->_compactorCondition);
TRI_InitCondition(&vocbase->_cleanupCondition);
TRI_CreateUserStructuresVocBase(vocbase);
return vocbase;
}
@ -1411,6 +1415,10 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_server_t* server,
////////////////////////////////////////////////////////////////////////////////
void TRI_DestroyInitialVocBase (TRI_vocbase_t* vocbase) {
if (vocbase->_userStructures != nullptr) {
TRI_FreeUserStructuresVocBase(vocbase);
}
// free replication
if (vocbase->_replicationApplier != nullptr) {
TRI_FreeReplicationApplier(vocbase->_replicationApplier);

View File

@ -31,6 +31,7 @@
#define ARANGODB_VOC_BASE_VOCBASE_H 1
#include "Basics/Common.h"
#include "Basics/ReadWriteLock.h"
#include "Basics/associative.h"
#include "Basics/locks.h"
@ -308,6 +309,9 @@ typedef struct TRI_vocbase_s {
TRI_read_write_lock_t _inventoryLock; // object lock needed when replication is assessing the state of the vocbase
// structures for user-defined volatile data
void* _userStructures;
TRI_associative_pointer_t _authInfo;
TRI_associative_pointer_t _authCache;
TRI_read_write_lock_t _authInfoLock;

View File

@ -1499,6 +1499,34 @@ static v8::Handle<v8::Value> ObjectJsonList (TRI_json_t const* json) {
return object;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief extracts keys or values from a TRI_json_t* array
////////////////////////////////////////////////////////////////////////////////
static v8::Handle<v8::Value> ExtractArray (TRI_json_t const* json,
size_t offset) {
v8::HandleScope scope;
if (json == nullptr || json->_type != TRI_JSON_ARRAY) {
return scope.Close(v8::Undefined());
}
size_t const n = TRI_LengthVector(&json->_value._objects);
v8::Handle<v8::Array> result = v8::Array::New(static_cast<int>(n / 2));
uint32_t count = 0;
for (size_t i = offset; i < n; i += 2) {
TRI_json_t const* value = static_cast<TRI_json_t const*>(TRI_AtVector(&json->_value._objects, i));
if (value != nullptr) {
result->Set(count++, TRI_ObjectJson(value));
}
}
return scope.Close(result);
}
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
@ -1527,6 +1555,26 @@ v8::Handle<v8::Array> TRI_ArrayAssociativePointer (TRI_associative_pointer_t con
return scope.Close(result);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the keys of a TRI_json_t* array into a V8 list
////////////////////////////////////////////////////////////////////////////////
v8::Handle<v8::Value> TRI_KeysJson (TRI_json_t const* json) {
v8::HandleScope scope;
return scope.Close(ExtractArray(json, 0));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the values of a TRI_json_t* array into a V8 list
////////////////////////////////////////////////////////////////////////////////
v8::Handle<v8::Value> TRI_ValuesJson (TRI_json_t const* json) {
v8::HandleScope scope;
return scope.Close(ExtractArray(json, 1));
}
////////////////////////////////////////////////////////////////////////////////
/// @brief converts a TRI_json_t into a V8 object
////////////////////////////////////////////////////////////////////////////////

View File

@ -51,6 +51,18 @@
v8::Handle<v8::Array> TRI_ArrayAssociativePointer (TRI_associative_pointer_t const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the keys of a TRI_json_t* array into a V8 list
////////////////////////////////////////////////////////////////////////////////
v8::Handle<v8::Value> TRI_KeysJson (TRI_json_t const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the values of a TRI_json_t* array into a V8 list
////////////////////////////////////////////////////////////////////////////////
v8::Handle<v8::Value> TRI_ValuesJson (TRI_json_t const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief converts a TRI_json_t into a V8 object
////////////////////////////////////////////////////////////////////////////////