Skip to content

Commit

Permalink
#105: implementing default job priority
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfsilva committed Jun 20, 2019
1 parent 4896cd6 commit ce2cf28
Showing 1 changed file with 42 additions and 34 deletions.
76 changes: 42 additions & 34 deletions src/wrench/workflow/job/WorkflowJob.cpp
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2017. The WRENCH Team.
* Copyright (c) 2017-2019. The WRENCH Team.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,8 +31,8 @@ namespace wrench {
* @param type: job type
*/
WorkflowJob::WorkflowJob(Type type) : type(type) {
this->parent_compute_service = nullptr;
this->submit_date = -1.0;
this->parent_compute_service = nullptr;
this->submit_date = -1.0;
}


Expand All @@ -42,7 +42,7 @@ namespace wrench {
* @return the type
*/
WorkflowJob::Type WorkflowJob::getType() {
return this->type;
return this->type;
}

/**
Expand All @@ -52,18 +52,18 @@ namespace wrench {
* @throw std::runtime_error
*/
std::string WorkflowJob::getTypeAsString() {
switch (this->type) {
case STANDARD: {
return "Standard";
}
case PILOT: {
return "Pilot";
}
default: {
throw std::runtime_error("WorkflowJob::getTypeAsString(): WorkflowJob type '" +
std::to_string(this->type) + "' cannot be converted to a string");
}
switch (this->type) {
case STANDARD: {
return "Standard";
}
case PILOT: {
return "Pilot";
}
default: {
throw std::runtime_error("WorkflowJob::getTypeAsString(): WorkflowJob type '" +
std::to_string(this->type) + "' cannot be converted to a string");
}
}
}

/**
Expand All @@ -72,7 +72,7 @@ namespace wrench {
* @return the name as a string
*/
std::string WorkflowJob::getName() {
return this->name;
return this->name;
}

/**
Expand All @@ -82,10 +82,10 @@ namespace wrench {
* @return the next callback mailbox
*/
std::string WorkflowJob::getCallbackMailbox() {
if (this->callback_mailbox_stack.empty()) {
return this->workflow->getCallbackMailbox();
}
return this->callback_mailbox_stack.top();
if (this->callback_mailbox_stack.empty()) {
return this->workflow->getCallbackMailbox();
}
return this->callback_mailbox_stack.top();
}

/**
Expand All @@ -94,7 +94,7 @@ namespace wrench {
* @return the next callback mailbox
*/
std::string WorkflowJob::getOriginCallbackMailbox() {
return this->workflow->getCallbackMailbox();
return this->workflow->getCallbackMailbox();
}


Expand All @@ -106,12 +106,12 @@ namespace wrench {
* @return the next callback mailbox
*/
std::string WorkflowJob::popCallbackMailbox() {
if (this->callback_mailbox_stack.empty()) {
return this->workflow->getCallbackMailbox();
}
std::string mailbox = this->callback_mailbox_stack.top();
this->callback_mailbox_stack.pop();
return mailbox;
if (this->callback_mailbox_stack.empty()) {
return this->workflow->getCallbackMailbox();
}
std::string mailbox = this->callback_mailbox_stack.top();
this->callback_mailbox_stack.pop();
return mailbox;
}

/**
Expand All @@ -120,7 +120,7 @@ namespace wrench {
* @param mailbox: the mailbox name
*/
void WorkflowJob::pushCallbackMailbox(std::string mailbox) {
this->callback_mailbox_stack.push(mailbox);
this->callback_mailbox_stack.push(mailbox);
}

/**
Expand All @@ -129,16 +129,16 @@ namespace wrench {
* @return a unique number
*/
unsigned long WorkflowJob::getNewUniqueNumber() {
static unsigned long sequence_number = 0;
return (sequence_number++);
static unsigned long sequence_number = 0;
return (sequence_number++);
}

/**
* @brief Set the parent compute service of the job
* @param compute_service: a compute service
*/
void WorkflowJob::setParentComputeService(std::shared_ptr<ComputeService> compute_service) {
this->parent_compute_service = compute_service;
this->parent_compute_service = compute_service;
}

/**
Expand All @@ -147,22 +147,30 @@ namespace wrench {
* @return a compute service
*/
std::shared_ptr<ComputeService> WorkflowJob::getParentComputeService() {
return this->parent_compute_service;
return this->parent_compute_service;
}

/**
* @brief Get the date at which the job was last submitted (<0 means "never submitted")
* @return the submit date
*/
double WorkflowJob::getSubmitDate() {
return this->submit_date;
return this->submit_date;
}

/**
* @brief Return the service-specific arguments that were used during job submission
* @return a map of argument name/values
*/
std::map<std::string, std::string> WorkflowJob::getServiceSpecificArguments() {
return this->service_specific_args;
return this->service_specific_args;
}

/**
* @brief Return default job priority as zero.
* @return priority as zero
*/
unsigned long WorkflowJob::getPriority() {
return 0;
}
};

0 comments on commit ce2cf28

Please sign in to comment.