1
0
Fork 0

Start support for create edge in coordinator in cluster.

This commit is contained in:
Max Neunhoeffer 2014-01-24 16:47:29 +01:00
parent ea2af50683
commit fe348a36ca
2 changed files with 62 additions and 0 deletions

View File

@ -34,6 +34,12 @@
#include "VocBase/document-collection.h"
#include "VocBase/edge-collection.h"
#ifdef TRI_ENABLE_CLUSTER
#include "Cluster/ServerState.h"
#include "Cluster/ClusterInfo.h"
#include "Cluster/ClusterMethods.h"
#endif
using namespace std;
using namespace triagens::basics;
using namespace triagens::rest;
@ -218,6 +224,14 @@ bool RestEdgeHandler::createDocument () {
return false;
}
#ifdef TRI_ENABLE_CLUSTER
if (ServerState::instance()->isCoordinator()) {
// json will be freed inside!
return createDocumentCoordinator(collection, waitForSync, json,
from, to);
}
#endif
if (! checkCreateCollection(collection, getCollectionType())) {
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
return false;
@ -318,6 +332,43 @@ bool RestEdgeHandler::createDocument () {
return true;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a document (an edge), coordinator case in a cluster
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_ENABLE_CLUSTER
bool RestEdgeHandler::createDocumentCoordinator (string const& collname,
bool waitForSync,
TRI_json_t* json,
char const* from,
char const* to) {
string const& dbname = _request->originalDatabaseName();
triagens::rest::HttpResponse::HttpResponseCode responseCode;
string contentType;
string resultBody;
// Not yet implemented:
generateTransactionError(collname.c_str(), TRI_ERROR_INTERNAL);
return false;
int error = triagens::arango::createDocumentOnCoordinator(
dbname, collname, waitForSync, json,
responseCode, contentType, resultBody);
if (error != TRI_ERROR_NO_ERROR) {
generateTransactionError(collname.c_str(), error);
return false;
}
// Essentially return the response we got from the DBserver, be it
// OK or an error:
_response = createResponse(responseCode);
_response->setContentType(contentType);
_response->body().appendText(resultBody.c_str(), resultBody.size());
return responseCode >= triagens::rest::HttpResponse::BAD;
}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief reads a single edge
///

View File

@ -113,6 +113,17 @@ namespace triagens {
bool createDocument ();
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a document (an edge), coordinator case in a cluster
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_ENABLE_CLUSTER
bool createDocumentCoordinator (string const& collname,
bool waitForSync,
TRI_json_t* json,
char const* from,
char const* to);
#endif
};
}
}