salsa  0.7.1
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 isJustFinished ()
 Returns if job was just finished.
 
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.
 
size_t maxIdsInJson () const
 Returns Maximum number when joh ids are produced in json.
 
void maxIdsInJson (size_t i)
 Set Maximum number when joh ids are produced in json.
 

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 {0}
 Time finished.
 
int mSubmitterSocketIndex {-1}
 Submitter socket index in NodeZyre::mZmqSockets.
 
void * mSubmitterSocketID {nullptr}
 Submitter socket identity.
 
size_t mMaxIdsInJson {1000}
 Maximum number when joh ids are produced in json.
 
bool mJustFinished {false}
 Flag if job is finished. Note that it is reported only once.
 

Private Attributes

bool mChanged = false
 Flag if job was changed.
 

Static Private Attributes

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

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 18 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 32 of file Job.cc.

References mGid, mTasks, and mUid.

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

◆ consumer() [1/2]

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

return consumer UUID

Definition at line 246 of file Job.cc.

References mConsumerUUID.

◆ consumer() [2/2]

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

Sets consumer uuid

Definition at line 238 of file Job.cc.

References mConsumerUUID, and uuid().

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

◆ feeder() [1/2]

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

return feeder UUID

Definition at line 263 of file Job.cc.

References mFeederUUID.

◆ feeder() [2/2]

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

Sets feeder uuid

Definition at line 255 of file Job.cc.

References mFeederUUID, and uuid().

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

◆ haveMoreTasks()

bool Salsa::Job::haveMoreTasks ( ) const

Task statuses.

return has more tasks

Definition at line 272 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 280 of file Job.cc.

References mJustFinished, 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 145 of file Job.cc.

References mTasks.

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

◆ json()

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

Export data in json format

Definition at line 173 of file Job.cc.

References mGid, mMaxIdsInJson, mTasks, mTimeFinished, mTimeStarted, mUid, mUUID, and size().

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 56 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 65 of file Job.cc.

References addTask(), mChanged, and mTasks.

◆ nextTask()

TaskInfo * Salsa::Job::nextTask ( )

return next job

Definition at line 114 of file Job.cc.

References moveTask(), and mTasks.

◆ print()

void Salsa::Job::print ( ) const

Prints job information

Definition at line 162 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 96 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 207 of file Job.cc.

References mTasks.

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

◆ sizeNotFinished()

size_t Salsa::Job::sizeNotFinished ( ) const

Returns number of unfinished jobs

Definition at line 227 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 130 of file Job.cc.

References mTasks.

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


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