Class CronSchedule

java.lang.Object
org.opensearch.jobscheduler.spi.schedule.CronSchedule
All Implemented Interfaces:
org.opensearch.common.io.stream.Writeable, org.opensearch.common.xcontent.ToXContent, org.opensearch.common.xcontent.ToXContentObject, Schedule

public class CronSchedule
extends java.lang.Object
implements Schedule
UnixCron Schedule implementation. Refer to https://en.wikipedia.org/wiki/Cron for cron syntax.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.opensearch.common.xcontent.ToXContent

    org.opensearch.common.xcontent.ToXContent.DelegatingMapParams, org.opensearch.common.xcontent.ToXContent.MapParams, org.opensearch.common.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.opensearch.common.io.stream.Writeable

    org.opensearch.common.io.stream.Writeable.Reader<V extends java.lang.Object>, org.opensearch.common.io.stream.Writeable.Writer<V extends java.lang.Object>
  • Field Summary

    Fields inherited from interface org.opensearch.jobscheduler.spi.schedule.Schedule

    DELAY_FIELD

    Fields inherited from interface org.opensearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors 
    Constructor Description
    CronSchedule​(java.lang.String expression, java.time.ZoneId timezone)  
    CronSchedule​(java.lang.String expression, java.time.ZoneId timezone, long scheduleDelay)  
    CronSchedule​(org.opensearch.common.io.stream.StreamInput input)  
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object o)  
    java.lang.String getCronExpression()  
    java.lang.Long getDelay()
    Gets the delay parameter of the schedule.
    java.time.Instant getNextExecutionTime​(java.time.Instant time)
    Gets next job execution time of given time parameter.
    org.opensearch.common.collect.Tuple<java.time.Instant,​java.time.Instant> getPeriodStartingAt​(java.time.Instant startTime)
    Gets the execution period starting at startTime.
    java.time.ZoneId getTimeZone()  
    int hashCode()  
    java.time.Duration nextTimeToExecute()
    Calculates the time duration between next execution time and now.
    java.lang.Boolean runningOnTime​(java.time.Instant lastExecutionTime)
    Returns if the job is running on time.
    java.lang.String toString()  
    org.opensearch.common.xcontent.XContentBuilder toXContent​(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params)  
    void writeTo​(org.opensearch.common.io.stream.StreamOutput out)  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.opensearch.common.xcontent.ToXContentObject

    isFragment
  • Constructor Details

    • CronSchedule

      public CronSchedule​(java.lang.String expression, java.time.ZoneId timezone)
    • CronSchedule

      public CronSchedule​(java.lang.String expression, java.time.ZoneId timezone, long scheduleDelay)
    • CronSchedule

      public CronSchedule​(org.opensearch.common.io.stream.StreamInput input) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • getTimeZone

      public java.time.ZoneId getTimeZone()
    • getCronExpression

      public java.lang.String getCronExpression()
    • getDelay

      public java.lang.Long getDelay()
      Description copied from interface: Schedule
      Gets the delay parameter of the schedule.
      Specified by:
      getDelay in interface Schedule
      Returns:
      the delay parameter of the schedule as a Long.
    • getNextExecutionTime

      public java.time.Instant getNextExecutionTime​(java.time.Instant time)
      Description copied from interface: Schedule
      Gets next job execution time of given time parameter.
      Specified by:
      getNextExecutionTime in interface Schedule
      Parameters:
      time - base time point
      Returns:
      next execution time since time parameter.
    • nextTimeToExecute

      public java.time.Duration nextTimeToExecute()
      Description copied from interface: Schedule
      Calculates the time duration between next execution time and now.
      Specified by:
      nextTimeToExecute in interface Schedule
      Returns:
      time duration between next execution and now.
    • getPeriodStartingAt

      public org.opensearch.common.collect.Tuple<java.time.Instant,​java.time.Instant> getPeriodStartingAt​(java.time.Instant startTime)
      Description copied from interface: Schedule
      Gets the execution period starting at startTime.
      Specified by:
      getPeriodStartingAt in interface Schedule
      Parameters:
      startTime - start time of the period.
      Returns:
      the start time and end time of the period in the tuple.
    • runningOnTime

      public java.lang.Boolean runningOnTime​(java.time.Instant lastExecutionTime)
      Description copied from interface: Schedule
      Returns if the job is running on time.
      Specified by:
      runningOnTime in interface Schedule
      Parameters:
      lastExecutionTime - last execution time.
      Returns:
      true if the job executes on time, otherwise false.
    • toXContent

      public org.opensearch.common.xcontent.XContentBuilder toXContent​(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.opensearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object o)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • writeTo

      public void writeTo​(org.opensearch.common.io.stream.StreamOutput out) throws java.io.IOException
      Specified by:
      writeTo in interface org.opensearch.common.io.stream.Writeable
      Throws:
      java.io.IOException