Example usage for com.google.common.util.concurrent ListenableScheduledFuture isDone

List of usage examples for com.google.common.util.concurrent ListenableScheduledFuture isDone

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ListenableScheduledFuture isDone.

Prototype

boolean isDone();

Source Link

Document

Returns true if this task completed.

Usage

From source file:com.github.rinde.rinsim.core.model.time.RealtimeModel.java

void shutdownExecutor() {
    LOGGER.trace("Shutting down executor..");
    final ListeningScheduledExecutorService ex = realtimeState.executor;
    if (ex != null) {
        ex.shutdown();//from w  w  w.  j a  v  a 2s  .c  o  m

        // in case the future could not be cancelled before, do it now
        final ListenableScheduledFuture<?> fut = realtimeState.schedulerFuture;
        if (fut != null && !fut.isDone()) {
            realtimeState.cancelTask();
        }

        try {
            ex.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
        } catch (final InterruptedException e) {
            throw new IllegalStateException(e);
        }
        LOGGER.trace("Executor shutdown.");
    }
    verifyNotNull(affinityLock).release();
}

From source file:io.druid.server.lookup.cache.LookupCoordinatorManager.java

@VisibleForTesting
boolean backgroundManagerIsRunning() {
    ListenableScheduledFuture backgroundManagerFuture = this.backgroundManagerFuture;
    return backgroundManagerFuture != null && !backgroundManagerFuture.isDone();
}

From source file:org.opendaylight.sxp.core.SxpNode.java

/**
 * Sets SxpNode specific Timer//from   w  w  w .j a va2  s.  com
 *
 * @param timerType Type of Timer that will be set
 * @param timer     Timer logic
 * @return ListenableScheduledFuture callback
 */
private ListenableScheduledFuture<?> setTimer(TimerType timerType, ListenableScheduledFuture<?> timer) {
    ListenableScheduledFuture<?> t = this.timers.put(timerType, timer);
    if (t != null && !t.isDone()) {
        t.cancel(false);
    }
    return timer;
}

From source file:org.opendaylight.sxp.core.SxpConnection.java

/**
 * Start DeleteHoldDown timer and if Reconciliation timer is started stop it
 *//* w w w . ja  v a2  s  . c  om*/
public void setDeleteHoldDownTimer() {
    if (connectionBuilder.getConnectionTimers().getDeleteHoldDownTime() == 0)
        return;
    LOG.info("{} onChannelInactivation/setDeleteHoldDownTimer", this);
    setTimer(TimerType.DeleteHoldDownTimer, connectionBuilder.getConnectionTimers().getDeleteHoldDownTime());
    ListenableScheduledFuture<?> ctReconciliation = getTimer(TimerType.ReconciliationTimer);
    if (ctReconciliation != null && !ctReconciliation.isDone()
            && connectionBuilder.getConnectionTimers().getReconciliationTime() != 0) {
        LOG.info("{} Stopping Reconciliation timer cause | Connection DOWN.", this);
        setTimer(TimerType.ReconciliationTimer, null);
    }
    setStateDeleteHoldDown();
}

From source file:org.opendaylight.sxp.core.SxpConnection.java

/**
 * Sets Reconciliation timer on current connection
 *//*w w  w  .  j a v a2s  .  c om*/
public void setReconciliationTimer() {
    if (getReconciliationTime() > 0) {
        ListenableScheduledFuture<?> ctDeleteHoldDown = getTimer(TimerType.DeleteHoldDownTimer);
        if (ctDeleteHoldDown != null && !ctDeleteHoldDown.isDone()) {
            LOG.info("{} Stopping Delete Hold Down timer.", this);
            setTimer(TimerType.DeleteHoldDownTimer, null);
        }
        LOG.info("{} Starting Reconciliation timer.", this);
        setTimer(TimerType.ReconciliationTimer, getReconciliationTime());
    }
}