mirror of https://gitee.com/bigwinds/arangodb
Introduced PregelFeature
This commit is contained in:
parent
c7379f6a06
commit
f67acf39be
|
@ -371,7 +371,7 @@ add_executable(${BIN_ARANGOD}
|
||||||
Wal/Slots.cpp
|
Wal/Slots.cpp
|
||||||
Wal/SynchronizerThread.cpp
|
Wal/SynchronizerThread.cpp
|
||||||
Pregel/Conductor.cpp
|
Pregel/Conductor.cpp
|
||||||
Pregel/JobMapping.cpp
|
Pregel/PregelFeature.cpp
|
||||||
Pregel/InMessageCache.cpp
|
Pregel/InMessageCache.cpp
|
||||||
Pregel/OutMessageCache.cpp
|
Pregel/OutMessageCache.cpp
|
||||||
Pregel/Vertex.cpp
|
Pregel/Vertex.cpp
|
||||||
|
|
|
@ -20,39 +20,63 @@
|
||||||
/// @author Simon Grätzer
|
/// @author Simon Grätzer
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "JobMapping.h"
|
#include "PregelFeature.h"
|
||||||
#include "Conductor.h"
|
#include "Conductor.h"
|
||||||
#include "Worker.h"
|
#include "Worker.h"
|
||||||
|
|
||||||
using namespace arangodb::pregel;
|
using namespace arangodb::pregel;
|
||||||
|
|
||||||
|
static PregelFeature *Instance;
|
||||||
|
|
||||||
static unsigned int _exeI = 0;
|
static unsigned int _exeI = 0;
|
||||||
unsigned int JobMapping::createExecutionNumber() {
|
unsigned int PregelFeature::createExecutionNumber() {
|
||||||
return ++_exeI;
|
return ++_exeI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobMapping::addExecution(Conductor* const exec, unsigned int executionNumber) {
|
PregelFeature::PregelFeature(application_features::ApplicationServer* server)
|
||||||
|
: ApplicationFeature(server, "Pregel") {
|
||||||
|
setOptional(true);
|
||||||
|
requiresElevatedPrivileges(false);
|
||||||
|
startsAfter("Database");
|
||||||
|
startsAfter("Logger");
|
||||||
|
startsAfter("Dispatcher");
|
||||||
|
Instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
PregelFeature::~PregelFeature() {
|
||||||
|
cleanupAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
PregelFeature* PregelFeature::instance() {
|
||||||
|
return Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PregelFeature::beginShutdown() {
|
||||||
|
cleanupAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PregelFeature::addExecution(Conductor* const exec, unsigned int executionNumber) {
|
||||||
//_executions.
|
//_executions.
|
||||||
_conductors[executionNumber] = exec;
|
_conductors[executionNumber] = exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
Conductor* JobMapping::conductor(int executionNumber) {
|
Conductor* PregelFeature::conductor(int executionNumber) {
|
||||||
auto it = _conductors.find(executionNumber);
|
auto it = _conductors.find(executionNumber);
|
||||||
if (it != _conductors.end()) return it->second;
|
if (it != _conductors.end()) return it->second;
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobMapping::addWorker(Worker* const worker, unsigned int executionNumber) {
|
void PregelFeature::addWorker(Worker* const worker, unsigned int executionNumber) {
|
||||||
_workers[executionNumber] = worker;
|
_workers[executionNumber] = worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
Worker* JobMapping::worker(unsigned int executionNumber) {
|
Worker* PregelFeature::worker(unsigned int executionNumber) {
|
||||||
auto it = _workers.find(executionNumber);
|
auto it = _workers.find(executionNumber);
|
||||||
if (it != _workers.end()) return it->second;
|
if (it != _workers.end()) return it->second;
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobMapping::cleanup(unsigned int executionNumber) {
|
void PregelFeature::cleanup(unsigned int executionNumber) {
|
||||||
auto cit = _conductors.find(executionNumber);
|
auto cit = _conductors.find(executionNumber);
|
||||||
if (cit != _conductors.end()) {
|
if (cit != _conductors.end()) {
|
||||||
delete(cit->second);
|
delete(cit->second);
|
||||||
|
@ -64,3 +88,14 @@ void JobMapping::cleanup(unsigned int executionNumber) {
|
||||||
_workers.erase(executionNumber);
|
_workers.erase(executionNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PregelFeature::cleanupAll() {
|
||||||
|
for (auto it : _conductors) {
|
||||||
|
delete(it.second);
|
||||||
|
}
|
||||||
|
_conductors.clear();
|
||||||
|
for (auto it : _workers) {
|
||||||
|
delete(it.second);
|
||||||
|
}
|
||||||
|
_workers.clear();
|
||||||
|
}
|
|
@ -20,10 +20,13 @@
|
||||||
/// @author Simon Grätzer
|
/// @author Simon Grätzer
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef ARANGODB_PREGEL_JOBMAPPING_H
|
#ifndef ARANGODB_PREGEL_FEATURE_H
|
||||||
#define ARANGODB_PREGEL_JOBMAPPING_H 1
|
#define ARANGODB_PREGEL_FEATURE_H 1
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include "Basics/Common.h"
|
||||||
|
#include "ApplicationFeatures/ApplicationFeature.h"
|
||||||
|
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
namespace pregel {
|
namespace pregel {
|
||||||
|
@ -31,14 +34,15 @@ namespace pregel {
|
||||||
class Conductor;
|
class Conductor;
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
||||||
class JobMapping {
|
class PregelFeature final
|
||||||
|
: public application_features::ApplicationFeature {
|
||||||
public:
|
public:
|
||||||
|
explicit PregelFeature(application_features::ApplicationServer* server);
|
||||||
|
~PregelFeature();
|
||||||
|
|
||||||
|
static PregelFeature* instance();
|
||||||
|
|
||||||
|
void beginShutdown() override final;
|
||||||
static JobMapping* instance() {
|
|
||||||
static JobMapping *Instance = new JobMapping();
|
|
||||||
return Instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
unsigned int createExecutionNumber();
|
unsigned int createExecutionNumber();
|
||||||
void addExecution(Conductor* const exec, unsigned int executionNumber);
|
void addExecution(Conductor* const exec, unsigned int executionNumber);
|
||||||
|
@ -48,13 +52,11 @@ namespace pregel {
|
||||||
Worker* worker(unsigned int executionNumber);
|
Worker* worker(unsigned int executionNumber);
|
||||||
|
|
||||||
void cleanup(unsigned int executionNumber);
|
void cleanup(unsigned int executionNumber);
|
||||||
|
void cleanupAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<unsigned int, Conductor*> _conductors;
|
std::unordered_map<unsigned int, Conductor*> _conductors;
|
||||||
std::unordered_map<unsigned int, Worker*> _workers;
|
std::unordered_map<unsigned int, Worker*> _workers;
|
||||||
|
|
||||||
JobMapping() {};
|
|
||||||
JobMapping(const JobMapping &c) {};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -199,9 +199,9 @@ void Worker::nextGlobalStep(VPackSlice data) {
|
||||||
|
|
||||||
std::unique_ptr<rest::Job> job(new WorkerJob(this, _ctx));
|
std::unique_ptr<rest::Job> job(new WorkerJob(this, _ctx));
|
||||||
int res = DispatcherFeature::DISPATCHER->addJob(job, true);
|
int res = DispatcherFeature::DISPATCHER->addJob(job, true);
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
LOG(ERR) << "Could not start worker job";
|
LOG(ERR) << "Could not start worker job";
|
||||||
}
|
}
|
||||||
LOG(INFO) << "Worker started new gss: " << gss;
|
LOG(INFO) << "Worker started new gss: " << gss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <velocypack/Builder.h>
|
#include <velocypack/Builder.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
#include "Pregel/JobMapping.h"
|
#include "Pregel/PregelFeature.h"
|
||||||
#include "Pregel/Conductor.h"
|
#include "Pregel/Conductor.h"
|
||||||
#include "Pregel/Worker.h"
|
#include "Pregel/Worker.h"
|
||||||
#include "Pregel/Utils.h"
|
#include "Pregel/Utils.h"
|
||||||
|
@ -69,31 +69,29 @@ RestHandler::status RestPregelHandler::execute() {
|
||||||
generateError(rest::ResponseCode::NOT_FOUND,
|
generateError(rest::ResponseCode::NOT_FOUND,
|
||||||
TRI_ERROR_HTTP_NOT_FOUND);
|
TRI_ERROR_HTTP_NOT_FOUND);
|
||||||
return status::DONE;
|
return status::DONE;
|
||||||
} else if (suffix[0] == "finishedGSS") {
|
} else if (suffix[0] == Utils::finishedGSSPath) {
|
||||||
LOG(INFO) << "finishedGSS";
|
Conductor *exe = PregelFeature::instance()->conductor(executionNumber);
|
||||||
Conductor *exe = JobMapping::instance()->conductor(executionNumber);
|
|
||||||
if (exe) {
|
if (exe) {
|
||||||
exe->finishedGlobalStep(body);
|
exe->finishedGlobalStep(body);
|
||||||
} else {
|
} else {
|
||||||
LOG(ERR) << "Conductor not found: " << executionNumber;
|
LOG(ERR) << "Conductor not found: " << executionNumber;
|
||||||
}
|
}
|
||||||
} else if (suffix[0] == "nextGSS") {
|
} else if (suffix[0] == Utils::nextGSSPath) {
|
||||||
LOG(INFO) << "nextGSS";
|
Worker *w = PregelFeature::instance()->worker(executionNumber);
|
||||||
Worker *w = JobMapping::instance()->worker(executionNumber);
|
|
||||||
if (!w) {// can happen if gss == 0
|
if (!w) {// can happen if gss == 0
|
||||||
LOG(INFO) << "creating worker";
|
LOG(INFO) << "creating worker";
|
||||||
w = new Worker(executionNumber, _vocbase, body);
|
w = new Worker(executionNumber, _vocbase, body);
|
||||||
JobMapping::instance()->addWorker(w, executionNumber);
|
PregelFeature::instance()->addWorker(w, executionNumber);
|
||||||
}
|
}
|
||||||
w->nextGlobalStep(body);
|
w->nextGlobalStep(body);
|
||||||
} else if (suffix[0] == "messages") {
|
} else if (suffix[0] == "messages") {
|
||||||
LOG(INFO) << "messages";
|
LOG(INFO) << "messages";
|
||||||
Worker *exe = JobMapping::instance()->worker(executionNumber);
|
Worker *exe = PregelFeature::instance()->worker(executionNumber);
|
||||||
if (exe) {
|
if (exe) {
|
||||||
exe->receivedMessages(body);
|
exe->receivedMessages(body);
|
||||||
}
|
}
|
||||||
} else if (suffix[0] == "writeResults") {
|
} else if (suffix[0] == "writeResults") {
|
||||||
Worker *exe = JobMapping::instance()->worker(executionNumber);
|
Worker *exe = PregelFeature::instance()->worker(executionNumber);
|
||||||
if (exe) {
|
if (exe) {
|
||||||
exe->writeResults();
|
exe->writeResults();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include "RestServer/UnitTestsFeature.h"
|
#include "RestServer/UnitTestsFeature.h"
|
||||||
#include "RestServer/UpgradeFeature.h"
|
#include "RestServer/UpgradeFeature.h"
|
||||||
#include "RestServer/WorkMonitorFeature.h"
|
#include "RestServer/WorkMonitorFeature.h"
|
||||||
|
#include "Pregel/PregelFeature.h"
|
||||||
#include "Scheduler/SchedulerFeature.h"
|
#include "Scheduler/SchedulerFeature.h"
|
||||||
#include "Ssl/SslFeature.h"
|
#include "Ssl/SslFeature.h"
|
||||||
#include "Ssl/SslServerFeature.h"
|
#include "Ssl/SslServerFeature.h"
|
||||||
|
@ -146,6 +147,7 @@ static int runServer(int argc, char** argv) {
|
||||||
server.addFeature(new LoggerFeature(&server, true));
|
server.addFeature(new LoggerFeature(&server, true));
|
||||||
server.addFeature(new NonceFeature(&server));
|
server.addFeature(new NonceFeature(&server));
|
||||||
server.addFeature(new PageSizeFeature(&server));
|
server.addFeature(new PageSizeFeature(&server));
|
||||||
|
server.addFeature(new pregel::PregelFeature(&server));
|
||||||
server.addFeature(new PrivilegeFeature(&server));
|
server.addFeature(new PrivilegeFeature(&server));
|
||||||
server.addFeature(new QueryRegistryFeature(&server));
|
server.addFeature(new QueryRegistryFeature(&server));
|
||||||
server.addFeature(new TraverserEngineRegistryFeature(&server));
|
server.addFeature(new TraverserEngineRegistryFeature(&server));
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#include "VocBase/modes.h"
|
#include "VocBase/modes.h"
|
||||||
#include "Wal/LogfileManager.h"
|
#include "Wal/LogfileManager.h"
|
||||||
#include "Pregel/Conductor.h"
|
#include "Pregel/Conductor.h"
|
||||||
#include "Pregel/JobMapping.h"
|
#include "Pregel/PregelFeature.h"
|
||||||
|
|
||||||
#include <velocypack/Builder.h>
|
#include <velocypack/Builder.h>
|
||||||
#include <velocypack/HexDump.h>
|
#include <velocypack/HexDump.h>
|
||||||
|
@ -1869,9 +1869,9 @@ static void JS_Pregel(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
TRI_V8_THROW_EXCEPTION_USAGE("Collections do not exist");
|
TRI_V8_THROW_EXCEPTION_USAGE("Collections do not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
result = pregel::JobMapping::instance()->createExecutionNumber();
|
result = pregel::PregelFeature::instance()->createExecutionNumber();
|
||||||
pregel::Conductor* e = new pregel::Conductor(result, vocbase, vertexColl, edgeColl, "todo");
|
pregel::Conductor* e = new pregel::Conductor(result, vocbase, vertexColl, edgeColl, "todo");
|
||||||
pregel::JobMapping::instance()->addExecution(e, result);
|
pregel::PregelFeature::instance()->addExecution(e, result);
|
||||||
|
|
||||||
LOG(INFO) << "Starting...";
|
LOG(INFO) << "Starting...";
|
||||||
e->start();
|
e->start();
|
||||||
|
|
Loading…
Reference in New Issue