mirror of https://gitee.com/bigwinds/arangodb
fixed test
This commit is contained in:
parent
61dd94bc27
commit
55729b78a9
|
@ -37,13 +37,13 @@
|
||||||
#include "Basics/string-buffer.h"
|
#include "Basics/string-buffer.h"
|
||||||
#include "Basics/json-utilities.h"
|
#include "Basics/json-utilities.h"
|
||||||
#include "Basics/VelocyPackHelper.h"
|
#include "Basics/VelocyPackHelper.h"
|
||||||
|
#include "Cluster/ClusterComm.h"
|
||||||
|
#include "Cluster/ClusterInfo.h"
|
||||||
|
#include "Cluster/ClusterMethods.h"
|
||||||
|
#include "Cluster/ServerState.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "VocBase/document-collection.h"
|
#include "VocBase/document-collection.h"
|
||||||
#include "VocBase/vocbase.h"
|
#include "VocBase/vocbase.h"
|
||||||
#include "Cluster/ServerState.h"
|
|
||||||
#include "Cluster/ClusterInfo.h"
|
|
||||||
#include "Cluster/ClusterComm.h"
|
|
||||||
#include "Cluster/ClusterMethods.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace triagens::basics;
|
using namespace triagens::basics;
|
||||||
|
@ -81,25 +81,37 @@ bool RestQueryHandler::isDirect () const {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
HttpHandler::status_t RestQueryHandler::execute () {
|
HttpHandler::status_t RestQueryHandler::execute () {
|
||||||
|
|
||||||
// extract the sub-request type
|
// extract the sub-request type
|
||||||
HttpRequest::HttpRequestType type = _request->requestType();
|
HttpRequest::HttpRequestType type = _request->requestType();
|
||||||
|
|
||||||
// execute one of the CRUD methods
|
// execute one of the CRUD methods
|
||||||
switch (type) {
|
try {
|
||||||
case HttpRequest::HTTP_REQUEST_DELETE: deleteQuery(); break;
|
switch (type) {
|
||||||
case HttpRequest::HTTP_REQUEST_GET: readQuery(); break;
|
case HttpRequest::HTTP_REQUEST_DELETE: deleteQuery(); break;
|
||||||
case HttpRequest::HTTP_REQUEST_PUT: replaceProperties(); break;
|
case HttpRequest::HTTP_REQUEST_GET: readQuery(); break;
|
||||||
case HttpRequest::HTTP_REQUEST_POST: parseQuery(); break;
|
case HttpRequest::HTTP_REQUEST_PUT: replaceProperties(); break;
|
||||||
|
case HttpRequest::HTTP_REQUEST_POST: parseQuery(); break;
|
||||||
|
|
||||||
case HttpRequest::HTTP_REQUEST_HEAD:
|
case HttpRequest::HTTP_REQUEST_HEAD:
|
||||||
case HttpRequest::HTTP_REQUEST_PATCH:
|
case HttpRequest::HTTP_REQUEST_PATCH:
|
||||||
case HttpRequest::HTTP_REQUEST_ILLEGAL:
|
case HttpRequest::HTTP_REQUEST_ILLEGAL:
|
||||||
default: {
|
default: {
|
||||||
generateNotImplemented("ILLEGAL " + DOCUMENT_PATH);
|
generateNotImplemented("ILLEGAL " + DOCUMENT_PATH);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception const& err) {
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
catch (std::exception const& ex) {
|
||||||
|
triagens::basics::Exception err(TRI_ERROR_INTERNAL, ex.what(), __FILE__, __LINE__);
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
triagens::basics::Exception err(TRI_ERROR_INTERNAL, __FILE__, __LINE__);
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
|
|
||||||
// this handler is done
|
// this handler is done
|
||||||
return status_t(HANDLER_DONE);
|
return status_t(HANDLER_DONE);
|
||||||
|
@ -167,6 +179,7 @@ bool RestQueryHandler::readQueryProperties () {
|
||||||
result.add("maxQueryStringLength", VPackValue(queryList->maxQueryStringLength()));
|
result.add("maxQueryStringLength", VPackValue(queryList->maxQueryStringLength()));
|
||||||
result.close();
|
result.close();
|
||||||
VPackSlice slice = result.slice();
|
VPackSlice slice = result.slice();
|
||||||
|
|
||||||
generateResult(slice);
|
generateResult(slice);
|
||||||
}
|
}
|
||||||
catch (Exception const& err) {
|
catch (Exception const& err) {
|
||||||
|
@ -253,13 +266,14 @@ bool RestQueryHandler::readQueryProperties () {
|
||||||
bool RestQueryHandler::readQuery (bool slow) {
|
bool RestQueryHandler::readQuery (bool slow) {
|
||||||
try {
|
try {
|
||||||
auto queryList = static_cast<QueryList*>(_vocbase->_queries);
|
auto queryList = static_cast<QueryList*>(_vocbase->_queries);
|
||||||
auto const&& queries = slow ? queryList->listSlow() : queryList->listCurrent();
|
auto queries = slow ? queryList->listSlow() : queryList->listCurrent();
|
||||||
|
|
||||||
VPackBuilder result;
|
VPackBuilder result;
|
||||||
result.add(VPackValue(VPackValueType::Array));
|
result.add(VPackValue(VPackValueType::Array));
|
||||||
|
|
||||||
for (auto it : queries) {
|
for (auto const& it : queries) {
|
||||||
const auto&& timeString = TRI_StringTimeStamp(it.started);
|
auto const& timeString = TRI_StringTimeStamp(it.started);
|
||||||
const auto& queryString = it.queryString;
|
auto const& queryString = it.queryString;
|
||||||
|
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add("id", VPackValue(StringUtils::itoa(it.id)));
|
result.add("id", VPackValue(StringUtils::itoa(it.id)));
|
||||||
|
@ -302,7 +316,7 @@ bool RestQueryHandler::readQuery () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& name = suffix[0];
|
auto const& name = suffix[0];
|
||||||
|
|
||||||
if (name == "slow") {
|
if (name == "slow") {
|
||||||
return readQuery(true);
|
return readQuery(true);
|
||||||
|
@ -344,19 +358,14 @@ bool RestQueryHandler::deleteQuerySlow () {
|
||||||
auto queryList = static_cast<triagens::aql::QueryList*>(_vocbase->_queries);
|
auto queryList = static_cast<triagens::aql::QueryList*>(_vocbase->_queries);
|
||||||
queryList->clearSlow();
|
queryList->clearSlow();
|
||||||
|
|
||||||
try {
|
VPackBuilder result;
|
||||||
VPackBuilder result;
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add("error", VPackValue(false));
|
||||||
result.add("error", VPackValue(false));
|
result.add("code", VPackValue(HttpResponse::OK));
|
||||||
result.add("code", VPackValue(HttpResponse::OK));
|
result.close();
|
||||||
result.close();
|
VPackSlice slice = result.slice();
|
||||||
VPackSlice slice = result.slice();
|
generateResult(slice);
|
||||||
generateResult(slice);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// Ignore the error
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,18 +407,13 @@ bool RestQueryHandler::deleteQuery (const string& name) {
|
||||||
auto res = queryList->kill(id);
|
auto res = queryList->kill(id);
|
||||||
|
|
||||||
if (res == TRI_ERROR_NO_ERROR) {
|
if (res == TRI_ERROR_NO_ERROR) {
|
||||||
try {
|
VPackBuilder result;
|
||||||
VPackBuilder result;
|
result.add(VPackValue(VPackValueType::Object));
|
||||||
result.add(VPackValue(VPackValueType::Object));
|
result.add("error", VPackValue(false));
|
||||||
result.add("error", VPackValue(false));
|
result.add("code", VPackValue(HttpResponse::OK));
|
||||||
result.add("code", VPackValue(HttpResponse::OK));
|
result.close();
|
||||||
result.close();
|
VPackSlice slice = result.slice();
|
||||||
VPackSlice slice = result.slice();
|
generateResult(slice);
|
||||||
generateResult(slice);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// Ignore the error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
generateError(HttpResponse::BAD, res, "cannot kill query '" + name + "'");
|
generateError(HttpResponse::BAD, res, "cannot kill query '" + name + "'");
|
||||||
|
@ -432,14 +436,12 @@ bool RestQueryHandler::deleteQuery () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& name = suffix[0];
|
auto const& name = suffix[0];
|
||||||
|
|
||||||
if (name == "slow") {
|
if (name == "slow") {
|
||||||
return deleteQuerySlow();
|
return deleteQuerySlow();
|
||||||
}
|
}
|
||||||
else {
|
return deleteQuery(name);
|
||||||
return deleteQuery(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -544,8 +546,8 @@ bool RestQueryHandler::replaceProperties () {
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute = body.get("slowQueryThreshold");
|
attribute = body.get("slowQueryThreshold");
|
||||||
if (attribute.isDouble()) {
|
if (attribute.isNumber()) {
|
||||||
slowQueryThreshold = attribute.getDouble();
|
slowQueryThreshold = attribute.getNumber<double>();
|
||||||
}
|
}
|
||||||
|
|
||||||
attribute = body.get("maxQueryStringLength");
|
attribute = body.get("maxQueryStringLength");
|
||||||
|
|
Loading…
Reference in New Issue