salsa
0.3.0
|
NodeManager class. More...
#include <NodeManager.hh>
Public Member Functions | |
NodeManager () | |
virtual | ~NodeManager () |
void | print (std::string opt="") const |
void | addConsumer (std::string uuid, std::shared_ptr< Socket > s) |
void | addFeeder (std::string uuid, std::shared_ptr< Socket > s) |
void | addWorker (std::string uuid, std::shared_ptr< Socket > s) |
void | addTask (TaskInfo *taskInfo, std::string cuuid, std::string fuuid, Salsa::Job::QueueType t=Salsa::Job::pending) |
virtual Socket * | onEnter (std::string self, std::string fromType, Message *msg, std::vector< std::string > &out) |
virtual Socket * | onExit (std::string self, Message *msg, std::vector< std::string > &out) |
virtual Socket * | onWhisper (std::string self, Message *msg, std::vector< std::string > &out) |
std::shared_ptr< Feeder > | feeder (std::string uuid) const |
std::shared_ptr< Consumer > | consumer (std::string uuid) const |
std::shared_ptr< Worker > | worker (std::string uuid) const |
Job * | job (std::string uuid) |
TaskPool * | taskPool () |
Get NM's task pool. More... | |
virtual void | addTaskSlot () |
bool | hasJobs () const |
int32_t | nSlots (double mult=1.0) const |
void | jobs (std::string clientUUID, std::vector< std::string > &jobs) const |
TaskInfo * | getNextTask () |
void | resultTask (TaskInfo *task) |
void | noMoreTasks (std::string jobUUID) |
bool | haveMoreTasks () |
bool | haveMoreTasks (std::string jobUUID) |
virtual void | runTask (TaskState *ts, std::string wk, std::string upstream)=0 |
Run task interface. | |
virtual void | terminateJob (std::string uuid) |
virtual void | terminateJobAll () |
virtual bool | handleTaskPool (void *p) |
virtual bool | sendWhisper (Socket *s, std::string to, std::vector< std::string > &v) |
virtual void | publisher (Publisher *p) |
virtual Publisher * | publisher () const |
virtual void | publish (std::string id) const |
Static Public Member Functions | |
static std::shared_ptr < spdlog::logger > | getConsoleOutput () |
Get console output. | |
static void | setConsoleLevel (spdlog::level::level_enum level) |
Sets console log level. | |
Protected Attributes | |
std::map< std::string, Job * > | mJobs {} |
List of jobs. | |
std::vector< std::string > | mActiveJobs {} |
List of active jobs. | |
std::map< std::string, std::shared_ptr< Worker > > | mWorkers {} |
List of Workers. | |
std::map< std::string, std::shared_ptr< Consumer > > | mConsumers {} |
List of Consumers. | |
std::map< std::string, std::shared_ptr< Feeder > > | mFeeders {} |
List of Feeders. | |
TaskPool * | mpTaskPool = nullptr |
Task pool. | |
Publisher * | mpPublisher = nullptr |
Publisher. | |
NodeManager class.
Definition at line 20 of file NodeManager.hh.
Salsa::NodeManager::NodeManager | ( | ) |
Constructor
Definition at line 5 of file NodeManager.cc.
|
virtual |
Destructor
Definition at line 12 of file NodeManager.cc.
References mJobs, mpPublisher, mpTaskPool, and Salsa::TaskPool::terminateJob().
void Salsa::NodeManager::addConsumer | ( | std::string | uuid, |
std::shared_ptr< Socket > | s | ||
) |
Add consumer
Definition at line 53 of file NodeManager.cc.
References mConsumers.
Referenced by Salsa::NodeZyre::init().
void Salsa::NodeManager::addFeeder | ( | std::string | uuid, |
std::shared_ptr< Socket > | s | ||
) |
Add feeder
Definition at line 60 of file NodeManager.cc.
References mFeeders.
Referenced by Salsa::NodeZyre::init().
void Salsa::NodeManager::addTask | ( | TaskInfo * | taskInfo, |
std::string | cuuid, | ||
std::string | fuuid, | ||
Salsa::Job::QueueType | t = Salsa::Job::pending |
||
) |
Adds task
subscribe to all clients
Definition at line 220 of file NodeManager.cc.
References Salsa::Job::addTask(), Salsa::Job::consumer(), feeder(), Salsa::Job::feeder(), mActiveJobs, mFeeders, and mJobs.
Referenced by Salsa::NodeZyre::handleZmq(), Salsa::Worker::onWhisper(), and Salsa::Consumer::onWhisper().
|
virtual |
Reserve task slot
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 431 of file NodeManager.cc.
References mpTaskPool.
Referenced by Salsa::Worker::Worker().
void Salsa::NodeManager::addWorker | ( | std::string | uuid, |
std::shared_ptr< Socket > | s | ||
) |
Add worker
Definition at line 67 of file NodeManager.cc.
References mWorkers.
Referenced by Salsa::NodeZyre::init().
std::shared_ptr< Consumer > Salsa::NodeManager::consumer | ( | std::string | uuid | ) | const |
Returns consumer /param uuid UUID
Definition at line 393 of file NodeManager.cc.
References mConsumers.
Referenced by onEnter(), Salsa::Feeder::onExit(), onExit(), Salsa::Feeder::onWhisper(), onWhisper(), and resultTask().
std::shared_ptr< Feeder > Salsa::NodeManager::feeder | ( | std::string | uuid | ) | const |
Returns uuid is feeder /param uuid UUID
Definition at line 381 of file NodeManager.cc.
References mFeeders.
Referenced by addTask(), nSlots(), onEnter(), onExit(), and onWhisper().
TaskInfo * Salsa::NodeManager::getNextTask | ( | ) |
Return Next task from job
Definition at line 252 of file NodeManager.cc.
References mActiveJobs, and mJobs.
Referenced by Salsa::Feeder::onWhisper().
|
virtual |
Handle task pool
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 441 of file NodeManager.cc.
bool Salsa::NodeManager::hasJobs | ( | ) | const |
Returns if jobs are active
Definition at line 457 of file NodeManager.cc.
References mActiveJobs.
Referenced by Salsa::Feeder::onEnter().
bool Salsa::NodeManager::haveMoreTasks | ( | ) |
Sets no more tasks to any job
Definition at line 501 of file NodeManager.cc.
References Salsa::Job::haveMoreTasks(), job(), mActiveJobs, and mJobs.
Referenced by Salsa::Feeder::onExit().
bool Salsa::NodeManager::haveMoreTasks | ( | std::string | jobUUID | ) |
Sets no more tasks to job with jobuuid
Definition at line 529 of file NodeManager.cc.
References mJobs.
Job * Salsa::NodeManager::job | ( | std::string | uuid | ) |
Returns job /param uuid UUID
Definition at line 418 of file NodeManager.cc.
References mJobs.
Referenced by Salsa::TaskPool::handlePipe(), haveMoreTasks(), Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), publish(), resultTask(), and Salsa::Feeder::terminateJob().
void Salsa::NodeManager::jobs | ( | std::string | clientUUID, |
std::vector< std::string > & | jobs | ||
) | const |
Returns list of jobs
Definition at line 465 of file NodeManager.cc.
References mJobs.
Referenced by Salsa::Consumer::onExit().
void Salsa::NodeManager::noMoreTasks | ( | std::string | jobUUID | ) |
Sets no more tasks to job with jobuuid
Definition at line 490 of file NodeManager.cc.
References mJobs.
Referenced by Salsa::Consumer::onWhisper().
int32_t Salsa::NodeManager::nSlots | ( | double | mult = 1.0 | ) | const |
Returns numer of slots
Definition at line 477 of file NodeManager.cc.
References feeder(), and mFeeders.
Referenced by Salsa::Consumer::onWhisper(), and resultTask().
|
virtual |
On ENTER event
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 76 of file NodeManager.cc.
References consumer(), feeder(), Salsa::Message::uuid(), and worker().
Referenced by Salsa::NodeManagerZyre::onEnter().
|
virtual |
On EXIT event
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 141 of file NodeManager.cc.
References consumer(), feeder(), Salsa::Message::uuid(), and worker().
Referenced by Salsa::NodeManagerZyre::onExit().
|
virtual |
On WHISPER event
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 179 of file NodeManager.cc.
References consumer(), feeder(), Salsa::Message::uuid(), and worker().
Referenced by Salsa::NodeManagerZyre::onWhisper().
void Salsa::NodeManager::print | ( | std::string | opt = "" | ) | const |
Prints NodeManager information
Definition at line 30 of file NodeManager.cc.
References mConsumers, mFeeders, mJobs, mpTaskPool, mWorkers, and Salsa::TaskPool::print().
Referenced by Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), publish(), resultTask(), and terminateJob().
|
virtual |
Publishes node manager state
Definition at line 557 of file NodeManager.cc.
References job(), Salsa::Job::json(), mJobs, mpPublisher, print(), and Salsa::Publisher::publish().
Referenced by Salsa::NodeZyre::exec().
|
virtual |
|
virtual |
void Salsa::NodeManager::resultTask | ( | TaskInfo * | task | ) |
Handle result of pTask
Definition at line 278 of file NodeManager.cc.
References Salsa::Job::consumer(), consumer(), Salsa::Job::feeder(), Salsa::Job::haveMoreTasks(), Salsa::Job::isTaskInQueue(), job(), Salsa::Job::moveTask(), nSlots(), print(), Salsa::Job::removeTask(), sendWhisper(), and Salsa::Job::size().
Referenced by Salsa::Feeder::onWhisper().
|
virtual |
Sends message
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 211 of file NodeManager.cc.
Referenced by Salsa::TaskPool::handlePipe(), Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), resultTask(), Salsa::Feeder::subscribe(), and Salsa::Feeder::terminateJob().
TaskPool * Salsa::NodeManager::taskPool | ( | ) |
Get NM's task pool.
Returns task pool
Definition at line 449 of file NodeManager.cc.
References mpTaskPool.
Referenced by Salsa::Worker::onWhisper().
|
virtual |
Cleans job
Definition at line 337 of file NodeManager.cc.
References mFeeders, mJobs, mpTaskPool, print(), and Salsa::TaskPool::terminateJob().
Referenced by Salsa::NodeZyre::handleZmq(), Salsa::Consumer::onExit(), Salsa::Worker::onWhisper(), and terminateJobAll().
|
virtual |
Terminate all jobs
Definition at line 364 of file NodeManager.cc.
References mJobs, and terminateJob().
Referenced by Salsa::NodeZyre::handleZmq().
std::shared_ptr< Worker > Salsa::NodeManager::worker | ( | std::string | uuid | ) | const |
Returns worker /param uuid UUID
Definition at line 405 of file NodeManager.cc.
References mWorkers.
Referenced by Salsa::TaskPool::handlePipe(), onEnter(), onExit(), and onWhisper().