mirror of https://gitee.com/bigwinds/arangodb
added RubyDispatcherThread
This commit is contained in:
parent
35ee4a3bff
commit
2a89e6e176
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -57,5 +57,5 @@ ArangoHttpServer::ArangoHttpServer (Scheduler* scheduler, Dispatcher* dispatcher
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -80,5 +80,5 @@ namespace triagens {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -80,6 +80,7 @@ using namespace triagens::arango;
|
||||||
#include "MRuby/MRLineEditor.h"
|
#include "MRuby/MRLineEditor.h"
|
||||||
#include "MRuby/MRLoader.h"
|
#include "MRuby/MRLoader.h"
|
||||||
#include "MRuby/mr-actions.h"
|
#include "MRuby/mr-actions.h"
|
||||||
|
#include "RestServer/RubyDispatcherThread.h"
|
||||||
|
|
||||||
#include "mruby.h"
|
#include "mruby.h"
|
||||||
#include "mruby/compile.h"
|
#include "mruby/compile.h"
|
||||||
|
@ -200,17 +201,13 @@ static DispatcherThread* SystemActionDispatcherThreadCreatorJS (DispatcherQueue*
|
||||||
#ifdef TRI_ENABLE_MRUBY
|
#ifdef TRI_ENABLE_MRUBY
|
||||||
|
|
||||||
static DispatcherThread* ClientActionDispatcherThreadCreatorMR (DispatcherQueue* queue) {
|
static DispatcherThread* ClientActionDispatcherThreadCreatorMR (DispatcherQueue* queue) {
|
||||||
return 0;
|
return new RubyDispatcherThread(queue,
|
||||||
#if 0
|
|
||||||
return new ActionDispatcherThread(queue,
|
|
||||||
Vocbase,
|
Vocbase,
|
||||||
GcIntervalJS,
|
|
||||||
"CLIENT-RUBY",
|
"CLIENT-RUBY",
|
||||||
AllowedClientActions,
|
AllowedClientActions,
|
||||||
StartupModulesJS,
|
StartupModulesMR,
|
||||||
&StartupLoaderJS,
|
&StartupLoaderMR,
|
||||||
&ActionLoaderJS);
|
&ActionLoaderMR);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -222,17 +219,13 @@ static DispatcherThread* ClientActionDispatcherThreadCreatorMR (DispatcherQueue*
|
||||||
#ifdef TRI_ENABLE_MRUBY
|
#ifdef TRI_ENABLE_MRUBY
|
||||||
|
|
||||||
static DispatcherThread* SystemActionDispatcherThreadCreatorMR (DispatcherQueue* queue) {
|
static DispatcherThread* SystemActionDispatcherThreadCreatorMR (DispatcherQueue* queue) {
|
||||||
return 0;
|
return new RubyDispatcherThread(queue,
|
||||||
#if 0
|
|
||||||
return new ActionDispatcherThread(queue,
|
|
||||||
Vocbase,
|
Vocbase,
|
||||||
GcIntervalJS,
|
|
||||||
"SYSTEM-RUBY",
|
"SYSTEM-RUBY",
|
||||||
AllowedAdminActions,
|
AllowedAdminActions,
|
||||||
StartupModulesJS,
|
StartupModulesMR,
|
||||||
&StartupLoaderJS,
|
&StartupLoaderMR,
|
||||||
&ActionLoaderJS);
|
&ActionLoaderMR);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -763,7 +756,7 @@ int ArangoServer::startupServer () {
|
||||||
|
|
||||||
#if TRI_ENABLE_MRUBY
|
#if TRI_ENABLE_MRUBY
|
||||||
if (0 < _actionThreadsMR) {
|
if (0 < _actionThreadsMR) {
|
||||||
// safe_cast<DispatcherImpl*>(dispatcher)->addQueue("CLIENT-RUBY", ClientActionDispatcherThreadCreatorMR, _actionThreadsMR);
|
safe_cast<DispatcherImpl*>(dispatcher)->addQueue("CLIENT-RUBY", ClientActionDispatcherThreadCreatorMR, _actionThreadsMR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -773,7 +766,7 @@ int ArangoServer::startupServer () {
|
||||||
safe_cast<DispatcherImpl*>(dispatcher)->addQueue("SYSTEM-JAVASCRIPT", SystemActionDispatcherThreadCreatorJS, 2);
|
safe_cast<DispatcherImpl*>(dispatcher)->addQueue("SYSTEM-JAVASCRIPT", SystemActionDispatcherThreadCreatorJS, 2);
|
||||||
|
|
||||||
#if TRI_ENABLE_MRUBY
|
#if TRI_ENABLE_MRUBY
|
||||||
// safe_cast<DispatcherImpl*>(dispatcher)->addQueue("SYSTEM-RUBY", SystemActionDispatcherThreadCreatorMR, 2);
|
safe_cast<DispatcherImpl*>(dispatcher)->addQueue("SYSTEM-RUBY", SystemActionDispatcherThreadCreatorMR, 2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1282,5 +1275,5 @@ void ArangoServer::closeDatabase () {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -441,5 +441,5 @@ namespace triagens {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -267,5 +267,5 @@ void JavascriptDispatcherThread::initialise () {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -261,5 +261,5 @@ namespace triagens {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -0,0 +1,271 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief dispatcher thread for JavaScript actions
|
||||||
|
///
|
||||||
|
/// @file
|
||||||
|
///
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Dr. Frank Celler
|
||||||
|
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "JavascriptDispatcherThread.h"
|
||||||
|
|
||||||
|
#include "Actions/actions.h"
|
||||||
|
#include "Logger/Logger.h"
|
||||||
|
#include "V8/v8-actions.h"
|
||||||
|
#include "V8/v8-conv.h"
|
||||||
|
#include "V8/v8-query.h"
|
||||||
|
#include "V8/v8-shell.h"
|
||||||
|
#include "V8/v8-utils.h"
|
||||||
|
#include "V8/v8-vocbase.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace triagens::basics;
|
||||||
|
using namespace triagens::rest;
|
||||||
|
using namespace triagens::arango;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- class ActionDispatcherThread
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- constructors and destructors
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief constructs a new dispatcher thread
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
JavascriptDispatcherThread::JavascriptDispatcherThread (rest::DispatcherQueue* queue,
|
||||||
|
TRI_vocbase_t* vocbase,
|
||||||
|
uint64_t gcInterval,
|
||||||
|
string const& actionQueue,
|
||||||
|
set<string> const& allowedContexts,
|
||||||
|
string startupModules,
|
||||||
|
JSLoader* startupLoader,
|
||||||
|
JSLoader* actionLoader)
|
||||||
|
: ActionDispatcherThread(queue),
|
||||||
|
_vocbase(vocbase),
|
||||||
|
_gcInterval(gcInterval),
|
||||||
|
_gc(0),
|
||||||
|
_isolate(0),
|
||||||
|
_context(),
|
||||||
|
_actionQueue(actionQueue),
|
||||||
|
_allowedContexts(allowedContexts),
|
||||||
|
_startupModules(startupModules),
|
||||||
|
_startupLoader(startupLoader),
|
||||||
|
_actionLoader(actionLoader) {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- ActionDispatcherThread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void* JavascriptDispatcherThread::context () {
|
||||||
|
return (void*) _isolate; // the isolate is the execution context
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- DispatcherThread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void JavascriptDispatcherThread::reportStatus () {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void JavascriptDispatcherThread::tick (bool idle) {
|
||||||
|
_gc += (idle ? 10 : 1);
|
||||||
|
|
||||||
|
if (_gc > _gcInterval) {
|
||||||
|
LOGGER_TRACE << "collecting garbage...";
|
||||||
|
|
||||||
|
while (! v8::V8::IdleNotification()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
_gc = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- Thread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void JavascriptDispatcherThread::run () {
|
||||||
|
initialise();
|
||||||
|
|
||||||
|
_isolate->Enter();
|
||||||
|
_context->Enter();
|
||||||
|
|
||||||
|
DispatcherThread::run();
|
||||||
|
|
||||||
|
// free memory for this thread
|
||||||
|
TRI_v8_global_t* v8g = (TRI_v8_global_t*) _isolate->GetData();
|
||||||
|
|
||||||
|
if (v8g) {
|
||||||
|
delete v8g;
|
||||||
|
}
|
||||||
|
|
||||||
|
_context->Exit();
|
||||||
|
_context.Dispose();
|
||||||
|
|
||||||
|
_isolate->Exit();
|
||||||
|
_isolate->Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief initialises the isolate and context
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void JavascriptDispatcherThread::initialise () {
|
||||||
|
bool ok;
|
||||||
|
char const* files[] = { "common/bootstrap/modules.js",
|
||||||
|
"common/bootstrap/print.js",
|
||||||
|
"common/bootstrap/errors.js",
|
||||||
|
"server/ahuacatl.js",
|
||||||
|
"server/server.js"
|
||||||
|
};
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
// enter a new isolate
|
||||||
|
_isolate = v8::Isolate::New();
|
||||||
|
_isolate->Enter();
|
||||||
|
|
||||||
|
// create the context
|
||||||
|
_context = v8::Context::New(0);
|
||||||
|
|
||||||
|
if (_context.IsEmpty()) {
|
||||||
|
LOGGER_FATAL << "cannot initialize V8 engine";
|
||||||
|
_isolate->Exit();
|
||||||
|
TRI_FlushLogging();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
_context->Enter();
|
||||||
|
|
||||||
|
TRI_InitV8VocBridge(_context, _vocbase);
|
||||||
|
TRI_InitV8Queries(_context);
|
||||||
|
TRI_InitV8Actions(_context, _actionQueue, _allowedContexts);
|
||||||
|
TRI_InitV8Conversions(_context);
|
||||||
|
TRI_InitV8Utils(_context, _startupModules);
|
||||||
|
TRI_InitV8Shell(_context);
|
||||||
|
|
||||||
|
// load all init files
|
||||||
|
for (i = 0; i < sizeof(files) / sizeof(files[0]); ++i) {
|
||||||
|
ok = _startupLoader->loadScript(_context, files[i]);
|
||||||
|
|
||||||
|
if (! ok) {
|
||||||
|
LOGGER_FATAL << "cannot load json utilities from file '" << files[i] << "'";
|
||||||
|
_context->Exit();
|
||||||
|
_isolate->Exit();
|
||||||
|
|
||||||
|
TRI_FlushLogging();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// load all actions
|
||||||
|
if (_actionLoader == 0) {
|
||||||
|
LOGGER_WARNING << "no action loader has been defined";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = _actionLoader->executeAllScripts(_context);
|
||||||
|
|
||||||
|
if (! ok) {
|
||||||
|
LOGGER_FATAL << "cannot load actions from directory '" << _actionLoader->getDirectory() << "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// and return from the context
|
||||||
|
_context->Exit();
|
||||||
|
_isolate->Exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- END-OF-FILE
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: outline-minor
|
||||||
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
|
// End:
|
|
@ -0,0 +1,243 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief dispatcher thread for Ruby actions
|
||||||
|
///
|
||||||
|
/// @file
|
||||||
|
///
|
||||||
|
/// DISCLAIMER
|
||||||
|
///
|
||||||
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
/// you may not use this file except in compliance with the License.
|
||||||
|
/// You may obtain a copy of the License at
|
||||||
|
///
|
||||||
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
///
|
||||||
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
/// See the License for the specific language governing permissions and
|
||||||
|
/// limitations under the License.
|
||||||
|
///
|
||||||
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||||
|
///
|
||||||
|
/// @author Dr. Frank Celler
|
||||||
|
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef TRIAGENS_REST_SERVER_RUBY_DISPATCHER_THREAD_H
|
||||||
|
#define TRIAGENS_REST_SERVER_RUBY_DISPATCHER_THREAD_H 1
|
||||||
|
|
||||||
|
#include "Actions/ActionDispatcherThread.h"
|
||||||
|
|
||||||
|
#include "MRuby/MRLoader.h"
|
||||||
|
#include "VocBase/vocbase.h"
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- class ActionDispatcherThread
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace triagens {
|
||||||
|
namespace arango {
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief dispatcher thread
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class RubyDispatcherThread : public ActionDispatcherThread {
|
||||||
|
private:
|
||||||
|
RubyDispatcherThread (RubyDispatcherThread const&);
|
||||||
|
RubyDispatcherThread& operator= (RubyDispatcherThread const&);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- constructors and destructors
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief constructs a new dispatcher thread
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
RubyDispatcherThread (rest::DispatcherQueue*,
|
||||||
|
TRI_vocbase_t*,
|
||||||
|
string const& actionQueue,
|
||||||
|
set<string> const& allowedContexts,
|
||||||
|
std::string startupModules,
|
||||||
|
MRLoader* startupLoader,
|
||||||
|
MRLoader* actionLoader);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- ActionDispatcherThread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void* context ();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- DispatcherThread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void reportStatus ();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void tick (bool idle);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- Thread methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void run ();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief initialises the isolate and context
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void initialise ();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @addtogroup ArangoDB
|
||||||
|
/// @{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief vocbase
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TRI_vocbase_t* _vocbase;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief V8 isolate
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
MR_state_t* _mrs;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief action queue
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string _actionQueue;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief allowed action contexts
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::set<std::string> _allowedContexts;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief modules path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
string _startupModules;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief startup path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
MRLoader* _startupLoader;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief action path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
MRLoader* _actionLoader;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: outline-minor
|
||||||
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
|
// End:
|
|
@ -5,7 +5,7 @@
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
|
@ -70,5 +70,5 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -39,9 +39,9 @@ class ArangoError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
################################################################################
|
## -----------------------------------------------------------------------------
|
||||||
## --SECTION-- END-OF-FILE
|
## --SECTION-- END-OF-FILE
|
||||||
################################################################################
|
## -----------------------------------------------------------------------------
|
||||||
|
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
## mode: outline-minor
|
## mode: outline-minor
|
||||||
|
|
|
@ -40,9 +40,9 @@ static string MR_common_bootstrap_error =
|
||||||
" end\n"
|
" end\n"
|
||||||
"end\n"
|
"end\n"
|
||||||
"\n"
|
"\n"
|
||||||
"################################################################################\n"
|
"## -----------------------------------------------------------------------------\n"
|
||||||
"## --SECTION-- END-OF-FILE\n"
|
"## --SECTION-- END-OF-FILE\n"
|
||||||
"################################################################################\n"
|
"## -----------------------------------------------------------------------------\n"
|
||||||
"\n"
|
"\n"
|
||||||
"## Local Variables:\n"
|
"## Local Variables:\n"
|
||||||
"## mode: outline-minor\n"
|
"## mode: outline-minor\n"
|
||||||
|
|
|
@ -77,9 +77,9 @@ static string MR_server_server =
|
||||||
"\n"
|
"\n"
|
||||||
"end\n"
|
"end\n"
|
||||||
"\n"
|
"\n"
|
||||||
"################################################################################\n"
|
"## -----------------------------------------------------------------------------\n"
|
||||||
"## --SECTION-- END-OF-FILE\n"
|
"## --SECTION-- END-OF-FILE\n"
|
||||||
"################################################################################\n"
|
"## -----------------------------------------------------------------------------\n"
|
||||||
"\n"
|
"\n"
|
||||||
"## Local Variables:\n"
|
"## Local Variables:\n"
|
||||||
"## mode: outline-minor\n"
|
"## mode: outline-minor\n"
|
||||||
|
|
|
@ -76,9 +76,9 @@ module Arango
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
################################################################################
|
## -----------------------------------------------------------------------------
|
||||||
## --SECTION-- END-OF-FILE
|
## --SECTION-- END-OF-FILE
|
||||||
################################################################################
|
## -----------------------------------------------------------------------------
|
||||||
|
|
||||||
## Local Variables:
|
## Local Variables:
|
||||||
## mode: outline-minor
|
## mode: outline-minor
|
||||||
|
|
Loading…
Reference in New Issue