mirror of https://gitee.com/bigwinds/arangodb
added request-source (#2599)
This commit is contained in:
parent
a0c4e3d9df
commit
b48583e68f
|
@ -38,6 +38,8 @@ using namespace arangodb::basics;
|
|||
using namespace arangodb::options;
|
||||
using namespace arangodb::rest;
|
||||
|
||||
consensus::Agent* AgencyFeature::AGENT = nullptr;
|
||||
|
||||
AgencyFeature::AgencyFeature(application_features::ApplicationServer* server)
|
||||
: ApplicationFeature(server, "Agency"),
|
||||
_activated(false),
|
||||
|
@ -216,7 +218,6 @@ void AgencyFeature::prepare() {
|
|||
}
|
||||
|
||||
void AgencyFeature::start() {
|
||||
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
@ -265,6 +266,8 @@ void AgencyFeature::start() {
|
|||
_compactionStepSize, _compactionKeepSize, _supervisionGracePeriod,
|
||||
_cmdLineTimings, _maxAppendSize)));
|
||||
|
||||
AGENT = _agent.get();
|
||||
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Starting agency personality";
|
||||
_agent->start();
|
||||
|
||||
|
@ -307,4 +310,6 @@ void AgencyFeature::stop() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
AGENT = nullptr;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ class Agent;
|
|||
}
|
||||
|
||||
class AgencyFeature : virtual public application_features::ApplicationFeature {
|
||||
public:
|
||||
static consensus::Agent* AGENT;
|
||||
|
||||
public:
|
||||
explicit AgencyFeature(application_features::ApplicationServer* server);
|
||||
~AgencyFeature();
|
||||
|
@ -47,7 +50,6 @@ class AgencyFeature : virtual public application_features::ApplicationFeature {
|
|||
bool _activated;
|
||||
uint64_t _size; // agency size (default: 5)
|
||||
uint64_t _poolSize;
|
||||
std::string _agentId;
|
||||
double _minElectionTimeout; // min election timeout
|
||||
double _maxElectionTimeout; // max election timeout
|
||||
bool _supervision;
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "ClusterComm.h"
|
||||
|
||||
#include "Agency/AgencyFeature.h"
|
||||
#include "Agency/Agent.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/HybridLogicalClock.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
|
@ -1099,6 +1102,18 @@ std::pair<ClusterCommResult*, HttpRequest*> ClusterComm::prepareRequest(std::str
|
|||
headersCopy[StaticStrings::HLCHeader] =
|
||||
arangodb::basics::HybridLogicalClock::encodeTimeStamp(timeStamp);
|
||||
|
||||
auto state = ServerState::instance();
|
||||
|
||||
if (state->isCoordinator() || state->isDBServer()) {
|
||||
headersCopy[StaticStrings::ClusterCommSource] = state->getId();
|
||||
} else if (state->isAgent()) {
|
||||
auto agent = AgencyFeature::AGENT;
|
||||
|
||||
if (agent != nullptr) {
|
||||
headersCopy[StaticStrings::ClusterCommSource] = "AGENT-" + agent->id();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_CLUSTER_COMM
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
#if ARANGODB_ENABLE_BACKTRACE
|
||||
|
|
|
@ -259,8 +259,9 @@ bool HttpCommTask::processRead(double startTime) {
|
|||
size_t headerLength = ptr - (_readBuffer.c_str() + _startPosition);
|
||||
|
||||
if (headerLength > MaximalHeaderSize) {
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "maximal header size is " << MaximalHeaderSize
|
||||
<< ", request header size is " << headerLength;
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME)
|
||||
<< "maximal header size is " << MaximalHeaderSize
|
||||
<< ", request header size is " << headerLength;
|
||||
|
||||
HttpRequest tmpRequest(_connectionInfo, nullptr, 0, _allowMethodOverride);
|
||||
// header is too large
|
||||
|
@ -626,6 +627,16 @@ void HttpCommTask::processRequest(std::unique_ptr<HttpRequest> request) {
|
|||
}
|
||||
}
|
||||
|
||||
// check source
|
||||
std::string const& source =
|
||||
request->header(StaticStrings::ClusterCommSource, found);
|
||||
|
||||
if (found) {
|
||||
LOG_TOPIC(TRACE, Logger::REQUESTS)
|
||||
<< "\"http-request-source\",\"" << (void*)this << "\",\""
|
||||
<< source << "\"";
|
||||
}
|
||||
|
||||
// create a handler and execute
|
||||
std::unique_ptr<GeneralResponse> response(
|
||||
new HttpResponse(rest::ResponseCode::SERVER_ERROR));
|
||||
|
|
|
@ -83,6 +83,7 @@ std::string const StaticStrings::BatchContentType(
|
|||
"application/x-arango-batchpart");
|
||||
std::string const StaticStrings::CacheControl("cache-control");
|
||||
std::string const StaticStrings::Close("Close");
|
||||
std::string const StaticStrings::ClusterCommSource("x-arango-source");
|
||||
std::string const StaticStrings::Code("code");
|
||||
std::string const StaticStrings::Connection("connection");
|
||||
std::string const StaticStrings::ContentEncoding("content-encoding");
|
||||
|
|
|
@ -82,6 +82,7 @@ class StaticStrings {
|
|||
static std::string const BatchContentType;
|
||||
static std::string const CacheControl;
|
||||
static std::string const Close;
|
||||
static std::string const ClusterCommSource;
|
||||
static std::string const Code;
|
||||
static std::string const Connection;
|
||||
static std::string const ContentEncoding;
|
||||
|
|
Loading…
Reference in New Issue