salsa 0.7.1
|
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::EQueueType 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. | |
virtual void | addTaskSlot () |
bool | hasJobs () const |
virtual bool | terminateFinishedJobs () |
uint64_t | finishedJobTimeout () const |
Returns finished job timeout. | |
void | finishedJobTimeout (uint64_t t) |
Sets finished job timeout. | |
int32_t | nSlots (double mult=1.0) const |
void | jobs (std::string clientUUID, std::vector< std::string > &jobs) const |
TaskInfo * | getNextTask () |
virtual void | resultTask (TaskInfo *task) |
virtual void | resultTaskToExternal (Job *, TaskInfo *) |
Handle return of task and send it to external client. | |
virtual void | noMoreTasks (std::string jobUUID) |
virtual bool | haveMoreTasks () |
virtual 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 | terminateAllJobs (bool finishedonly=false) |
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 bool | publish (std::string id, bool force=false) const |
void | clusterAlias (std::string n) |
Sets Cluster alias. | |
std::string | clusterAlias () |
Returns Cluster alias. | |
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::string | mClusterAlias {"local"} |
Cluster alias. | |
std::map< std::string, Job * > | mJobs {} |
List of jobs. | |
std::vector< std::string > | mActiveJobs {} |
List of active jobs. | |
std::vector< std::string > | mFinishedJobs {} |
List of finished jobs. | |
uint64_t | mFinishedJobTimeout |
Finished job timeout in seconds. | |
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. | |
Static Private Attributes | |
static std::shared_ptr< spdlog::logger > | mspConsoleLogger = spdlog::stdout_color_mt("salsa") |
Pointer to spd logger. | |
NodeManager class.
Definition at line 22 of file NodeManager.hh.
Salsa::NodeManager::NodeManager | ( | ) |
Constructor
Definition at line 4 of file NodeManager.cc.
References mFinishedJobTimeout, and Salsa::Object::Object().
Referenced by Salsa::NodeManagerZyre::NodeManagerZyre().
|
virtual |
Destructor
Definition at line 14 of file NodeManager.cc.
References job(), mJobs, mpPublisher, and mpTaskPool.
void Salsa::NodeManager::addConsumer | ( | std::string | uuid, |
std::shared_ptr< Socket > | s ) |
void Salsa::NodeManager::addFeeder | ( | std::string | uuid, |
std::shared_ptr< Socket > | s ) |
void Salsa::NodeManager::addTask | ( | TaskInfo * | taskInfo, |
std::string | cuuid, | ||
std::string | fuuid, | ||
Salsa::Job::EQueueType | t = Salsa::Job::pending ) |
Adds task
subscribe to all clients
Definition at line 228 of file NodeManager.cc.
References Salsa::Job::addTask(), Salsa::Job::consumer(), Salsa::Job::feeder(), feeder(), mActiveJobs, mFeeders, and mJobs.
|
virtual |
Reserve task slot
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 495 of file NodeManager.cc.
References mpTaskPool.
void Salsa::NodeManager::addWorker | ( | std::string | uuid, |
std::shared_ptr< Socket > | s ) |
|
inline |
|
inline |
std::shared_ptr< Consumer > Salsa::NodeManager::consumer | ( | std::string | uuid | ) | const |
Returns consumer /param uuid UUID
Definition at line 457 of file NodeManager.cc.
References mConsumers.
Referenced by onEnter(), onExit(), onWhisper(), and resultTask().
std::shared_ptr< Feeder > Salsa::NodeManager::feeder | ( | std::string | uuid | ) | const |
Returns uuid is feeder /param uuid UUID
Definition at line 443 of file NodeManager.cc.
References mFeeders.
Referenced by addTask(), nSlots(), onEnter(), onExit(), onWhisper(), and publish().
|
inline |
Returns finished job timeout.
Definition at line 55 of file NodeManager.hh.
References mFinishedJobTimeout.
|
inline |
Sets finished job timeout.
Definition at line 57 of file NodeManager.hh.
References mFinishedJobTimeout.
|
inlinestaticinherited |
Get console output.
Definition at line 21 of file Object.hh.
References mspConsoleLogger.
Referenced by Salsa::ConfigZyre::apply().
TaskInfo * Salsa::NodeManager::getNextTask | ( | ) |
Return Next task from job
Definition at line 260 of file NodeManager.cc.
References mActiveJobs, and mJobs.
|
virtual |
Handle task pool
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 505 of file NodeManager.cc.
bool Salsa::NodeManager::hasJobs | ( | ) | const |
|
virtual |
Sets no more tasks to any job
Definition at line 567 of file NodeManager.cc.
References job(), mActiveJobs, and mJobs.
|
virtual |
Sets no more tasks to job with jobuuid
Definition at line 595 of file NodeManager.cc.
References mJobs.
Job * Salsa::NodeManager::job | ( | std::string | uuid | ) |
Returns job /param uuid UUID
Definition at line 482 of file NodeManager.cc.
References mJobs.
Referenced by haveMoreTasks(), publish(), resultTask(), Salsa::NodeManagerZyre::resultTaskToExternal(), terminateAllJobs(), terminateFinishedJobs(), and ~NodeManager().
void Salsa::NodeManager::jobs | ( | std::string | clientUUID, |
std::vector< std::string > & | jobs ) const |
|
virtual |
Sets no more tasks to job with jobuuid
Definition at line 554 of file NodeManager.cc.
int32_t Salsa::NodeManager::nSlots | ( | double | mult = 1.0 | ) | const |
Returns numer of slots
Definition at line 541 of file NodeManager.cc.
References feeder(), and mFeeders.
Referenced by resultTask().
|
virtual |
On ENTER event
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 84 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 149 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 187 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 32 of file NodeManager.cc.
References mConsumers, mFeeders, mJobs, mpTaskPool, and mWorkers.
Referenced by resultTask(), and terminateJob().
|
virtual |
Publishes node manager state
Definition at line 625 of file NodeManager.cc.
References feeder(), job(), mClusterAlias, mJobs, and mpPublisher.
|
virtual |
|
virtual |
|
virtual |
Handle result of pTask
Moving to finished jobs. They will be removed after some inactivity time
Definition at line 288 of file NodeManager.cc.
References Salsa::Job::consumer(), consumer(), Salsa::Job::feeder(), Salsa::Job::haveMoreTasks(), Salsa::Job::isFinished(), Salsa::Job::isTaskInQueue(), job(), mFinishedJobs, Salsa::Job::moveTask(), nSlots(), print(), Salsa::Job::removeTask(), resultTaskToExternal(), sendWhisper(), Salsa::Job::size(), and Salsa::Job::uuid().
|
inlinevirtual |
Handle return of task and send it to external client.
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 66 of file NodeManager.hh.
Referenced by resultTask().
|
pure virtual |
Run task interface.
Implemented in Salsa::NodeManagerZyre.
|
virtual |
Sends message
Reimplemented in Salsa::NodeManagerZyre.
Definition at line 219 of file NodeManager.cc.
Referenced by resultTask().
|
inlinestaticinherited |
TaskPool * Salsa::NodeManager::taskPool | ( | ) |
Get NM's task pool.
Returns task pool
Definition at line 513 of file NodeManager.cc.
References mpTaskPool.
|
virtual |
Terminate all jobs
Definition at line 422 of file NodeManager.cc.
References job(), mFinishedJobs, mJobs, and terminateJob().
|
virtual |
Clear finished jobs
Definition at line 391 of file NodeManager.cc.
References job(), mFinishedJobs, mFinishedJobTimeout, and terminateJob().
|
virtual |
Cleans job
Definition at line 362 of file NodeManager.cc.
References mFeeders, mFinishedJobs, mJobs, mpTaskPool, and print().
Referenced by terminateAllJobs(), and terminateFinishedJobs().
std::shared_ptr< Worker > Salsa::NodeManager::worker | ( | std::string | uuid | ) | const |
Returns worker /param uuid UUID
Definition at line 469 of file NodeManager.cc.
References mWorkers.
Referenced by onEnter(), onExit(), and onWhisper().
|
protected |
List of active jobs.
Definition at line 93 of file NodeManager.hh.
Referenced by addTask(), getNextTask(), hasJobs(), and haveMoreTasks().
|
protected |
Cluster alias.
Definition at line 91 of file NodeManager.hh.
Referenced by clusterAlias(), clusterAlias(), and publish().
|
protected |
List of Consumers.
Definition at line 97 of file NodeManager.hh.
Referenced by addConsumer(), consumer(), and print().
|
protected |
List of Feeders.
Definition at line 98 of file NodeManager.hh.
Referenced by addFeeder(), addTask(), feeder(), nSlots(), print(), and terminateJob().
|
protected |
List of finished jobs.
Definition at line 94 of file NodeManager.hh.
Referenced by resultTask(), terminateAllJobs(), terminateFinishedJobs(), and terminateJob().
|
protected |
Finished job timeout in seconds.
Definition at line 95 of file NodeManager.hh.
Referenced by finishedJobTimeout(), finishedJobTimeout(), NodeManager(), and terminateFinishedJobs().
|
protected |
List of jobs.
Definition at line 92 of file NodeManager.hh.
Referenced by addTask(), getNextTask(), haveMoreTasks(), haveMoreTasks(), job(), jobs(), print(), publish(), terminateAllJobs(), terminateJob(), and ~NodeManager().
|
protected |
Definition at line 100 of file NodeManager.hh.
Referenced by publish(), publisher(), publisher(), and ~NodeManager().
|
protected |
Task pool.
Definition at line 99 of file NodeManager.hh.
Referenced by addTaskSlot(), Salsa::NodeManagerZyre::addTaskSlot(), Salsa::NodeManagerZyre::handleTaskPool(), print(), taskPool(), terminateJob(), and ~NodeManager().
|
staticprivateinherited |
Pointer to spd logger.
Definition at line 32 of file Object.hh.
Referenced by getConsoleOutput(), and setConsoleLevel().
|
protected |
List of Workers.
Definition at line 96 of file NodeManager.hh.
Referenced by addWorker(), print(), and worker().