Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperYoko committed Jan 5, 2023
1 parent a5e21c8 commit 07059ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/meta/processors/job/JobDescription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ cpp2::JobDesc JobDescription::toJobDesc() {
return ret;
}

bool JobDescription::canForceSetStatus(Status status) {
return status != cpp2::JobStatus::FINISHED;
}

bool JobDescription::setStatus(Status newStatus, bool force) {
if (status_ == cpp2::JobStatus::FINISHED) {
// no one should change the status of a finished job
// in case that recovered job running again, but set finished to finished should be ok
return newStatus == cpp2::JobStatus::FINISHED;
if (canForceSetStatus(status_)) {
// no need to change time.
return status_ == newStatus;
}

if (JobStatus::laterThan(status_, newStatus) && !force) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/meta/processors/job/JobDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class JobDescription {
return !(*this == that);
}

private:
bool canForceSetStatus(Status status);

private:
// Because all jobs are space-level, spaceName is not in paras_.
GraphSpaceID space_;
Expand Down
1 change: 1 addition & 0 deletions src/meta/processors/job/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ bool JobManager::isExpiredJob(JobDescription& jobDesc) {
auto jobStart = jobDesc.getStartTime();
if (jobStart == 0) {
// should not happend, but just in case keep this job
LOG(INFO) << "Job " << jobDesc.getJobId() << " start time is not set, keep it for now";
return false;
}
auto duration = std::difftime(nebula::time::WallClock::fastNowInSec(), jobStart);
Expand Down

0 comments on commit 07059ef

Please sign in to comment.