Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.amazonaws.services.simpleworkflow.flow.interceptors;
 
 import java.util.Date;
 
Schedule that represents invocations with a fixed delay up to a specified expiration interval or count.

Author(s):
fateev
    protected static final int SECOND = 1000;
    private final long intervalMilliseconds;
    private final long expirationMilliseconds;
    private final int maxInvocationCount;
    public FixedIntervalInvocationSchedule(int intervalSecondsint expirationSecondsint maxInvocationCount) {
        this. = intervalSeconds * ;
        this. = expirationSeconds * ;
        this. = maxInvocationCount;
    }
    
    public FixedIntervalInvocationSchedule(int intervalSecondsint expirationSeconds) {
        this. = intervalSeconds * ;
        this. = expirationSeconds * ;
        this. = .;
    }
    @Override
    public long nextInvocationDelaySeconds(Date currentTimeDate startTimeDate lastInvocationTimeint pastInvocatonsCount) {
        if (pastInvocatonsCount >= ) {
            return .;
        }
        long resultMilliseconds;
        if (lastInvocationTime == null) {
            resultMilliseconds = startTime.getTime() +  - currentTime.getTime();
        }
        else {
            resultMilliseconds = lastInvocationTime.getTime() +  - currentTime.getTime();
        }
        if (resultMilliseconds < 0) {
            resultMilliseconds = 0;
        }
        if (currentTime.getTime() + resultMilliseconds - startTime.getTime() >= ) {
            return .;
        }
        return resultMilliseconds / ;
    }
New to GrepCode? Check out our FAQ X