Initialization for a fixed-rate or fixed-delay task.

@param isFixedRate indicates if this is a fixed-rate or fixed-delay task
@param initialDelay milliseconds before first execution
@param interval milliseconds between task executions
431570
@Trivial
    void initForRepeatingTask(boolean isFixedRate, long initialDelay, long interval) {
        this.initialDelay = initialDelay;
        this.interval = interval;
        this.isFixedRate = isFixedRate;
    }
909976
public static long getNextIntervalStart(long time, int intervalInMinutes, int offsetInMinutes) {
		long interval = MINUTE_IN_MS * intervalInMinutes;
		return getPreviousIntervalStart(time, intervalInMinutes, offsetInMinutes) + interval;
	}
120326
public void setMinRate(double min)
    {
        if(min <= 0 || Double.isNaN(min) || Double.isInfinite(min))
            throw new RuntimeException("minRate should be positive, not " + min);
        this.min = min;
    }
804162
public void setInitialLearningRate(double initialLearningRate)
    {
        if(initialLearningRate <= 0 || Double.isInfinite(initialLearningRate) || Double.isNaN(initialLearningRate))
            throw new IllegalArgumentException("Learning rate must be a positive constant, not " + initialLearningRate);
        this.initialLearningRate = initialLearningRate;
    }
465794
protected void init (long milliDivider, long microDivider)
    {
        _milliDivider = milliDivider;
        _microDivider = microDivider;
        reset();
        log.info("Using " + getClass() + " timer", "mfreq", _milliDivider,
                 "ufreq", _microDivider, "start", _startStamp);
    }
564085
public void initialize() {

        if (m_taskFuture != null) {
            // in case initialize has been called before on this object, cancel the existing task
            m_taskFuture.cancel(false);
            m_taskFuture = null;
        }
        m_state = readCompleteConfiguration();
        // In debug mode, use a shorter delay to speed up the test cases
        long delay = DEBUG ? 500 : TASK_DELAY_MILLIS;
        m_taskFuture = OpenCms.getExecutor().scheduleWithFixedDelay(new Runnable() {

            public void run() {

                performUpdate();
            }
        }, delay, delay, TimeUnit.MILLISECONDS);
    }
148699
synchronized void start(long initialDelay, long period, TimeUnit unit, Runnable runnable) {
        if (this.scheduledFuture != null) {
            throw new IllegalArgumentException("Reporter already started");
        }

        this.scheduledFuture = executor.scheduleAtFixedRate(runnable, initialDelay, period, unit);
    }
1301644
@Override
    public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date startTime, long period) {
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return this.scheduledExecutor.scheduleAtFixedRate(decorateTask(task, true), initialDelay, period,
                    TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task,
                    ex);
        }
    }
1110665
public static ScheduledFuture<?> runWithScheduleAtFixedRate(
            long initialDelayMillis, long periodMillis, Runnable runnable) {
        return runWithScheduleAtFixedRate(initialDelayMillis, periodMillis,
                "runWithScheduleAtFixedRate", runnable);
    }
1255530
@Override
    @SuppressWarnings("nls")
    public void initialize() {
        try {
            ScheduledExecutorService schedulerService = Executors.newSingleThreadScheduledExecutor();
            CountDownLatch cdl = new CountDownLatch(1);
            Holder<Exception> exception = new Holder<>();

            ScheduledFuture<?> sched = schedulerService.scheduleAtFixedRate(() -> {
                logger.info("Polling for Elasticsearch...");
                try {
                    esClient.execute(new Health.Builder().build());
                    cdl.countDown();
                } catch (IOException e) {
                    logger.info("Unable to reach Elasticsearch. Will continue polling.");
                    //System.out.println("Result of polling", e);
                    exception.setValue(e);
                }
            },
            0, // Start immediately
            1, // Poll every 1 seconds
            TimeUnit.SECONDS);

            cdl.await(30, TimeUnit.SECONDS); // Max wait 30 seconds
            sched.cancel(true);

            // CDL > 0 means we never successfully hit the health endpoint.
            if (exception.getValue() != null && cdl.getCount() > 0) {
                throw exception.getValue();
            }
            // TODO Do we need a loop to wait for all nodes to join the cluster?
            Action<JestResult> action = new IndicesExists.Builder(getIndexName()).build();
            synchronized(EsStorage.class) {
                JestResult result = esClient.execute(action);
                if (!result.isSucceeded()) {
                    createIndex(getIndexName());
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
897349
public final void initializeInternalTimer() {
        // if it is the first the instance is started, we initialize the
        // internal timer thread
        if (!internalTimerInitialized) {

            TimerTask internalTimerTask = new TimerTask() {

                /**
                 * this method is triggered every TIMER_INTERVAL_MILLIS
                 */
                @Override
                public void run() {

                    if (terminated) {
                        running = false;
                        booting = false;
                        stopping = false;
                        pubDns = null;
                        this.cancel();
                        onTerminated();
                        return;
                    }

                    if (running) {

                        if (booting) {

                            // delay a random 'boot time'
                            if (MAX_BOOT_TIME_MILLS != 0) {
                                try {
                                    Thread.sleep(MIN_BOOT_TIME_MILLS
                                            + random.nextInt((int) (MAX_BOOT_TIME_MILLS
                                                    - MIN_BOOT_TIME_MILLS)));
                                } catch (InterruptedException e) {
                                    throw new AwsMockException(
                                            "InterruptedException caught when delaying a mock random 'boot time'",
                                            e);
                                }
                            }

                            // booted, assign a mock pub dns name
                            pubDns = generatePubDns();

                            booting = false;

                            onBooted();

                        } else if (stopping) {

                            // delay a random 'shutdown time'
                            if (MAX_SHUTDOWN_TIME_MILLS != 0) {
                                try {
                                    Thread.sleep(MIN_SHUTDOWN_TIME_MILLS
                                            + random.nextInt((int) (MAX_SHUTDOWN_TIME_MILLS
                                                    - MIN_SHUTDOWN_TIME_MILLS)));
                                } catch (InterruptedException e) {
                                    throw new AwsMockException(
                                            "InterruptedException caught when delaying a mock random 'shutdown time'",
                                            e);
                                }
                            }

                            // unset pub dns name
                            pubDns = null;

                            stopping = false;

                            running = false;

                            onStopped();

                        }

                        onInternalTimer();

                    }

                }
            };
            timer = new SerializableTimer(true);
            timer.schedule(internalTimerTask, 0L, TIMER_INTERVAL_MILLIS);

            internalTimerInitialized = true;
        }
    }
1234939
public final void schedule (long initialDelay, long repeatDelay)
    {
        if (!_mgr.isRegisteredFrameParticipant(this)) {
            _mgr.registerFrameParticipant(this);
        }

        _repeatDelay = repeatDelay;
        _initDelay = initialDelay;
        _nextTime = -1;
    }
917421
public void register(int interval, @NonNull OnTickListener onTickListener, boolean intermediate) {
        mDefaultTimer.register(interval, onTickListener, intermediate);
    }
1084863
private void initProperties(int interval)
  {
    // Limit to 1 .. MAXIMUM_INTERVAL
    if (interval > MAXIMUM_INTERVAL) interval = MAXIMUM_INTERVAL;
    if (interval < 1) interval = 1;
    _interval = interval;
  }
304732
public void setDeliveryDelay(long deliveryDelay) {
        if (deliveryDelay < 0 || deliveryDelay > MAXIMUM_DELIVERY_DELAY_MILLISECONDS) {
            throw new IllegalArgumentException("Delivery delay must be non-negative and at most 15 minutes: " + deliveryDelay);
        }
        if (deliveryDelay % 1000 != 0) {
            throw new IllegalArgumentException("Delivery delay must be a multiple of 1000: " + deliveryDelay);
        }
        this.deliveryDelaySeconds = (int)(deliveryDelay / 1000);
    }
826202
@Override
    public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
        ScheduledExecutorService executor = getScheduledExecutor();
        long initialDelay = startTime.getTime() - System.currentTimeMillis();
        try {
            return executor.scheduleWithFixedDelay(errorHandlingTask(task, true), initialDelay, delay,
                    TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException ex) {
            throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
        }
    }
1371297
public void schedule(BackoffTask task, long initialDelay, long fixedDelay) {
    	synchronized (queue) {
	    	start();
	        queue.put(new DelayedTimerTask(task, initialDelay, fixedDelay));
    	}
    }