Skip to content
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

CADC-12563 expect the PackageRunner job to be SUSPENDED instead of QUEUED #97

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cadc-pkg-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.2.0'
version = '1.2.1'

description = 'OpenCADC CADC package server library'
def git_url = 'https://github.com/opencadc/dal'
Expand All @@ -25,7 +25,7 @@ dependencies {
implementation 'org.opencadc:cadc-util:[1.6,2.0)'
implementation 'org.opencadc:cadc-log:[1.0,)'
implementation 'org.opencadc:cadc-registry:[1.0,)'
implementation 'org.opencadc:cadc-uws-server:[1.2,1.3)'
implementation 'org.opencadc:cadc-uws-server:[1.2.20,2.0)'

testImplementation 'junit:junit:[4.0,5.0)'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,23 @@ public void run() {
log.info(logInfo.end());
}

protected ExecutionPhase getInitialPhase() {
return ExecutionPhase.QUEUED;
}

private void doIt() {
ExecutionPhase ep;
PackageWriter writer = null;
try {
ep = jobUpdater.setPhase(job.getID(), ExecutionPhase.QUEUED, ExecutionPhase.EXECUTING, new Date());

ep = jobUpdater.setPhase(job.getID(), getInitialPhase(), ExecutionPhase.EXECUTING, new Date());
if (!ExecutionPhase.EXECUTING.equals(ep)) {
ep = jobUpdater.getPhase(job.getID());
log.debug(job.getID() + ": QUEUED -> EXECUTING [FAILED] -- DONE");
log.debug(String.format("%s: %s -> EXECUTING [FAILED] -- DONE", job.getID(), getInitialPhase()));
logInfo.setSuccess(false);
logInfo.setMessage("Could not set job phase to executing, was: " + ep);
return;
}
log.debug(job.getID() + ": QUEUED -> EXECUTING [OK]");
log.debug(String.format("%s: %s -> EXECUTING [OK]", job.getID(), getInitialPhase()));

// Package name should be set here, and anything else needed for
// package to be created aside from initializing the output stream.
Expand Down Expand Up @@ -204,18 +207,10 @@ private void doIt() {
log.debug(job.getID() + ": EXECUTING -> COMPLETED [OK]");

} catch (Throwable t) {
if (ThrowableUtil.isACause(t, InterruptedException.class)) {
try {
ep = jobUpdater.setPhase(job.getID(), ExecutionPhase.QUEUED, ExecutionPhase.EXECUTING, new Date());

if (!ExecutionPhase.ABORTED.equals(ep)) {
return; // clean exit of aborted job
}

} catch (Exception ex2) {
log.error("failed to check job phase after InterruptedException", ex2);

}
try {
ep = jobUpdater.setPhase(job.getID(), ExecutionPhase.EXECUTING, ExecutionPhase.ERROR, new Date());
} catch (Exception ex) {
log.error("failed to update job phase to ERROR after exception", ex);
}
sendError(t, 500);
} finally {
Expand All @@ -242,7 +237,7 @@ private void doIt() {
private ByteCountOutputStream initOutputStream(String mimeType, String contentDisposition)
throws IOException {
// set up syncOutput response and headers
syncOutput.setResponseCode(200);
syncOutput.setCode(200);
syncOutput.setHeader("Content-Type", mimeType);
syncOutput.setHeader("Content-Disposition", contentDisposition);
return new ByteCountOutputStream(syncOutput.getOutputStream());
Expand Down
Loading