ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: gg-12389
Date Mon, 03 Jul 2017 11:29:41 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-gg-12389 084249882 -> 861c6d913


gg-12389


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/861c6d91
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/861c6d91
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/861c6d91

Branch: refs/heads/ignite-gg-12389
Commit: 861c6d913e519242456e608b06472373308c4fd7
Parents: 0842498
Author: sboikov <sboikov@gridgain.com>
Authored: Mon Jul 3 11:16:36 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Jul 3 14:28:55 2017 +0300

----------------------------------------------------------------------
 .../internal/managers/discovery/DiscoCache.java |  3 +
 .../discovery/DiscoveryLocalJoinData.java       | 29 ++++++-
 .../cache/CacheAffinitySharedManager.java       |  3 +-
 .../processors/cache/ClusterCachesInfo.java     | 23 +++--
 .../internal/processors/cache/ClusterState.java | 38 ---------
 .../processors/cache/ExchangeActions.java       |  2 +-
 .../processors/cache/GridCacheMvccManager.java  |  5 ++
 .../GridCachePartitionExchangeManager.java      | 35 ++------
 .../processors/cache/GridCacheProcessor.java    | 16 +++-
 .../cache/GridCacheSharedContext.java           |  2 +-
 .../processors/cache/PendingDiscoveryEvent.java | 12 +++
 .../processors/cache/StateChangeRequest.java    |  8 ++
 .../dht/GridDhtPartitionTopologyImpl.java       |  1 -
 .../GridDhtPartitionsExchangeFuture.java        | 10 ++-
 .../GridCacheDatabaseSharedManager.java         | 15 ++--
 .../IgniteCacheDatabaseSharedManager.java       |  1 +
 .../cache/version/GridCacheVersionManager.java  |  1 +
 .../cluster/ChangeGlobalStateFinishMessage.java | 16 +++-
 .../cluster/ChangeGlobalStateMessage.java       | 26 ++++--
 .../cluster/DiscoveryDataClusterState.java      | 33 +++++++-
 .../cluster/GridClusterStateProcessor.java      | 82 +++---------------
 .../cluster/IgniteChangeGlobalStateSupport.java |  1 -
 .../IgniteClusterActivateDeactivateTest.java    | 88 ++++++++++++++++++--
 .../IgniteChangeGlobalStateCacheTest.java       |  2 +-
 24 files changed, 261 insertions(+), 191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java
index 7605ae7..4c1077b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoCache.java
@@ -125,6 +125,9 @@ public class DiscoCache {
         this.alives.addAll(alives);
     }
 
+    /**
+     * @return Current cluster state.
+     */
     public DiscoveryDataClusterState state() {
         return state;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java
index 061112c..a1f2aa7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java
@@ -20,10 +20,11 @@ package org.apache.ignite.internal.managers.discovery;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
 /**
- *
+ * Information about local join event.
  */
 public class DiscoveryLocalJoinData {
     /** */
@@ -41,6 +42,12 @@ public class DiscoveryLocalJoinData {
     /** */
     private final boolean active;
 
+    /**
+     * @param evt Event.
+     * @param discoCache Discovery data cache.
+     * @param transitionWaitFut Future if cluster state transition is in progress.
+     * @param active Cluster active status.
+     */
     public DiscoveryLocalJoinData(DiscoveryEvent evt,
         DiscoCache discoCache,
         @Nullable IgniteInternalFuture<Boolean> transitionWaitFut,
@@ -55,23 +62,43 @@ public class DiscoveryLocalJoinData {
         joinTopVer = new AffinityTopologyVersion(evt.topologyVersion(), 0);
     }
 
+    /**
+     * @return Future if cluster state transition is in progress.
+     */
     @Nullable public IgniteInternalFuture<Boolean> transitionWaitFuture() {
         return transitionWaitFut;
     }
 
+    /**
+     * @return Cluster state.
+     */
     public boolean active() {
         return active;
     }
 
+    /**
+     * @return Event.
+     */
     public DiscoveryEvent event() {
         return evt;
     }
 
+    /**
+     * @return Discovery data cache.
+     */
     public DiscoCache discoCache() {
         return discoCache;
     }
 
+    /**
+     * @return Join topology version.
+     */
     public AffinityTopologyVersion joinTopologyVersion() {
         return joinTopVer;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(DiscoveryLocalJoinData.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index a208641..b78937e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -146,12 +146,13 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
      * Callback invoked from discovery thread when discovery message is received.
      *
      * @param type Event type.
+     * @param customMsg Custom message instance.
      * @param node Event node.
      * @param topVer Topology version.
      * @param state Cluster state.
      */
     void onDiscoveryEvent(int type,
-        DiscoveryCustomMessage customMsg,
+        @Nullable DiscoveryCustomMessage customMsg,
         ClusterNode node,
         AffinityTopologyVersion topVer,
         DiscoveryDataClusterState state) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 80b9715..003d4f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -99,7 +99,7 @@ class ClusterCachesInfo {
     /** */
     private Map<UUID, CacheClientReconnectDiscoveryData> clientReconnectReqs;
 
-    /** */
+    /** {@code True} if joined cluster while cluster state change was in progress. */
     private boolean joinOnTransition;
 
     /**
@@ -349,13 +349,14 @@ class ClusterCachesInfo {
      * @param exchangeActions Exchange actions to update.
      * @param reqs Requests.
      * @param topVer Topology version.
+     * @param persistedCfgs {@code True} if process start of persisted caches during cluster activation.
      * @return {@code True} if minor topology version should be increased.
      */
-    CacheChangeProcessResult processCacheChangeRequests(
+    private CacheChangeProcessResult processCacheChangeRequests(
         ExchangeActions exchangeActions,
         Collection<DynamicCacheChangeRequest> reqs,
         AffinityTopologyVersion topVer,
-        boolean onClusterActivate) {
+        boolean persistedCfgs) {
         CacheChangeProcessResult res = new CacheChangeProcessResult();
 
         final List<T2<DynamicCacheChangeRequest, AffinityTopologyVersion>> reqsToComplete = new ArrayList<>();
@@ -387,7 +388,7 @@ class ClusterCachesInfo {
                     res.addedDescs.add(templateDesc);
                 }
 
-                if (!onClusterActivate)
+                if (!persistedCfgs)
                     ctx.cache().completeTemplateAddFuture(ccfg.getName(), req.deploymentId());
 
                 continue;
@@ -414,7 +415,7 @@ class ClusterCachesInfo {
                         IgniteCheckedException err = new IgniteCheckedException("Failed to start " +
                             "cache. " + conflictErr);
 
-                        if (onClusterActivate)
+                        if (persistedCfgs)
                             res.errs.add(err);
                         else
                             ctx.cache().completeCacheStartFuture(req, false, err);
@@ -423,7 +424,7 @@ class ClusterCachesInfo {
                     }
 
                     if (req.clientStartOnly()) {
-                        assert !onClusterActivate;
+                        assert !persistedCfgs;
 
                         ctx.cache().completeCacheStartFuture(req, false, new IgniteCheckedException("Failed to start " +
                             "client cache (a cache with the given name is not started): " + req.cacheName()));
@@ -433,7 +434,7 @@ class ClusterCachesInfo {
                             req.startCacheConfiguration(), registeredCaches.values());
 
                         if (err != null) {
-                            if (onClusterActivate)
+                            if (persistedCfgs)
                                 res.errs.add(err);
                             else
                                 ctx.cache().completeCacheStartFuture(req, false, err);
@@ -478,13 +479,11 @@ class ClusterCachesInfo {
                             ccfg.getName(),
                             ccfg.getNearConfiguration() != null);
 
-                        if (req.initiatingNodeId() != null) {
+                        if (!persistedCfgs) {
                             ctx.discovery().addClientNode(req.cacheName(),
                                 req.initiatingNodeId(),
                                 req.nearCacheConfiguration() != null);
                         }
-                        else
-                            assert onClusterActivate;
 
                         res.addedDescs.add(startDesc);
 
@@ -494,7 +493,7 @@ class ClusterCachesInfo {
                     }
                 }
                 else {
-                    assert !onClusterActivate;
+                    assert !persistedCfgs;
                     assert req.initiatingNodeId() != null : req;
 
                     if (req.failIfExists()) {
@@ -1059,7 +1058,7 @@ class ClusterCachesInfo {
     }
 
     /**
-     *
+     * @param msg Message.
      */
     void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) {
         if (joinOnTransition) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterState.java
deleted file mode 100644
index 1e1ef71..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterState.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-/**
- *
- */
-public enum ClusterState {
-    /**
-     * Cache is inactive. No operations are allowed, no partition assignments or rebalancing is performed.
-     */
-    INACTIVE,
-
-    /**
-     * Cache is active and operations. There are no lost partitions.
-     */
-    ACTIVE,
-
-    /**
-     * Cache is inactive. But process of it activation in progress.
-     */
-    TRANSITION
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
index e9ece5a..0a30a37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
@@ -347,7 +347,7 @@ public class ExchangeActions {
     /**
      *
      */
-    public static class ActionData {
+    static class ActionData {
         /** */
         private final DynamicCacheChangeRequest req;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index b156708..c688454 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -272,7 +272,12 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
         exchLog = cctx.logger(getClass().getName() + ".exchange");
 
         pendingExplicit = GridConcurrentFactory.newMap();
+    }
 
+    /**
+     * Cache futures listener must be registered after communication listener.
+     */
+    public void onKernalStart() {
         cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 9198967..de9b8d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -195,6 +195,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     /** */
     private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
 
+    /** Events received while cluster state transition was in progress. */
+    private final List<PendingDiscoveryEvent> pendingEvts = new ArrayList<>();
+
     /** {@inheritDoc} */
     @Override protected void start0() throws IgniteCheckedException {
         super.start0();
@@ -261,10 +264,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
         }
     }
 
-    /** */
-    private final List<PendingDiscoveryEvent> pendingEvts = new ArrayList<>();
-
     /**
+     * Callback for local join event (needed since now regular event for local join is not generated).
+     *
      * @param evt Event.
      * @param cache Cache.
      */
@@ -342,6 +344,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     };
 
     private void processEventInactive(DiscoveryEvent evt, DiscoCache cache) {
+        assert false;
+
         log.info("Ignore event: " + evt);
 
         // TODO GG-12389: finish operations with error.
@@ -445,7 +449,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     /**
      * @param task Task to run in exchange worker thread.
      */
-    public void addCustomTask(CachePartitionExchangeWorkerTask task) {
+    void addCustomTask(CachePartitionExchangeWorkerTask task) {
         assert task != null;
 
         exchWorker.addCustomTask(task);
@@ -485,7 +489,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
         GridDhtPartitionsExchangeFuture fut = null;
 
         if (active) {
-            // Generate dummy discovery event for local node joining.
             DiscoveryEvent discoEvt = locJoin.event();
             DiscoCache discoCache = locJoin.discoCache();
 
@@ -1735,28 +1738,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
     }
 
     /**
-     * @param deque Deque to poll from.
-     * @param time Time to wait.
-     * @param w Worker.
-     * @return Polled item.
-     * @throws InterruptedException If interrupted.
-     */
-    @Nullable private <T> T poll(BlockingQueue<T> deque, long time, GridWorker w) throws InterruptedException {
-        assert w != null;
-
-        // There is currently a case where {@code interrupted}
-        // flag on a thread gets flipped during stop which causes the pool to hang.  This check
-        // will always make sure that interrupted flag gets reset before going into wait conditions.
-        // The true fix should actually make sure that interrupted flag does not get reset or that
-        // interrupted exception gets propagated. Until we find a real fix, this method should
-        // always work to make sure that there is no hanging during stop.
-        if (w.isCancelled())
-            Thread.currentThread().interrupt();
-
-        return deque.poll(time, MILLISECONDS);
-    }
-
-    /**
      * Exchange future thread. All exchanges happen only by one thread and next
      * exchange will not start until previous one completes.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 52d607f..21e36d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -836,12 +836,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
             ctx.query().onCacheKernalStart();
 
+            sharedCtx.mvcc().onKernalStart();
+
             sharedCtx.exchange().onKernalStart(active, false);
         }
         finally {
             cacheStartedLatch.countDown();
         }
 
+        if (!ctx.clientNode() && !ctx.isDaemon())
+            addRemovedItemsCleanupTask(Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000));
+
         // Escape if cluster inactive.
         if (!active)
             return;
@@ -872,9 +877,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             syncFuts.get(i).get();
 
         assert ctx.config().isDaemon() || caches.containsKey(CU.UTILITY_CACHE_NAME) : "Utility cache should be started";
-
-        if (!ctx.clientNode() && !ctx.isDaemon())
-            addRemovedItemsCleanupTask(Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000));
     }
 
     /**
@@ -2900,10 +2902,16 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
     /**
      * @param type Event type.
+     * @param customMsg Custom message instance.
      * @param node Event node.
      * @param topVer Topology version.
+     * @param state Cluster state.
      */
-    public void onDiscoveryEvent(int type, DiscoveryCustomMessage customMsg, ClusterNode node, AffinityTopologyVersion topVer, DiscoveryDataClusterState state) {
+    public void onDiscoveryEvent(int type,
+        @Nullable DiscoveryCustomMessage customMsg,
+        ClusterNode node,
+        AffinityTopologyVersion topVer,
+        DiscoveryDataClusterState state) {
         cachesInfo.onDiscoveryEvent(type, node, topVer);
 
         sharedCtx.affinity().onDiscoveryEvent(type, customMsg, node, topVer, state);

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index 925ffbc..32a2bce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -249,7 +249,7 @@ public class GridCacheSharedContext<K, V> {
     }
 
     /**
-     * @throws IgniteCheckedException If failed.
+     *
      */
     public void deactivate() {
         for (int i = stateAwareMgrs.size() - 1; i >= 0; i--)

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java
index acf5fb4..b4274f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.internal.managers.discovery.DiscoCache;
+import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  *
@@ -39,11 +40,22 @@ public class PendingDiscoveryEvent {
         this.cache = cache;
     }
 
+    /**
+     * @return Event.
+     */
     public DiscoveryEvent event() {
         return evt;
     }
 
+    /**
+     * @return Discovery data cache.
+     */
     public DiscoCache discoCache() {
         return cache;
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(PendingDiscoveryEvent.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
index c156ca1..d10aa58 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache;
 import java.util.UUID;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
+import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  *
@@ -28,10 +29,12 @@ public class StateChangeRequest {
     /** */
     private final ChangeGlobalStateMessage msg;
 
+    /** */
     private final AffinityTopologyVersion topVer;
 
     /**
      * @param msg Message.
+     * @param topVer State change topology versoin.
      */
     public StateChangeRequest(ChangeGlobalStateMessage msg,
         AffinityTopologyVersion topVer) {
@@ -57,4 +60,9 @@ public class StateChangeRequest {
     public UUID initiatorNodeId() {
         return msg.initiatorNodeId();
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(StateChangeRequest.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 1313c9a..52044a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -41,7 +41,6 @@ import org.apache.ignite.internal.managers.discovery.DiscoCache;
 import org.apache.ignite.internal.processors.affinity.AffinityAssignment;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.ClusterState;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 6438718..c7d2d19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -459,6 +459,9 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         evtLatch.countDown();
     }
 
+    /**
+     * @return {@code True} if cluster state change exchange.
+     */
     private boolean stateChangeExchange() {
         return exchActions != null && exchActions.stateChangeRequest() != null;
     }
@@ -1213,7 +1216,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
         if (partHistReserved0 != null)
             m.partitionHistoryCounters(partHistReserved0);
 
-        if (activateCluster() && changeGlobalStateE != null)
+        if (stateChangeExchange() && changeGlobalStateE != null)
             m.setException(changeGlobalStateE);
 
         if (log.isDebugEnabled())
@@ -1818,9 +1821,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                 }
             }
 
-            if (discoEvt.type() == EVT_NODE_JOINED) {
+            if (discoEvt.type() == EVT_NODE_JOINED)
                 assignPartitionsStates();
-            }
             else if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
                 assert discoEvt instanceof DiscoveryCustomEvent;
 
@@ -1873,7 +1875,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
                     if (!F.isEmpty(changeGlobalStateExceptions))
                         cctx.kernalContext().state().onStateChangeError(changeGlobalStateExceptions, req);
 
-                    // TODO GG-12389 (case when sent full message but failed before custom message sent)
+                    // TODO GG-12389 (check result + case when sent full message but failed before custom message sent)
                     ChangeGlobalStateFinishMessage msg = new ChangeGlobalStateFinishMessage(req.requestId(),
                         req.activate());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index ceb91ff..5cebb07 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -65,7 +65,6 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.PersistenceMetrics;
-import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.DataPageEvictionMode;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.MemoryConfiguration;
@@ -100,12 +99,11 @@ import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionDestroyRecor
 import org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.ClusterState;
-import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
-import org.apache.ignite.internal.processors.cache.ExchangeActions;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.StoredCacheData;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
 import org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.CheckpointMetricsTracker;
 import org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx;
@@ -114,9 +112,6 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
 import org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO;
 import org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer;
 import org.apache.ignite.internal.processors.cache.persistence.wal.crc.PureJavaCrc32;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
 import org.apache.ignite.internal.processors.port.GridPortRecord;
 import org.apache.ignite.internal.util.GridConcurrentHashSet;
 import org.apache.ignite.internal.util.GridMultiCollectionWrapper;
@@ -129,7 +124,6 @@ import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.P3;
 import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
@@ -1513,9 +1507,10 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
         Map<T2<Integer, Integer>, T2<Integer, Long>> partStates
     ) throws IgniteCheckedException {
         for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
-            if (grp.isLocal() || !grp.affinityNode())
+            if (grp.isLocal() || !grp.affinityNode()) {
                 // Local cache has no partitions and its states.
                 continue;
+            }
 
             int grpId = grp.groupId();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
index 230fffe..e6cf274 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheDatabaseSharedManager.java
@@ -148,6 +148,7 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
 
     /**
      * @param dbCfg Database config.
+     * @throws IgniteCheckedException If failed.
      */
     protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
         freeListMap = U.newHashMap(memPlcMap.size());

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
index 7cf1932..5cad4d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
@@ -87,6 +87,7 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter {
         cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_METRICS_UPDATED);
     }
 
+    // TODO GG-12389.
     /** {@inheritDoc} */
 //    @Override protected void onKernalStart0(boolean active, boolean reconnect) throws IgniteCheckedException {
 //        for (ClusterNode n : cctx.discovery().remoteNodes())

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
index 1eedb62..0771198 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
@@ -33,21 +33,33 @@ public class ChangeGlobalStateFinishMessage implements DiscoveryCustomMessage {
     /** Custom message ID. */
     private IgniteUuid id = IgniteUuid.randomUuid();
 
-    /** */
+    /** State change request ID. */
     private UUID reqId;
 
-    /** */
+    /** New cluster state. */
     private boolean clusterActive;
 
+    /**
+     * @param reqId State change request ID.
+     * @param clusterActive New cluster state.
+     */
     public ChangeGlobalStateFinishMessage(UUID reqId, boolean clusterActive) {
+        assert reqId != null;
+
         this.reqId = reqId;
         this.clusterActive = clusterActive;
     }
 
+    /**
+     * @return State change request ID.
+     */
     public UUID requestId() {
         return reqId;
     }
 
+    /**
+     * @return New cluster state.
+     */
     public boolean clusterActive() {
         return clusterActive;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
index 46b7927..6cba0df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
@@ -22,6 +22,7 @@ import java.util.UUID;
 import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
 import org.apache.ignite.internal.processors.cache.ExchangeActions;
 import org.apache.ignite.internal.processors.cache.StoredCacheData;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
@@ -45,21 +46,28 @@ public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
     /** If true activate else deactivate. */
     private boolean activate;
 
-    /** */
+    /** Configurations read from persistent store. */
     private List<StoredCacheData> storedCfgs;
 
     /** */
+    @GridToStringExclude
     private transient ExchangeActions exchangeActions;
 
     /**
-     *
+     * @param requestId State change request ID.
+     * @param initiatingNodeId Node initiated state change.
+     * @param storedCfgs Configurations read from persistent store.
+     * @param activate New cluster state.
      */
     public ChangeGlobalStateMessage(
         UUID requestId,
         UUID initiatingNodeId,
-        List<StoredCacheData> storedCfgs,
+        @Nullable List<StoredCacheData> storedCfgs,
         boolean activate
     ) {
+        assert requestId != null;
+        assert initiatingNodeId != null;
+
         this.requestId = requestId;
         this.initiatingNodeId = initiatingNodeId;
         this.storedCfgs = storedCfgs;
@@ -67,7 +75,7 @@ public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
     }
 
     /**
-     * @return Stored cache configurations.
+     * @return Configurations read from persistent store..
      */
     @Nullable public List<StoredCacheData> storedCacheConfigurations() {
         return storedCfgs;
@@ -83,7 +91,7 @@ public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
     /**
      * @param exchangeActions Cache updates to be executed on exchange.
      */
-    public void exchangeActions(ExchangeActions exchangeActions) {
+    void exchangeActions(ExchangeActions exchangeActions) {
         assert exchangeActions != null && !exchangeActions.empty() : exchangeActions;
 
         this.exchangeActions = exchangeActions;
@@ -105,21 +113,21 @@ public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
     }
 
    /**
-     *
-     */
+    * @return Node initiated state change.
+    */
     public UUID initiatorNodeId() {
         return initiatingNodeId;
     }
 
     /**
-     *
+     * @return New cluster state.
      */
     public boolean activate() {
         return activate;
     }
 
     /**
-     *
+     * @return State change request ID.
      */
     public UUID requestId() {
         return requestId;

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
index 4b33ccd..1342000 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
@@ -51,11 +51,22 @@ public class DiscoveryDataClusterState implements Serializable {
     /** */
     private transient volatile Boolean transitionRes;
 
-    public static DiscoveryDataClusterState createState(boolean active) {
+    /**
+     * @param active Current status.
+     * @return State instance.
+     */
+    static DiscoveryDataClusterState createState(boolean active) {
         return new DiscoveryDataClusterState(active, null, null, null);
     }
 
-    public static DiscoveryDataClusterState createTransitionState(boolean active,
+    /**
+     * @param active New status.
+     * @param transitionReqId State change request ID.
+     * @param transitionTopVer State change topology version.
+     * @param transitionNodes Nodes participating in state change exchange.
+     * @return State instance.
+     */
+    static DiscoveryDataClusterState createTransitionState(boolean active,
         UUID transitionReqId,
         AffinityTopologyVersion transitionTopVer,
         Set<UUID> transitionNodes) {
@@ -82,6 +93,9 @@ public class DiscoveryDataClusterState implements Serializable {
         this.transitionNodes = transitionNodes;
     }
 
+    /**
+     * @return
+     */
     @Nullable public Boolean transitionResult() {
         return transitionRes;
     }
@@ -101,22 +115,37 @@ public class DiscoveryDataClusterState implements Serializable {
         }
     }
 
+    /**
+     * @return State change request ID.
+     */
     public UUID transitionRequestId() {
         return transitionReqId;
     }
 
+    /**
+     * @return {@code True} if state change is in progress.
+     */
     public boolean transition() {
         return transitionReqId != null;
     }
 
+    /**
+     * @return State change exchange version.
+     */
     public AffinityTopologyVersion transitionTopologyVersion() {
         return transitionTopVer;
     }
 
+    /**
+     * @return Current cluster state (or new state in case when transition is in progress).
+     */
     public boolean active() {
         return active;
     }
 
+    /**
+     * @return Nodes participating in state change exchange.
+     */
     public Set<UUID> transitionNodes() {
         return transitionNodes;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
index 6586813..e6b36be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridClusterStateProcessor.java
@@ -76,7 +76,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
     /** Local action future. */
     private final AtomicReference<GridChangeGlobalStateFuture> stateChangeFut = new AtomicReference<>();
 
-    /** */
+    /** Future initialized if node joins when cluster state change is in progress. */
     private TransitionOnJoinWaitFuture joinFut;
 
     /** Process. */
@@ -168,15 +168,15 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
      * @param msg Message.
      */
     public void onStateFinishMessage(ChangeGlobalStateFinishMessage msg) {
-        if (joinFut != null)
-            joinFut.onDone(msg.clusterActive());
-
         if (msg.requestId().equals(globalState.transitionRequestId())) {
             log.info("Received state change finish message: " + msg.clusterActive());
 
             globalState = DiscoveryDataClusterState.createState(msg.clusterActive());
 
             ctx.cache().onStateChangeFinish(msg);
+
+            if (joinFut != null)
+                joinFut.onDone(msg.clusterActive());
         }
         else
             U.warn(log, "Received state finish message with unexpected ID: " + msg);
@@ -348,7 +348,8 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
     }
 
     /**
-     *
+     * @param activate New cluster state.
+     * @return State change future.
      */
     public IgniteInternalFuture<?> changeGlobalState(final boolean activate) {
         if (ctx.isDaemon() || ctx.clientNode()) {
@@ -434,9 +435,10 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
     }
 
     /**
-     *
+     * @param activate New cluster state.
+     * @param resFut State change future.
      */
-    private void sendCompute(boolean activate, final GridFutureAdapter<Void> res) {
+    private void sendCompute(boolean activate, final GridFutureAdapter<Void> resFut) {
         AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
 
         IgniteCompute comp = ((ClusterGroupAdapter)ctx.cluster().get().forServers()).compute();
@@ -455,17 +457,18 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
                 try {
                     fut.get();
 
-                    res.onDone();
+                    resFut.onDone();
                 }
                 catch (Exception e) {
-                    res.onDone(e);
+                    resFut.onDone(e);
                 }
             }
         });
     }
 
     /**
-     * @param exs Exs.
+     * @param exs Errors.
+     * @param req State change request.
      */
     public void onStateChangeError(Map<UUID, Exception> exs, StateChangeRequest req) {
         assert !F.isEmpty(exs);
@@ -520,65 +523,6 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
     /**
      *
      */
-    private Exception onActivate(AffinityTopologyVersion topVer) {
-        if (log.isInfoEnabled()) {
-            log.info("Start activation process [nodeId=" + ctx.localNodeId() +
-                ", client=" + ctx.clientNode() +
-                ", topVer=" + topVer + "]");
-        }
-
-        try {
-            sharedCtx.activate();
-
-            if (log.isInfoEnabled()) {
-                log.info("Successfully activated persistence managers [nodeId=" + ctx.localNodeId() +
-                    ", client=" + ctx.clientNode() +
-                    ", topVer=" + topVer + "]");
-            }
-
-            return null;
-        }
-        catch (Exception e) {
-            U.error(log, "Failed to activate persistence managers [nodeId=" + ctx.localNodeId() +
-                ", client=" + ctx.clientNode() +
-                ", topVer=" + topVer + "]", e);
-
-            return e;
-        }
-    }
-
-    /**
-     *
-     */
-    private Exception onDeActivate(AffinityTopologyVersion topVer) {
-        final boolean client = ctx.clientNode();
-
-        if (log.isInfoEnabled())
-            log.info("Starting deactivation [id=" + ctx.localNodeId() + ", client=" +
-                client + ", topVer=" + topVer + "]");
-
-        try {
-            ctx.dataStructures().onDeActivate(ctx);
-
-            ctx.service().onDeActivate(ctx);
-
-            if (log.isInfoEnabled())
-                log.info("Successfully deactivated persistence processors [id=" + ctx.localNodeId() + ", client=" +
-                    client + ", topVer=" + topVer + "]");
-
-            return null;
-        }
-        catch (Exception e) {
-            U.error(log, "Failed to execute deactivation callback [nodeId=" + ctx.localNodeId() + ", client=" + client +
-                ", topVer=" + topVer + "]", e);
-
-            return e;
-        }
-    }
-
-    /**
-     *
-     */
     private void onFinalActivate(final StateChangeRequest req) {
         ctx.closure().runLocalSafe(new Runnable() {
             @Override public void run() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IgniteChangeGlobalStateSupport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IgniteChangeGlobalStateSupport.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IgniteChangeGlobalStateSupport.java
index 1f2bbdb..5d77f57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IgniteChangeGlobalStateSupport.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/IgniteChangeGlobalStateSupport.java
@@ -36,7 +36,6 @@ public interface IgniteChangeGlobalStateSupport {
      * Called when cluster performing deactivation.
      *
      * @param kctx Kernal context.
-     * @throws IgniteCheckedException If failed.
      */
     public void onDeActivate(GridKernalContext kctx);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
index 5091f4a..894bd3e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
@@ -315,10 +315,12 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest
      * @param srvs Number of servers.
      * @param clients Number of clients.
      * @param initiallyActive If {@code true} start cluster in active state (otherwise in inactive).
-     * @return Activation future.
+     * @return State change future.
      * @throws Exception If failed.
      */
-    private IgniteInternalFuture<?> startNodesAndBlockStatusChange(int srvs, int clients, boolean initiallyActive) throws Exception {
+    private IgniteInternalFuture<?> startNodesAndBlockStatusChange(int srvs,
+        int clients,
+        final boolean initiallyActive) throws Exception {
         active = initiallyActive;
         testSpi = true;
 
@@ -350,9 +352,9 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest
             }
         });
 
-        IgniteInternalFuture<?> activeFut = GridTestUtils.runAsync(new Runnable() {
+        IgniteInternalFuture<?> stateChangeFut = GridTestUtils.runAsync(new Runnable() {
             @Override public void run() {
-                ignite(0).active(true);
+                ignite(0).active(!initiallyActive);
             }
         });
 
@@ -360,16 +362,88 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest
 
         U.sleep(500);
 
-        assertFalse(activeFut.isDone());
+        assertFalse(stateChangeFut.isDone());
 
-        return activeFut;
+        return stateChangeFut;
     }
 
     /**
      * @throws Exception If failed.
      */
     public void testJoinWhileDeactivate1_Server() throws Exception {
-        joinWhileActivate1(false, false);
+        joinWhileDeactivate1(false, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJoinWhileDeactivate1_WithCache_Server() throws Exception {
+        joinWhileDeactivate1(false, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testJoinWhileDeactivate1_Client() throws Exception {
+        joinWhileDeactivate1(true, false);
+    }
+
+    /**
+     * @param startClient If {@code true} joins client node, otherwise server.
+     * @param withNewCache If {@code true} joining node has new cache in configuration.
+     * @throws Exception If failed.
+     */
+    private void joinWhileDeactivate1(final boolean startClient, final boolean withNewCache) throws Exception {
+        IgniteInternalFuture<?> activeFut = startNodesAndBlockStatusChange(2, 0, true);
+
+        IgniteInternalFuture<?> startFut = GridTestUtils.runAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                client = startClient;
+
+                ccfgs = withNewCache ? cacheConfigurations2() : cacheConfigurations1();
+
+                startGrid(2);
+
+                return null;
+            }
+        });
+
+        TestRecordingCommunicationSpi spi1 = TestRecordingCommunicationSpi.spi(ignite(1));
+
+        spi1.stopBlock();
+
+        activeFut.get();
+        startFut.get();
+
+        checkNoCaches(3);
+
+        ignite(2).active(true);
+
+        for (int c = 0; c < 2; c++)
+            checkCache(ignite(2), CACHE_NAME_PREFIX + c, true);
+
+        if (withNewCache) {
+            for (int i = 0; i < 3; i++) {
+                for (int c = 0; c < 4; c++)
+                    checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+            }
+        }
+
+        awaitPartitionMapExchange();
+
+        checkCaches(3, withNewCache ? 4 : 2);
+
+        client = false;
+
+        startGrid(3);
+
+        checkCaches(4, withNewCache ? 4 : 2);
+
+        client = true;
+
+        startGrid(4);
+
+        checkCaches(5, withNewCache ? 4 : 2);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/861c6d91/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
index 2f2385d..938b3c8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateCacheTest.java
@@ -62,7 +62,7 @@ public class IgniteChangeGlobalStateCacheTest extends IgniteChangeGlobalStateAbs
     }
 
     /**
-     *
+     * @throws Exception If failed.
      */
     public void testMoreKeyValueAfterActivate() throws Exception {
         String cacheName = "my-cache";


Mime
View raw message