Search in sources :

Example 6 with GridDhtPartitionsExchangeFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture in project ignite by apache.

the class GridCachePartitionExchangeManager method affinityReadyFuture.

/**
     * @param ver Topology version.
     * @return Future or {@code null} is future is already completed.
     */
@Nullable
public IgniteInternalFuture<?> affinityReadyFuture(AffinityTopologyVersion ver) {
    GridDhtPartitionsExchangeFuture lastInitializedFut0 = lastInitializedFut;
    if (lastInitializedFut0 != null && lastInitializedFut0.topologyVersion().compareTo(ver) == 0) {
        if (log.isDebugEnabled())
            log.debug("Return lastInitializedFut for topology ready future " + "[ver=" + ver + ", fut=" + lastInitializedFut0 + ']');
        return lastInitializedFut0;
    }
    AffinityTopologyVersion topVer = readyTopVer.get();
    if (topVer.compareTo(ver) >= 0) {
        if (log.isDebugEnabled())
            log.debug("Return finished future for topology ready future [ver=" + ver + ", topVer=" + topVer + ']');
        return null;
    }
    GridFutureAdapter<AffinityTopologyVersion> fut = F.addIfAbsent(readyFuts, ver, new AffinityReadyFuture(ver));
    if (log.isDebugEnabled())
        log.debug("Created topology ready future [ver=" + ver + ", fut=" + fut + ']');
    topVer = readyTopVer.get();
    if (topVer.compareTo(ver) >= 0) {
        if (log.isDebugEnabled())
            log.debug("Completing created topology ready future " + "[ver=" + topVer + ", topVer=" + topVer + ", fut=" + fut + ']');
        fut.onDone(topVer);
    } else if (stopErr != null)
        fut.onDone(stopErr);
    return fut;
}
Also used : GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with GridDhtPartitionsExchangeFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpDebugInfo.

/**
     * @param exchTopVer Optional current exchange topology version.
     * @throws Exception If failed.
     */
public void dumpDebugInfo(@Nullable AffinityTopologyVersion exchTopVer) throws Exception {
    U.warn(log, "Ready affinity version: " + readyTopVer.get());
    U.warn(log, "Last exchange future: " + lastInitializedFut);
    exchWorker.dumpExchangeDebugInfo();
    if (!readyFuts.isEmpty()) {
        U.warn(log, "Pending affinity ready futures:");
        for (AffinityReadyFuture fut : readyFuts.values()) U.warn(log, ">>> " + fut);
    }
    ExchangeFutureSet exchFuts = this.exchFuts;
    if (exchFuts != null) {
        U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
        int cnt = 0;
        for (GridDhtPartitionsExchangeFuture fut : exchFuts.values()) {
            U.warn(log, ">>> " + fut);
            if (++cnt == 10)
                break;
        }
    }
    dumpPendingObjects(exchTopVer);
    for (GridCacheContext cacheCtx : cctx.cacheContexts()) cacheCtx.preloader().dumpDebugInfo();
    cctx.affinity().dumpDebugInfo();
    // Dump IO manager statistics.
    cctx.gridIO().dumpStats();
}
Also used : GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture)

Example 8 with GridDhtPartitionsExchangeFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture in project ignite by apache.

the class GridCachePartitionExchangeManager method onKernalStop0.

/** {@inheritDoc} */
@Override
protected void onKernalStop0(boolean cancel) {
    cctx.gridEvents().removeDiscoveryEventListener(discoLsnr);
    cctx.io().removeHandler(0, GridDhtPartitionsSingleMessage.class);
    cctx.io().removeHandler(0, GridDhtPartitionsFullMessage.class);
    cctx.io().removeHandler(0, GridDhtPartitionsSingleRequest.class);
    stopErr = cctx.kernalContext().clientDisconnected() ? new IgniteClientDisconnectedCheckedException(cctx.kernalContext().cluster().clientReconnectFuture(), "Client node disconnected: " + cctx.igniteInstanceName()) : new IgniteInterruptedCheckedException("Node is stopping: " + cctx.igniteInstanceName());
    // Finish all exchange futures.
    ExchangeFutureSet exchFuts0 = exchFuts;
    if (exchFuts0 != null) {
        for (GridDhtPartitionsExchangeFuture f : exchFuts.values()) f.onDone(stopErr);
    }
    for (AffinityReadyFuture f : readyFuts.values()) f.onDone(stopErr);
    if (!cctx.kernalContext().clientNode()) {
        for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) cctx.io().removeOrderedHandler(rebalanceTopic(cnt));
    }
    U.cancel(exchWorker);
    if (log.isDebugEnabled())
        log.debug("Before joining on exchange worker: " + exchWorker);
    U.join(exchWorker, log);
    ResendTimeoutObject resendTimeoutObj = pendingResend.getAndSet(null);
    if (resendTimeoutObj != null)
        cctx.time().removeTimeoutObject(resendTimeoutObj);
}
Also used : IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)

Example 9 with GridDhtPartitionsExchangeFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture in project ignite by apache.

the class GridCachePartitionExchangeManager method dumpLongRunningOperations.

/**
     * @param timeout Operation timeout.
     */
public void dumpLongRunningOperations(long timeout) {
    try {
        GridDhtPartitionsExchangeFuture lastFut = lastInitializedFut;
        // If exchange is in progress it will dump all hanging operations if any.
        if (lastFut != null && !lastFut.isDone())
            return;
        long curTime = U.currentTimeMillis();
        boolean found = false;
        IgniteTxManager tm = cctx.tm();
        if (tm != null) {
            for (IgniteInternalTx tx : tm.activeTransactions()) {
                if (curTime - tx.startTime() > timeout) {
                    found = true;
                    if (longRunningOpsDumpCnt < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
                        U.warn(log, "Found long running transaction [startTime=" + formatTime(tx.startTime()) + ", curTime=" + formatTime(curTime) + ", tx=" + tx + ']');
                    } else
                        break;
                }
            }
        }
        GridCacheMvccManager mvcc = cctx.mvcc();
        if (mvcc != null) {
            for (GridCacheFuture<?> fut : mvcc.activeFutures()) {
                if (curTime - fut.startTime() > timeout) {
                    found = true;
                    if (longRunningOpsDumpCnt < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
                        U.warn(log, "Found long running cache future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                    } else
                        break;
                }
            }
            for (GridCacheFuture<?> fut : mvcc.atomicFutures()) {
                if (curTime - fut.startTime() > timeout) {
                    found = true;
                    if (longRunningOpsDumpCnt < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
                        U.warn(log, "Found long running cache future [startTime=" + formatTime(fut.startTime()) + ", curTime=" + formatTime(curTime) + ", fut=" + fut + ']');
                    } else
                        break;
                }
            }
        }
        if (found) {
            if (longRunningOpsDumpCnt < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
                longRunningOpsDumpCnt++;
                if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT, false)) {
                    U.warn(log, "Found long running cache operations, dump threads.");
                    U.dumpThreads(log);
                }
                U.warn(log, "Found long running cache operations, dump IO statistics.");
                // Dump IO manager statistics.
                cctx.gridIO().dumpStats();
            }
        } else
            longRunningOpsDumpCnt = 0;
    } catch (Exception e) {
        U.error(log, "Failed to dump debug information: " + e, e);
    }
}
Also used : GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Example 10 with GridDhtPartitionsExchangeFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture in project ignite by apache.

the class GridCachePartitionExchangeManager method onKernalStart0.

/** {@inheritDoc} */
@Override
protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
    super.onKernalStart0(reconnect);
    ClusterNode loc = cctx.localNode();
    long startTime = loc.metrics().getStartTime();
    assert startTime > 0;
    // Generate dummy discovery event for local node joining.
    T2<DiscoveryEvent, DiscoCache> locJoin = cctx.discovery().localJoin();
    DiscoveryEvent discoEvt = locJoin.get1();
    DiscoCache discoCache = locJoin.get2();
    GridDhtPartitionExchangeId exchId = initialExchangeId();
    GridDhtPartitionsExchangeFuture fut = exchangeFuture(exchId, discoEvt, discoCache, null, null);
    if (reconnect)
        reconnectExchangeFut = new GridFutureAdapter<>();
    exchWorker.addFirstExchangeFuture(fut);
    if (!cctx.kernalContext().clientNode()) {
        for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) {
            final int idx = cnt;
            cctx.io().addOrderedHandler(rebalanceTopic(cnt), new CI2<UUID, GridCacheMessage>() {

                @Override
                public void apply(final UUID id, final GridCacheMessage m) {
                    if (!enterBusy())
                        return;
                    try {
                        GridCacheContext cacheCtx = cctx.cacheContext(m.cacheId);
                        if (cacheCtx != null) {
                            if (m instanceof GridDhtPartitionSupplyMessage)
                                cacheCtx.preloader().handleSupplyMessage(idx, id, (GridDhtPartitionSupplyMessage) m);
                            else if (m instanceof GridDhtPartitionDemandMessage)
                                cacheCtx.preloader().handleDemandMessage(idx, id, (GridDhtPartitionDemandMessage) m);
                            else
                                U.error(log, "Unsupported message type: " + m.getClass().getName());
                        }
                    } finally {
                        leaveBusy();
                    }
                }
            });
        }
    }
    new IgniteThread(cctx.igniteInstanceName(), "exchange-worker", exchWorker).start();
    if (reconnect) {
        fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {

            @Override
            public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
                try {
                    fut.get();
                    for (GridCacheContext cacheCtx : cctx.cacheContexts()) cacheCtx.preloader().onInitialExchangeComplete(null);
                    reconnectExchangeFut.onDone();
                } catch (IgniteCheckedException e) {
                    for (GridCacheContext cacheCtx : cctx.cacheContexts()) cacheCtx.preloader().onInitialExchangeComplete(e);
                    reconnectExchangeFut.onDone(e);
                }
            }
        });
    } else {
        if (log.isDebugEnabled())
            log.debug("Beginning to wait on local exchange future: " + fut);
        boolean first = true;
        while (true) {
            try {
                fut.get(cctx.preloadExchangeTimeout());
                break;
            } catch (IgniteFutureTimeoutCheckedException ignored) {
                if (first) {
                    U.warn(log, "Failed to wait for initial partition map exchange. " + "Possible reasons are: " + U.nl() + "  ^-- Transactions in deadlock." + U.nl() + "  ^-- Long running transactions (ignore if this is the case)." + U.nl() + "  ^-- Unreleased explicit locks.");
                    first = false;
                } else
                    U.warn(log, "Still waiting for initial partition map exchange [fut=" + fut + ']');
            } catch (IgniteNeedReconnectException e) {
                throw e;
            } catch (Exception e) {
                if (fut.reconnectOnError(e))
                    throw new IgniteNeedReconnectException(cctx.localNode(), e);
                throw e;
            }
        }
        AffinityTopologyVersion nodeStartVer = new AffinityTopologyVersion(discoEvt.topologyVersion(), 0);
        for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
            if (nodeStartVer.equals(cacheCtx.startTopologyVersion()))
                cacheCtx.preloader().onInitialExchangeComplete(null);
        }
        if (log.isDebugEnabled())
            log.debug("Finished waiting for initial exchange: " + fut.exchangeId());
    }
}
Also used : DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridDhtPartitionExchangeId(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) UUID(java.util.UUID) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridDhtPartitionSupplyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) IgniteThread(org.apache.ignite.thread.IgniteThread) GridDhtPartitionDemandMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage)

Aggregations

GridDhtPartitionsExchangeFuture (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture)12 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)7 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)3 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)3 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 NavigableMap (java.util.NavigableMap)2 TreeMap (java.util.TreeMap)2 UUID (java.util.UUID)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)2 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)2 IgniteFutureTimeoutCheckedException (org.apache.ignite.internal.IgniteFutureTimeoutCheckedException)2 IgniteNeedReconnectException (org.apache.ignite.internal.IgniteNeedReconnectException)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2