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

prototype: add setAppName and pass value through to JobRunner impl #57

Merged
merged 1 commit into from
Oct 12, 2023
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
2 changes: 1 addition & 1 deletion cadc-uws-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.2.18'
version = '1.2.19'

description = 'OpenCADC UWS server library'
def git_url = 'https://github.com/opencadc/uws'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public abstract class AbstractExecutor implements JobExecutor

protected JobUpdater jobUpdater;
protected Class<JobRunner> jobRunnerClass;
protected String appName;

private AbstractExecutor() { }

Expand All @@ -106,6 +107,13 @@ public void terminate()
// no-op
}

@Override
public void setAppName(String appName) {
JobExecutor.super.setAppName(appName);
this.appName = appName;
}


public void setJobUpdater(JobUpdater jobUpdater)
{
this.jobUpdater = jobUpdater;
Expand Down Expand Up @@ -163,6 +171,7 @@ public final void execute(Job job, SyncOutput sync)
JobRunner jobRunner = getJobRunner();
jobRunner.setJobUpdater(jobUpdater);
jobRunner.setJob(job);
jobRunner.setAppName(appName);
jobRunner.setSyncOutput(sync);

if (sync != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@
*/
public interface JobExecutor
{
default void setAppName(String appName) {
// no-op
}

/**
* Shutdown and release any resources. This includes ThreadPools, connections, open files, etc.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
*/
public interface JobManager {

default void setAppName(String appName) {
// no-op
}

void terminate() throws InterruptedException;

Job create(String requestPath, Job job)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
*/
public interface JobRunner extends Runnable
{
default void setAppName(String appName) {
// no-op
}

public void setJobUpdater(JobUpdater jobUpdater);

public void setJob(Job job);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected void initJobManager(String cname) {
{
Class<JobManager> clazz = (Class<JobManager>) Class.forName(cname);
this.jobManager = clazz.newInstance();
jobManager.setAppName(appName);

Context ctx = new InitialContext();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class SimpleJobManager implements JobManager {

protected JobPersistence jobPersistenceImpl;
protected JobExecutor jobExecutorImpl;
protected String appName;
protected Long maxExecDuration = 3600L;
protected Long maxQuote = 3600L;
protected Long maxDestruction = 7 * 24 * 3600L;
Expand All @@ -112,6 +113,14 @@ public void terminate() throws InterruptedException {
}
}

@Override
public void setAppName(String appName) {
this.appName = appName;
if (jobExecutorImpl != null) {
jobExecutorImpl.setAppName(appName);
}
}

/**
* Set a single (global) JobPersistence instance to be used for all requests.
*
Expand All @@ -128,6 +137,9 @@ public void setJobPersistence(JobPersistence jobPersistence) {
*/
public void setJobExecutor(JobExecutor jobExecutor) {
this.jobExecutorImpl = jobExecutor;
if (appName != null) {
jobExecutorImpl.setAppName(appName);
}
}

protected JobPersistence getJobPersistence(String requestPath) {
Expand Down
Loading