|
salsa
0.4.15
|
#include <Job.hh>
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. | |
| 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 {} |
| 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. | |
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. | |
| Salsa::Job::Job | ( | std::string | uuid = "", |
| std::string | type = "NONE" |
||
| ) |
| 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().
| std::string Salsa::Job::consumer | ( | ) | const |
| void Salsa::Job::consumer | ( | std::string | uuid | ) |
Sets consumer uuid
Definition at line 229 of file Job.cc.
References mConsumerUUID, and uuid().
Referenced by Salsa::NodeManager::addTask(), Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().
| std::string Salsa::Job::feeder | ( | ) | const |
| void Salsa::Job::feeder | ( | std::string | uuid | ) |
Sets feeder uuid
Definition at line 246 of file Job.cc.
References mFeederUUID, and uuid().
Referenced by Salsa::NodeManager::addTask(), Salsa::Feeder::onExit(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().
| bool Salsa::Job::haveMoreTasks | ( | ) | const |
Task statuses.
return has more tasks
Definition at line 263 of file Job.cc.
References mTasks.
Referenced by Salsa::NodeManager::resultTask().
| bool Salsa::Job::isFinished | ( | ) |
Returns if jobs is finished.
Returns if job is finished
Definition at line 271 of file Job.cc.
References mTimeFinished, and sizeNotFinished().
Referenced by Salsa::NodeManager::resultTask().
| 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::onExit(), Salsa::Feeder::onWhisper(), and Salsa::NodeManager::resultTask().
| void Salsa::Job::json | ( | Json::Value & | json | ) |
Export data in json format
Definition at line 164 of file Job.cc.
References mGid, mMaxIdsInJson, mTasks, mTimeFinished, mTimeStarted, mUid, mUUID, and size().
Referenced by Salsa::NodeManager::publish().
| 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().
| bool Salsa::Job::moveTask | ( | uint32_t | id, |
| TaskInfo * | pJI, | ||
| EQueueType | from, | ||
| EQueueType | to | ||
| ) |
| TaskInfo * Salsa::Job::nextTask | ( | ) |
| 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().
| 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_t Salsa::Job::size | ( | EQueueType | t = all | ) | const |
| size_t Salsa::Job::sizeNotFinished | ( | ) | const |
Returns number of unfinished jobs
Definition at line 218 of file Job.cc.
References mTasks.
Referenced by isFinished().
| 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::TaskPool::terminateJob(), and Salsa::Feeder::terminateJob().