public class OpenGridService
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
OpenGridService.JobCompletionInvoker |
(package private) static class |
OpenGridService.JobStatusTimerTask
Task for checking current status of jobs that has been
sent to the cluster.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,OpenGridCluster> |
clusters |
private Extension<ServiceControllerAction> |
ext |
private static OpenGridService |
instance |
private boolean |
isRunning |
private java.util.TimerTask |
jobStatusTimer |
private java.util.Set<JobIdentifier> |
jobsToAbort |
private java.util.Set<JobIdentifier> |
jobsToUpdate |
private long |
lastJobStatusUpdate |
private static org.slf4j.Logger |
logger |
private static long |
MIN_WAIT_INTERVAL |
private java.util.Map<JobIdentifier,JobStatusUpdater> |
nonGridJobsToUpdate |
private SessionControl |
rootSc |
private SessionControl |
systemSc |
private java.util.Set<JobIdentifier> |
unknownJobs |
Modifier | Constructor and Description |
---|---|
private |
OpenGridService() |
Modifier and Type | Method and Description |
---|---|
void |
asyncJobAbort(JobIdentifier jobId)
Register a job that should be aborted.
|
void |
asyncJobStatusUpdate(JobIdentifier jobId)
Register a status update request for a job.
|
void |
asyncJobStatusUpdate(JobIdentifier jobId,
JobStatusUpdater updater)
Register a status update request for a job that is is
not an Open Grid job.
|
OpenGridCluster |
getClusterById(DbControl dc,
java.lang.String clusterId)
Get information about a cluster with known id.
|
java.util.Collection<OpenGridCluster> |
getClusters(java.util.Collection<JobAgent> jobAgents)
Get a collection with all registered clusters that are
either open to all or referencing one of the listed job agents
where the logged in user has at least USE permission.
|
java.util.Collection<OpenGridCluster> |
getClusters(DbControl dc,
java.util.Collection<Include> include)
Get all clusters that the logged in user is allowed to use.
|
static OpenGridService |
getInstance()
Get the singleton instance of the service.
|
private OpenGridSession |
getSession(JobIdentifier jobId,
java.util.Map<java.lang.String,OpenGridSession> sessions)
Get an existing session from the cache or create a new connection if
it doesn't exists.
|
boolean |
isDefined(java.lang.String clusterId)
Check if a cluster with the given id has been defined and
registered with this service.
|
boolean |
isRunning()
Is the Open Grid service running or not?
|
(package private) void |
processAsyncRequests()
Process async requests since the last time.
|
private boolean |
setErrorOnBaseJob(JobIdentifier jobId,
java.lang.String msg)
Set ERROR status on a BASE job.
|
private boolean |
setProgressOnBaseJob(JobIdentifier jobId,
int progress,
java.lang.String msg)
Update the progress status on a BASE job.
|
(package private) void |
start(SessionControl systemSc,
Extension<ServiceControllerAction> ext)
Start the service if it is not running.
|
(package private) void |
stop()
Stop the service if it is running.
|
private void |
stopInternal() |
private OpenGridSession |
tryConnect(JobIdentifier jobId)
Try to connect to the cluster referenced by the job identifier.
|
private boolean |
updateJobStatusInBase(JobStatus jobStatus,
OpenGridSession session,
OpenGridService.JobCompletionInvoker jobCompletionInvoker) |
private static final org.slf4j.Logger logger
private static OpenGridService instance
private static final long MIN_WAIT_INTERVAL
private final java.util.Map<java.lang.String,OpenGridCluster> clusters
private volatile boolean isRunning
private java.util.TimerTask jobStatusTimer
private long lastJobStatusUpdate
private SessionControl systemSc
private SessionControl rootSc
private Extension<ServiceControllerAction> ext
private final java.util.Set<JobIdentifier> jobsToAbort
private final java.util.Set<JobIdentifier> jobsToUpdate
private final java.util.Map<JobIdentifier,JobStatusUpdater> nonGridJobsToUpdate
private final java.util.Set<JobIdentifier> unknownJobs
public static final OpenGridService getInstance()
public boolean isDefined(java.lang.String clusterId)
public OpenGridCluster getClusterById(DbControl dc, java.lang.String clusterId)
dc
- An open DbControl for permission check against job agents
(null is allowed if the cluster is not linked to a job agent)clusterId
- The ID of the clusterItemNotFoundException
- If a cluster is found but the job agent it is
linked to is not foundPermissionDeniedException
- If the cluster is linked to a job agent
that the user doens't have permission to usepublic java.util.Collection<OpenGridCluster> getClusters(DbControl dc, java.util.Collection<Include> include)
Include.IN_PROJECT
). Clusters that
are open to all are always included.dc
- An open DbControlinclude
- A set of include options for the job agent query
(if null the default query options are used)public java.util.Collection<OpenGridCluster> getClusters(java.util.Collection<JobAgent> jobAgents)
jobAgents
- A list of job agents (must exist in the database)
If null or empty, only clusters that are open to all are
returnedpublic boolean isRunning()
void start(SessionControl systemSc, Extension<ServiceControllerAction> ext)
void stop()
private void stopInternal()
public void asyncJobAbort(JobIdentifier jobId)
jobId
- The job identifierpublic void asyncJobStatusUpdate(JobIdentifier jobId)
jobId
- The job identifierpublic void asyncJobStatusUpdate(JobIdentifier jobId, JobStatusUpdater updater)
JobIdentifier.getClusterId()
is found the JobStatusUpdater.getJobStatus(OpenGridSession, JobIdentifier)
is provided with a connected session, otherwise that parameter is null.
The JobIdentifier.getClusterJobId()
can always be substituted
with some other ID.jobId
- A job identifier with exceptions as noted aboveupdater
- The actual instance that performs the update checkvoid processAsyncRequests()
private OpenGridSession getSession(JobIdentifier jobId, java.util.Map<java.lang.String,OpenGridSession> sessions)
private OpenGridSession tryConnect(JobIdentifier jobId)
private boolean setErrorOnBaseJob(JobIdentifier jobId, java.lang.String msg)
private boolean setProgressOnBaseJob(JobIdentifier jobId, int progress, java.lang.String msg)
private boolean updateJobStatusInBase(JobStatus jobStatus, OpenGridSession session, OpenGridService.JobCompletionInvoker jobCompletionInvoker)