salsa 0.7.1
Loading...
Searching...
No Matches
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. More...
 
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.
 
bool isFinished ()
 Returns if jobs is finished.
 
bool isJustFinished ()
 Returns if job was just finished.
 
bool isTaskInQueue (uint32_t id, EQueueType type) const
 Check task presence in certain queue.
 
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

Member Typedef Documentation

◆ JobID_t

using Salsa::Job::JobID_t = uint32_t

Job ID type alias.

Definition at line 68 of file Job.hh.

Member Enumeration Documentation

◆ EQueueType

Queue types.

Definition at line 19 of file Job.hh.

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, mType, mUUID, Salsa::Object::Object(), and uuid().

◆ ~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().

◆ changed() [1/2]

bool Salsa::Job::changed ( ) const
inline

Returns if job info was changed.

Definition at line 71 of file Job.hh.

References mChanged.

◆ changed() [2/2]

void Salsa::Job::changed ( bool c)
inline

Set if job info was changed.

Definition at line 73 of file Job.hh.

References mChanged.

◆ 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().

◆ getConsoleOutput()

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

Get console output.

Definition at line 21 of file Object.hh.

References mspConsoleLogger.

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

◆ 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().

◆ isJustFinished()

bool Salsa::Job::isJustFinished ( )

Returns if job was just finished.

Definition at line 296 of file Job.cc.

References mJustFinished.

◆ 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 json(), mGid, mMaxIdsInJson, mTasks, mTimeFinished, mTimeStarted, mUid, mUUID, and size().

Referenced by json().

◆ maxIdsInJson() [1/2]

size_t Salsa::Job::maxIdsInJson ( ) const
inline

Returns Maximum number when joh ids are produced in json.

Definition at line 86 of file Job.hh.

References mMaxIdsInJson.

◆ maxIdsInJson() [2/2]

void Salsa::Job::maxIdsInJson ( size_t i)
inline

Set Maximum number when joh ids are produced in json.

Definition at line 88 of file Job.hh.

References mMaxIdsInJson.

◆ 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.

References moveTask().

Referenced by moveTask(), 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().

◆ 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 mspConsoleLogger.

◆ 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().

◆ submitterSocketID() [1/2]

void * Salsa::Job::submitterSocketID ( ) const
inline

Returns submitter socket identity.

Definition at line 81 of file Job.hh.

References mSubmitterSocketID.

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

◆ submitterSocketID() [2/2]

void Salsa::Job::submitterSocketID ( void * id)
inline

Set submitter socket identity.

Definition at line 83 of file Job.hh.

References mSubmitterSocketID.

◆ submitterSocketIndex() [1/2]

int Salsa::Job::submitterSocketIndex ( ) const
inline

Returns submitter socket index.

Definition at line 76 of file Job.hh.

References mSubmitterSocketIndex.

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

◆ submitterSocketIndex() [2/2]

void Salsa::Job::submitterSocketIndex ( int i)
inline

Set submitter socket index.

Definition at line 78 of file Job.hh.

References mSubmitterSocketIndex.

◆ 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().

◆ timeFinished()

uint64_t Salsa::Job::timeFinished ( ) const
inline

Returns time finished for the job.

Definition at line 33 of file Job.hh.

References mTimeFinished.

◆ timeStarted()

uint64_t Salsa::Job::timeStarted ( ) const
inline

Return time started for the job.

Definition at line 31 of file Job.hh.

References mTimeStarted.

◆ uuid()

std::string Salsa::Job::uuid ( ) const
inline

returns UUID

Definition at line 28 of file Job.hh.

References mUUID.

Referenced by consumer(), feeder(), Job(), and Salsa::NodeManager::resultTask().

Member Data Documentation

◆ mChanged

bool Salsa::Job::mChanged = false
private

Flag if job was changed.

Definition at line 106 of file Job.hh.

Referenced by changed(), changed(), and moveTask().

◆ mConsumerUUID

std::string Salsa::Job::mConsumerUUID {""}
protected

Source (consumer) UUID.

Definition at line 95 of file Job.hh.

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

◆ mFeederUUID

std::string Salsa::Job::mFeederUUID {""}
protected

Feeder UUID.

Definition at line 96 of file Job.hh.

Referenced by feeder(), feeder(), and print().

◆ mGid

uint32_t Salsa::Job::mGid {99}
protected

Job group id (nogroup : 99)

Definition at line 94 of file Job.hh.

Referenced by addTask(), and json().

◆ mJustFinished

bool Salsa::Job::mJustFinished {false}
protected

Flag if job is finished. Note that it is reported only once.

Definition at line 103 of file Job.hh.

Referenced by isFinished(), and isJustFinished().

◆ mMaxIdsInJson

size_t Salsa::Job::mMaxIdsInJson {1000}
protected

Maximum number when joh ids are produced in json.

Definition at line 102 of file Job.hh.

Referenced by json(), maxIdsInJson(), and maxIdsInJson().

◆ 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 getConsoleOutput(), and setConsoleLevel().

◆ mSubmitterSocketID

void* Salsa::Job::mSubmitterSocketID {nullptr}
protected

Submitter socket identity.

Definition at line 101 of file Job.hh.

Referenced by submitterSocketID(), and submitterSocketID().

◆ mSubmitterSocketIndex

int Salsa::Job::mSubmitterSocketIndex {-1}
protected

Submitter socket index in NodeZyre::mZmqSockets.

Definition at line 100 of file Job.hh.

Referenced by submitterSocketIndex(), and submitterSocketIndex().

◆ mTasks

std::map<uint32_t, TaskInfo *> Salsa::Job::mTasks[all] = {}
protected

Lists of jobs.

Definition at line 91 of file Job.hh.

Referenced by addTask(), haveMoreTasks(), isTaskInQueue(), json(), moveTask(), nextTask(), print(), removeTask(), size(), sizeNotFinished(), tasks(), and ~Job().

◆ mTimeFinished

uint64_t Salsa::Job::mTimeFinished {0}
protected

Time finished.

Definition at line 99 of file Job.hh.

Referenced by isFinished(), json(), print(), and timeFinished().

◆ mTimeStarted

uint64_t Salsa::Job::mTimeStarted {}
protected

Time started.

Definition at line 98 of file Job.hh.

Referenced by Job(), json(), print(), and timeStarted().

◆ mType

std::string Salsa::Job::mType {"NONE"}
protected

Job type.

Definition at line 97 of file Job.hh.

Referenced by Job().

◆ mUid

uint32_t Salsa::Job::mUid {99}
protected

Job user id (nobody : 99)

Definition at line 93 of file Job.hh.

Referenced by addTask(), and json().

◆ mUUID

std::string Salsa::Job::mUUID {""}
protected

Job UUID.

Definition at line 92 of file Job.hh.

Referenced by Job(), json(), print(), and uuid().


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