salsa  0.3.0
 All Classes Functions Variables Enumerations Pages
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::QueueType 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. 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 Publisherpublisher () 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.
 
TaskPoolmpTaskPool = nullptr
 Task pool.
 
PublishermpPublisher = nullptr
 Publisher.
 

Detailed Description

Constructor & Destructor Documentation

Salsa::NodeManager::NodeManager ( )

Constructor

Definition at line 5 of file NodeManager.cc.

Salsa::NodeManager::~NodeManager ( )
virtual

Destructor

Definition at line 12 of file NodeManager.cc.

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

Member Function Documentation

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 
)
void Salsa::NodeManager::addTaskSlot ( )
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().

bool Salsa::NodeManager::handleTaskPool ( void *  p)
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)
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().

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 76 of file NodeManager.cc.

References consumer(), feeder(), Salsa::Message::uuid(), and worker().

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

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 141 of file NodeManager.cc.

References consumer(), feeder(), Salsa::Message::uuid(), and worker().

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

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 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
void Salsa::NodeManager::publish ( std::string  id) const
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().

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

Sets publisher

Definition at line 541 of file NodeManager.cc.

References mpPublisher.

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

Returns publisher

Definition at line 549 of file NodeManager.cc.

References mpPublisher.

void Salsa::NodeManager::resultTask ( TaskInfo *  task)
bool Salsa::NodeManager::sendWhisper ( Socket s,
std::string  to,
std::vector< std::string > &  v 
)
virtual
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().

void Salsa::NodeManager::terminateJob ( std::string  uuid)
virtual
void Salsa::NodeManager::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().


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