-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add markJobSuccessful api call #595
Merged
brndnmtthws
merged 5 commits into
mesos:master
from
Califax:add-mark-job-successful-api-call
Mar 28, 2016
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4ac543e
add markJobSuccessful api call and logic for markJobSuccessAndFireOff…
Califax 7becebb
formatting
Califax 1639dc8
formatting
Califax ae24179
update documentation for marking job successful
Califax ab5172c
update successful call of job to reset dependencies as a job that sta…
Califax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,18 +267,7 @@ class JobScheduler @Inject()(val scheduleHorizon: Period, | |
val job = jobOption.get | ||
jobsObserver.apply(JobFinished(job, taskStatus, attempt)) | ||
|
||
val newJob = job match { | ||
case job: ScheduleBasedJob => | ||
job.copy(successCount = job.successCount + 1, | ||
errorsSinceLastSuccess = 0, | ||
lastSuccess = DateTime.now(DateTimeZone.UTC).toString) | ||
case job: DependencyBasedJob => | ||
job.copy(successCount = job.successCount + 1, | ||
errorsSinceLastSuccess = 0, | ||
lastSuccess = DateTime.now(DateTimeZone.UTC).toString) | ||
case _ => | ||
throw new IllegalArgumentException("Cannot handle unknown task type") | ||
} | ||
val newJob = getNewSuccessfulJob(job) | ||
replaceJob(job, newJob) | ||
processDependencies(jobName, taskDate) | ||
|
||
|
@@ -310,6 +299,43 @@ class JobScheduler @Inject()(val scheduleHorizon: Period, | |
} | ||
} | ||
|
||
/** | ||
* Mark job by job name as successful. Trigger any dependent children jobs that should be run as a result | ||
*/ | ||
def markJobSuccessAndFireOffDependencies(jobName : String): Boolean = { | ||
val optionalJob = jobGraph.getJobForName(jobName) | ||
if (optionalJob.isEmpty) { | ||
log.warning("%s not found in job graph, not marking success".format(jobName)) | ||
return false | ||
} else { | ||
val job = optionalJob.get | ||
jobMetrics.updateJobStatus(jobName, success = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't jobsObserver be notified here? |
||
val newJob = getNewSuccessfulJob(job) | ||
replaceJob(job, newJob) | ||
log.info("Resetting dependency invocations for %s".format(newJob)) | ||
jobGraph.resetDependencyInvocations(jobName) | ||
log.info("Processing dependencies for %s".format(jobName)) | ||
processDependencies(jobName, Option(DateTime.parse(newJob.lastSuccess))) | ||
} | ||
true | ||
} | ||
|
||
private def getNewSuccessfulJob(job: BaseJob): BaseJob = { | ||
val newJob = job match { | ||
case job: ScheduleBasedJob => | ||
job.copy(successCount = job.successCount + 1, | ||
errorsSinceLastSuccess = 0, | ||
lastSuccess = DateTime.now(DateTimeZone.UTC).toString) | ||
case job: DependencyBasedJob => | ||
job.copy(successCount = job.successCount + 1, | ||
errorsSinceLastSuccess = 0, | ||
lastSuccess = DateTime.now(DateTimeZone.UTC).toString) | ||
case _ => | ||
throw new scala.IllegalArgumentException("Cannot handle unknown task type") | ||
} | ||
newJob | ||
} | ||
|
||
def replaceJob(oldJob: BaseJob, newJob: BaseJob) { | ||
lock.synchronized { | ||
jobGraph.replaceVertex(oldJob, newJob) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response is actually a string formatted with:
"marked job %s as successful: %b"
It is always
200 OK
even ifsuccess
is false, which basically forces clients of the API to parse the returned string. Returning JSON would simplify parsing, using a different status code would be even better.