salsa  0.4.0
Salsa::Job Class Reference


Job class More...

#include <Job.hh>

Inheritance diagram for Salsa::Job:
Salsa::Object

Public Types

enum  EQueueType {
  pending = 0, assigned = 1, running = 2, done = 3,
  failed = 4, all = 5
}
 Queue types.
 
using JobID_t = uint32_t
 Job ID type alias.
 

Public Member Functions

 Job (std::string uuid="", std::string type="NONE")
 
virtual ~Job ()
 
void print () const
 
void json (Json::Value &json)
 
std::string uuid () const
 returns UUID
 
uint64_t timeStarted () const
 Return time started for the job.
 
uint64_t timeFinished () const
 Returns time finished for the job.
 
TaskInfo * nextTask ()
 
void tasks (std::vector< TaskInfo *> &v, EQueueType type, bool clear=true)
 
bool addTask (uint32_t id, TaskInfo *pJob, EQueueType type)
 
bool moveTask (uint32_t id, EQueueType from, EQueueType to)
 
bool moveTask (uint32_t id, TaskInfo *pJI, EQueueType from, EQueueType to)
 
bool removeTask (uint32_t id, EQueueType from)
 
size_t size (EQueueType t=all) const
 
size_t sizeNotFinished () const
 
void consumer (std::string uuid)
 
std::string consumer () const
 
void feeder (std::string uuid)
 
std::string feeder () const
 
bool haveMoreTasks () const
 Task statuses. More...
 
bool isFinished ()
 Returns if jobs is finished. More...
 
bool isTaskInQueue (uint32_t id, EQueueType type) const
 Check task presence in certain queue. More...
 
bool changed () const
 Returns if job info was changed.
 
void changed (bool c)
 Set if job info was changed.
 
int submitterSocketIndex () const
 Returns submitter socket index.
 
void submitterSocketIndex (int i)
 Set submitter socket index.
 
void * submitterSocketID () const
 Returns submitter socket identity.
 
void submitterSocketID (void *id)
 Set submitter socket identity.
 

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< uint32_t, TaskInfo * > mTasks [all] = {}
 Lists of jobs.
 
std::string mUUID {""}
 Job UUID.
 
uint32_t mUid {99}
 Job user id (nobody : 99)
 
uint32_t mGid {99}
 Job group id (nogroup : 99)
 
std::string mConsumerUUID {""}
 Source (consumer) UUID.
 
std::string mFeederUUID {""}
 Feeder UUID.
 
std::string mType {"NONE"}
 Job type.
 
uint64_t mTimeStarted {}
 Time started.
 
uint64_t mTimeFinished {}
 Time finished.
 
int mSubmitterSocketIndex {-1}
 Submitter socket index in NodeZyre::mZmqSockets.
 
void * mSubmitterSocketID {nullptr}
 Submitter socket identity.
 

Private Attributes

bool mChanged = false
 Flag if job was changed.
 

Detailed Description

Constructor & Destructor Documentation

◆ Job()

Salsa::Job::Job ( std::string  uuid = "",
std::string  type = "NONE" 
)


Constructor

Definition at line 4 of file Job.cc.

References mTimeStarted.

◆ ~Job()

Salsa::Job::~Job ( )
virtual


Destructor

Definition at line 15 of file Job.cc.

References mTasks.

Member Function Documentation

◆ addTask()

bool Salsa::Job::addTask ( uint32_t  id,
TaskInfo *  pJob,
EQueueType  type 
)


Adds task to list of jobs

Definition at line 29 of file Job.cc.

References mGid, mTasks, and mUid.

Referenced by Salsa::NodeManager::addTask(), and moveTask().

◆ consumer() [1/2]

void Salsa::Job::consumer ( std::string  uuid)


Sets consumer uuid

Definition at line 227 of file Job.cc.

References mConsumerUUID, and uuid().

Referenced by Salsa::NodeManager::addTask(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().

◆ consumer() [2/2]

std::string Salsa::Job::consumer ( ) const


return consumer UUID

Definition at line 235 of file Job.cc.

References mConsumerUUID.

◆ feeder() [1/2]

void Salsa::Job::feeder ( std::string  uuid)


Sets feeder uuid

Definition at line 244 of file Job.cc.

References mFeederUUID, and uuid().

Referenced by Salsa::NodeManager::addTask(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().

◆ feeder() [2/2]

std::string Salsa::Job::feeder ( ) const


return feeder UUID

Definition at line 252 of file Job.cc.

References mFeederUUID.

◆ haveMoreTasks()

bool Salsa::Job::haveMoreTasks ( ) const

Task statuses.


return has more tasks

Definition at line 261 of file Job.cc.

References mTasks.

Referenced by Salsa::NodeManager::resultTask().

◆ isFinished()

bool Salsa::Job::isFinished ( )

Returns if jobs is finished.


Returns if job is finished

Definition at line 269 of file Job.cc.

References mTimeFinished, and sizeNotFinished().

Referenced by Salsa::NodeManager::resultTask().

◆ isTaskInQueue()

bool Salsa::Job::isTaskInQueue ( uint32_t  id,
EQueueType  type 
) const

Check task presence in certain queue.


Returns if task is i queue

Definition at line 136 of file Job.cc.

References mTasks.

Referenced by Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().

◆ json()

void Salsa::Job::json ( Json::Value &  json)


Export data in json format

Definition at line 164 of file Job.cc.

References mGid, mTasks, mTimeFinished, mTimeStarted, mUid, and mUUID.

Referenced by Salsa::NodeManager::publish().

◆ moveTask() [1/2]

bool Salsa::Job::moveTask ( uint32_t  id,
EQueueType  from,
EQueueType  to 
)


Moves job from queue FROM to TO

Definition at line 52 of file Job.cc.

Referenced by nextTask(), Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().

◆ moveTask() [2/2]

bool Salsa::Job::moveTask ( uint32_t  id,
TaskInfo *  pJI,
EQueueType  from,
EQueueType  to 
)


Moves job from queue FROM to TO

Definition at line 61 of file Job.cc.

References addTask(), mChanged, and mTasks.

◆ nextTask()

TaskInfo * Salsa::Job::nextTask ( )


return next job

Definition at line 105 of file Job.cc.

References moveTask(), and mTasks.

◆ print()

void Salsa::Job::print ( ) const


Prints job information

Definition at line 153 of file Job.cc.

References mConsumerUUID, mFeederUUID, mTasks, mTimeFinished, mTimeStarted, mUUID, and size().

Referenced by Salsa::TaskPool::terminateJob().

◆ removeTask()

bool Salsa::Job::removeTask ( uint32_t  id,
EQueueType  from 
)


Removes job from queue

Definition at line 89 of file Job.cc.

References mTasks.

Referenced by Salsa::TaskPool::handlePipe(), and Salsa::NodeManager::resultTask().

◆ size()

size_t Salsa::Job::size ( EQueueType  t = all) const


Return size in queue (if EQueueType::all is set is show sum of sizes)

Definition at line 196 of file Job.cc.

References mTasks.

Referenced by print(), and Salsa::NodeManager::resultTask().

◆ sizeNotFinished()

size_t Salsa::Job::sizeNotFinished ( ) const


Returns number of unfinished jobs

Definition at line 216 of file Job.cc.

References mTasks.

Referenced by isFinished().

◆ tasks()

void Salsa::Job::tasks ( std::vector< TaskInfo *> &  v,
EQueueType  type,
bool  clear = true 
)


return next job

Definition at line 121 of file Job.cc.

References mTasks.

Referenced by Salsa::Feeder::terminateJob(), and Salsa::TaskPool::terminateJob().


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