1
0
Fork 0

added stubs for communication layer

This commit is contained in:
Jan Steemann 2013-12-05 14:28:52 +01:00
parent e18d4eb162
commit a976f1b2b9
5 changed files with 465 additions and 5 deletions

View File

@ -74,7 +74,9 @@ bin_arangod_SOURCES = \
arangod/RestServer/ArangoServer.cpp \ arangod/RestServer/ArangoServer.cpp \
arangod/RestServer/VocbaseContext.cpp \ arangod/RestServer/VocbaseContext.cpp \
arangod/RestServer/arango.cpp \ arangod/RestServer/arango.cpp \
arangod/Sharding/AgencyComm.cpp \
arangod/Sharding/server-state.cpp \ arangod/Sharding/server-state.cpp \
arangod/Sharding/HeartbeatThread.cpp \
arangod/SkipLists/skiplistIndex.c \ arangod/SkipLists/skiplistIndex.c \
arangod/Utils/DocumentHelper.cpp \ arangod/Utils/DocumentHelper.cpp \
arangod/V8Server/ApplicationV8.cpp \ arangod/V8Server/ApplicationV8.cpp \

View File

@ -0,0 +1,188 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief communication with agency node(s)
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-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 Jan Steemann
/// @author Copyright 2013, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "Sharding/AgencyComm.h"
#include "BasicsC/logging.h"
//using namespace triagens::basics;
using namespace triagens::arango;
// -----------------------------------------------------------------------------
// --SECTION-- Agent
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
Agent::Agent () {
}
Agent::~Agent () {
}
// -----------------------------------------------------------------------------
// --SECTION-- AgencyCommResult
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
AgencyCommResult::AgencyCommResult () {
}
AgencyCommResult::~AgencyCommResult () {
}
// -----------------------------------------------------------------------------
// --SECTION-- AgencyComm
// -----------------------------------------------------------------------------
std::string AgencyComm::_prefix;
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs an agency communication object
////////////////////////////////////////////////////////////////////////////////
AgencyComm::AgencyComm () {
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys an agency communication object
////////////////////////////////////////////////////////////////////////////////
AgencyComm::~AgencyComm () {
}
// -----------------------------------------------------------------------------
// --SECTION-- public static methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the global prefix for all operations
////////////////////////////////////////////////////////////////////////////////
void AgencyComm::setPrefix (std::string const& prefix) {
_prefix = prefix;
}
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief establishes the communication channels
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::connect () {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief disconnects all communication channels
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::disconnect () {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an agent to the agents list
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::addAgent (Agent agent) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an agent from the agents list
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::removeAgent (Agent agent) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an agent from the agents list
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::setValue (std::string const& key,
std::string const& value) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief gets one or multiple values from the back end
////////////////////////////////////////////////////////////////////////////////
AgencyCommResult AgencyComm::getValues (std::string const& key,
bool recursive) {
AgencyCommResult result;
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief removes one or multiple values from the back end
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::removeValues (std::string const& key,
bool recursive) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief compares and swaps a single value in the back end
////////////////////////////////////////////////////////////////////////////////
int AgencyComm::casValue (std::string const& key,
std::string const& oldValue,
std::string const& newValue) {
return 0;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief blocks on a change of a single value in the back end
////////////////////////////////////////////////////////////////////////////////
AgencyCommResult AgencyComm::watchValues (std::string const& key,
double timeout) {
AgencyCommResult result;
return result;
}
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -44,6 +44,9 @@ namespace triagens {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
struct Agent { struct Agent {
Agent ();
~Agent ();
std::string _name; std::string _name;
std::string _endpoint; std::string _endpoint;
@ -76,22 +79,92 @@ namespace triagens {
~AgencyComm (); ~AgencyComm ();
// -----------------------------------------------------------------------------
// --SECTION-- public static methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief sets the global prefix for all operations
////////////////////////////////////////////////////////////////////////////////
void setPrefix (std::string const&);
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief establishes the communication channels
////////////////////////////////////////////////////////////////////////////////
int connect ();
////////////////////////////////////////////////////////////////////////////////
/// @brief disconnects all communication channels
////////////////////////////////////////////////////////////////////////////////
int disconnect ();
////////////////////////////////////////////////////////////////////////////////
/// @brief adds an agent to the agents list
////////////////////////////////////////////////////////////////////////////////
int addAgent (Agent); int addAgent (Agent);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an agent from the agents list
////////////////////////////////////////////////////////////////////////////////
int removeAgent (Agent); int removeAgent (Agent);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes an agent from the agents list
////////////////////////////////////////////////////////////////////////////////
int setValue (std::string const& key, std::string const& value); int setValue (std::string const& key,
std::string const& value);
////////////////////////////////////////////////////////////////////////////////
/// @brief gets one or multiple values from the back end
////////////////////////////////////////////////////////////////////////////////
AgencyCommResult getValues (std::string const& key, bool recursive); AgencyCommResult getValues (std::string const& key,
bool recursive);
////////////////////////////////////////////////////////////////////////////////
/// @brief removes one or multiple values from the back end
////////////////////////////////////////////////////////////////////////////////
int removeValue (std::string const& key, bool recursive); int removeValues (std::string const& key,
bool recursive);
////////////////////////////////////////////////////////////////////////////////
/// @brief compares and swaps a single value in the back end
////////////////////////////////////////////////////////////////////////////////
int casValue (std::string const& key, std::string const& oldValue, std::string const& newValue); int casValue (std::string const& key,
std::string const& oldValue,
std::string const& newValue);
////////////////////////////////////////////////////////////////////////////////
/// @brief blocks on a change of a single value in the back end
////////////////////////////////////////////////////////////////////////////////
AgencyCommResult watchValues (std::string const& key, double timeout); AgencyCommResult watchValues (std::string const& key,
double timeout);
// -----------------------------------------------------------------------------
// --SECTION-- private static variables
// -----------------------------------------------------------------------------
private: private:
////////////////////////////////////////////////////////////////////////////////
/// @brief the global prefix
////////////////////////////////////////////////////////////////////////////////
static std::string _prefix;
}; };
} }

View File

@ -0,0 +1,86 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief heartbeat thread
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-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 Jan Steemann
/// @author Copyright 2013, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#include "HeartbeatThread.h"
#include "BasicsC/logging.h"
using namespace triagens::basics;
using namespace triagens::arango;
// -----------------------------------------------------------------------------
// --SECTION-- HeartbeatThread
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a heartbeat thread
////////////////////////////////////////////////////////////////////////////////
HeartbeatThread::HeartbeatThread ()
: Thread("heartbeat") {
allowAsynchronousCancelation();
_agency.connect();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a heartbeat thread
////////////////////////////////////////////////////////////////////////////////
HeartbeatThread::~HeartbeatThread () {
_agency.disconnect();
}
// -----------------------------------------------------------------------------
// --SECTION-- Thread methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief heartbeat main loop
////////////////////////////////////////////////////////////////////////////////
void HeartbeatThread::run () {
LOG_INFO("starting heartbeat thread");
while (1) {
sleep(5);
LOG_INFO("heartbeat");
}
LOG_INFO("stopping heartbeat thread");
}
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -0,0 +1,111 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief heartbeat thread
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-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 Jan Steemann
/// @author Copyright 2013, triagens GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_SHARDING_HEARTBEAT_THREAD_H
#define TRIAGENS_SHARDING_HEARTBEAT_THREAD_H 1
#include "Basics/Common.h"
#include "Basics/Thread.h"
#include "Sharding/AgencyComm.h"
#ifdef __cplusplus
extern "C" {
#endif
namespace triagens {
namespace arango {
// -----------------------------------------------------------------------------
// --SECTION-- HeartbeatThread
// -----------------------------------------------------------------------------
class HeartbeatThread : public basics::Thread {
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
private:
HeartbeatThread (HeartbeatThread const&);
HeartbeatThread& operator= (HeartbeatThread const&);
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a heartbeat thread
////////////////////////////////////////////////////////////////////////////////
HeartbeatThread ();
////////////////////////////////////////////////////////////////////////////////
/// @brief destroys a heartbeat thread
////////////////////////////////////////////////////////////////////////////////
~HeartbeatThread ();
// -----------------------------------------------------------------------------
// --SECTION-- Thread methods
// -----------------------------------------------------------------------------
protected:
////////////////////////////////////////////////////////////////////////////////
/// @brief heartbeat main loop
////////////////////////////////////////////////////////////////////////////////
void run ();
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
private:
////////////////////////////////////////////////////////////////////////////////
/// @brief AgencyComm instance
////////////////////////////////////////////////////////////////////////////////
AgencyComm _agency;
};
}
}
#ifdef __cplusplus
}
#endif
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
// End: