1
0
Fork 0
arangodb/arangod/Replication/Syncer.h

293 lines
11 KiB
C++

////////////////////////////////////////////////////////////////////////////////
/// @brief replication syncer base class
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2013 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_REPLICATION_SYNCER_H
#define TRIAGENS_REPLICATION_SYNCER_H 1
#include "Basics/Common.h"
#include "BasicsC/logging.h"
#include "VocBase/replication-applier.h"
#include "VocBase/replication-master.h"
#include "VocBase/server.h"
#include "VocBase/transaction.h"
#include "VocBase/update-policy.h"
// -----------------------------------------------------------------------------
// --SECTION-- forward declarations
// -----------------------------------------------------------------------------
struct TRI_json_s;
struct TRI_replication_applier_configuration_s;
struct TRI_transaction_collection_s;
struct TRI_vocbase_s;
struct TRI_vocbase_col_s;
namespace triagens {
namespace httpclient {
class GeneralClientConnection;
class SimpleHttpClient;
class SimpleHttpResult;
}
namespace rest {
class Endpoint;
}
namespace arango {
// -----------------------------------------------------------------------------
// --SECTION-- Syncer
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Replication
/// @{
////////////////////////////////////////////////////////////////////////////////
class Syncer {
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Replication
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
Syncer (struct TRI_vocbase_s*,
struct TRI_replication_applier_configuration_s const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
////////////////////////////////////////////////////////////////////////////////
virtual ~Syncer ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Replication
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief request location rewriter (injects database name)
////////////////////////////////////////////////////////////////////////////////
static string rewriteLocation (void*, const string&);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- protected methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Replication
/// @{
////////////////////////////////////////////////////////////////////////////////
protected:
////////////////////////////////////////////////////////////////////////////////
/// @brief extract the collection id from JSON
////////////////////////////////////////////////////////////////////////////////
TRI_voc_cid_t getCid (struct TRI_json_s const*) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a transaction hint
////////////////////////////////////////////////////////////////////////////////
TRI_transaction_hint_t getHint (const size_t) const;
////////////////////////////////////////////////////////////////////////////////
/// @brief apply a single marker from the collection dump
////////////////////////////////////////////////////////////////////////////////
int applyCollectionDumpMarker (struct TRI_transaction_collection_s*,
TRI_replication_operation_e,
const TRI_voc_key_t,
const TRI_voc_rid_t,
struct TRI_json_s const*,
std::string&);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a collection, based on the JSON provided
////////////////////////////////////////////////////////////////////////////////
int createCollection (struct TRI_json_s const*,
struct TRI_vocbase_col_s**);
////////////////////////////////////////////////////////////////////////////////
/// @brief drops a collection, based on the JSON provided
////////////////////////////////////////////////////////////////////////////////
int dropCollection (struct TRI_json_s const*,
bool);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates an index, based on the JSON provided
////////////////////////////////////////////////////////////////////////////////
int createIndex (struct TRI_json_s const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief drops an index, based on the JSON provided
////////////////////////////////////////////////////////////////////////////////
int dropIndex (struct TRI_json_s const*);
////////////////////////////////////////////////////////////////////////////////
/// @brief get master state
////////////////////////////////////////////////////////////////////////////////
int getMasterState (std::string&);
////////////////////////////////////////////////////////////////////////////////
/// @brief handle the state response of the master
////////////////////////////////////////////////////////////////////////////////
int handleStateResponse (struct TRI_json_s const*,
std::string&);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- protected variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Replication
/// @{
////////////////////////////////////////////////////////////////////////////////
protected:
////////////////////////////////////////////////////////////////////////////////
/// @brief vocbase base pointer
////////////////////////////////////////////////////////////////////////////////
struct TRI_vocbase_s* _vocbase;
////////////////////////////////////////////////////////////////////////////////
/// @brief configuration
////////////////////////////////////////////////////////////////////////////////
TRI_replication_applier_configuration_t _configuration;
////////////////////////////////////////////////////////////////////////////////
/// @brief information about the master state
////////////////////////////////////////////////////////////////////////////////
TRI_replication_master_info_t _masterInfo;
////////////////////////////////////////////////////////////////////////////////
/// @brief the update policy object (will be the same for all actions)
////////////////////////////////////////////////////////////////////////////////
TRI_doc_update_policy_t _policy;
////////////////////////////////////////////////////////////////////////////////
/// @brief the endpoint (master) we're connected to
////////////////////////////////////////////////////////////////////////////////
rest::Endpoint* _endpoint;
////////////////////////////////////////////////////////////////////////////////
/// @brief the connection to the master
////////////////////////////////////////////////////////////////////////////////
httpclient::GeneralClientConnection* _connection;
////////////////////////////////////////////////////////////////////////////////
/// @brief the http client we're using
////////////////////////////////////////////////////////////////////////////////
httpclient::SimpleHttpClient* _client;
////////////////////////////////////////////////////////////////////////////////
/// @brief database name
////////////////////////////////////////////////////////////////////////////////
std::string _databaseName;
////////////////////////////////////////////////////////////////////////////////
/// @brief local server id
////////////////////////////////////////////////////////////////////////////////
std::string _localServerIdString;
////////////////////////////////////////////////////////////////////////////////
/// @brief local server id
////////////////////////////////////////////////////////////////////////////////
TRI_server_id_t _localServerId;
////////////////////////////////////////////////////////////////////////////////
/// @brief base url of the replication API
////////////////////////////////////////////////////////////////////////////////
static const std::string BaseUrl;
};
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
// End: