com.atlassian.scheduler.config
Class JobConfig

java.lang.Object
  extended by com.atlassian.scheduler.config.JobConfig

@Immutable
@PublicApi
public final class JobConfig
extends Object

Configuration options available when scheduling a job to be run. This is similar to JobDetails, but provides only the information that is relevant to configuring the job or for the job to reference when it is actually running.

See Also:
JobDetails

Method Summary
 boolean equals(Object o)
           
static JobConfig forJobRunnerKey(JobRunnerKey jobRunnerKey)
          Creates a new job configuration for the specified job runner key.
 JobRunnerKey getJobRunnerKey()
           
 Map<String,Serializable> getParameters()
           
 RunMode getRunMode()
           
 Schedule getSchedule()
           
 int hashCode()
           
 String toString()
           
 JobConfig withParameters(Map<String,Serializable> parameters)
          Returns a copy of this job config that will use the specified parameters instead of what it currently uses.
 JobConfig withRunMode(RunMode runMode)
          Returns a copy of this job config that will use the specified run mode instead of what it currently uses.
 JobConfig withSchedule(Schedule schedule)
          Returns a copy of this job config that will use the specified schedule instead of what it currently uses.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

forJobRunnerKey

public static JobConfig forJobRunnerKey(JobRunnerKey jobRunnerKey)
Creates a new job configuration for the specified job runner key.

By default, the job configuration will assume:

Any of which may be overridden by calling the appropriate method. Note that chaining the methods is recommended, as these methods return an altered copy rather than modifiying the original JobConfig in place. For example, use:

     JobConfig config = JobConfig.forJobRunnerKey("myJobToDoImportantThings")
              .withSchedule(Schedule.forInterval(Date, long))
              .withRunMode(RunMode.RUN_LOCALLY);
 

Parameters:
jobRunnerKey - the unique identifier used to register the JobRunner
Returns:
a job configuration for the specified job runner key that will use the default settings

getJobRunnerKey

@Nonnull
public JobRunnerKey getJobRunnerKey()

getRunMode

@Nonnull
public RunMode getRunMode()

getSchedule

@Nonnull
public Schedule getSchedule()

getParameters

@Nonnull
public Map<String,Serializable> getParameters()

withRunMode

public JobConfig withRunMode(RunMode runMode)
Returns a copy of this job config that will use the specified run mode instead of what it currently uses.

Parameters:
runMode - the new run mode; may be null, in which case the default RunMode.RUN_ONCE_PER_CLUSTER is used
Returns:
the new job configuration; the original is left unchanged

withSchedule

public JobConfig withSchedule(Schedule schedule)
Returns a copy of this job config that will use the specified schedule instead of what it currently uses.

Parameters:
schedule - the new schedule; may be null, in which case the default runOnce(new Date()) is used
Returns:
the new job configuration; the original is left unchanged

withParameters

public JobConfig withParameters(Map<String,Serializable> parameters)
Returns a copy of this job config that will use the specified parameters instead of what it currently uses.

WARNING: The parameters map must be serializable, so all of its contents must be as well. Using objects that are not serializable, even as data members of objects that are themselves serializable, will usually fail. Developers are encouraged to limit the information stored here to a few simple keys for accessing the runtime data that is needed instead of storing large objects, injectable components, etc. in the parameters map.

WARNING: The scheduler service assumes that the objects within the parameters map are immutable. Modifying objects after they have been added to the parameters map may have unpredictable results.

Parameters:
parameters - the new parameters; may be null, in which case the JobRunner is provided with an empty map at run time. The map should contain only immutable, serializable data
Returns:
the new job configuration; the original is left unchanged

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Atlassian. All Rights Reserved.