salsa 0.7.1
Loading...
Searching...
No Matches
Salsa::NodeManager Class Referenceabstract

NodeManager class. More...

#include <NodeManager.hh>

Inheritance diagram for Salsa::NodeManager:
Salsa::Object Salsa::NodeManagerZyre

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 SocketonEnter (std::string self, std::string fromType, Message *msg, std::vector< std::string > &out)
 
virtual SocketonExit (std::string self, Message *msg, std::vector< std::string > &out)
 
virtual SocketonWhisper (std::string self, Message *msg, std::vector< std::string > &out)
 
std::shared_ptr< Feederfeeder (std::string uuid) const
 
std::shared_ptr< Consumerconsumer (std::string uuid) const
 
std::shared_ptr< Workerworker (std::string uuid) const
 
Jobjob (std::string uuid)
 
TaskPooltaskPool ()
 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 Publisherpublisher () 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.
 
TaskPoolmpTaskPool = nullptr
 Task pool.
 
PublishermpPublisher = nullptr
 Publisher.
 

Static Private Attributes

static std::shared_ptr< spdlog::logger > mspConsoleLogger = spdlog::stdout_color_mt("salsa")
 Pointer to spd logger.
 

Detailed Description

Constructor & Destructor Documentation

◆ NodeManager()

Salsa::NodeManager::NodeManager ( )

Constructor

Definition at line 4 of file NodeManager.cc.

◆ ~NodeManager()

Salsa::NodeManager::~NodeManager ( )
virtual

Destructor

Definition at line 14 of file NodeManager.cc.

References job(), mJobs, mpPublisher, mpTaskPool, and Salsa::TaskPool::terminateJob().

Member Function Documentation

◆ addConsumer()

void Salsa::NodeManager::addConsumer ( std::string uuid,
std::shared_ptr< Socket > s )

Add consumer

Definition at line 57 of file NodeManager.cc.

References mConsumers.

Referenced by Salsa::NodeZyre::init().

◆ addFeeder()

void Salsa::NodeManager::addFeeder ( std::string uuid,
std::shared_ptr< Socket > s )

Add feeder

Definition at line 66 of file NodeManager.cc.

References mFeeders.

Referenced by Salsa::NodeZyre::init().

◆ addTask()

void Salsa::NodeManager::addTask ( TaskInfo * taskInfo,
std::string cuuid,
std::string fuuid,
Salsa::Job::EQueueType t = Salsa::Job::pending )

◆ addTaskSlot()

void Salsa::NodeManager::addTaskSlot ( )
virtual

Reserve task slot

Reimplemented in Salsa::NodeManagerZyre.

Definition at line 495 of file NodeManager.cc.

References mpTaskPool.

Referenced by Salsa::Worker::Worker().

◆ addWorker()

void Salsa::NodeManager::addWorker ( std::string uuid,
std::shared_ptr< Socket > s )

Add worker

Definition at line 75 of file NodeManager.cc.

References mWorkers.

Referenced by Salsa::NodeZyre::init().

◆ clusterAlias() [1/2]

std::string Salsa::NodeManager::clusterAlias ( )
inline

Returns Cluster alias.

Definition at line 88 of file NodeManager.hh.

References mClusterAlias.

◆ clusterAlias() [2/2]

void Salsa::NodeManager::clusterAlias ( std::string n)
inline

Sets Cluster alias.

Definition at line 86 of file NodeManager.hh.

References mClusterAlias.

Referenced by Salsa::NodeZyre::init().

◆ consumer()

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(), Salsa::Feeder::onExit(), onExit(), Salsa::Feeder::onWhisper(), onWhisper(), and resultTask().

◆ feeder()

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(), Salsa::NodeZyre::init(), nSlots(), onEnter(), onExit(), onWhisper(), and publish().

◆ finishedJobTimeout() [1/2]

uint64_t Salsa::NodeManager::finishedJobTimeout ( ) const
inline

Returns finished job timeout.

Definition at line 55 of file NodeManager.hh.

References mFinishedJobTimeout.

Referenced by Salsa::NodeZyre::init().

◆ finishedJobTimeout() [2/2]

void Salsa::NodeManager::finishedJobTimeout ( uint64_t t)
inline

Sets finished job timeout.

Definition at line 57 of file NodeManager.hh.

References mFinishedJobTimeout.

◆ getConsoleOutput()

static std::shared_ptr< spdlog::logger > Salsa::Object::getConsoleOutput ( )
inlinestaticinherited

Get console output.

Definition at line 21 of file Object.hh.

References Salsa::Object::mspConsoleLogger.

Referenced by Salsa::ConfigZyre::apply().

◆ getNextTask()

TaskInfo * Salsa::NodeManager::getNextTask ( )

Return Next task from job

Definition at line 260 of file NodeManager.cc.

References mActiveJobs, and mJobs.

Referenced by Salsa::Feeder::onWhisper().

◆ handleTaskPool()

bool Salsa::NodeManager::handleTaskPool ( void * p)
virtual

Handle task pool

Reimplemented in Salsa::NodeManagerZyre.

Definition at line 505 of file NodeManager.cc.

◆ hasJobs()

bool Salsa::NodeManager::hasJobs ( ) const

Returns if jobs are active

Definition at line 521 of file NodeManager.cc.

References mActiveJobs.

Referenced by Salsa::Feeder::onEnter().

◆ haveMoreTasks() [1/2]

bool Salsa::NodeManager::haveMoreTasks ( )
virtual

Sets no more tasks to any job

Definition at line 567 of file NodeManager.cc.

References job(), mActiveJobs, and mJobs.

Referenced by Salsa::Feeder::onExit().

◆ haveMoreTasks() [2/2]

bool Salsa::NodeManager::haveMoreTasks ( std::string jobUUID)
virtual

Sets no more tasks to job with jobuuid

Definition at line 595 of file NodeManager.cc.

References Salsa::TaskPool::find(), and mJobs.

◆ job()

◆ jobs()

void Salsa::NodeManager::jobs ( std::string clientUUID,
std::vector< std::string > & jobs ) const

Returns list of jobs

Definition at line 529 of file NodeManager.cc.

References jobs(), and mJobs.

Referenced by jobs(), and Salsa::Consumer::onExit().

◆ noMoreTasks()

void Salsa::NodeManager::noMoreTasks ( std::string jobUUID)
virtual

Sets no more tasks to job with jobuuid

Definition at line 554 of file NodeManager.cc.

Referenced by Salsa::Consumer::onWhisper().

◆ nSlots()

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 Salsa::NodeZyre::handleExternalZmq(), Salsa::Consumer::onWhisper(), and resultTask().

◆ onEnter()

Socket * Salsa::NodeManager::onEnter ( std::string self,
std::string fromType,
Message * msg,
std::vector< std::string > & out )
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().

◆ onExit()

Socket * Salsa::NodeManager::onExit ( std::string self,
Message * msg,
std::vector< std::string > & out )
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().

◆ onWhisper()

Socket * Salsa::NodeManager::onWhisper ( std::string self,
Message * msg,
std::vector< std::string > & out )
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().

◆ print()

void Salsa::NodeManager::print ( std::string opt = "") const

◆ publish()

bool Salsa::NodeManager::publish ( std::string id,
bool force = false ) const
virtual

◆ publisher() [1/2]

Publisher * Salsa::NodeManager::publisher ( ) const
virtual

Returns publisher

Definition at line 617 of file NodeManager.cc.

References mpPublisher.

◆ publisher() [2/2]

void Salsa::NodeManager::publisher ( Publisher * p)
virtual

Sets publisher

Definition at line 609 of file NodeManager.cc.

References mpPublisher.

Referenced by Salsa::NodeZyre::init().

◆ resultTask()

void Salsa::NodeManager::resultTask ( TaskInfo * task)
virtual

◆ resultTaskToExternal()

virtual void Salsa::NodeManager::resultTaskToExternal ( Job * ,
TaskInfo *  )
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().

◆ runTask()

virtual void Salsa::NodeManager::runTask ( TaskState * ts,
std::string wk,
std::string upstream )
pure virtual

Run task interface.

Implemented in Salsa::NodeManagerZyre.

Referenced by Salsa::Worker::onWhisper().

◆ sendWhisper()

bool Salsa::NodeManager::sendWhisper ( Socket * s,
std::string to,
std::vector< std::string > & v )
virtual

◆ setConsoleLevel()

static void Salsa::Object::setConsoleLevel ( spdlog::level::level_enum level)
inlinestaticinherited

Sets console log level.

Definition at line 29 of file Object.hh.

References Salsa::Object::mspConsoleLogger.

◆ taskPool()

TaskPool * Salsa::NodeManager::taskPool ( )

Get NM's task pool.

Returns task pool

Definition at line 513 of file NodeManager.cc.

References mpTaskPool.

Referenced by Salsa::Worker::onWhisper().

◆ terminateAllJobs()

void Salsa::NodeManager::terminateAllJobs ( bool finishedonly = false)
virtual

Terminate all jobs

Definition at line 422 of file NodeManager.cc.

References job(), mFinishedJobs, mJobs, and terminateJob().

Referenced by Salsa::NodeZyre::handleExternalZmq().

◆ terminateFinishedJobs()

bool Salsa::NodeManager::terminateFinishedJobs ( )
virtual

Clear finished jobs

Definition at line 391 of file NodeManager.cc.

References job(), mFinishedJobs, mFinishedJobTimeout, and terminateJob().

Referenced by Salsa::NodeZyre::exec().

◆ terminateJob()

void Salsa::NodeManager::terminateJob ( std::string uuid)
virtual

◆ worker()

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 Salsa::TaskPool::handlePipe(), Salsa::NodeZyre::init(), onEnter(), onExit(), and onWhisper().

Member Data Documentation

◆ mActiveJobs

std::vector<std::string> Salsa::NodeManager::mActiveJobs {}
protected

List of active jobs.

Definition at line 93 of file NodeManager.hh.

Referenced by addTask(), getNextTask(), hasJobs(), and haveMoreTasks().

◆ mClusterAlias

std::string Salsa::NodeManager::mClusterAlias {"local"}
protected

Cluster alias.

Definition at line 91 of file NodeManager.hh.

Referenced by clusterAlias(), clusterAlias(), and publish().

◆ mConsumers

std::map<std::string, std::shared_ptr<Consumer> > Salsa::NodeManager::mConsumers {}
protected

List of Consumers.

Definition at line 97 of file NodeManager.hh.

Referenced by addConsumer(), consumer(), and print().

◆ mFeeders

std::map<std::string, std::shared_ptr<Feeder> > Salsa::NodeManager::mFeeders {}
protected

List of Feeders.

Definition at line 98 of file NodeManager.hh.

Referenced by addFeeder(), addTask(), feeder(), nSlots(), print(), and terminateJob().

◆ mFinishedJobs

std::vector<std::string> Salsa::NodeManager::mFinishedJobs {}
protected

List of finished jobs.

Definition at line 94 of file NodeManager.hh.

Referenced by resultTask(), terminateAllJobs(), terminateFinishedJobs(), and terminateJob().

◆ mFinishedJobTimeout

uint64_t Salsa::NodeManager::mFinishedJobTimeout
protected

Finished job timeout in seconds.

Definition at line 95 of file NodeManager.hh.

Referenced by finishedJobTimeout(), finishedJobTimeout(), and terminateFinishedJobs().

◆ mJobs

std::map<std::string, Job *> Salsa::NodeManager::mJobs {}
protected

◆ mpPublisher

Publisher* Salsa::NodeManager::mpPublisher = nullptr
protected

Publisher.

Definition at line 100 of file NodeManager.hh.

Referenced by publish(), publisher(), publisher(), and ~NodeManager().

◆ mpTaskPool

TaskPool* Salsa::NodeManager::mpTaskPool = nullptr
protected

◆ mspConsoleLogger

std::shared_ptr< spdlog::logger > Salsa::Object::mspConsoleLogger = spdlog::stdout_color_mt("salsa")
staticprivateinherited

Pointer to spd logger.

Definition at line 32 of file Object.hh.

Referenced by Salsa::Object::getConsoleOutput(), and Salsa::Object::setConsoleLevel().

◆ mWorkers

std::map<std::string, std::shared_ptr<Worker> > Salsa::NodeManager::mWorkers {}
protected

List of Workers.

Definition at line 96 of file NodeManager.hh.

Referenced by addWorker(), print(), and worker().


The documentation for this class was generated from the following files: