Search in sources :

Example 1 with ClusterActivationEvent

use of org.apache.ignite.events.ClusterActivationEvent in project ignite by apache.

the class GridCachePartitionExchangeManager method onClusterStateChangeFinish.

/**
 */
private void onClusterStateChangeFinish(IgniteInternalFuture<AffinityTopologyVersion> fut, ExchangeActions exchActions, boolean baselineChanging) {
    A.notNull(exchActions, "exchActions");
    GridEventStorageManager evtMngr = cctx.kernalContext().event();
    if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED) || exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED) || exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
        List<Event> evts = new ArrayList<>(2);
        ClusterNode locNode = cctx.kernalContext().discovery().localNode();
        Collection<BaselineNode> bltNodes = cctx.kernalContext().cluster().get().currentBaselineTopology();
        boolean collectionUsed = false;
        if (exchActions.activate() && evtMngr.isRecordable(EVT_CLUSTER_ACTIVATED)) {
            assert !exchActions.deactivate() : exchActions;
            collectionUsed = true;
            evts.add(new ClusterActivationEvent(locNode, "Cluster activated.", EVT_CLUSTER_ACTIVATED, bltNodes));
        }
        if (exchActions.deactivate() && evtMngr.isRecordable(EVT_CLUSTER_DEACTIVATED)) {
            assert !exchActions.activate() : exchActions;
            collectionUsed = true;
            evts.add(new ClusterActivationEvent(locNode, "Cluster deactivated.", EVT_CLUSTER_DEACTIVATED, bltNodes));
        }
        if (exchActions.changedClusterState() && evtMngr.isRecordable(EVT_CLUSTER_STATE_CHANGED)) {
            StateChangeRequest req = exchActions.stateChangeRequest();
            if (collectionUsed && bltNodes != null)
                bltNodes = new ArrayList<>(bltNodes);
            evts.add(new ClusterStateChangeEvent(req.prevState(), req.state(), bltNodes, locNode, "Cluster state changed."));
        }
        A.notEmpty(evts, "events " + exchActions);
        cctx.kernalContext().pools().getSystemExecutorService().submit(() -> evts.forEach(e -> cctx.kernalContext().event().record(e)));
    }
    GridKernalContext ctx = cctx.kernalContext();
    DiscoveryDataClusterState state = ctx.state().clusterState();
    if (baselineChanging) {
        ctx.pools().getStripedExecutorService().execute(new Runnable() {

            @Override
            public void run() {
                if (ctx.event().isRecordable(EventType.EVT_BASELINE_CHANGED)) {
                    ctx.event().record(new BaselineChangedEvent(ctx.discovery().localNode(), "Baseline changed.", EventType.EVT_BASELINE_CHANGED, ctx.cluster().get().currentBaselineTopology()));
                }
            }
        });
    }
}
Also used : GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) RebalanceFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander.RebalanceFuture) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridPartitionStateMap(org.apache.ignite.internal.util.GridPartitionStateMap) GridDhtPartitionsSingleRequest(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest) CachePartitionFullCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap) Map(java.util.Map) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) ClusterGroup(org.apache.ignite.cluster.ClusterGroup) GridStringBuilder(org.apache.ignite.internal.util.GridStringBuilder) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) FinishPreloadingTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.FinishPreloadingTask) ClusterGroupEmptyException(org.apache.ignite.cluster.ClusterGroupEmptyException) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Event(org.apache.ignite.events.Event) Set(java.util.Set) ChangeGlobalStateFinishMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage) TRANSACTION_OWNER_THREAD_DUMP_PROVIDING(org.apache.ignite.internal.IgniteFeatures.TRANSACTION_OWNER_THREAD_DUMP_PROVIDING) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) IGNITE_DIAGNOSTIC_WARN_LIMIT(org.apache.ignite.IgniteSystemProperties.IGNITE_DIAGNOSTIC_WARN_LIMIT) CountDownLatch(java.util.concurrent.CountDownLatch) SnapshotDiscoveryMessage(org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotDiscoveryMessage) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteDhtPartitionsToReloadMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap) SYSTEM_WORKER_TERMINATION(org.apache.ignite.failure.FailureType.SYSTEM_WORKER_TERMINATION) DiscoveryLocalJoinData(org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData) GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) GridListSet(org.apache.ignite.internal.util.GridListSet) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) IgniteCompute(org.apache.ignite.IgniteCompute) IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT) SecurityContext(org.apache.ignite.internal.processors.security.SecurityContext) IgniteThread(org.apache.ignite.thread.IgniteThread) SecurityUtils.remoteSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.remoteSecurityContext) ClusterState(org.apache.ignite.cluster.ClusterState) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteLogger(org.apache.ignite.IgniteLogger) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteBiInClosure(org.apache.ignite.lang.IgniteBiInClosure) ClusterNode(org.apache.ignite.cluster.ClusterNode) CI1(org.apache.ignite.internal.util.typedef.CI1) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteInternalTx(org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) S(org.apache.ignite.internal.util.typedef.internal.S) IgniteDiagnosticAware(org.apache.ignite.internal.IgniteDiagnosticAware) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) EXCHANGE_FUTURE(org.apache.ignite.internal.processors.tracing.SpanType.EXCHANGE_FUTURE) IGNITE_IO_DUMP_ON_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_IO_DUMP_ON_TIMEOUT) A(org.apache.ignite.internal.util.typedef.internal.A) CachePartitionPartialCountersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap) Ignite(org.apache.ignite.Ignite) BaselineNode(org.apache.ignite.cluster.BaselineNode) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) RebalanceReassignExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.RebalanceReassignExchangeTask) T2(org.apache.ignite.internal.util.typedef.T2) NONE(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion.NONE) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) CLUSTER_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.CLUSTER_METRICS) GridDhtPartitionsExchangeFuture.nextDumpTimeout(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.nextDumpTimeout) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridDhtPartitionsFullMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) GridDhtPartitionExchangeId(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) CRITICAL_ERROR(org.apache.ignite.failure.FailureType.CRITICAL_ERROR) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) GridDhtPartitionSupplyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage) ExchangeLatchManager(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.latch.ExchangeLatchManager) CacheRebalanceMode(org.apache.ignite.cache.CacheRebalanceMode) GridWorker(org.apache.ignite.internal.util.worker.GridWorker) StopCachesOnClientReconnectExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.StopCachesOnClientReconnectExchangeTask) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) PME_OPS_BLOCKED_DURATION(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_OPS_BLOCKED_DURATION) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BooleanMetricImpl(org.apache.ignite.internal.processors.metric.impl.BooleanMetricImpl) X(org.apache.ignite.internal.util.typedef.X) IgniteDhtPartitionHistorySuppliersMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap) PME_METRICS(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_METRICS) IgniteFuture(org.apache.ignite.lang.IgniteFuture) SecurityUtils.withRemoteSecurityContext(org.apache.ignite.internal.processors.security.SecurityUtils.withRemoteSecurityContext) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) EventType(org.apache.ignite.events.EventType) OperationSecurityContext(org.apache.ignite.internal.processors.security.OperationSecurityContext) IgniteFeatures.allNodesSupports(org.apache.ignite.internal.IgniteFeatures.allNodesSupports) Collection(java.util.Collection) SpanTags(org.apache.ignite.internal.processors.tracing.SpanTags) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) EVT_CLUSTER_ACTIVATED(org.apache.ignite.events.EventType.EVT_CLUSTER_ACTIVATED) NavigableSet(java.util.NavigableSet) IgniteDiagnosticPrepareContext(org.apache.ignite.internal.IgniteDiagnosticPrepareContext) IgniteNeedReconnectException(org.apache.ignite.internal.IgniteNeedReconnectException) UUID(java.util.UUID) Instant(java.time.Instant) CI2(org.apache.ignite.internal.util.typedef.CI2) Collectors(java.util.stream.Collectors) IGNITE_PRELOAD_RESEND_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_PRELOAD_RESEND_TIMEOUT) IgniteSystemProperties.getLong(org.apache.ignite.IgniteSystemProperties.getLong) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) DiscoveryEventListener(org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener) GridDhtPartitionDemandMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage) TOPIC_CACHE(org.apache.ignite.internal.GridTopic.TOPIC_CACHE) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent) CU(org.apache.ignite.internal.util.typedef.internal.CU) GridDhtPartitionDemandLegacyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandLegacyMessage) Optional(java.util.Optional) IgniteFutureTimeoutCheckedException(org.apache.ignite.internal.IgniteFutureTimeoutCheckedException) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) NotNull(org.jetbrains.annotations.NotNull) ForceRebalanceExchangeTask(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.ForceRebalanceExchangeTask) PME_DURATION_HISTOGRAM(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_DURATION_HISTOGRAM) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) Span(org.apache.ignite.internal.processors.tracing.Span) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) HashMap(java.util.HashMap) DFLT_PRELOAD_RESEND_TIMEOUT(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader.DFLT_PRELOAD_RESEND_TIMEOUT) DiscoCache(org.apache.ignite.internal.managers.discovery.DiscoCache) AtomicReference(java.util.concurrent.atomic.AtomicReference) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) SchemaNodeLeaveExchangeWorkerTask(org.apache.ignite.internal.processors.query.schema.SchemaNodeLeaveExchangeWorkerTask) GridClientPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridClientPartitionTopology) FailureContext(org.apache.ignite.failure.FailureContext) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) PME_OPS_BLOCKED_DURATION_HISTOGRAM(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_OPS_BLOCKED_DURATION_HISTOGRAM) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) ReentrantLock(java.util.concurrent.locks.ReentrantLock) EVT_CLUSTER_DEACTIVATED(org.apache.ignite.events.EventType.EVT_CLUSTER_DEACTIVATED) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) EVT_CLUSTER_STATE_CHANGED(org.apache.ignite.events.EventType.EVT_CLUSTER_STATE_CHANGED) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) PARTIAL_COUNTERS_MAP_SINCE(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionPartialCountersMap.PARTIAL_COUNTERS_MAP_SINCE) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) TimeUnit(java.util.concurrent.TimeUnit) PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) HistogramMetricImpl(org.apache.ignite.internal.processors.metric.impl.HistogramMetricImpl) ChangeGlobalStateMessage(org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) TransactionState(org.apache.ignite.transactions.TransactionState) PME_DURATION(org.apache.ignite.internal.processors.metric.GridMetricManager.PME_DURATION) REBALANCED(org.apache.ignite.internal.processors.metric.GridMetricManager.REBALANCED) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) GridEventStorageManager(org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager) Comparator(java.util.Comparator) Collections(java.util.Collections) GridKernalContext(org.apache.ignite.internal.GridKernalContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) BaselineNode(org.apache.ignite.cluster.BaselineNode) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) ClusterActivationEvent(org.apache.ignite.events.ClusterActivationEvent) Event(org.apache.ignite.events.Event) ClusterStateChangeEvent(org.apache.ignite.events.ClusterStateChangeEvent) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) BaselineChangedEvent(org.apache.ignite.events.BaselineChangedEvent)

Aggregations

Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 NavigableSet (java.util.NavigableSet)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 UUID (java.util.UUID)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ConcurrentNavigableMap (java.util.concurrent.ConcurrentNavigableMap)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1