Class BatchConfig


public class BatchConfig
extends AbstractLockable<BatchConfig>
Configuration settings related to a batch of jobs that are about to be submitted to the cluster at more or less the same time. The information becomes readonly when linked to a JobDefinition instance. A single configuration instance can (should!) be used with multiple jobs.
Since:
1.5
Author:
nicklas
  • Field Details

    • delayInterval

      private int delayInterval
    • initialDelay

      private int initialDelay
    • nextTime

      private long nextTime
  • Constructor Details

    • BatchConfig

      public BatchConfig()
      Creates a default batch configuration with a delay interval of 30 seconds and no initial delay.
  • Method Details

    • setDelayInterval

      public void setDelayInterval​(int seconds)
      If multiple jobs are submitted in a batch, instruct the scheduler to defer each job for a short amount of time. This can, for example, be used to prevent a situation where several similar jobs are started at the same time that all try to load the same resource over the network. This option is enabled and set to 30 seconds by default. The value must be a positive integer. Disable by setting the value to null.
      Since:
      1.5
    • getDelayInterval

      public int getDelayInterval()
    • setInitialDelay

      public void setInitialDelay​(int seconds)
      Set the delay of the first job that is submitted in a batch. The value must be an non-negative integer. The default value is 0.
      Since:
      1.5
    • getInitialDelay

      public int getInitialDelay()
    • getNextStartTime

      public long getNextStartTime()
      Get the start time fo the next job that is scheduled. If auto delay is enabled the start time is increased by the configured amount for each call to this method.
    • getDelayForNextJob

      public int getDelayForNextJob()
      Helper method that get the start time for the next job and calculates the delay in seconds from the current time.
    • checkValid

      protected void checkValid​(boolean forLock)
      Check that the initial and delay interval are >=0. If locking, the start time for the next job is set by adding the current time and initial delay.
      Overrides:
      checkValid in class AbstractLockable<BatchConfig>
      Parameters:
      forLock - If TRUE, the instance will be locked after validation