uws.service.controller
Class ExecutionDurationController

java.lang.Object
  extended by uws.service.controller.ExecutionDurationController
All Implemented Interfaces:
java.io.Serializable

public class ExecutionDurationController
extends java.lang.Object
implements java.io.Serializable

Lets controlling the execution duration of all jobs managed by a UWS. Thus it is possible to set a default and a maximum value. Moreover you can indicate whether the execution duration of jobs can be modified by the user or not.

Note: By default, the execution duration can be modified by anyone without any limitation. The default value is AbstractJob.UNLIMITED_DURATION.

Version:
02/2011
Author:
Grégory Mantelet (CDS)
See Also:
Serialized Form

Field Summary
protected  boolean allowModification
          Indicates whether the execution duration of jobs can be modified.
protected  long defaultDuration
          The default duration.
protected  long maxDuration
          The maximum duration.
 
Constructor Summary
ExecutionDurationController()
           
 
Method Summary
 boolean allowModification()
          Tells whether the execution duration of any managed job can be modified.
 void allowModification(boolean allowModification)
          Lets indicating whether the execution duration of any managed job can be modified.
 void control(AbstractJob jobToControl, long durationToCheck)
          Controls the given execution duration.
 void control(AbstractJob job, java.util.Map<java.lang.String,java.lang.String> params)
          Extracts the execution duration from the given map and controls its value.
 long getDefaultExecutionDuration()
          Gets the default execution duration.
 long getMaxExecutionDuration()
          Gets the maximum execution duration.
 void init(java.util.Map<java.lang.String,java.lang.String> params)
          Controls the execution duration given in the map or initializes it with the default value if not present in the map.
 void setDefaultExecutionDuration(AbstractJob job)
          Sets the execution duration of the given job with the default value.
 boolean setDefaultExecutionDuration(long defaultExecutionDuration)
          Sets the default execution duration.
 void setExecutionDuration(AbstractJob job, long duration)
          Controls the given value and sets the execution duration of the given job with this value.
 void setMaxExecutionDuration(long maxExecutionDuration)
          Sets the maximum execution duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultDuration

protected long defaultDuration
The default duration.


maxDuration

protected long maxDuration
The maximum duration.


allowModification

protected boolean allowModification
Indicates whether the execution duration of jobs can be modified.

Constructor Detail

ExecutionDurationController

public ExecutionDurationController()
Method Detail

getDefaultExecutionDuration

public final long getDefaultExecutionDuration()
Gets the default execution duration.

Returns:
The default execution duration (0 or less mean an unlimited duration).

setDefaultExecutionDuration

public final boolean setDefaultExecutionDuration(long defaultExecutionDuration)
Sets the default execution duration.

Parameters:
defaultExecutionDuration - The new default execution duration (AbstractJob.UNLIMITED_DURATION, 0 or a negative value mean an unlimited duration).

getMaxExecutionDuration

public final long getMaxExecutionDuration()
Gets the maximum execution duration.

Returns:
The maximum execution duration (0 or less mean an unlimited duration).

setMaxExecutionDuration

public final void setMaxExecutionDuration(long maxExecutionDuration)
Sets the maximum execution duration.

Parameters:
maxExecutionDuration - The maximum execution duration (AbstractJob.UNLIMITED_DURATION, 0 or a negative value mean an unlimited duration).

allowModification

public final boolean allowModification()
Tells whether the execution duration of any managed job can be modified.

Returns:
true if the execution duration can be modified, false otherwise.

allowModification

public final void allowModification(boolean allowModification)
Lets indicating whether the execution duration of any managed job can be modified.

Parameters:
allowModification - true if the execution duration can be modified, false otherwise.

init

public void init(java.util.Map<java.lang.String,java.lang.String> params)
          throws UWSException
Controls the execution duration given in the map or initializes it with the default value if not present in the map.

Parameters:
params - The map of all parameters to use for the creation of a job.
Throws:
UWSException - If the execution duration given in the map is not valid.
See Also:
control(AbstractJob, Map)

control

public void control(AbstractJob job,
                    java.util.Map<java.lang.String,java.lang.String> params)
             throws UWSException
Extracts the execution duration from the given map and controls its value.

Parameters:
job - The job whose the execution duration will be set.
params - The map which contains the new execution duration of the given job.
Throws:
UWSException - If the new execution duration is not a long number or if the execution duration of the given job can not be modified or if the given value exceeds the maximum value.
See Also:
control(AbstractJob, long)

control

public void control(AbstractJob jobToControl,
                    long durationToCheck)
             throws UWSException
Controls the given execution duration.

Parameters:
jobToControl - The job whose the execution duration will be updated by the given value.
durationToCheck - The new execution duration of the given value.
Throws:
UWSException - If the current phase of the job doesn't allow any modification or if this controller forbids the modification of the execution duration or if the new execution duration exceeds the maximum value.

setDefaultExecutionDuration

public void setDefaultExecutionDuration(AbstractJob job)
                                 throws UWSException
Sets the execution duration of the given job with the default value.

Parameters:
job - The job whose the execution duration must be set.
Throws:
UWSException - If it is impossible to set the execution duration of the given job (for instance, if the job is running or is finished).
See Also:
setExecutionDuration(AbstractJob, long)

setExecutionDuration

public void setExecutionDuration(AbstractJob job,
                                 long duration)
                          throws UWSException
Controls the given value and sets the execution duration of the given job with this value.

Parameters:
job - The job whose the execution duration must be set.
duration - The new execution duration of the given job.
Throws:
UWSException - If the current phase of the job doesn't allow any modification or if this controller forbids the modification of the execution duration or if the new execution duration exceeds the maximum value.
See Also:
control(AbstractJob, long), AbstractJob.setExecutionDuration(long)