1
0
Fork 0

introducing cluster sanity checking to agency

This commit is contained in:
Kaveh Vahedipour 2016-04-12 11:35:27 +02:00
parent 9a608f3037
commit 66636cdb7d
5 changed files with 108 additions and 1 deletions

View File

@ -16,6 +16,7 @@ void SanityCheck::wakeUp () {
} }
bool SanityCheck::doChecks (bool timedout) { bool SanityCheck::doChecks (bool timedout) {
LOG_TOPIC(INFO, Logger::AGENCY) << "Sanity checks";
return true; return true;
} }

View File

@ -37,6 +37,34 @@
using namespace arangodb::consensus; using namespace arangodb::consensus;
inline static enpointPathFromUrl (
std::string const& url, std::string& enpoint, std::string& path) {
std::stringstream ep;
path = "/";
size_t pos = 7;
if (i.find("http://")==0) {
ep << "tcp://";
} else if (i.find("https://")==0) {
ep << "ssl://";
++pos;
} else {
LOG_TOPIC(WARN,Logger::AGENCY) << "Malformed notification URL " << i;
return;
}
size_t slash_p = i.find("/",pos);
if ((slash_p==std::string::npos)) {
ep << i.substr(pos);
} else {
ep << i.substr(pos,slash_p-pos);
path = i.substr(slash_p);
}
endpoint = ep.str();
}
struct NotEmpty { struct NotEmpty {
bool operator()(const std::string& s) { return !s.empty(); } bool operator()(const std::string& s) { return !s.empty(); }
}; };
@ -707,6 +735,7 @@ std::vector<bool> Store::apply (
} }
for (auto const& url : urls) { for (auto const& url : urls) {
Builder tmp; // host Builder tmp; // host
tmp.openObject(); tmp.openObject();
tmp.add("term",VPackValue(0)); tmp.add("term",VPackValue(0));
@ -720,6 +749,19 @@ std::vector<bool> Store::apply (
} }
tmp.close(); tmp.close();
std::string endpoint, path;
endpointPathFromUrl (url,endpoint,path);
std::unique_ptr<std::map<std::string, std::string>> headerFields =
std::make_unique<std::map<std::string, std::string> >();
ClusterCommResult res =
arangodb::ClusterComm::instance()->asyncRequest(
"1", 1, endpoint, GeneralRequest::RequestType::POST, path,
std::make_shared<std::string>(body.toString()), headerFields,
nullptr, 0.0, true);
} }
return applied; return applied;

View File

@ -0,0 +1,12 @@
#include "StoreCallback.h"
#include "Store.h"
using namespace arangodb::consensus;
using namespace arangodb::velocypack;
StoreCallback::StoreCallback() {}
bool StoreCallback::operator()(arangodb::ClusterCommResult* res) {
return true;
}

View File

@ -0,0 +1,51 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 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 ArangoDB GmbH, Cologne, Germany
///
/// @author Kaveh Vahedipour
////////////////////////////////////////////////////////////////////////////////
#ifndef __ARANGODB_CONSENSUS_STORE_CALLBACK__
#define __ARANGODB_CONSENSUS_STORE_CALLBACK__
#include "Cluster/ClusterComm.h"
#include "AgencyCommon.h"
namespace arangodb {
namespace consensus {
class StoreCallback : public arangodb::ClusterCommCallback {
public:
StoreCallback();
explicit StoreCallback();
virtual bool operator()(arangodb::ClusterCommResult*) override final;
void shutdown();
private:
};
}} // namespace
#endif

View File

@ -69,12 +69,13 @@ add_executable(${BIN_ARANGOD}
Actions/RestActionHandler.cpp Actions/RestActionHandler.cpp
Actions/actions.cpp Actions/actions.cpp
Agency/Agent.cpp Agency/Agent.cpp
Agency/AgentCallback.cpp
Agency/ApplicationAgency.cpp Agency/ApplicationAgency.cpp
Agency/Constituent.cpp Agency/Constituent.cpp
Agency/SanityCheck.cpp Agency/SanityCheck.cpp
Agency/State.cpp Agency/State.cpp
Agency/Store.cpp Agency/Store.cpp
Agency/AgentCallback.cpp Agency/StoreCallback.cpp
ApplicationServer/ApplicationFeature.cpp ApplicationServer/ApplicationFeature.cpp
ApplicationServer/ApplicationServer.cpp ApplicationServer/ApplicationServer.cpp
Aql/Aggregator.cpp Aql/Aggregator.cpp