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
-
Field Summary
-
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 booleanequals(java.lang.Object o)java.lang.StringgetCronExpression()java.lang.LonggetDelay()Gets the delay parameter of the schedule.java.time.InstantgetNextExecutionTime(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 atstartTime.java.time.ZoneIdgetTimeZone()inthashCode()java.time.DurationnextTimeToExecute()Calculates the time duration between next execution time and now.java.lang.BooleanrunningOnTime(java.time.Instant lastExecutionTime)Returns if the job is running on time.java.lang.StringtoString()org.opensearch.common.xcontent.XContentBuildertoXContent(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params)voidwriteTo(org.opensearch.common.io.stream.StreamOutput out)
-
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:ScheduleGets the delay parameter of the schedule. -
getNextExecutionTime
public java.time.Instant getNextExecutionTime(java.time.Instant time)Description copied from interface:ScheduleGets next job execution time of given time parameter.- Specified by:
getNextExecutionTimein interfaceSchedule- Parameters:
time- base time point- Returns:
- next execution time since time parameter.
-
nextTimeToExecute
public java.time.Duration nextTimeToExecute()Description copied from interface:ScheduleCalculates the time duration between next execution time and now.- Specified by:
nextTimeToExecutein interfaceSchedule- 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:ScheduleGets the execution period starting atstartTime.- Specified by:
getPeriodStartingAtin interfaceSchedule- 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:ScheduleReturns if the job is running on time.- Specified by:
runningOnTimein interfaceSchedule- 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:
toXContentin interfaceorg.opensearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
writeTo
public void writeTo(org.opensearch.common.io.stream.StreamOutput out) throws java.io.IOException- Specified by:
writeToin interfaceorg.opensearch.common.io.stream.Writeable- Throws:
java.io.IOException
-