ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-gg-12389
Date Tue, 04 Jul 2017 14:10:53 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-gg-12389 57d73160a -> 578864957


ignite-gg-12389


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

Branch: refs/heads/ignite-gg-12389
Commit: 57886495742b1ffd87252f25e0e6b5f30d2db58b
Parents: 57d7316
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Jul 4 17:10:48 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Jul 4 17:10:48 2017 +0300

----------------------------------------------------------------------
 .../discovery/GridDiscoveryManager.java         | 22 +++++----
 .../processors/cache/ClusterCachesInfo.java     |  4 +-
 .../cluster/GridClusterStateProcessor.java      | 35 ++++++++++++--
 .../IgniteClusterActivateDeactivateTest.java    | 49 ++++++++++++++++++--
 4 files changed, 94 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/57886495/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 88f7dd1..9f5bd3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -145,6 +145,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SECURITY_COMP
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SERVICES_COMPATIBILITY_MODE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_USER_NAME;
 import static org.apache.ignite.internal.IgniteVersionUtils.VER;
+import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT;
 import static org.apache.ignite.internal.processors.security.SecurityUtils.SERVICE_PERMISSIONS_SINCE;
 import static org.apache.ignite.internal.processors.security.SecurityUtils.isSecurityCompatibilityMode;
 import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.NOOP;
@@ -571,7 +572,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
                     if (type != EVT_NODE_SEGMENTED &&
                         type != EVT_CLIENT_NODE_DISCONNECTED &&
                         type != EVT_CLIENT_NODE_RECONNECTED &&
-                        type != DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
+                        type != EVT_DISCOVERY_CUSTOM_EVT) {
                         minorTopVer = 0;
 
                         verChanged = true;
@@ -593,17 +594,19 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
                 IgniteInternalFuture<Boolean> transitionWaitFut = null;
 
+                ChangeGlobalStateFinishMessage stateFinishMsg = null;
+
                 if (locJoinEvt) {
                     discoCache = createDiscoCache(ctx.state().clusterState(), locNode, topSnapshot);
 
                     transitionWaitFut = ctx.state().onLocalJoin(discoCache);
                 }
                 else if (type == EVT_NODE_FAILED || type == EVT_NODE_LEFT)
-                    ctx.state().onNodeLeft(node);
+                    stateFinishMsg = ctx.state().onNodeLeft(node);
 
                 final AffinityTopologyVersion nextTopVer;
 
-                if (type == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
+                if (type == EVT_DISCOVERY_CUSTOM_EVT) {
                     assert customMsg != null;
 
                     boolean incMinorTopVer;
@@ -643,7 +646,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
                 ctx.cache().onDiscoveryEvent(type, customMsg, node, nextTopVer, ctx.state().clusterState());
 
-                if (type == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
+                if (type == EVT_DISCOVERY_CUSTOM_EVT) {
                     for (Class cls = customMsg.getClass(); cls != null; cls = cls.getSuperclass())
{
                         List<CustomEventListener<DiscoveryCustomMessage>> list
= customEvtLsnrs.get(cls);
 
@@ -768,6 +771,9 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
                 if (type == EVT_CLIENT_NODE_DISCONNECTED || type == EVT_NODE_SEGMENTED ||
!ctx.clientDisconnected())
                     discoWrk.addEvent(type, nextTopVer, node, discoCache, topSnapshot, customMsg);
+
+                if (stateFinishMsg != null)
+                    discoWrk.addEvent(EVT_DISCOVERY_CUSTOM_EVT, nextTopVer, node, discoCache,
topSnapshot, stateFinishMsg);
             }
         });
 
@@ -867,7 +873,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
      * @return {@code True} if should not process message.
      */
     private boolean skipMessage(int type, @Nullable DiscoveryCustomMessage customMsg) {
-        if (type == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) {
+        if (type == EVT_DISCOVERY_CUSTOM_EVT) {
             assert customMsg != null && customMsg.id() != null : customMsg;
 
             if (rcvdCustomMsgs.contains(customMsg.id())) {
@@ -2056,7 +2062,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
     public void clientCacheStartEvent(UUID reqId,
         @Nullable Map<String, DynamicCacheChangeRequest> startReqs,
         @Nullable Set<String> cachesToClose) {
-        discoWrk.addEvent(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT,
+        discoWrk.addEvent(EVT_DISCOVERY_CUSTOM_EVT,
             AffinityTopologyVersion.NONE,
             localNode(),
             null,
@@ -2620,8 +2626,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
                     break;
                 }
 
-                case DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT: {
-                    if (ctx.event().isRecordable(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT))
{
+                case EVT_DISCOVERY_CUSTOM_EVT: {
+                    if (ctx.event().isRecordable(EVT_DISCOVERY_CUSTOM_EVT)) {
                         DiscoveryCustomEvent customEvt = new DiscoveryCustomEvent();
 
                         customEvt.node(ctx.discovery().localNode());

http://git-wip-us.apache.org/repos/asf/ignite/blob/57886495/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 94e313b..7ade879 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
@@ -1100,8 +1100,8 @@ class ClusterCachesInfo {
             for (DynamicCacheDescriptor desc : registeredCaches.values()) {
                 desc.startTopologyVersion(topVer);
 
-                T2<CacheConfiguration, NearCacheConfiguration> locCfg =
-                    locCfgsForActivation.get(desc.cacheName());
+                T2<CacheConfiguration, NearCacheConfiguration> locCfg =  F.isEmpty(locCfgsForActivation)
?
+                    locCfgsForActivation.get(desc.cacheName()) : null;
 
                 DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(),
                     desc.cacheName(),

http://git-wip-us.apache.org/repos/asf/ignite/blob/57886495/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 0f27073..a1246ad 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
@@ -145,6 +145,16 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
         ctx.event().addLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
     }
 
+    /** {@inheritDoc} */
+    @Override public void onKernalStop(boolean cancel) {
+        GridChangeGlobalStateFuture fut = this.stateChangeFut.get();
+
+        if (fut != null)
+            fut.onDone(new IgniteCheckedException("Failed to wait for cluster state change,
node is stopping."));
+
+        super.onKernalStop(cancel);
+    }
+
     /**
      * @param discoCache Discovery data cache.
      * @return If transition is in progress returns future which is completed when transition
finishes.
@@ -161,9 +171,26 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
     /**
      * @param node Failed node.
+     * @return Message if cluster state changed.
      */
-    public void onNodeLeft(ClusterNode node) {
-        // TODO GG-12389.
+    @Nullable public ChangeGlobalStateFinishMessage onNodeLeft(ClusterNode node) {
+        if (globalState.transition()) {
+            Set<UUID> nodes = globalState.transitionNodes();
+
+            if (nodes.remove(node.id()) && nodes.isEmpty()) {
+                U.warn(log, "Failed to change cluster state, all participating nodes failed.
" +
+                    "Switching to inactive state.");
+
+                ChangeGlobalStateFinishMessage msg =
+                    new ChangeGlobalStateFinishMessage(globalState.transitionRequestId(),
false);
+
+                onStateFinishMessage(msg);
+
+                return msg;
+            }
+        }
+
+        return null;
     }
 
     /**
@@ -177,8 +204,10 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
 
             ctx.cache().onStateChangeFinish(msg);
 
+            TransitionOnJoinWaitFuture joinFut = this.joinFut;
+
             if (joinFut != null)
-                joinFut.onDone(msg.clusterActive());
+                joinFut.onDone(false);
         }
         else
             U.warn(log, "Received state finish message with unexpected ID: " + msg);

http://git-wip-us.apache.org/repos/asf/ignite/blob/57886495/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 bb6d23b..d78c7c2 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
@@ -937,7 +937,7 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest
     /**
      * @throws Exception If failed.
      */
-    public void testInvactiveTopologyChanges() throws Exception {
+    public void testInactiveTopologyChanges() throws Exception {
         testSpi = true;
 
         testSpiRecord = new Class[]{GridDhtPartitionsSingleMessage.class, GridDhtPartitionsFullMessage.class};
@@ -1139,10 +1139,53 @@ public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest
      * @throws Exception If failed.
      */
     private void stateChangeFailover3(boolean activate) throws Exception {
-        // Nodes 1 and 4 do not reply to coordinator.
-        IgniteInternalFuture<?> fut = startNodesAndBlockStatusChange(4, 4, 3, !activate,
1, 4);
+        startNodesAndBlockStatusChange(4, 0, 0, !activate);
+
+        // Do not allow last node to finish exchange.
+        TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(ignite(3));
+
+        spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+            @Override public boolean apply(ClusterNode clusterNode, Message message) {
+                return true;
+            }
+        });
+
+        client = false;
+
+        IgniteInternalFuture startFut1 = GridTestUtils.runAsync(new Callable() {
+            @Override public Object call() throws Exception {
+                startGrid(4);
+
+                return null;
+            }
+        }, "start-node1");
 
+        IgniteInternalFuture startFut2 = GridTestUtils.runAsync(new Callable() {
+            @Override public Object call() throws Exception {
+                startGrid(5);
+
+                return null;
+            }
+        }, "start-node2");
+
+        U.sleep(1000);
+
+        // Stop all nodes participating in state change.
+        for (int i = 0; i < 4; i++)
+            stopGrid(getTestIgniteInstanceName(i), true, false);
+
+        startFut1.get();
+        startFut2.get();
+
+        assertFalse(ignite(4).active());
+        assertFalse(ignite(5).active());
+
+        ignite(4).active(true);
+
+        for (int i = 0; i < 4; i++)
+            startGrid(i);
 
+        checkCaches1(6);
     }
 
     /**


Mime
View raw message