Search in sources :

Example 1 with IgniteChangeGlobalStateSupport

use of org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport in project ignite by apache.

the class DataStructuresProcessor method onActivate.

/** {@inheritDoc} */
@Override
public void onActivate(GridKernalContext ctx) throws IgniteCheckedException {
    if (log.isDebugEnabled())
        log.debug("Activate data structure processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]");
    this.initFailed = false;
    this.initLatch = new CountDownLatch(1);
    this.qryId = null;
    ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
    onKernalStart0(true);
    for (Map.Entry<GridCacheInternal, GridCacheRemovable> e : dsMap.entrySet()) {
        GridCacheRemovable v = e.getValue();
        if (v instanceof IgniteChangeGlobalStateSupport)
            ((IgniteChangeGlobalStateSupport) v).onActivate(ctx);
    }
}
Also used : GridCacheInternal(org.apache.ignite.internal.processors.cache.GridCacheInternal) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) IgniteCountDownLatch(org.apache.ignite.IgniteCountDownLatch) CountDownLatch(java.util.concurrent.CountDownLatch) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 2 with IgniteChangeGlobalStateSupport

use of org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport in project ignite by apache.

the class GridDhtPartitionsExchangeFuture method onClusterStateChangeRequest.

/**
 * @param crd Coordinator flag.
 * @return Exchange type.
 */
private ExchangeType onClusterStateChangeRequest(boolean crd) {
    assert exchActions != null && !exchActions.empty() : this;
    StateChangeRequest req = exchActions.stateChangeRequest();
    assert req != null : exchActions;
    GridKernalContext kctx = cctx.kernalContext();
    DiscoveryDataClusterState state = kctx.state().clusterState();
    if (state.transitionError() != null)
        exchangeLocE = state.transitionError();
    if (req.activeChanged()) {
        if (req.state().active()) {
            if (log.isInfoEnabled()) {
                log.info("Start activation process [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]. New state: " + req.state());
            }
            try {
                cctx.exchange().exchangerBlockingSectionBegin();
                try {
                    cctx.activate();
                } finally {
                    cctx.exchange().exchangerBlockingSectionEnd();
                }
                assert registerCachesFuture == null : "No caches registration should be scheduled before new caches have started.";
                cctx.exchange().exchangerBlockingSectionBegin();
                try {
                    registerCachesFuture = cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
                    if (!kctx.clientNode())
                        cctx.cache().shutdownNotFinishedRecoveryCaches();
                } finally {
                    cctx.exchange().exchangerBlockingSectionEnd();
                }
                if (log.isInfoEnabled()) {
                    log.info("Successfully activated caches [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + ", newState=" + req.state() + "]");
                }
            } catch (Exception e) {
                U.error(log, "Failed to activate node components [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + ", newState=" + req.state() + "]", e);
                exchangeLocE = e;
                if (crd) {
                    cctx.exchange().exchangerBlockingSectionBegin();
                    try {
                        synchronized (mux) {
                            exchangeGlobalExceptions.put(cctx.localNodeId(), e);
                        }
                    } finally {
                        cctx.exchange().exchangerBlockingSectionEnd();
                    }
                }
            }
        } else {
            if (log.isInfoEnabled()) {
                log.info("Start deactivation process [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]");
            }
            cctx.exchange().exchangerBlockingSectionBegin();
            try {
                kctx.dataStructures().onDeActivate(kctx);
                assert registerCachesFuture == null : "No caches registration should be scheduled before new caches have started.";
                registerCachesFuture = cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
                kctx.encryption().onDeActivate(kctx);
                ((IgniteChangeGlobalStateSupport) kctx.distributedMetastorage()).onDeActivate(kctx);
                if (log.isInfoEnabled()) {
                    log.info("Successfully deactivated data structures, services and caches [" + "nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]");
                }
            } catch (Exception e) {
                U.error(log, "Failed to deactivate node components [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]", e);
                exchangeLocE = e;
            } finally {
                cctx.exchange().exchangerBlockingSectionEnd();
            }
        }
    } else if (req.state().active()) {
        cctx.exchange().exchangerBlockingSectionBegin();
        // TODO: BLT changes on inactive cluster can't be handled easily because persistent storage hasn't been initialized yet.
        try {
            if (!forceAffReassignment) {
                // possible only if cluster contains nodes without forceAffReassignment mode
                assert firstEventCache().minimumNodeVersion().compareToIgnoreTimestamp(FORCE_AFF_REASSIGNMENT_SINCE) < 0 : firstEventCache().minimumNodeVersion();
                cctx.affinity().onBaselineTopologyChanged(this, crd);
            }
            if (CU.isPersistenceEnabled(kctx.config()) && !kctx.clientNode())
                kctx.state().onBaselineTopologyChanged(req.baselineTopology(), req.prevBaselineTopologyHistoryItem());
        } catch (Exception e) {
            U.error(log, "Failed to change baseline topology [nodeId=" + cctx.localNodeId() + ", client=" + kctx.clientNode() + ", topVer=" + initialVersion() + "]", e);
            exchangeLocE = e;
        } finally {
            cctx.exchange().exchangerBlockingSectionEnd();
        }
    }
    return kctx.clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL;
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) StateChangeRequest(org.apache.ignite.internal.processors.cache.StateChangeRequest) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IOException(java.io.IOException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

IgniteChangeGlobalStateSupport (org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteCountDownLatch (org.apache.ignite.IgniteCountDownLatch)1 IgniteException (org.apache.ignite.IgniteException)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)1 IgniteFutureTimeoutCheckedException (org.apache.ignite.internal.IgniteFutureTimeoutCheckedException)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 IgniteNeedReconnectException (org.apache.ignite.internal.IgniteNeedReconnectException)1 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)1 GridCacheInternal (org.apache.ignite.internal.processors.cache.GridCacheInternal)1 StateChangeRequest (org.apache.ignite.internal.processors.cache.StateChangeRequest)1 DiscoveryDataClusterState (org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState)1