mirror of https://gitee.com/bigwinds/arangodb
added stub REST API for cluster requests
This commit is contained in:
parent
0136a88076
commit
e1fb1f3d14
|
@ -0,0 +1,101 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief shard control request handler
|
||||||
|
///
|
||||||
|
/// @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 2010-2013, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RestShardHandler.h"
|
||||||
|
#include "Rest/HttpRequest.h"
|
||||||
|
#include "Rest/HttpResponse.h"
|
||||||
|
#include "Cluster/ServerState.h"
|
||||||
|
|
||||||
|
using namespace triagens::arango;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- public constants
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief name of the queue
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const string RestShardHandler::QUEUE_NAME = "STANDARD";
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- constructors and destructors
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief constructor
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
RestShardHandler::RestShardHandler (triagens::rest::HttpRequest* request)
|
||||||
|
: RestBaseHandler(request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- Handler methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool RestShardHandler::isDirect () {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
string const& RestShardHandler::queue () const {
|
||||||
|
return QUEUE_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
triagens::rest::HttpHandler::status_e RestShardHandler::execute () {
|
||||||
|
ServerState::RoleEnum role = ServerState::instance()->getRole();
|
||||||
|
|
||||||
|
if (role == ServerState::ROLE_COORDINATOR) {
|
||||||
|
generateError(triagens::rest::HttpResponse::BAD,
|
||||||
|
(int) triagens::rest::HttpResponse::BAD,
|
||||||
|
"this API is meant to be called on a coordinator node");
|
||||||
|
return HANDLER_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// respond with a 202
|
||||||
|
_response = createResponse(triagens::rest::HttpResponse::ACCEPTED);
|
||||||
|
|
||||||
|
return HANDLER_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: outline-minor
|
||||||
|
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||||
|
// End:
|
|
@ -0,0 +1,103 @@
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief shard request handler
|
||||||
|
///
|
||||||
|
/// @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 2010-2013, triAGENS GmbH, Cologne, Germany
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef TRIAGENS_ARANGOD_CLUSTER_REST_SHARD_HANDLER_H
|
||||||
|
#define TRIAGENS_ARANGOD_CLUSTER_REST_SHARD_HANDLER_H 1
|
||||||
|
|
||||||
|
#include "Admin/RestBaseHandler.h"
|
||||||
|
|
||||||
|
namespace triagens {
|
||||||
|
namespace arango {
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- class RestShardHandler
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief shard control request handler
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class RestShardHandler : public triagens::admin::RestBaseHandler {
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- constructors and destructors
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief constructor
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
RestShardHandler (triagens::rest::HttpRequest* request);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- Handler methods
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool isDirect ();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// {@inheritDoc}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
string const& queue () const;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief executes the handler
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
status_e execute ();
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private variables
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief name of the queue
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static const std::string QUEUE_NAME;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Local Variables:
|
||||||
|
// mode: outline-minor
|
||||||
|
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||||
|
// End:
|
|
@ -112,9 +112,10 @@ if ENABLE_CLUSTER
|
||||||
bin_arangod_SOURCES += \
|
bin_arangod_SOURCES += \
|
||||||
arangod/Cluster/AgencyComm.cpp \
|
arangod/Cluster/AgencyComm.cpp \
|
||||||
arangod/Cluster/ApplicationCluster.cpp \
|
arangod/Cluster/ApplicationCluster.cpp \
|
||||||
|
arangod/Cluster/ClusterComm.cpp \
|
||||||
arangod/Cluster/HeartbeatThread.cpp \
|
arangod/Cluster/HeartbeatThread.cpp \
|
||||||
arangod/Cluster/ServerState.cpp \
|
arangod/Cluster/RestShardHandler.cpp \
|
||||||
arangod/Cluster/ClusterComm.cpp
|
arangod/Cluster/ServerState.cpp
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
|
|
||||||
#ifdef TRI_ENABLE_CLUSTER
|
#ifdef TRI_ENABLE_CLUSTER
|
||||||
#include "Cluster/ApplicationCluster.h"
|
#include "Cluster/ApplicationCluster.h"
|
||||||
|
#include "Cluster/RestShardHandler.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "V8/V8LineEditor.h"
|
#include "V8/V8LineEditor.h"
|
||||||
|
@ -134,6 +135,12 @@ static void DefineApiHandlers (HttpHandlerFactory* factory,
|
||||||
// add "/upload" handler
|
// add "/upload" handler
|
||||||
factory->addPrefixHandler(RestVocbaseBaseHandler::UPLOAD_PATH,
|
factory->addPrefixHandler(RestVocbaseBaseHandler::UPLOAD_PATH,
|
||||||
RestHandlerCreator<RestUploadHandler>::createNoData);
|
RestHandlerCreator<RestUploadHandler>::createNoData);
|
||||||
|
|
||||||
|
#ifdef TRI_ENABLE_CLUSTER
|
||||||
|
// add "/shard-comm" handler
|
||||||
|
factory->addPrefixHandler("/_api/shard-comm",
|
||||||
|
RestHandlerCreator<RestShardHandler>::createNoData);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue