Search in sources :

Example 1 with IgniteFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFutureImpl in project ignite by apache.

the class IgniteKernal method onDisconnected.

/**
     *
     */
public void onDisconnected() {
    Throwable err = null;
    reconnectState.waitPreviousReconnect();
    GridFutureAdapter<?> reconnectFut = ctx.gateway().onDisconnected();
    if (reconnectFut == null) {
        assert ctx.gateway().getState() != STARTED : ctx.gateway().getState();
        return;
    }
    IgniteFutureImpl<?> curFut = (IgniteFutureImpl<?>) ctx.cluster().get().clientReconnectFuture();
    IgniteFuture<?> userFut;
    // In case of previous reconnect did not finish keep reconnect future.
    if (curFut != null && curFut.internalFuture() == reconnectFut)
        userFut = curFut;
    else {
        userFut = new IgniteFutureImpl<>(reconnectFut);
        ctx.cluster().get().clientReconnectFuture(userFut);
    }
    ctx.disconnected(true);
    List<GridComponent> comps = ctx.components();
    for (ListIterator<GridComponent> it = comps.listIterator(comps.size()); it.hasPrevious(); ) {
        GridComponent comp = it.previous();
        try {
            if (!skipDaemon(comp))
                comp.onDisconnected(userFut);
        } catch (IgniteCheckedException e) {
            err = e;
        } catch (Throwable e) {
            err = e;
            if (e instanceof Error)
                throw e;
        }
    }
    for (GridCacheContext cctx : ctx.cache().context().cacheContexts()) {
        cctx.gate().writeLock();
        cctx.gate().writeUnlock();
    }
    ctx.gateway().writeLock();
    ctx.gateway().writeUnlock();
    if (err != null) {
        reconnectFut.onDone(err);
        U.error(log, "Failed to reconnect, will stop node", err);
        close();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl)

Example 2 with IgniteFutureImpl

use of org.apache.ignite.internal.util.future.IgniteFutureImpl in project ignite by apache.

the class IgniteMessagingImpl method remoteListenAsync.

/** {@inheritDoc} */
@Override
public IgniteFuture<UUID> remoteListenAsync(@Nullable Object topic, IgniteBiPredicate<UUID, ?> p) throws IgniteException {
    A.notNull(p, "p");
    guard();
    try {
        GridContinuousHandler hnd = new GridMessageListenHandler(topic, (IgniteBiPredicate<UUID, Object>) p);
        return new IgniteFutureImpl<>(ctx.continuous().startRoutine(hnd, false, 1, 0, false, prj.predicate()));
    } finally {
        unguard();
    }
}
Also used : IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) GridContinuousHandler(org.apache.ignite.internal.processors.continuous.GridContinuousHandler) UUID(java.util.UUID)

Aggregations

IgniteFutureImpl (org.apache.ignite.internal.util.future.IgniteFutureImpl)2 UUID (java.util.UUID)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 GridContinuousHandler (org.apache.ignite.internal.processors.continuous.GridContinuousHandler)1