You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/07/05 08:21:02 UTC
[1/7] ignite git commit: Reworked cluster activation/deactivation.
Repository: ignite
Updated Branches:
refs/heads/ignite-2.1 44fad244a -> b67b8c443
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
index d0b2d56..92d1f21 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateFailOverTest.java
@@ -25,6 +25,7 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.internal.U;
import static java.lang.Thread.sleep;
import static org.apache.ignite.testframework.GridTestUtils.runAsync;
@@ -54,7 +55,7 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActivateDeActivateOnFixTopology() throws Exception {
final Ignite igB1 = backUp(0);
@@ -140,7 +141,7 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActivateDeActivateOnJoiningNode() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-5520");
@@ -168,9 +169,9 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
final IgniteInternalFuture<Void> af = runAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
while (!stop.get()) {
- Ignite ig = randomBackUp(false);
-
if (canAct.get()) {
+ Ignite ig = randomBackUp(false);
+
long start = System.currentTimeMillis();
ig.active(true);
@@ -184,6 +185,8 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
canAct.set(false);
}
+ else
+ U.sleep(100);
}
return null;
@@ -193,9 +196,9 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
final IgniteInternalFuture<Void> df = runAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
while (!stop.get()) {
- Ignite ig = randomBackUp(false);
-
if (!canAct.get()) {
+ Ignite ig = randomBackUp(false);
+
long start = System.currentTimeMillis();
ig.active(false);
@@ -209,7 +212,8 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
canAct.set(true);
}
-
+ else
+ U.sleep(100);
}
return null;
}
@@ -243,16 +247,16 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
jf2.get();
}
finally {
- log.info("total started nodes: " + (seqIdx.get() - backUpNodes()));
+ log.info("Total started nodes: " + (seqIdx.get() - backUpNodes()));
- log.info("total activate/deactivate:" + cntA.get() + "/" + cntD.get() + " aTime/dTime: "
+ log.info("Total activate/deactivate:" + cntA.get() + "/" + cntD.get() + " aTime/dTime: "
+ (timeA.get() / cntA.get() + "/" + (timeD.get() / cntD.get()))
);
}
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActivateDeActivateOnFixTopologyWithPutValues() throws Exception {
final Ignite igB1 = backUp(0);
@@ -348,7 +352,7 @@ public class IgniteChangeGlobalStateFailOverTest extends IgniteChangeGlobalState
df.get();
}
finally {
- log.info("total activate/deactivate:" + cntA.get() + "/" + cntD.get() + " aTime/dTime:"
+ log.info("Total activate/deactivate:" + cntA.get() + "/" + cntD.get() + " aTime/dTime:"
+ (timeA.get() / cntA.get() + "/" + (timeD.get() / cntD.get()) + " nodes: " + backUpNodes()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
index 9151c24..80bf1fb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateTest.java
@@ -128,74 +128,65 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
stopAllPrimary();
- final AtomicInteger exCnt = new AtomicInteger();
-
final CyclicBarrier barrier = new CyclicBarrier(backUpNodes() + backUpClientNodes());
IgniteInternalFuture<Void> f1 = runAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
- try {
- barrier.await();
- ig1B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ barrier.await();
+
+ ig1B.active(true);
+
return null;
}
});
- IgniteInternalFuture<Void> f2 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig2B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> f2 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig2B.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> f3 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig3B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> f3 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig3B.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> f4 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig1C.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> f4 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig1C.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> f5 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig2C.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> f5 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig2C.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> f6 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig3C.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> f6 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig3C.active(true);
+
+ return null;
}
});
@@ -207,8 +198,6 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
f5.get();
f6.get();
- assertTrue(exCnt.get() > 0);
-
assertTrue(ig1B.active());
assertTrue(ig2B.active());
assertTrue(ig3B.active());
@@ -232,40 +221,35 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
stopAllPrimary();
- final AtomicInteger exCnt = new AtomicInteger();
-
final CyclicBarrier barrier = new CyclicBarrier(3);
- IgniteInternalFuture<Void> act1 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig1B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> act1 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig1B.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> act2 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig2B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> act2 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig2B.active(true);
+
+ return null;
}
});
- IgniteInternalFuture<Void> act3 = runAsync(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- ig3B.active(true);
- }catch (Exception e){
- exCnt.incrementAndGet();
- }
+ IgniteInternalFuture<?> act3 = runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ barrier.await();
+
+ ig3B.active(true);
+
+ return null;
}
});
@@ -273,15 +257,13 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
act2.get();
act3.get();
- assertEquals(2, exCnt.get());
-
assertTrue(ig1B.active());
assertTrue(ig2B.active());
assertTrue(ig3B.active());
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActiveAndInActiveAtTheSameTimeCluster() throws Exception {
Ignite ig1P = primary(0);
@@ -318,7 +300,7 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActivateOnAlreadyActivatedCluster() throws Exception {
Ignite ig1P = primary(0);
@@ -375,7 +357,7 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @throws Exception If failed.
*/
public void testTryUseCacheInActiveCluster() throws Exception {
Ignite ig1B = backUp(0);
@@ -410,13 +392,14 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
IgniteCache cache = ig.cache("cache");
+
return null;
}
}, IgniteException.class, "Can not perform the operation because the cluster is inactive.");
}
/**
- *
+ * @throws Exception If failed.
*/
public void testTryUseServiceInActiveCluster() throws Exception {
Ignite ig1B = backUp(0);
@@ -445,7 +428,7 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @param ig Node to check.
*/
private void checkExceptionTryUseService(final Ignite ig) {
assertThrows(log, new Callable<Void>() {
@@ -458,7 +441,7 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @throws Exception If failed.
*/
public void testTryUseDataStructureInActiveCluster() throws Exception {
Ignite ig1B = backUp(0);
@@ -487,19 +470,20 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @param ig Node.
*/
private void checkExceptionTryUseDataStructure(final Ignite ig){
assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {
IgniteAtomicSequence seq = ig.atomicSequence("seq", 0, true);
+
return null;
}
}, IgniteException.class, "Can not perform the operation because the cluster is inactive.");
}
/**
- *
+ * @throws Exception If failed.
*/
public void testFailGetLock() throws Exception {
Ignite ig1P = primary(0);
@@ -556,7 +540,7 @@ public class IgniteChangeGlobalStateTest extends IgniteChangeGlobalStateAbstract
}
/**
- *
+ * @throws Exception If failed.
*/
public void testActivateAfterFailGetLock() throws Exception {
Ignite ig1P = primary(0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
index c3bdcda..2678e51 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteStandByClusterTest.java
@@ -60,7 +60,7 @@ public class IgniteStandByClusterTest extends GridCommonAbstractTest {
/**
* @throws Exception if fail.
*/
- public void testNotStartDynamicCachesOnClientAfterActivation() throws Exception {
+ public void testStartDynamicCachesAfterActivation() throws Exception {
final String cacheName0 = "cache0";
final String cacheName = "cache";
@@ -114,13 +114,10 @@ public class IgniteStandByClusterTest extends GridCommonAbstractTest {
Map<String, GridCacheAdapter<?, ?>> caches = U.field(ig3.context().cache(), "caches");
// Only system cache and cache0
- assertTrue(caches.size() == 2);
+ assertEquals("Unexpected caches: " + caches.keySet(), 3, caches.size());
assertTrue(caches.containsKey(CU.UTILITY_CACHE_NAME));
assertTrue(caches.containsKey(cacheName0));
-
- assertNull(caches.get(cacheName));
-
- assertNotNull(caches.get(cacheName0));
+ assertTrue(caches.containsKey(cacheName));
assertNotNull(ig3.cache(cacheName));
}
@@ -156,12 +153,6 @@ public class IgniteStandByClusterTest extends GridCommonAbstractTest {
assertTrue(!ig2.active());
assertTrue(!ig3.active());
- for (IgniteEx ig : Arrays.asList(ig1, ig2, ig3)) {
- Map<String, DynamicCacheDescriptor> desc = U.field(U.field(ig.context().cache(), "cachesInfo"), "registeredCaches");
-
- assertEquals(0, desc.size());
- }
-
ig3.active(true);
assertTrue(ig1.active());
@@ -286,7 +277,7 @@ public class IgniteStandByClusterTest extends GridCommonAbstractTest {
private final String name;
/**
- * @param name
+ * @param name Node name.
*/
private NodeFilterIgnoreByName(String name) {
this.name = name;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
index 9c5f017..8e90e78 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/JoinActiveNodeToActiveCluster.java
@@ -29,9 +29,7 @@ import org.junit.Assert;
*
*/
public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
JoinNodeTestPlanBuilder b = builder();
@@ -56,9 +54,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
return b;
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder staticCacheConfigurationOnJoinTemplate() throws Exception {
JoinNodeTestPlanBuilder b = builder();
@@ -85,9 +81,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
return b;
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder staticCacheConfigurationInClusterTemplate() throws Exception {
JoinNodeTestPlanBuilder b = builder();
@@ -115,9 +109,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
return b;
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder staticCacheConfigurationSameOnBothTemplate() throws Exception {
JoinNodeTestPlanBuilder b = builder();
@@ -146,9 +138,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
return b;
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder staticCacheConfigurationDifferentOnBothTemplate() throws Exception {
JoinNodeTestPlanBuilder b = builder();
@@ -207,62 +197,46 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
withOutConfigurationTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testStaticCacheConfigurationOnJoin() throws Exception {
staticCacheConfigurationOnJoinTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testStaticCacheConfigurationInCluster() throws Exception {
staticCacheConfigurationInClusterTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testStaticCacheConfigurationSameOnBoth() throws Exception {
staticCacheConfigurationSameOnBothTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testStaticCacheConfigurationDifferentOnBoth() throws Exception {
staticCacheConfigurationDifferentOnBothTemplate().execute();
}
// Client node join.
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testJoinClientWithOutConfiguration() throws Exception {
joinClientWithOutConfigurationTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testJoinClientStaticCacheConfigurationOnJoin() throws Exception {
joinClientStaticCacheConfigurationOnJoinTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-5518");
joinClientStaticCacheConfigurationInClusterTemplate().execute();
}
- /**
- *
- */
+ /** {@inheritDoc} */
@Override public void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception {
joinClientStaticCacheConfigurationSameOnBothTemplate().execute();
}
@@ -276,14 +250,17 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
joinClientStaticCacheConfigurationDifferentOnBothTemplate().execute();
}
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder joinClientWithOutConfigurationTemplate() throws Exception {
return withOutConfigurationTemplate().nodeConfiguration(setClient);
}
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationOnJoinTemplate() throws Exception {
return staticCacheConfigurationOnJoinTemplate().nodeConfiguration(setClient);
}
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationInClusterTemplate() throws Exception {
return staticCacheConfigurationInClusterTemplate()
.nodeConfiguration(setClient)
@@ -360,8 +337,10 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
});
}
- @Override
- public JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationDifferentOnBothTemplate() throws Exception {
+ /** {@inheritDoc} */
+ @Override public JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationDifferentOnBothTemplate()
+ throws Exception
+ {
return staticCacheConfigurationDifferentOnBothTemplate()
.nodeConfiguration(setClient)
.afterActivate(new Runnable() {
@@ -436,6 +415,7 @@ public class JoinActiveNodeToActiveCluster extends AbstractNodeJoinTemplate {
});
}
+ /** {@inheritDoc} */
@Override public JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationSameOnBothTemplate() throws Exception {
return staticCacheConfigurationSameOnBothTemplate().nodeConfiguration(setClient);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
index 60388fa..1ccfb7d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/join/persistence/JoinActiveNodeToActiveClusterWithPersistence.java
@@ -30,6 +30,10 @@ public class JoinActiveNodeToActiveClusterWithPersistence extends JoinActiveNode
return persistentCfg(super.cfg(name));
}
+ /**
+ * @param b Builder.
+ * @return Builder.
+ */
private AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder persistent(AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder b) {
b.afterClusterStarted(
b.checkCacheEmpty()
@@ -44,6 +48,7 @@ public class JoinActiveNodeToActiveClusterWithPersistence extends JoinActiveNode
return b;
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception {
AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder b = persistent(super.withOutConfigurationTemplate());
@@ -52,6 +57,7 @@ public class JoinActiveNodeToActiveClusterWithPersistence extends JoinActiveNode
return b;
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder joinClientWithOutConfigurationTemplate() throws Exception {
AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder b = persistent(super.joinClientWithOutConfigurationTemplate());
@@ -60,46 +66,57 @@ public class JoinActiveNodeToActiveClusterWithPersistence extends JoinActiveNode
return b;
}
+ /** {@inheritDoc} */
@Override public void testJoinWithOutConfiguration() throws Exception {
withOutConfigurationTemplate().execute();
}
+ /** {@inheritDoc} */
@Override public void testJoinClientWithOutConfiguration() throws Exception {
joinClientWithOutConfigurationTemplate().execute();
}
+ /** {@inheritDoc} */
@Override public void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception {
staticCacheConfigurationDifferentOnBothTemplate().execute();
}
+ /** {@inheritDoc} */
@Override public void testJoinClientStaticCacheConfigurationInCluster() throws Exception {
staticCacheConfigurationInClusterTemplate().execute();
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder staticCacheConfigurationOnJoinTemplate() throws Exception {
return persistent(super.staticCacheConfigurationOnJoinTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder staticCacheConfigurationInClusterTemplate() throws Exception {
return persistent(super.staticCacheConfigurationInClusterTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder staticCacheConfigurationSameOnBothTemplate() throws Exception {
return persistent(super.staticCacheConfigurationSameOnBothTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder staticCacheConfigurationDifferentOnBothTemplate() throws Exception {
return persistent(super.staticCacheConfigurationDifferentOnBothTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationOnJoinTemplate() throws Exception {
return persistent(super.joinClientStaticCacheConfigurationOnJoinTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationInClusterTemplate() throws Exception {
return persistent(super.joinClientStaticCacheConfigurationInClusterTemplate());
}
+ /** {@inheritDoc} */
@Override public AbstractNodeJoinTemplate.JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationDifferentOnBothTemplate() throws Exception {
return persistent(super.joinClientStaticCacheConfigurationDifferentOnBothTemplate());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
index 02f7d00..548dba2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectTest.java
@@ -24,7 +24,9 @@ import org.apache.ignite.internal.IgniteEx;
*
*/
public class IgniteStandByClientReconnectTest extends IgniteAbstractStandByClientReconnectTest {
-
+ /**
+ * @throws Exception If failed.
+ */
public void testActiveClientReconnectToActiveCluster() throws Exception {
CountDownLatch activateLatch = new CountDownLatch(1);
@@ -103,6 +105,9 @@ public class IgniteStandByClientReconnectTest extends IgniteAbstractStandByClien
checkAllCaches();
}
+ /**
+ * @throws Exception If failed.
+ */
public void testActiveClientReconnectToInActiveCluster() throws Exception {
CountDownLatch activateLatch = new CountDownLatch(1);
@@ -180,6 +185,9 @@ public class IgniteStandByClientReconnectTest extends IgniteAbstractStandByClien
checkAllCaches();
}
+ /**
+ * @throws Exception If failed.
+ */
public void testInActiveClientReconnectToActiveCluster() throws Exception {
CountDownLatch activateLatch = new CountDownLatch(1);
@@ -234,6 +242,9 @@ public class IgniteStandByClientReconnectTest extends IgniteAbstractStandByClien
checkAllCaches();
}
+ /**
+ * @throws Exception If failed.
+ */
public void testInActiveClientReconnectToInActiveCluster() throws Exception {
startNodes(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
index 2bcc177..2da32e3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/reconnect/IgniteStandByClientReconnectToNewClusterTest.java
@@ -27,7 +27,9 @@ import org.apache.ignite.internal.IgniteEx;
*
*/
public class IgniteStandByClientReconnectToNewClusterTest extends IgniteAbstractStandByClientReconnectTest {
-
+ /**
+ * @throws Exception If failed.
+ */
public void testActiveClientReconnectToActiveCluster() throws Exception {
CountDownLatch activateLatch = new CountDownLatch(1);
@@ -104,6 +106,9 @@ public class IgniteStandByClientReconnectToNewClusterTest extends IgniteAbstract
checkAllCaches();
}
+ /**
+ * @throws Exception If failed.
+ */
public void testActiveClientReconnectToInActiveCluster() throws Exception {
startNodes(null);
@@ -181,6 +186,9 @@ public class IgniteStandByClientReconnectToNewClusterTest extends IgniteAbstract
checkAllCaches();
}
+ /**
+ * @throws Exception If failed.
+ */
public void testInActiveClientReconnectToActiveCluster() throws Exception {
CountDownLatch activateLatch = new CountDownLatch(1);
@@ -236,6 +244,9 @@ public class IgniteStandByClientReconnectToNewClusterTest extends IgniteAbstract
checkDescriptors(client, exp2);
}
+ /**
+ * @throws Exception If failed.
+ */
public void testInActiveClientReconnectToInActiveCluster() throws Exception {
startNodes(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
index 90af25e..bc07028 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
@@ -479,7 +479,7 @@ public class GridTcpCommunicationSpiMultithreadedSelfTest extends GridSpiAbstrac
timeoutProcessor.start();
- timeoutProcessor.onKernalStart();
+ timeoutProcessor.onKernalStart(true);
for (int i = 0; i < getSpiCount(); i++) {
CommunicationSpi<Message> spi = newCommunicationSpi();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index a9a870e..d6d241c 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -2099,13 +2099,13 @@ public abstract class GridAbstractTest extends TestCase {
for (Ignite g : G.allGrids()) {
final GridKernalContext ctx = ((IgniteKernal)g).context();
- if (ctx.isStopping())
+ if (ctx.isStopping() || !g.active())
continue;
AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion();
- if (! topVer.equals(exchVer)) {
+ if (!topVer.equals(exchVer)) {
info("Topology version mismatch [node=" + g.name() +
", exchVer=" + exchVer +
", topVer=" + topVer + ']');
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 3f87c76..dc7e89d 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -596,6 +596,9 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
else
startTime = g0.context().discovery().gridStartTime();
+ if (g.cluster().localNode().isDaemon())
+ continue;
+
IgniteInternalFuture<?> exchFut =
g0.context().cache().context().exchange().affinityReadyFuture(waitTopVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java
index 6fa158d..f016e39 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteStandByClusterSuite.java
@@ -18,6 +18,7 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.IgniteClusterActivateDeactivateTest;
import org.apache.ignite.internal.processors.cache.persistence.standbycluster.IgniteChangeGlobalStateCacheTest;
import org.apache.ignite.internal.processors.cache.persistence.standbycluster.IgniteChangeGlobalStateDataStreamerTest;
import org.apache.ignite.internal.processors.cache.persistence.standbycluster.IgniteChangeGlobalStateDataStructureTest;
@@ -41,11 +42,13 @@ import org.apache.ignite.internal.processors.cache.persistence.standbycluster.re
*/
public class IgniteStandByClusterSuite extends TestSuite {
/**
- *
+ * @return Test suite.
*/
public static TestSuite suite() {
TestSuite suite = new TestSuite("Ignite Activate/DeActivate Cluster Test Suit");
+ suite.addTestSuite(IgniteClusterActivateDeactivateTest.class);
+
suite.addTestSuite(IgniteStandByClusterTest.class);
suite.addTestSuite(IgniteStandByClientReconnectTest.class);
suite.addTestSuite(IgniteStandByClientReconnectToNewClusterTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
index 329d67f..231fc22 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopProcessor.java
@@ -95,8 +95,8 @@ public class HadoopProcessor extends HadoopProcessorAdapter {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
- super.onKernalStart();
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
+ super.onKernalStart(active);
if (hctx == null)
return;
[6/7] ignite git commit: Reworked cluster activation/deactivation.
Posted by sb...@apache.org.
Reworked cluster activation/deactivation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1337901f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1337901f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1337901f
Branch: refs/heads/ignite-2.1
Commit: 1337901f04c866e20093b20449c0872f089fb64b
Parents: 54572c3
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jul 5 11:19:43 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jul 5 11:19:43 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/GridComponent.java | 4 +-
.../ignite/internal/GridPluginComponent.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 33 +-
.../internal/managers/GridManagerAdapter.java | 2 +-
.../internal/managers/discovery/DiscoCache.java | 17 +-
.../discovery/DiscoveryLocalJoinData.java | 104 ++
.../discovery/GridDiscoveryManager.java | 128 +-
.../pagemem/store/IgnitePageStoreManager.java | 3 +-
.../processors/GridProcessorAdapter.java | 2 +-
.../cache/CacheAffinitySharedManager.java | 67 +-
.../processors/cache/CacheGroupContext.java | 4 +-
.../processors/cache/CacheGroupData.java | 4 +-
.../cache/ChangeGlobalStateMessage.java | 120 --
.../processors/cache/ClusterCachesInfo.java | 490 +++++--
.../internal/processors/cache/ClusterState.java | 38 -
.../cache/DynamicCacheChangeRequest.java | 52 +-
.../processors/cache/ExchangeActions.java | 37 +-
.../processors/cache/GridCacheEventManager.java | 2 -
.../cache/GridCacheEvictionManager.java | 1 -
.../processors/cache/GridCacheIoManager.java | 13 +-
.../processors/cache/GridCacheMvccManager.java | 9 +-
.../GridCachePartitionExchangeManager.java | 423 +++---
.../processors/cache/GridCacheProcessor.java | 177 ++-
.../cache/GridCacheSharedContext.java | 60 +-
.../cache/GridCacheSharedManager.java | 6 -
.../cache/GridCacheSharedManagerAdapter.java | 16 -
.../processors/cache/PendingDiscoveryEvent.java | 61 +
.../processors/cache/StateChangeRequest.java | 77 ++
.../binary/CacheObjectBinaryProcessorImpl.java | 4 +-
.../distributed/GridCacheTxRecoveryFuture.java | 1 -
.../distributed/dht/GridDhtCacheAdapter.java | 1 -
.../cache/distributed/dht/GridDhtGetFuture.java | 1 -
.../distributed/dht/GridDhtGetSingleFuture.java | 2 -
.../dht/GridDhtPartitionTopologyImpl.java | 13 +-
.../dht/GridDhtTopologyFutureAdapter.java | 2 +-
.../dht/GridPartitionedSingleGetFuture.java | 3 -
.../GridNearAtomicAbstractUpdateFuture.java | 1 -
.../dht/preloader/GridDhtForceKeysFuture.java | 1 -
.../dht/preloader/GridDhtPartitionDemander.java | 2 +
.../GridDhtPartitionsExchangeFuture.java | 228 +++-
.../preloader/GridDhtPartitionsFullMessage.java | 44 +-
.../GridDhtPartitionsSingleMessage.java | 38 +-
.../dht/preloader/GridDhtPreloader.java | 2 +-
.../distributed/near/GridNearGetFuture.java | 2 -
.../near/GridNearTxPrepareRequest.java | 1 -
.../GridCacheDatabaseSharedManager.java | 105 +-
.../persistence/GridCacheOffheapManager.java | 5 +-
.../IgniteCacheDatabaseSharedManager.java | 64 +-
.../persistence/IgniteCacheSnapshotManager.java | 12 +-
.../persistence/file/FilePageStoreManager.java | 14 +-
.../wal/FileWriteAheadLogManager.java | 8 -
.../query/GridCacheDistributedQueryManager.java | 4 +-
.../store/GridCacheStoreManagerAdapter.java | 1 -
.../cache/version/GridCacheVersionManager.java | 6 -
.../cacheobject/IgniteCacheObjectProcessor.java | 5 -
.../IgniteCacheObjectProcessorImpl.java | 5 -
.../cluster/ChangeGlobalStateFinishMessage.java | 86 ++
.../cluster/ChangeGlobalStateMessage.java | 140 ++
.../processors/cluster/ClusterProcessor.java | 3 +-
.../cluster/DiscoveryDataClusterState.java | 157 +++
.../cluster/GridClusterStateProcessor.java | 1122 ++++++---------
.../cluster/IgniteChangeGlobalStateSupport.java | 3 +-
.../datastructures/DataStructuresProcessor.java | 6 +-
.../datastructures/GridCacheAtomicLongImpl.java | 2 +-
.../GridCacheAtomicReferenceImpl.java | 2 +-
.../GridCacheAtomicSequenceImpl.java | 2 +-
.../GridCacheAtomicStampedImpl.java | 2 +-
.../GridCacheCountDownLatchImpl.java | 2 +-
.../datastructures/GridCacheLockImpl.java | 4 +-
.../datastructures/GridCacheQueueAdapter.java | 1 -
.../datastructures/GridCacheSemaphoreImpl.java | 2 +-
.../datastructures/GridCacheSetImpl.java | 1 -
.../internal/processors/igfs/IgfsImpl.java | 2 -
.../internal/processors/igfs/IgfsProcessor.java | 2 +-
.../processors/query/GridQueryProcessor.java | 4 +-
.../processors/rest/GridRestProcessor.java | 2 +-
.../cluster/GridChangeStateCommandHandler.java | 2 +-
.../service/GridServiceProcessor.java | 6 +-
.../processors/task/GridTaskProcessor.java | 2 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 12 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 10 +-
.../internal/TestRecordingCommunicationSpi.java | 10 +
...GridManagerLocalMessageListenerSelfTest.java | 4 +-
.../cache/IgniteActiveClusterTest.java | 182 ---
.../IgniteClusterActivateDeactivateTest.java | 1284 ++++++++++++++++++
...erActivateDeactivateTestWithPersistence.java | 197 +++
.../IgniteDaemonNodeMarshallerCacheTest.java | 10 -
.../pagemem/NoOpPageStoreManager.java | 12 +-
.../persistence/pagemem/NoOpWALManager.java | 23 +-
.../AbstractNodeJoinTemplate.java | 149 +-
.../IgniteChangeGlobalStateAbstractTest.java | 65 +-
.../IgniteChangeGlobalStateCacheTest.java | 2 +-
...IgniteChangeGlobalStateDataStreamerTest.java | 5 +-
...gniteChangeGlobalStateDataStructureTest.java | 6 +-
.../IgniteChangeGlobalStateFailOverTest.java | 26 +-
.../IgniteChangeGlobalStateTest.java | 158 +--
.../IgniteStandByClusterTest.java | 17 +-
.../join/JoinActiveNodeToActiveCluster.java | 62 +-
...ctiveNodeToActiveClusterWithPersistence.java | 17 +
.../IgniteStandByClientReconnectTest.java | 13 +-
...eStandByClientReconnectToNewClusterTest.java | 13 +-
...cpCommunicationSpiMultithreadedSelfTest.java | 2 +-
.../testframework/junits/GridAbstractTest.java | 4 +-
.../junits/common/GridCommonAbstractTest.java | 3 +
.../testsuites/IgniteStandByClusterSuite.java | 5 +-
.../processors/hadoop/HadoopProcessor.java | 4 +-
106 files changed, 4180 insertions(+), 2197 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
index 0505929..93ffe95 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridComponent.java
@@ -84,9 +84,11 @@ public interface GridComponent {
* Callback that notifies that kernal has successfully started,
* including all managers and processors.
*
+ * @param active Cluster active flag (note: should be used carefully since state can
+ * change concurrently).
* @throws IgniteCheckedException Thrown in case of any errors.
*/
- public void onKernalStart() throws IgniteCheckedException;
+ public void onKernalStart(boolean active) throws IgniteCheckedException;
/**
* Callback to notify that kernal is about to stop.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java b/modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java
index cc1ae71..fd59d24 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridPluginComponent.java
@@ -61,7 +61,7 @@ public class GridPluginComponent implements GridComponent {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
plugin.onIgniteStart();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 31ee3e2..0c17b32 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -98,6 +98,7 @@ import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager;
import org.apache.ignite.internal.managers.collision.GridCollisionManager;
import org.apache.ignite.internal.managers.communication.GridIoManager;
import org.apache.ignite.internal.managers.deployment.GridDeploymentManager;
+import org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData;
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.managers.failover.GridFailoverManager;
@@ -207,7 +208,6 @@ import static org.apache.ignite.internal.IgniteComponentType.HADOOP_HELPER;
import static org.apache.ignite.internal.IgniteComponentType.IGFS;
import static org.apache.ignite.internal.IgniteComponentType.IGFS_HELPER;
import static org.apache.ignite.internal.IgniteComponentType.SCHEDULE;
-import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_ACTIVE_ON_START;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_DATE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CLIENT_MODE;
@@ -818,8 +818,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
List<PluginProvider> plugins = U.allPluginProviders();
- final boolean activeOnStart = cfg.isActiveOnStart();
-
// Spin out SPIs & managers.
try {
ctx = new GridKernalContextImpl(log,
@@ -994,11 +992,28 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Suggest Operation System optimizations.
ctx.performance().addAll(OsConfigurationSuggestions.getSuggestions());
+ DiscoveryLocalJoinData joinData = ctx.discovery().localJoin();
+
+ IgniteInternalFuture<Boolean> transitionWaitFut = joinData.transitionWaitFuture();
+
+ boolean active;
+
+ if (transitionWaitFut != null) {
+ if (log.isInfoEnabled()) {
+ log.info("Join cluster while cluster state transition is in progress, " +
+ "waiting when transition finish.");
+ }
+
+ active = transitionWaitFut.get();
+ }
+ else
+ active = joinData.active();
+
// Notify discovery manager the first to make sure that topology is discovered.
- ctx.discovery().onKernalStart();
+ ctx.discovery().onKernalStart(active);
// Notify IO manager the second so further components can send and receive messages.
- ctx.io().onKernalStart();
+ ctx.io().onKernalStart(active);
// Start plugins.
for (PluginProvider provider : ctx.plugins().allProviders())
@@ -1021,7 +1036,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
if (!skipDaemon(comp)) {
try {
- comp.onKernalStart();
+ comp.onKernalStart(active);
}
catch (IgniteNeedReconnectException e) {
assert ctx.discovery().reconnectSupported();
@@ -1486,7 +1501,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER_USE_DFLT_SUID,
getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID));
add(ATTR_LATE_AFFINITY_ASSIGNMENT, cfg.isLateAffinityAssignment());
- add(ATTR_ACTIVE_ON_START, cfg.isActiveOnStart());
if (cfg.getMarshaller() instanceof BinaryMarshaller) {
add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ?
@@ -3395,7 +3409,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
guard();
try {
- return context().state().active();
+ return context().state().publicApiActiveState();
}
finally {
unguard();
@@ -3694,10 +3708,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
* @throws IgniteException if cluster in inActive state
*/
private void checkClusterState() throws IgniteException {
- if (!ctx.state().active())
+ if (!ctx.state().publicApiActiveState()) {
throw new IgniteException("Can not perform the operation because the cluster is inactive. Note, that " +
"the cluster is considered inactive by default if Ignite Persistent Store is used to let all the nodes " +
"join the cluster. To activate the cluster call Ignite.activate(true).");
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
index 7dfeffb..a151eb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
@@ -362,7 +362,7 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements GridMan
}
/** {@inheritDoc} */
- @Override public final void onKernalStart() throws IgniteCheckedException {
+ @Override public final void onKernalStart(boolean active) throws IgniteCheckedException {
for (final IgniteSpi spi : spis) {
try {
spi.onContextInitialized(new IgniteSpiContext() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 2b3c4fc..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
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
@@ -37,6 +38,9 @@ import org.jetbrains.annotations.Nullable;
*
*/
public class DiscoCache {
+ /** */
+ private final DiscoveryDataClusterState state;
+
/** Local node. */
private final ClusterNode loc;
@@ -78,6 +82,7 @@ public class DiscoCache {
private final Set<UUID> alives = new GridConcurrentHashSet<>();
/**
+ * @param state Current cluster state.
* @param loc Local node.
* @param rmtNodes Remote nodes.
* @param allNodes All nodes.
@@ -91,7 +96,9 @@ public class DiscoCache {
* @param nodeMap Node map.
* @param alives Alive nodes.
*/
- DiscoCache(ClusterNode loc,
+ DiscoCache(
+ DiscoveryDataClusterState state,
+ ClusterNode loc,
List<ClusterNode> rmtNodes,
List<ClusterNode> allNodes,
List<ClusterNode> srvNodes,
@@ -103,6 +110,7 @@ public class DiscoCache {
Map<Integer, List<ClusterNode>> cacheGrpAffNodes,
Map<UUID, ClusterNode> nodeMap,
Set<UUID> alives) {
+ this.state = state;
this.loc = loc;
this.rmtNodes = rmtNodes;
this.allNodes = allNodes;
@@ -117,6 +125,13 @@ public class DiscoCache {
this.alives.addAll(alives);
}
+ /**
+ * @return Current cluster state.
+ */
+ public DiscoveryDataClusterState state() {
+ return state;
+ }
+
/** @return Local node. */
public ClusterNode localNode() {
return loc;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..a1f2aa7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/DiscoveryLocalJoinData.java
@@ -0,0 +1,104 @@
+/*
+ * 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.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 {
+ /** */
+ private final DiscoveryEvent evt;
+
+ /** */
+ private final DiscoCache discoCache;
+
+ /** */
+ private final AffinityTopologyVersion joinTopVer;
+
+ /** */
+ private final IgniteInternalFuture<Boolean> transitionWaitFut;
+
+ /** */
+ 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,
+ boolean active) {
+ assert evt != null && evt.topologyVersion() > 0 : evt;
+
+ this.evt = evt;
+ this.discoCache = discoCache;
+ this.transitionWaitFut = transitionWaitFut;
+ this.active = active;
+
+ 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/1337901f/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 c38e37a..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
@@ -75,8 +75,11 @@ import org.apache.ignite.internal.processors.cache.ClientCacheChangeDummyDiscove
import org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest;
import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
-import org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
+import org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetrics;
import org.apache.ignite.internal.processors.security.SecurityContext;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
@@ -90,7 +93,6 @@ import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.P1;
-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;
@@ -133,7 +135,6 @@ import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED;
import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED;
-import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_ACTIVE_ON_START;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DEPLOYMENT_MODE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LATE_AFFINITY_ASSIGNMENT;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
@@ -144,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;
@@ -238,7 +240,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
private long segChkFreq;
/** Local node join to topology event. */
- private GridFutureAdapter<T2<DiscoveryEvent, DiscoCache>> locJoin = new GridFutureAdapter<>();
+ private GridFutureAdapter<DiscoveryLocalJoinData> locJoin = new GridFutureAdapter<>();
/** GC CPU load. */
private volatile double gcCpuLoad;
@@ -570,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;
@@ -586,15 +588,50 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
updateClientNodes(node.id());
}
+ DiscoCache discoCache = null;
+
+ boolean locJoinEvt = type == EVT_NODE_JOINED && node.id().equals(locNode.id());
+
+ 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)
+ 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 = ctx.cache().onCustomEvent(
- customMsg,
- new AffinityTopologyVersion(topVer, minorTopVer),
- node);
+ boolean incMinorTopVer;
+
+ if (customMsg instanceof ChangeGlobalStateMessage) {
+ incMinorTopVer = ctx.state().onStateChangeMessage(
+ new AffinityTopologyVersion(topVer, minorTopVer),
+ (ChangeGlobalStateMessage)customMsg,
+ discoCache());
+ }
+ else if (customMsg instanceof ChangeGlobalStateFinishMessage) {
+ ctx.state().onStateFinishMessage((ChangeGlobalStateFinishMessage)customMsg);
+
+ discoCache = createDiscoCache(ctx.state().clusterState(), locNode, topSnapshot);
+
+ topSnap.set(new Snapshot(topSnap.get().topVer, discoCache));
+
+ incMinorTopVer = false;
+ }
+ else {
+ incMinorTopVer = ctx.cache().onCustomEvent(
+ customMsg,
+ new AffinityTopologyVersion(topVer, minorTopVer),
+ node);
+ }
if (incMinorTopVer) {
minorTopVer++;
@@ -603,17 +640,13 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
nextTopVer = new AffinityTopologyVersion(topVer, minorTopVer);
-
- if (verChanged)
- ctx.cache().onDiscoveryEvent(type, node, nextTopVer);
}
- else {
+ else
nextTopVer = new AffinityTopologyVersion(topVer, minorTopVer);
- ctx.cache().onDiscoveryEvent(type, node, nextTopVer);
- }
+ 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);
@@ -630,13 +663,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
}
- final DiscoCache discoCache;
-
// Put topology snapshot into discovery history.
// There is no race possible between history maintenance and concurrent discovery
// event notifications, since SPI notifies manager about all events from this listener.
if (verChanged) {
- discoCache = createDiscoCache(locNode, topSnapshot);
+ if (discoCache == null)
+ discoCache = createDiscoCache(ctx.state().clusterState(), locNode, topSnapshot);
discoCacheHist.put(nextTopVer, discoCache);
@@ -650,8 +682,10 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
// Current version.
discoCache = discoCache();
+ final DiscoCache discoCache0 = discoCache;
+
// If this is a local join event, just save it and do not notify listeners.
- if (type == EVT_NODE_JOINED && node.id().equals(locNode.id())) {
+ if (locJoinEvt) {
if (gridStartTime == 0)
gridStartTime = getSpi().getGridStartTime();
@@ -668,7 +702,15 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
discoEvt.topologySnapshot(topVer, new ArrayList<>(F.view(topSnapshot, FILTER_DAEMON)));
- locJoin.onDone(new T2<>(discoEvt, discoCache));
+ discoWrk.discoCache = discoCache;
+
+ if (!isLocDaemon && !ctx.clientDisconnected())
+ ctx.cache().context().exchange().onLocalJoin(discoEvt, discoCache);
+
+ locJoin.onDone(new DiscoveryLocalJoinData(discoEvt,
+ discoCache,
+ transitionWaitFut,
+ ctx.state().clusterState().active()));
return;
}
@@ -697,7 +739,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
topHist.clear();
topSnap.set(new Snapshot(AffinityTopologyVersion.ZERO,
- createDiscoCache(locNode, Collections.<ClusterNode>emptySet())));
+ createDiscoCache(ctx.state().clusterState(), locNode, Collections.<ClusterNode>emptySet())));
}
else if (type == EVT_CLIENT_NODE_RECONNECTED) {
assert locNode.isClient() : locNode;
@@ -709,12 +751,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
((IgniteKernal)ctx.grid()).onReconnected(clusterRestarted);
+ ctx.cache().context().exchange().onLocalJoin(localJoinEvent(), discoCache);
+
ctx.cluster().clientReconnectFuture().listen(new CI1<IgniteFuture<?>>() {
@Override public void apply(IgniteFuture<?> fut) {
try {
fut.get();
- discoWrk.addEvent(type, nextTopVer, node, discoCache, topSnapshot, null);
+ discoWrk.addEvent(type, nextTopVer, node, discoCache0, topSnapshot, null);
}
catch (IgniteException ignore) {
// No-op.
@@ -727,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);
}
});
@@ -826,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())) {
@@ -1157,7 +1204,6 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
locMarshStrSerVer2;
boolean locDelayAssign = locNode.attribute(ATTR_LATE_AFFINITY_ASSIGNMENT);
- boolean locActiveOnStart = locNode.attribute(ATTR_ACTIVE_ON_START);
Boolean locSrvcCompatibilityEnabled = locNode.attribute(ATTR_SERVICES_COMPATIBILITY_MODE);
Boolean locSecurityCompatibilityEnabled = locNode.attribute(ATTR_SECURITY_COMPATIBILITY_MODE);
@@ -1971,7 +2017,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/** @return Event that represents a local node joined to topology. */
public DiscoveryEvent localJoinEvent() {
try {
- return locJoin.get().get1();
+ return locJoin.get().event();
}
catch (IgniteCheckedException e) {
throw new IgniteException(e);
@@ -1981,7 +2027,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/**
* @return Tuple that consists of a local join event and discovery cache at the join time.
*/
- public T2<DiscoveryEvent, DiscoCache> localJoin() {
+ public DiscoveryLocalJoinData localJoin() {
try {
return locJoin.get();
}
@@ -2016,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,
@@ -2098,11 +2144,14 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/**
* Called from discovery thread.
*
+ * @param state Current state.
* @param loc Local node.
* @param topSnapshot Topology snapshot.
* @return Newly created discovery cache.
*/
- @NotNull private DiscoCache createDiscoCache(ClusterNode loc, Collection<ClusterNode> topSnapshot) {
+ @NotNull private DiscoCache createDiscoCache(DiscoveryDataClusterState state,
+ ClusterNode loc,
+ Collection<ClusterNode> topSnapshot) {
HashSet<UUID> alives = U.newHashSet(topSnapshot.size());
HashMap<UUID, ClusterNode> nodeMap = U.newHashMap(topSnapshot.size());
@@ -2177,6 +2226,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
return new DiscoCache(
+ state,
loc,
Collections.unmodifiableList(rmtNodes),
Collections.unmodifiableList(allNodes),
@@ -2318,7 +2368,7 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
discoWrk.addEvent(EVT_NODE_SEGMENTED,
AffinityTopologyVersion.NONE,
node,
- createDiscoCache(node, empty),
+ createDiscoCache(null, node, empty),
empty,
null);
@@ -2339,6 +2389,9 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
/** Worker for discovery events. */
private class DiscoveryWorker extends GridWorker {
+ /** */
+ private DiscoCache discoCache;
+
/** Event queue. */
private final BlockingQueue<GridTuple6<Integer, AffinityTopologyVersion, ClusterNode,
DiscoCache, Collection<ClusterNode>, DiscoveryCustomMessage>> evts = new LinkedBlockingQueue<>();
@@ -2457,6 +2510,9 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
boolean segmented = false;
+ if (evt.get4() != null)
+ discoCache = evt.get4();
+
switch (type) {
case EVT_NODE_JOINED: {
assert !discoOrdered || topVer.topologyVersion() == node.order() : "Invalid topology version [topVer=" + topVer +
@@ -2570,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());
@@ -2581,6 +2637,12 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
customEvt.affinityTopologyVersion(topVer);
customEvt.customMessage(evt.get6());
+ if (evt.get4() == null) {
+ assert discoCache != null : evt.get6();
+
+ evt.set4(discoCache);
+ }
+
ctx.event().record(customEvt, evt.get4());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java
index 468d35d..fa6e9e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/store/IgnitePageStoreManager.java
@@ -183,11 +183,10 @@ public interface IgnitePageStoreManager extends GridCacheSharedManager, IgniteCh
public Map<String, StoredCacheData> readCacheConfigurations() throws IgniteCheckedException;
/**
- * @param grpDesc Cache group descriptor.
* @param cacheData Cache configuration.
* @throws IgniteCheckedException If failed.
*/
- public void storeCacheData(CacheGroupDescriptor grpDesc, StoredCacheData cacheData) throws IgniteCheckedException;
+ public void storeCacheData(StoredCacheData cacheData) throws IgniteCheckedException;
/**
* @param grpId Cache group ID.
* @return {@code True} if index store for given cache group existed before node started.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/GridProcessorAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/GridProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/GridProcessorAdapter.java
index 690ba0e..d6f78ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/GridProcessorAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/GridProcessorAdapter.java
@@ -65,7 +65,7 @@ public abstract class GridProcessorAdapter implements GridProcessor {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 9516f84..8d08c3f 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
@@ -41,6 +41,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
+import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
@@ -52,6 +53,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -108,6 +111,9 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
/** */
private final ThreadLocal<ClientCacheChangeDiscoveryMessage> clientCacheChanges = new ThreadLocal<>();
+ /** Caches initialized flag (initialized when join activate cluster or after activation. */
+ private boolean cachesInitialized;
+
/** Discovery listener. */
private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -140,10 +146,19 @@ 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, ClusterNode node, AffinityTopologyVersion topVer) {
+ void onDiscoveryEvent(int type,
+ @Nullable DiscoveryCustomMessage customMsg,
+ ClusterNode node,
+ AffinityTopologyVersion topVer,
+ DiscoveryDataClusterState state) {
+ if (state.transition() || !state.active())
+ return;
+
if (type == EVT_NODE_JOINED && node.isLocal()) {
// Clean-up in case of client reconnect.
caches.clear();
@@ -153,6 +168,15 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
lastAffVer = null;
caches.init(cctx.cache().cacheGroupDescriptors(), cctx.cache().cacheDescriptors());
+
+ cachesInitialized = true;
+ }
+ else if (customMsg instanceof ChangeGlobalStateFinishMessage) {
+ if (!cachesInitialized && ((ChangeGlobalStateFinishMessage)customMsg).clusterActive()) {
+ caches.init(cctx.cache().cacheGroupDescriptors(), cctx.cache().cacheDescriptors());
+
+ cachesInitialized = true;
+ }
}
if (!CU.clientNode(node) && (type == EVT_NODE_FAILED || type == EVT_NODE_JOINED || type == EVT_NODE_LEFT)) {
@@ -404,7 +428,10 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
DynamicCacheChangeRequest startReq = startReqs.get(desc.cacheName());
- cctx.cache().prepareCacheStart(desc, startReq.nearCacheConfiguration(), topVer);
+ cctx.cache().prepareCacheStart(desc.cacheConfiguration(),
+ desc,
+ startReq.nearCacheConfiguration(),
+ topVer);
startedInfos.put(desc.cacheId(), startReq.nearCacheConfiguration() != null);
@@ -683,19 +710,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
NearCacheConfiguration nearCfg = null;
- if (exchActions.newClusterState() == ClusterState.ACTIVE) {
- if (CU.isSystemCache(req.cacheName()))
- startCache = true;
- else if (!cctx.localNode().isClient()) {
- startCache = cctx.cacheContext(action.descriptor().cacheId()) == null &&
- CU.affinityNode(cctx.localNode(), req.startCacheConfiguration().getNodeFilter());
-
- nearCfg = req.nearCacheConfiguration();
- }
- else // Only static cache configured on client must be started.
- startCache = cctx.kernalContext().state().isLocallyConfigured(req.cacheName());
- }
- else if (cctx.localNodeId().equals(req.initiatingNodeId())) {
+ if (req.locallyConfigured() || (cctx.localNodeId().equals(req.initiatingNodeId()) && !exchActions.activate())) {
startCache = true;
nearCfg = req.nearCacheConfiguration();
@@ -703,7 +718,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
else {
// Cache should not be started
assert cctx.cacheContext(cacheDesc.cacheId()) == null
- : "Starting cache has not null context: " + cacheDesc.cacheName();
+ : "Starting cache has not null context: " + cacheDesc.cacheName();
IgniteCacheProxy cacheProxy = cctx.cache().jcacheProxy(req.cacheName());
@@ -711,27 +726,29 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
if (cacheProxy != null) {
// Cache should be in restarting mode
assert cacheProxy.isRestarting()
- : "Cache has non restarting proxy " + cacheProxy;
+ : "Cache has non restarting proxy " + cacheProxy;
startCache = true;
}
- else
- startCache = CU.affinityNode(cctx.localNode(), cacheDesc.groupDescriptor().config().getNodeFilter());
+ else {
+ startCache = CU.affinityNode(cctx.localNode(),
+ cacheDesc.groupDescriptor().config().getNodeFilter());
+ }
}
try {
// Save configuration before cache started.
- if (cctx.pageStore() != null && !cctx.localNode().isClient())
+ if (cctx.pageStore() != null && !cctx.kernalContext().clientNode()) {
cctx.pageStore().storeCacheData(
- cacheDesc.groupDescriptor(),
new StoredCacheData(req.startCacheConfiguration())
);
+ }
if (startCache) {
- cctx.cache().prepareCacheStart(cacheDesc, nearCfg, fut.topologyVersion());
-
- if (exchActions.newClusterState() == null)
- cctx.kernalContext().state().onCacheStart(req);
+ cctx.cache().prepareCacheStart(req.startCacheConfiguration(),
+ cacheDesc,
+ nearCfg,
+ fut.topologyVersion());
if (fut.cacheAddedOnExchange(cacheDesc.cacheId(), cacheDesc.receivedFrom())) {
if (fut.discoCache().cacheGroupAffinityNodes(cacheDesc.groupId()).isEmpty())
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
index c3ddc5f..14eb362 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupContext.java
@@ -683,6 +683,8 @@ public class CacheGroupContext {
aff.cancelFutures(err);
+ preldr.onKernalStop();
+
offheapMgr.stop();
ctx.io().removeCacheGroupHandlers(grpId);
@@ -853,8 +855,6 @@ public class CacheGroupContext {
preldr = new GridCachePreloaderAdapter(this);
if (ctx.kernalContext().config().getPersistentStoreConfiguration() != null) {
- ClassLoader clsLdr = U.gridClassLoader();
-
try {
offheapMgr = new GridCacheOffheapManager();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
index a290caf..99b7b1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheGroupData.java
@@ -78,8 +78,8 @@ public class CacheGroupData implements Serializable {
Map<String, Integer> caches,
long flags) {
assert cacheCfg != null;
- assert grpId != 0;
- assert deploymentId != null;
+ assert grpId != 0 : cacheCfg.getName();
+ assert deploymentId != null : cacheCfg.getName();
this.cacheCfg = cacheCfg;
this.grpName = grpName;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ChangeGlobalStateMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ChangeGlobalStateMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ChangeGlobalStateMessage.java
deleted file mode 100644
index 4d1a50b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ChangeGlobalStateMessage.java
+++ /dev/null
@@ -1,120 +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;
-
-import java.util.UUID;
-import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Message represent request for change cluster global state.
- */
-public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Custom message ID. */
- private IgniteUuid id = IgniteUuid.randomUuid();
-
- /** Request ID */
- private UUID requestId;
-
- /** Initiator node ID. */
- private UUID initiatingNodeId;
-
- /** If true activate else deactivate. */
- private boolean activate;
-
- /** Batch contains all requests for start or stop caches. */
- private DynamicCacheChangeBatch changeGlobalStateBatch;
-
- /** If happened concurrent activate/deactivate then processed only first message, other message must be skip. */
- private boolean concurrentChangeState;
-
- /**
- *
- */
- public ChangeGlobalStateMessage(
- UUID requestId,
- UUID initiatingNodeId,
- boolean activate,
- DynamicCacheChangeBatch changeGlobalStateBatch
- ) {
- this.requestId = requestId;
- this.initiatingNodeId = initiatingNodeId;
- this.activate = activate;
- this.changeGlobalStateBatch = changeGlobalStateBatch;
- }
-
- /**
- *
- */
- public DynamicCacheChangeBatch getDynamicCacheChangeBatch() {
- return changeGlobalStateBatch;
- }
-
- /** {@inheritDoc} */
- @Override public IgniteUuid id() {
- return id;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public DiscoveryCustomMessage ackMessage() {
- return !concurrentChangeState ? changeGlobalStateBatch : null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMutable() {
- return false;
- }
-
- /**
- *
- */
- public UUID initiatorNodeId() {
- return initiatingNodeId;
- }
-
- /**
- *
- */
- public boolean activate() {
- return activate;
- }
-
- /**
- *
- */
- public UUID requestId() {
- return requestId;
- }
-
- /**
- *
- */
- public void concurrentChangeState() {
- this.concurrentChangeState = true;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ChangeGlobalStateMessage.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 8f124b2..5452bd2 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
@@ -40,6 +40,9 @@ import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
import org.apache.ignite.internal.processors.query.QuerySchema;
import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.processors.query.schema.SchemaOperationException;
@@ -93,10 +96,13 @@ class ClusterCachesInfo {
private List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches;
/** */
- private Map<UUID, CacheClientReconnectDiscoveryData> clientReconnectReqs;
+ private Map<String, T2<CacheConfiguration, NearCacheConfiguration>> locCfgsForActivation;
/** */
- private volatile Exception onJoinCacheException;
+ private Map<UUID, CacheClientReconnectDiscoveryData> clientReconnectReqs;
+
+ /** {@code True} if joined cluster while cluster state change was in progress. */
+ private boolean joinOnTransition;
/**
* @param ctx Context.
@@ -113,14 +119,25 @@ class ClusterCachesInfo {
*/
void onStart(CacheJoinNodeDiscoveryData joinDiscoData) throws IgniteCheckedException {
this.joinDiscoData = joinDiscoData;
- }
- /**
- *
- * @return Exception if cache has conflict.
- */
- Exception onJoinCacheException(){
- return onJoinCacheException;
+ Map<String, CacheConfiguration> grpCfgs = new HashMap<>();
+
+ for (CacheJoinNodeDiscoveryData.CacheInfo info : joinDiscoData.caches().values()) {
+ if (info.cacheData().config().getGroupName() == null)
+ continue;
+
+ CacheConfiguration ccfg = grpCfgs.get(info.cacheData().config().getGroupName());
+
+ if (ccfg == null)
+ grpCfgs.put(info.cacheData().config().getGroupName(), info.cacheData().config());
+ else
+ validateCacheGroupConfiguration(ccfg, info.cacheData().config());
+ }
+
+ String conflictErr = processJoiningNode(joinDiscoData, ctx.localNodeId(), true);
+
+ if (conflictErr != null)
+ throw new IgniteCheckedException("Failed to start configured cache. " + conflictErr);
}
/**
@@ -142,7 +159,9 @@ class ClusterCachesInfo {
if (gridData != null && gridData.conflictErr != null)
throw new IgniteCheckedException(gridData.conflictErr);
- if (joinDiscoData != null && gridData != null) {
+ if (gridData != null && gridData.joinDiscoData != null) {
+ CacheJoinNodeDiscoveryData joinDiscoData = gridData.joinDiscoData;
+
for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values()) {
CacheConfiguration locCfg = locCacheInfo.cacheData().config();
@@ -165,9 +184,9 @@ class ClusterCachesInfo {
}
}
- joinDiscoData = null;
gridData = null;
}
+
/**
* Checks that remote caches has configuration compatible with the local.
*
@@ -308,22 +327,64 @@ class ClusterCachesInfo {
}
}
}
-
/**
* @param batch Cache change request.
* @param topVer Topology version.
* @return {@code True} if minor topology version should be increased.
*/
boolean onCacheChangeRequested(DynamicCacheChangeBatch batch, AffinityTopologyVersion topVer) {
- ExchangeActions exchangeActions = new ExchangeActions();
+ DiscoveryDataClusterState state = ctx.state().clusterState();
+
+ if (state.active() && !state.transition()) {
+ ExchangeActions exchangeActions = new ExchangeActions();
+
+ CacheChangeProcessResult res = processCacheChangeRequests(exchangeActions,
+ batch.requests(),
+ topVer,
+ false);
- boolean incMinorTopVer = false;
+ if (res.needExchange) {
+ assert !exchangeActions.empty() : exchangeActions;
- List<DynamicCacheDescriptor> addedDescs = new ArrayList<>();
+ batch.exchangeActions(exchangeActions);
+ }
+
+ return res.needExchange;
+ }
+ else {
+ IgniteCheckedException err = new IgniteCheckedException("Failed to start/stop cache, cluster state change " +
+ "is in progress.");
+
+ for (DynamicCacheChangeRequest req : batch.requests()) {
+ if (req.template()) {
+ ctx.cache().completeTemplateAddFuture(req.startCacheConfiguration().getName(),
+ req.deploymentId());
+ }
+ else
+ ctx.cache().completeCacheStartFuture(req, false, err);
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * @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 Process result.
+ */
+ private CacheChangeProcessResult processCacheChangeRequests(
+ ExchangeActions exchangeActions,
+ Collection<DynamicCacheChangeRequest> reqs,
+ AffinityTopologyVersion topVer,
+ boolean persistedCfgs) {
+ CacheChangeProcessResult res = new CacheChangeProcessResult();
final List<T2<DynamicCacheChangeRequest, AffinityTopologyVersion>> reqsToComplete = new ArrayList<>();
- for (DynamicCacheChangeRequest req : batch.requests()) {
+ for (DynamicCacheChangeRequest req : reqs) {
if (req.template()) {
CacheConfiguration ccfg = req.startCacheConfiguration();
@@ -347,17 +408,18 @@ class ClusterCachesInfo {
assert old == null;
- addedDescs.add(templateDesc);
+ res.addedDescs.add(templateDesc);
}
- ctx.cache().completeTemplateAddFuture(ccfg.getName(), req.deploymentId());
+ if (!persistedCfgs)
+ ctx.cache().completeTemplateAddFuture(ccfg.getName(), req.deploymentId());
continue;
}
assert !req.clientStartOnly() : req;
- DynamicCacheDescriptor desc = req.globalStateChange() ? null : registeredCaches.get(req.cacheName());
+ DynamicCacheDescriptor desc = registeredCaches.get(req.cacheName());
boolean needExchange = false;
@@ -373,22 +435,32 @@ class ClusterCachesInfo {
if (conflictErr != null) {
U.warn(log, "Ignore cache start request. " + conflictErr);
- ctx.cache().completeCacheStartFuture(req, false, new IgniteCheckedException("Failed to start " +
- "cache. " + conflictErr));
+ IgniteCheckedException err = new IgniteCheckedException("Failed to start " +
+ "cache. " + conflictErr);
+
+ if (persistedCfgs)
+ res.errs.add(err);
+ else
+ ctx.cache().completeCacheStartFuture(req, false, err);
continue;
}
if (req.clientStartOnly()) {
+ 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()));
}
else {
SchemaOperationException err = QueryUtils.checkQueryEntityConflicts(
- req.startCacheConfiguration(), ctx.cache().cacheDescriptors().values());
+ req.startCacheConfiguration(), registeredCaches.values());
if (err != null) {
- ctx.cache().completeCacheStartFuture(req, false, err);
+ if (persistedCfgs)
+ res.errs.add(err);
+ else
+ ctx.cache().completeCacheStartFuture(req, false, err);
continue;
}
@@ -430,11 +502,13 @@ class ClusterCachesInfo {
ccfg.getName(),
ccfg.getNearConfiguration() != null);
- ctx.discovery().addClientNode(req.cacheName(),
- req.initiatingNodeId(),
- req.nearCacheConfiguration() != null);
+ if (!persistedCfgs) {
+ ctx.discovery().addClientNode(req.cacheName(),
+ req.initiatingNodeId(),
+ req.nearCacheConfiguration() != null);
+ }
- addedDescs.add(startDesc);
+ res.addedDescs.add(startDesc);
exchangeActions.addCacheToStart(req, startDesc);
@@ -442,6 +516,7 @@ class ClusterCachesInfo {
}
}
else {
+ assert !persistedCfgs;
assert req.initiatingNodeId() != null : req;
if (req.failIfExists()) {
@@ -489,8 +564,6 @@ class ClusterCachesInfo {
}
}
}
- else if (req.globalStateChange())
- exchangeActions.newClusterState(req.state());
else if (req.resetLostPartitions()) {
if (desc != null) {
needExchange = true;
@@ -559,18 +632,18 @@ class ClusterCachesInfo {
assert false : req;
if (!needExchange) {
- if (!clientCacheStart && req.initiatingNodeId().equals(ctx.localNodeId()))
+ if (!clientCacheStart && ctx.localNodeId().equals(req.initiatingNodeId()))
reqsToComplete.add(new T2<>(req, waitTopVer));
}
else
- incMinorTopVer = true;
+ res.needExchange = true;
}
- if (!F.isEmpty(addedDescs)) {
- AffinityTopologyVersion startTopVer = incMinorTopVer ? topVer.nextMinorVersion() : topVer;
+ if (!F.isEmpty(res.addedDescs)) {
+ AffinityTopologyVersion startTopVer = res.needExchange ? topVer.nextMinorVersion() : topVer;
- for (DynamicCacheDescriptor desc : addedDescs) {
- assert desc.template() || incMinorTopVer;
+ for (DynamicCacheDescriptor desc : res.addedDescs) {
+ assert desc.template() || res.needExchange;
desc.startTopologyVersion(startTopVer);
}
@@ -602,13 +675,7 @@ class ClusterCachesInfo {
});
}
- if (incMinorTopVer) {
- assert !exchangeActions.empty() : exchangeActions;
-
- batch.exchangeActions(exchangeActions);
- }
-
- return incMinorTopVer;
+ return res;
}
/**
@@ -669,7 +736,7 @@ class ClusterCachesInfo {
return new CacheClientReconnectDiscoveryData(cacheGrpsInfo, cachesInfo);
}
else {
- assert ctx.config().isDaemon() || joinDiscoData != null || !ctx.state().active();
+ assert ctx.config().isDaemon() || joinDiscoData != null;
return joinDiscoData;
}
@@ -720,31 +787,6 @@ class ClusterCachesInfo {
return started != null ? started : Collections.<DynamicCacheDescriptor>emptyList();
}
- public void addJoinInfo() {
- try {
- Map<String, CacheConfiguration> grpCfgs = new HashMap<>();
-
- for (CacheJoinNodeDiscoveryData.CacheInfo info : joinDiscoData.caches().values()) {
- if (info.cacheData().config().getGroupName() == null)
- continue;
-
- CacheConfiguration ccfg = grpCfgs.get(info.cacheData().config().getGroupName());
-
- if (ccfg == null)
- grpCfgs.put(info.cacheData().config().getGroupName(), info.cacheData().config());
- else
- validateCacheGroupConfiguration(ccfg, info.cacheData().config());
- }
-
- String conflictErr = processJoiningNode(joinDiscoData, ctx.localNodeId(), true);
-
- if (conflictErr != null)
- onJoinCacheException = new IgniteCheckedException("Failed to start configured cache. " + conflictErr);
- }catch (IgniteCheckedException e){
- onJoinCacheException = e;
- }
- }
-
/**
* Discovery event callback, executed from discovery thread.
*
@@ -771,10 +813,7 @@ class ClusterCachesInfo {
if (node.id().equals(ctx.discovery().localNode().id())) {
if (gridData == null) { // First node starts.
- assert joinDiscoData != null || !ctx.state().active();
-
- if (ctx.state().active())
- addJoinInfo();
+ assert joinDiscoData != null;
initStartCachesForLocalJoin(true);
}
@@ -864,7 +903,7 @@ class ClusterCachesInfo {
if (ctx.isDaemon() || data.commonData() == null)
return;
- assert joinDiscoData != null || disconnectedState() || !ctx.state().active();
+ assert joinDiscoData != null || disconnectedState();
assert data.commonData() instanceof CacheNodeCommonDiscoveryData : data;
CacheNodeCommonDiscoveryData cachesData = (CacheNodeCommonDiscoveryData)data.commonData();
@@ -965,7 +1004,7 @@ class ClusterCachesInfo {
}
}
- gridData = new GridData(cachesData, conflictErr);
+ gridData = new GridData(joinDiscoData, cachesData, conflictErr);
if (!disconnectedState())
initStartCachesForLocalJoin(false);
@@ -977,11 +1016,20 @@ class ClusterCachesInfo {
* @param firstNode {@code True} if first node in cluster starts.
*/
private void initStartCachesForLocalJoin(boolean firstNode) {
- assert locJoinStartCaches == null;
+ assert F.isEmpty(locJoinStartCaches) : locJoinStartCaches;
+
+ if (ctx.state().clusterState().transition()) {
+ joinOnTransition = true;
- locJoinStartCaches = new ArrayList<>();
+ return;
+ }
if (joinDiscoData != null) {
+ locJoinStartCaches = new ArrayList<>();
+ locCfgsForActivation = new HashMap<>();
+
+ boolean active = ctx.state().clusterState().active();
+
for (DynamicCacheDescriptor desc : registeredCaches.values()) {
if (firstNode && !joinDiscoData.caches().containsKey(desc.cacheName()))
continue;
@@ -997,13 +1045,13 @@ class ClusterCachesInfo {
DynamicCacheDescriptor desc0 = new DynamicCacheDescriptor(ctx,
locCfg.cacheData().config(),
- desc.cacheType(),
- desc.groupDescriptor(),
- desc.template(),
- desc.receivedFrom(),
- desc.staticallyConfigured(),
- desc.sql(),
- desc.deploymentId(),
+ desc.cacheType(),
+ desc.groupDescriptor(),
+ desc.template(),
+ desc.receivedFrom(),
+ desc.staticallyConfigured(),
+ desc.sql(),
+ desc.deploymentId(),
new QuerySchema(locCfg.cacheData().queryEntities()));
desc0.startTopologyVersion(desc.startTopologyVersion());
@@ -1016,14 +1064,126 @@ class ClusterCachesInfo {
if (locCfg != null ||
joinDiscoData.startCaches() ||
CU.affinityNode(ctx.discovery().localNode(), desc.groupDescriptor().config().getNodeFilter())) {
- // Move system and internal caches first.
- if (desc.cacheType().userCache())
- locJoinStartCaches.add(new T2<>(desc, nearCfg));
+ if (active) {
+ // Move system and internal caches first.
+ if (desc.cacheType().userCache())
+ locJoinStartCaches.add(new T2<>(desc, nearCfg));
+ else
+ locJoinStartCaches.add(0, new T2<>(desc, nearCfg));
+ }
else
- locJoinStartCaches.add(0, new T2<>(desc, nearCfg));
+ locCfgsForActivation.put(desc.cacheName(), new T2<>(desc.cacheConfiguration(), nearCfg));
+ }
+ }
+ }
+ }
+
+ /**
+ * @param msg Message.
+ */
+ void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) {
+ if (joinOnTransition) {
+ initStartCachesForLocalJoin(false);
+
+ joinOnTransition = false;
+ }
+ }
+
+ /**
+ * @param msg Message.
+ * @param topVer Current topology version.
+ * @return Exchange action.
+ * @throws IgniteCheckedException If configuration validation failed.
+ */
+ ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer)
+ throws IgniteCheckedException {
+ ExchangeActions exchangeActions = new ExchangeActions();
+
+ if (msg.activate()) {
+ for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+ desc.startTopologyVersion(topVer);
+
+ T2<CacheConfiguration, NearCacheConfiguration> locCfg = !F.isEmpty(locCfgsForActivation) ?
+ locCfgsForActivation.get(desc.cacheName()) : null;
+
+ DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(),
+ desc.cacheName(),
+ msg.initiatorNodeId());
+
+ req.startCacheConfiguration(desc.cacheConfiguration());
+ req.cacheType(desc.cacheType());
+
+ if (locCfg != null) {
+ if (locCfg.get1() != null)
+ req.startCacheConfiguration(locCfg.get1());
+
+ req.nearCacheConfiguration(locCfg.get2());
+
+ req.locallyConfigured(true);
+ }
+
+ exchangeActions.addCacheToStart(req, desc);
+ }
+
+ for (CacheGroupDescriptor grpDesc : registeredCacheGroups().values())
+ exchangeActions.addCacheGroupToStart(grpDesc);
+
+ List<StoredCacheData> storedCfgs = msg.storedCacheConfigurations();
+
+ if (storedCfgs != null) {
+ List<DynamicCacheChangeRequest> reqs = new ArrayList<>();
+
+ IgniteUuid deplymentId = IgniteUuid.fromUuid(msg.requestId());
+
+ for (StoredCacheData storedCfg : storedCfgs) {
+ CacheConfiguration ccfg = storedCfg.config();
+
+ if (!registeredCaches.containsKey(ccfg.getName())) {
+ DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(msg.requestId(),
+ ccfg.getName(),
+ msg.initiatorNodeId());
+
+ req.deploymentId(deplymentId);
+ req.startCacheConfiguration(ccfg);
+ req.cacheType(ctx.cache().cacheType(ccfg.getName()));
+ req.schema(new QuerySchema(storedCfg.queryEntities()));
+
+ reqs.add(req);
+ }
+ }
+
+ CacheChangeProcessResult res = processCacheChangeRequests(exchangeActions, reqs, topVer, true);
+
+ if (!res.errs.isEmpty()) {
+ IgniteCheckedException err = new IgniteCheckedException("Failed to activate cluster.");
+
+ for (IgniteCheckedException err0 : res.errs)
+ err.addSuppressed(err0);
+
+ throw err;
}
}
}
+ else {
+ locCfgsForActivation = new HashMap<>();
+
+ for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+ DynamicCacheChangeRequest req = DynamicCacheChangeRequest.stopRequest(ctx,
+ desc.cacheName(),
+ desc.sql(),
+ false);
+
+ exchangeActions.addCacheToStop(req, desc);
+
+ if (ctx.discovery().cacheClientNode(ctx.discovery().localNode(), desc.cacheName()))
+ locCfgsForActivation.put(desc.cacheName(), new T2<>((CacheConfiguration)null, (NearCacheConfiguration)null));
+ }
+
+ for (CacheGroupDescriptor grpDesc : registeredCacheGroups().values())
+ exchangeActions.addCacheGroupToStop(grpDesc, false);
+ }
+
+ return exchangeActions;
}
/**
@@ -1053,16 +1213,20 @@ class ClusterCachesInfo {
* @param clientNodeId Client node ID.
*/
private void processClientReconnectData(CacheClientReconnectDiscoveryData clientData, UUID clientNodeId) {
- for (CacheClientReconnectDiscoveryData.CacheInfo cacheInfo : clientData.clientCaches().values()) {
- String cacheName = cacheInfo.config().getName();
+ DiscoveryDataClusterState state = ctx.state().clusterState();
+
+ if (state.active() && !state.transition()) {
+ for (CacheClientReconnectDiscoveryData.CacheInfo cacheInfo : clientData.clientCaches().values()) {
+ String cacheName = cacheInfo.config().getName();
- if (surviveReconnect(cacheName))
- ctx.discovery().addClientNode(cacheName, clientNodeId, false);
- else {
- DynamicCacheDescriptor desc = registeredCaches.get(cacheName);
+ if (surviveReconnect(cacheName))
+ ctx.discovery().addClientNode(cacheName, clientNodeId, false);
+ else {
+ DynamicCacheDescriptor desc = registeredCaches.get(cacheName);
- if (desc != null && desc.deploymentId().equals(cacheInfo.deploymentId()))
- ctx.discovery().addClientNode(cacheName, clientNodeId, cacheInfo.nearCache());
+ if (desc != null && desc.deploymentId().equals(cacheInfo.deploymentId()))
+ ctx.discovery().addClientNode(cacheName, clientNodeId, cacheInfo.nearCache());
+ }
}
}
}
@@ -1371,6 +1535,7 @@ class ClusterCachesInfo {
*/
void onDisconnect() {
cachesOnDisconnect = new CachesOnDisconnect(
+ ctx.state().clusterState(),
new HashMap<>(registeredCacheGrps),
new HashMap<>(registeredCaches));
@@ -1382,57 +1547,82 @@ class ClusterCachesInfo {
}
/**
+ * @param active {@code True} if reconnected to active cluster.
+ * @param transition {@code True} if reconnected while state transition in progress.
* @return Information about stopped caches and cache groups.
*/
- ClusterCachesReconnectResult onReconnected() {
+ ClusterCachesReconnectResult onReconnected(boolean active, boolean transition) {
assert disconnectedState();
Set<String> stoppedCaches = new HashSet<>();
Set<Integer> stoppedCacheGrps = new HashSet<>();
- for (Map.Entry<Integer, CacheGroupDescriptor> e : cachesOnDisconnect.cacheGrps.entrySet()) {
- CacheGroupDescriptor locDesc = e.getValue();
-
- CacheGroupDescriptor desc;
- boolean stopped = true;
+ if (!active) {
+ joinOnTransition = transition;
- if (locDesc.sharedGroup()) {
- desc = cacheGroupByName(locDesc.groupName());
+ if (F.isEmpty(locCfgsForActivation)) {
+ locCfgsForActivation = new HashMap<>();
- if (desc != null && desc.deploymentId().equals(locDesc.deploymentId()))
- stopped = false;
+ for (IgniteInternalCache cache : ctx.cache().caches()) {
+ locCfgsForActivation.put(cache.name(),
+ new T2<>((CacheConfiguration)null, cache.configuration().getNearConfiguration()));
+ }
}
- else {
- desc = nonSharedCacheGroupByCacheName(locDesc.config().getName());
- if (desc != null &&
- (surviveReconnect(locDesc.config().getName()) || desc.deploymentId().equals(locDesc.deploymentId())))
- stopped = false;
- }
+ for (Map.Entry<Integer, CacheGroupDescriptor> e : cachesOnDisconnect.cacheGrps.entrySet())
+ stoppedCacheGrps.add(e.getValue().groupId());
- if (stopped)
- stoppedCacheGrps.add(locDesc.groupId());
- else
- assert locDesc.groupId() == desc.groupId();
+ for (Map.Entry<String, DynamicCacheDescriptor> e : cachesOnDisconnect.caches.entrySet())
+ stoppedCaches.add(e.getKey());
}
+ else {
+ for (Map.Entry<Integer, CacheGroupDescriptor> e : cachesOnDisconnect.cacheGrps.entrySet()) {
+ CacheGroupDescriptor locDesc = e.getValue();
- for (Map.Entry<String, DynamicCacheDescriptor> e : cachesOnDisconnect.caches.entrySet()) {
- DynamicCacheDescriptor desc = e.getValue();
+ CacheGroupDescriptor desc;
+ boolean stopped = true;
- String cacheName = e.getKey();
+ if (locDesc.sharedGroup()) {
+ desc = cacheGroupByName(locDesc.groupName());
- boolean stopped;
+ if (desc != null && desc.deploymentId().equals(locDesc.deploymentId()))
+ stopped = false;
+ }
+ else {
+ desc = nonSharedCacheGroupByCacheName(locDesc.config().getName());
- if (!surviveReconnect(cacheName) || !ctx.state().active()) {
- DynamicCacheDescriptor newDesc = registeredCaches.get(cacheName);
+ if (desc != null &&
+ (surviveReconnect(locDesc.config().getName()) || desc.deploymentId().equals(locDesc.deploymentId())))
+ stopped = false;
+ }
- stopped = newDesc == null || !desc.deploymentId().equals(newDesc.deploymentId());
+ if (stopped)
+ stoppedCacheGrps.add(locDesc.groupId());
+ else
+ assert locDesc.groupId() == desc.groupId();
}
- else
- stopped = false;
- if (stopped)
- stoppedCaches.add(cacheName);
+ for (Map.Entry<String, DynamicCacheDescriptor> e : cachesOnDisconnect.caches.entrySet()) {
+ DynamicCacheDescriptor desc = e.getValue();
+
+ String cacheName = e.getKey();
+
+ boolean stopped;
+
+ if (!surviveReconnect(cacheName)) {
+ DynamicCacheDescriptor newDesc = registeredCaches.get(cacheName);
+
+ stopped = newDesc == null || !desc.deploymentId().equals(newDesc.deploymentId());
+ }
+ else
+ stopped = false;
+
+ if (stopped)
+ stoppedCaches.add(cacheName);
+ }
+
+ if (!cachesOnDisconnect.clusterActive())
+ initStartCachesForLocalJoin(false);
}
if (clientReconnectReqs != null) {
@@ -1450,7 +1640,7 @@ class ClusterCachesInfo {
/**
* @return {@code True} if client node is currently in disconnected state.
*/
- public boolean disconnectedState() {
+ private boolean disconnectedState() {
return cachesOnDisconnect != null;
}
@@ -1465,27 +1655,23 @@ class ClusterCachesInfo {
/**
*
*/
- void clearCaches() {
- registeredCacheGrps.clear();
-
- registeredCaches.clear();
- }
-
- /**
- *
- */
private static class GridData {
/** */
+ private final CacheJoinNodeDiscoveryData joinDiscoData;
+
+ /** */
private final CacheNodeCommonDiscoveryData gridData;
/** */
private final String conflictErr;
/**
+ * @param joinDiscoData Discovery data collected for local node join.
* @param gridData Grid data.
* @param conflictErr Cache configuration conflict error.
*/
- GridData(CacheNodeCommonDiscoveryData gridData, String conflictErr) {
+ GridData(CacheJoinNodeDiscoveryData joinDiscoData, CacheNodeCommonDiscoveryData gridData, String conflictErr) {
+ this.joinDiscoData = joinDiscoData;
this.gridData = gridData;
this.conflictErr = conflictErr;
}
@@ -1496,18 +1682,46 @@ class ClusterCachesInfo {
*/
private static class CachesOnDisconnect {
/** */
+ final DiscoveryDataClusterState state;
+
+ /** */
final Map<Integer, CacheGroupDescriptor> cacheGrps;
/** */
final Map<String, DynamicCacheDescriptor> caches;
/**
+ * @param state Cluster state.
* @param cacheGrps Cache groups.
* @param caches Caches.
*/
- CachesOnDisconnect(Map<Integer, CacheGroupDescriptor> cacheGrps, Map<String, DynamicCacheDescriptor> caches) {
+ CachesOnDisconnect(DiscoveryDataClusterState state,
+ Map<Integer, CacheGroupDescriptor> cacheGrps,
+ Map<String, DynamicCacheDescriptor> caches) {
+ this.state = state;
this.cacheGrps = cacheGrps;
this.caches = caches;
}
+
+ /**
+ * @return {@code True} if cluster was in active state.
+ */
+ boolean clusterActive() {
+ return state.active() && !state.transition();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class CacheChangeProcessResult {
+ /** */
+ private boolean needExchange;
+
+ /** */
+ private final List<DynamicCacheDescriptor> addedDescs = new ArrayList<>();
+
+ /** */
+ private final List<IgniteCheckedException> errs = new ArrayList<>();
}
}
[7/7] ignite git commit: Merge remote-tracking branch
'origin/ignite-2.1' into ignite-2.1
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.1' into ignite-2.1
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b67b8c44
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b67b8c44
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b67b8c44
Branch: refs/heads/ignite-2.1
Commit: b67b8c4438f240038b61ca65b947394106b0e43b
Parents: 1337901 44fad24
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jul 5 11:20:54 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jul 5 11:20:54 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/jdbc/thin/JdbcThinConnection.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[3/7] ignite git commit: Reworked cluster activation/deactivation.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 d57c720..8cea13f 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
@@ -18,49 +18,34 @@
package org.apache.ignite.internal.processors.cluster;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
-import org.apache.ignite.internal.managers.discovery.CustomEventListener;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.managers.discovery.DiscoCache;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
-import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheClientReconnectDiscoveryData;
-import org.apache.ignite.internal.processors.cache.CacheData;
-import org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData;
-import org.apache.ignite.internal.processors.cache.CacheJoinNodeDiscoveryData.CacheInfo;
-import org.apache.ignite.internal.processors.cache.CacheNodeCommonDiscoveryData;
-import org.apache.ignite.internal.processors.cache.ChangeGlobalStateMessage;
-import org.apache.ignite.internal.processors.cache.ClusterState;
-import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch;
-import org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest;
import org.apache.ignite.internal.processors.cache.ExchangeActions;
import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse;
+import org.apache.ignite.internal.processors.cache.StateChangeRequest;
import org.apache.ignite.internal.processors.cache.StoredCacheData;
-import org.apache.ignite.internal.processors.query.QuerySchema;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -72,34 +57,27 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.DiscoveryDataBag;
-import org.apache.ignite.spi.discovery.DiscoveryDataBag.JoiningNodeDiscoveryData;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
-import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.CACHE_PROC;
import static org.apache.ignite.internal.GridComponent.DiscoveryDataExchangeType.STATE_PROC;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
-import static org.apache.ignite.internal.processors.cache.ClusterState.ACTIVE;
-import static org.apache.ignite.internal.processors.cache.ClusterState.INACTIVE;
-import static org.apache.ignite.internal.processors.cache.ClusterState.TRANSITION;
-import static org.apache.ignite.internal.processors.cache.DynamicCacheChangeRequest.stopRequest;
/**
*
*/
public class GridClusterStateProcessor extends GridProcessorAdapter {
- /** Global status. */
- private volatile ClusterState globalState;
-
- /** Action context. */
- private volatile ChangeGlobalStateContext lastCgsCtx;
+ /** */
+ private volatile DiscoveryDataClusterState globalState;
/** Local action future. */
- private final AtomicReference<GridChangeGlobalStateFuture> cgsLocFut = new AtomicReference<>();
+ private final AtomicReference<GridChangeGlobalStateFuture> stateChangeFut = new AtomicReference<>();
+
+ /** Future initialized if node joins when cluster state change is in progress. */
+ private TransitionOnJoinWaitFuture joinFut;
/** Process. */
@GridToStringExclude
@@ -109,12 +87,6 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
@GridToStringExclude
private GridCacheSharedContext<?, ?> sharedCtx;
- /** */
- private final ConcurrentHashMap<String, CacheInfo> cacheData = new ConcurrentHashMap<>();
-
- /** */
- private volatile CacheJoinNodeDiscoveryData localCacheData;
-
/** Listener. */
private final GridLocalEventListener lsr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -124,14 +96,15 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
assert e.type() == EVT_NODE_LEFT || e.type() == EVT_NODE_FAILED : this;
- final GridChangeGlobalStateFuture f = cgsLocFut.get();
+ final GridChangeGlobalStateFuture f = stateChangeFut.get();
- if (f != null)
+ if (f != null) {
f.initFut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override public void apply(IgniteInternalFuture<?> fut) {
- f.onDiscoveryEvent(e);
+ f.onNodeLeft(e);
}
});
+ }
}
};
@@ -142,531 +115,417 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
super(ctx);
}
- /** {@inheritDoc} */
- @Override public void start() throws IgniteCheckedException {
- // Start first node as inactive if persistent enable.
- globalState = ctx.config().isPersistentStoreEnabled() ? INACTIVE :
- ctx.config().isActiveOnStart() ? ACTIVE : INACTIVE;
-
- ctx.discovery().setCustomEventListener(
- ChangeGlobalStateMessage.class, new CustomEventListener<ChangeGlobalStateMessage>() {
- @Override public void onCustomEvent(
- AffinityTopologyVersion topVer, ClusterNode snd, ChangeGlobalStateMessage msg) {
- assert topVer != null;
- assert snd != null;
- assert msg != null;
-
- boolean activate = msg.activate();
-
- ChangeGlobalStateContext actx = lastCgsCtx;
-
- if (actx != null && globalState == TRANSITION) {
- GridChangeGlobalStateFuture f = cgsLocFut.get();
-
- if (log.isDebugEnabled())
- log.debug("Concurrent " + prettyStr(activate) + " [id=" +
- ctx.localNodeId() + " topVer=" + topVer + " actx=" + actx + ", msg=" + msg + "]");
-
- if (f != null && f.requestId.equals(msg.requestId()))
- f.onDone(new IgniteCheckedException(
- "Concurrent change state, now in progress=" + (activate)
- + ", initiatingNodeId=" + actx.initiatingNodeId
- + ", you try=" + (prettyStr(activate)) + ", locNodeId=" + ctx.localNodeId()
- ));
-
- msg.concurrentChangeState();
- }
- else {
- if (log.isInfoEnabled())
- log.info("Create " + prettyStr(activate) + " context [id=" +
- ctx.localNodeId() + " topVer=" + topVer + ", reqId=" +
- msg.requestId() + ", initiatingNodeId=" + msg.initiatorNodeId() + "]");
-
- lastCgsCtx = new ChangeGlobalStateContext(
- msg.requestId(),
- msg.initiatorNodeId(),
- msg.getDynamicCacheChangeBatch(),
- msg.activate());
-
- globalState = TRANSITION;
- }
- }
- });
-
- ctx.event().addLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
- }
-
/**
- * @param data Joining node discovery data.
+ * @return Cluster state to be used on public API.
*/
- public void cacheProcessorStarted(CacheJoinNodeDiscoveryData data) {
- assert data != null;
+ public boolean publicApiActiveState() {
+ DiscoveryDataClusterState globalState = this.globalState;
- localCacheData = data;
+ assert globalState != null;
- cacheProc = ctx.cache();
- sharedCtx = cacheProc.context();
+ if (globalState.transition()) {
+ Boolean transitionRes = globalState.transitionResult();
- sharedCtx.io().addCacheHandler(
- 0, GridChangeGlobalStateMessageResponse.class,
- new CI2<UUID, GridChangeGlobalStateMessageResponse>() {
- @Override public void apply(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
- processChangeGlobalStateResponse(nodeId, msg);
- }
- });
+ if (transitionRes != null)
+ return transitionRes;
+ else
+ return false;
+ }
+ else
+ return globalState.active();
}
/** {@inheritDoc} */
- @Override public void stop(boolean cancel) throws IgniteCheckedException {
- super.stop(cancel);
-
- sharedCtx.io().removeHandler(false, 0, GridChangeGlobalStateMessageResponse.class);
- ctx.event().removeLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
-
- IgniteCheckedException stopErr = new IgniteInterruptedCheckedException(
- "Node is stopping: " + ctx.igniteInstanceName());
-
- GridChangeGlobalStateFuture f = cgsLocFut.get();
+ @Override public void start() throws IgniteCheckedException {
+ // Start first node as inactive if persistence is enabled.
+ boolean activeOnStart = !ctx.config().isPersistentStoreEnabled() && ctx.config().isActiveOnStart();
- if (f != null)
- f.onDone(stopErr);
+ globalState = DiscoveryDataClusterState.createState(activeOnStart);
- cgsLocFut.set(null);
+ ctx.event().addLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
- super.onKernalStart();
+ @Override public void onKernalStop(boolean cancel) {
+ GridChangeGlobalStateFuture fut = this.stateChangeFut.get();
- if (ctx.isDaemon())
- return;
+ if (fut != null)
+ fut.onDone(new IgniteCheckedException("Failed to wait for cluster state change, node is stopping."));
- List<ClusterNode> nodes = ctx.discovery().serverNodes(AffinityTopologyVersion.NONE);
-
- assert localCacheData != null;
-
- // First node started (coordinator).
- if (nodes.isEmpty() || nodes.get(0).isLocal())
- cacheData.putAll(localCacheData.caches());
-
- if (globalState == INACTIVE) { // Accept inactivate state after join.
- if (log != null && log.isInfoEnabled())
- log.info("Got inactivate state from cluster during node join.");
-
- // Revert start action if get INACTIVE state on join.
- sharedCtx.snapshot().onDeActivate(ctx);
-
- if (sharedCtx.pageStore() != null)
- sharedCtx.pageStore().onDeActivate(ctx);
-
- if (sharedCtx.wal() != null)
- sharedCtx.wal().onDeActivate(ctx);
-
- sharedCtx.database().onDeActivate(ctx);
- }
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public DiscoveryDataExchangeType discoveryDataType() {
- return DiscoveryDataExchangeType.STATE_PROC;
+ super.onKernalStop(cancel);
}
- /** {@inheritDoc} */
- @Override public void collectGridNodeData(DiscoveryDataBag dataBag) {
- if (!dataBag.commonDataCollectedFor(STATE_PROC.ordinal()))
- dataBag.addGridCommonData(STATE_PROC.ordinal(), globalState);
- }
+ /**
+ * @param discoCache Discovery data cache.
+ * @return If transition is in progress returns future which is completed when transition finishes.
+ */
+ @Nullable public IgniteInternalFuture<Boolean> onLocalJoin(DiscoCache discoCache) {
+ if (globalState.transition()) {
+ joinFut = new TransitionOnJoinWaitFuture(globalState, discoCache);
- /** {@inheritDoc} */
- @Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
- ClusterState state = (ClusterState)data.commonData();
+ return joinFut;
+ }
- if (state != null)
- globalState = state;
+ return null;
}
/**
- *
+ * @param node Failed node.
+ * @return Message if cluster state changed.
*/
- public IgniteInternalFuture<?> changeGlobalState(final boolean activate) {
- if (ctx.isDaemon()) {
- GridFutureAdapter<Void> fut = new GridFutureAdapter<>();
+ @Nullable public ChangeGlobalStateFinishMessage onNodeLeft(ClusterNode node) {
+ if (globalState.transition()) {
+ Set<UUID> nodes = globalState.transitionNodes();
- sendCompute(activate, fut);
+ if (nodes.remove(node.id()) && nodes.isEmpty()) {
+ U.warn(log, "Failed to change cluster state, all participating nodes failed. " +
+ "Switching to inactive state.");
- return fut;
- }
+ ChangeGlobalStateFinishMessage msg =
+ new ChangeGlobalStateFinishMessage(globalState.transitionRequestId(), false);
- if (cacheProc.transactions().tx() != null || sharedCtx.lockedTopologyVersion(null) != null)
- throw new IgniteException("Failed to " + prettyStr(activate) + " cluster (must invoke the " +
- "method outside of an active transaction).");
+ onStateFinishMessage(msg);
- if ((globalState == ACTIVE && activate) || (globalState == INACTIVE && !activate))
- return new GridFinishedFuture<>();
+ return msg;
+ }
+ }
- final UUID requestId = UUID.randomUUID();
+ return null;
+ }
- final GridChangeGlobalStateFuture cgsFut = new GridChangeGlobalStateFuture(requestId, activate, ctx);
+ /**
+ * @param msg Message.
+ */
+ public void onStateFinishMessage(ChangeGlobalStateFinishMessage msg) {
+ if (msg.requestId().equals(globalState.transitionRequestId())) {
+ log.info("Received state change finish message: " + msg.clusterActive());
- if (!cgsLocFut.compareAndSet(null, cgsFut)) {
- GridChangeGlobalStateFuture locF = cgsLocFut.get();
+ globalState = DiscoveryDataClusterState.createState(msg.clusterActive());
- if (locF.activate == activate)
- return locF;
+ ctx.cache().onStateChangeFinish(msg);
- return new GridFinishedFuture<>(new IgniteException(
- "Failed to " + prettyStr(activate) + ", because another state change operation is currently " +
- "in progress: " + prettyStr(locF.activate)));
- }
+ TransitionOnJoinWaitFuture joinFut = this.joinFut;
- if (globalState == ACTIVE && !activate && ctx.cache().context().snapshot().snapshotOperationInProgress()){
- return new GridFinishedFuture<>(new IgniteException(
- "Failed to " + prettyStr(activate) + ", because snapshot operation in progress."));
+ if (joinFut != null)
+ joinFut.onDone(false);
}
+ else
+ U.warn(log, "Received state finish message with unexpected ID: " + msg);
+ }
- if (ctx.clientNode())
- sendCompute(activate, cgsFut);
- else {
- try {
- List<DynamicCacheChangeRequest> reqs = new ArrayList<>();
-
- DynamicCacheChangeRequest changeGlobalStateReq = new DynamicCacheChangeRequest(
- requestId, activate ? ACTIVE : INACTIVE, ctx.localNodeId());
-
- reqs.add(changeGlobalStateReq);
-
- List<DynamicCacheChangeRequest> cacheReqs = activate ? startAllCachesRequests() : stopAllCachesRequests();
+ /**
+ * @param topVer Current topology version.
+ * @param msg Message.
+ * @param discoCache Current nodes.
+ * @return {@code True} if need start state change process.
+ */
+ public boolean onStateChangeMessage(AffinityTopologyVersion topVer,
+ ChangeGlobalStateMessage msg,
+ DiscoCache discoCache) {
+ if (globalState.transition()) {
+ if (globalState.active() != msg.activate()) {
+ GridChangeGlobalStateFuture fut = changeStateFuture(msg);
+
+ if (fut != null)
+ fut.onDone(concurrentStateChangeError(msg.activate()));
+ }
+ else {
+ final GridChangeGlobalStateFuture stateFut = changeStateFuture(msg);
- reqs.addAll(cacheReqs);
+ if (stateFut != null) {
+ IgniteInternalFuture<?> exchFut = ctx.cache().context().exchange().affinityReadyFuture(
+ globalState.transitionTopologyVersion());
- printCacheInfo(cacheReqs, activate);
+ if (exchFut == null)
+ exchFut = new GridFinishedFuture<>();
- ChangeGlobalStateMessage changeGlobalStateMsg = new ChangeGlobalStateMessage(
- requestId, ctx.localNodeId(), activate, new DynamicCacheChangeBatch(reqs));
+ exchFut.listen(new CI1<IgniteInternalFuture<?>>() {
+ @Override public void apply(IgniteInternalFuture<?> exchFut) {
+ stateFut.onDone();
+ }
+ });
+ }
+ }
+ }
+ else {
+ if (globalState.active() != msg.activate()) {
+ ExchangeActions exchangeActions;
try {
- ctx.discovery().sendCustomEvent(changeGlobalStateMsg);
-
- if (ctx.isStopping())
- cgsFut.onDone(new IgniteCheckedException("Failed to execute " + prettyStr(activate) + " request, " +
- "node is stopping."));
+ exchangeActions = ctx.cache().onStateChangeRequest(msg, topVer);
}
catch (IgniteCheckedException e) {
- U.error(log, "Failed to create or send global state change request: " + cgsFut, e);
-
- cgsFut.onDone(e);
- }
- }
- catch (IgniteCheckedException e) {
- cgsFut.onDone(e);
- }
- }
+ GridChangeGlobalStateFuture fut = changeStateFuture(msg);
- return cgsFut;
- }
+ if (fut != null)
+ fut.onDone(e);
- /**
- *
- */
- private void sendCompute(boolean activate, final GridFutureAdapter<Void> res) {
- AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
+ return false;
+ }
- IgniteCompute comp = ((ClusterGroupAdapter)ctx.cluster().get().forServers()).compute();
+ Set<UUID> nodeIds = U.newHashSet(discoCache.allNodes().size());
- if (log.isInfoEnabled())
- log.info("Sending " + prettyStr(activate) + " request from node [id=" +
- ctx.localNodeId() + " topVer=" + topVer + " isClient=" + ctx.isDaemon() +
- " isDaemon" + ctx.isDaemon() + "]");
+ for (ClusterNode node : discoCache.allNodes())
+ nodeIds.add(node.id());
- IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate));
+ GridChangeGlobalStateFuture fut = changeStateFuture(msg);
- fut.listen(new CI1<IgniteFuture>() {
- @Override public void apply(IgniteFuture fut) {
- try {
- fut.get();
+ if (fut != null)
+ fut.setRemaining(nodeIds, topVer.nextMinorVersion());
- res.onDone();
- }
- catch (Exception e) {
- res.onDone(e);
- }
- }
- });
- }
- /**
- * @param reqs Requests to print.
- * @param active Active flag.
- */
- private void printCacheInfo(List<DynamicCacheChangeRequest> reqs, boolean active) {
- assert reqs != null;
+ log.info("Start state transition: " + msg.activate());
- StringBuilder sb = new StringBuilder();
+ globalState = DiscoveryDataClusterState.createTransitionState(msg.activate(),
+ msg.requestId(),
+ topVer,
+ nodeIds);
- sb.append("[");
+ AffinityTopologyVersion stateChangeTopVer = topVer.nextMinorVersion();
- for (int i = 0; i < reqs.size() - 1; i++)
- sb.append(reqs.get(i).cacheName()).append(", ");
+ StateChangeRequest req = new StateChangeRequest(msg, stateChangeTopVer);
- sb.append(reqs.get(reqs.size() - 1).cacheName());
+ exchangeActions.stateChangeRequest(req);
- sb.append("]");
+ msg.exchangeActions(exchangeActions);
- sb.append(" ").append(reqs.size())
- .append(" caches will be ")
- .append(active ? "started" : "stopped");
+ return true;
+ }
+ else {
+ // State already changed.
+ GridChangeGlobalStateFuture stateFut = changeStateFuture(msg);
- if (log.isInfoEnabled())
- log.info(sb.toString());
- }
+ if (stateFut != null)
+ stateFut.onDone();
+ }
+ }
- /**
- * @param req Cache being started.
- */
- public void onCacheStart(DynamicCacheChangeRequest req) {
- CacheInfo cacheInfo = cacheData.get(req.cacheName());
-
- if (cacheInfo == null)
- cacheData.put(req.cacheName(),
- new CacheInfo(
- new StoredCacheData(req.startCacheConfiguration()),
- req.cacheType(), req.sql(),
- 0L)
- );
+ return false;
}
/**
- * @param req Cache being stopped.
+ * @return Current cluster state, should be called only from discovery thread.
*/
- public void onCacheStop(DynamicCacheChangeRequest req) {
- CacheInfo cacheInfo = cacheData.get(req.cacheName());
-
- if (cacheInfo != null)
- cacheData.remove(req.cacheName());
+ public DiscoveryDataClusterState clusterState() {
+ return globalState;
}
/**
- * @return All caches map.
+ * @param msg State change message.
+ * @return Local future for state change process.
*/
- private Map<String, CacheConfiguration> allCaches() {
- Map<String, CacheConfiguration> cfgs = new HashMap<>();
-
- for (Map.Entry<String, CacheInfo> entry : cacheData.entrySet())
- if (cfgs.get(entry.getKey()) == null)
- cfgs.put(entry.getKey(), entry.getValue().cacheData().config());
-
- return cfgs;
+ @Nullable private GridChangeGlobalStateFuture changeStateFuture(ChangeGlobalStateMessage msg) {
+ return changeStateFuture(msg.initiatorNodeId(), msg.requestId());
}
/**
- * @return Collection of all caches start requests.
- * @throws IgniteCheckedException If failed to create requests.
+ * @param initiatorNode Node initiated state change process.
+ * @param reqId State change request ID.
+ * @return Local future for state change process.
*/
- private List<DynamicCacheChangeRequest> startAllCachesRequests() throws IgniteCheckedException {
- assert !ctx.config().isDaemon();
-
- Collection<CacheConfiguration> cacheCfgs = allCaches().values();
-
- final List<DynamicCacheChangeRequest> reqs = new ArrayList<>();
-
- if (sharedCtx.pageStore() != null && sharedCtx.database().persistenceEnabled()) {
- Map<String, StoredCacheData> ccfgs = sharedCtx.pageStore().readCacheConfigurations();
-
- for (Map.Entry<String, StoredCacheData> entry : ccfgs.entrySet())
- reqs.add(createRequest(entry.getValue().config()));
+ @Nullable private GridChangeGlobalStateFuture changeStateFuture(UUID initiatorNode, UUID reqId) {
+ assert initiatorNode != null;
+ assert reqId != null;
- for (CacheConfiguration cfg : cacheCfgs)
- if (!ccfgs.keySet().contains(cfg.getName()))
- reqs.add(createRequest(cfg));
+ if (initiatorNode.equals(ctx.localNodeId())) {
+ GridChangeGlobalStateFuture fut = stateChangeFut.get();
- return reqs;
+ if (fut != null && fut.requestId.equals(reqId))
+ return fut;
}
- else {
- for (CacheConfiguration cfg : cacheCfgs)
- reqs.add(createRequest(cfg));
- return reqs;
- }
+ return null;
}
/**
- * @return Collection of requests to stop caches.
+ * @param activate New state.
+ * @return State change error.
*/
- private List<DynamicCacheChangeRequest> stopAllCachesRequests() {
- Collection<CacheConfiguration> cacheCfgs = allCaches().values();
-
- List<DynamicCacheChangeRequest> reqs = new ArrayList<>(cacheCfgs.size());
-
- for (CacheConfiguration cfg : cacheCfgs) {
- DynamicCacheChangeRequest req = stopRequest(ctx, cfg.getName(), false, false);
-
- reqs.add(req);
- }
-
- return reqs;
+ private IgniteCheckedException concurrentStateChangeError(boolean activate) {
+ return new IgniteCheckedException("Failed to " + prettyStr(activate) +
+ ", because another state change operation is currently in progress: " + prettyStr(!activate));
}
/**
- * @param cfg Configuration to create request for.
- * @return Dynamic cache change request.
+ *
*/
- private DynamicCacheChangeRequest createRequest(CacheConfiguration cfg) {
- assert cfg != null;
- assert cfg.getName() != null;
-
- String cacheName = cfg.getName();
+ public void cacheProcessorStarted() {
+ cacheProc = ctx.cache();
+ sharedCtx = cacheProc.context();
- DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(
- UUID.randomUUID(), cacheName, ctx.localNodeId());
+ sharedCtx.io().addCacheHandler(
+ 0, GridChangeGlobalStateMessageResponse.class,
+ new CI2<UUID, GridChangeGlobalStateMessageResponse>() {
+ @Override public void apply(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
+ processChangeGlobalStateResponse(nodeId, msg);
+ }
+ });
+ }
- req.startCacheConfiguration(cfg);
- req.template(cfg.getName().endsWith("*"));
- req.nearCacheConfiguration(cfg.getNearConfiguration());
- req.deploymentId(IgniteUuid.randomUuid());
- req.schema(new QuerySchema(cfg.getQueryEntities()));
- req.cacheType(cacheProc.cacheType(cacheName));
+ /** {@inheritDoc} */
+ @Override public void stop(boolean cancel) throws IgniteCheckedException {
+ super.stop(cancel);
- return req;
- }
+ if (sharedCtx != null)
+ sharedCtx.io().removeHandler(false, 0, GridChangeGlobalStateMessageResponse.class);
- /**
- *
- */
- public boolean active() {
- ChangeGlobalStateContext actx = lastCgsCtx;
+ ctx.event().removeLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED);
- if (actx != null && !actx.activate && globalState == TRANSITION)
- return true;
+ IgniteCheckedException stopErr = new IgniteCheckedException(
+ "Node is stopping: " + ctx.igniteInstanceName());
- if (actx != null && actx.activate && globalState == TRANSITION)
- return false;
+ GridChangeGlobalStateFuture f = stateChangeFut.get();
- return globalState == ACTIVE;
+ if (f != null)
+ f.onDone(stopErr);
}
- /**
- * @param cacheName Cache name to check.
- * @return Locally configured flag.
- */
- public boolean isLocallyConfigured(String cacheName){
- assert localCacheData != null;
+ /** {@inheritDoc} */
+ @Nullable @Override public DiscoveryDataExchangeType discoveryDataType() {
+ return DiscoveryDataExchangeType.STATE_PROC;
+ }
- return localCacheData.caches().containsKey(cacheName) || localCacheData.templates().containsKey(cacheName);
+ /** {@inheritDoc} */
+ @Override public void collectGridNodeData(DiscoveryDataBag dataBag) {
+ if (!dataBag.commonDataCollectedFor(STATE_PROC.ordinal()))
+ dataBag.addGridCommonData(STATE_PROC.ordinal(), globalState);
}
- /**
- * Invoked if cluster is inactive.
- *
- * @param dataBag Bag to collect data to.
- */
- public void collectGridNodeData0(DiscoveryDataBag dataBag) {
- if (!dataBag.commonDataCollectedFor(CACHE_PROC.ordinal()))
- dataBag.addGridCommonData(CACHE_PROC.ordinal(), cacheData);
+ /** {@inheritDoc} */
+ @Override public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data) {
+ DiscoveryDataClusterState state = (DiscoveryDataClusterState)data.commonData();
+
+ if (state != null)
+ globalState = state;
}
/**
- * @param data Joining node discovery data.
+ * @param activate New cluster state.
+ * @return State change future.
*/
- public void onJoiningNodeDataReceived0(JoiningNodeDiscoveryData data) {
- if (data.hasJoiningNodeData()) {
- if (data.joiningNodeData() instanceof CacheJoinNodeDiscoveryData) {
- CacheJoinNodeDiscoveryData data0 = (CacheJoinNodeDiscoveryData)data.joiningNodeData();
+ public IgniteInternalFuture<?> changeGlobalState(final boolean activate) {
+ if (ctx.isDaemon() || ctx.clientNode()) {
+ GridFutureAdapter<Void> fut = new GridFutureAdapter<>();
- cacheData.putAll(data0.caches());
- }
- else if (data.joiningNodeData() instanceof CacheClientReconnectDiscoveryData) {
- CacheClientReconnectDiscoveryData data0 = (CacheClientReconnectDiscoveryData)data.joiningNodeData();
+ sendCompute(activate, fut);
- // No-op.
- }
+ return fut;
}
- }
- public void onGridDataReceived0(DiscoveryDataBag.GridDiscoveryData data) {
- // Receive data from active cluster.
- if (data.commonData() instanceof CacheNodeCommonDiscoveryData) {
- CacheNodeCommonDiscoveryData data0 = (CacheNodeCommonDiscoveryData)data.commonData();
+ if (cacheProc.transactions().tx() != null || sharedCtx.lockedTopologyVersion(null) != null) {
+ return new GridFinishedFuture<>(new IgniteCheckedException("Failed to " + prettyStr(activate) +
+ " cluster (must invoke the method outside of an active transaction)."));
+ }
- Map<String, CacheData> caches = data0.caches();
+ DiscoveryDataClusterState curState = globalState;
- Map<String, CacheInfo> cacheInfos = new HashMap<>();
+ if (!curState.transition() && curState.active() == activate)
+ return new GridFinishedFuture<>();
- for (Map.Entry<String, CacheData> entry : caches.entrySet()) {
- CacheData val = entry.getValue();
+ GridChangeGlobalStateFuture startedFut = null;
- CacheInfo info = new CacheInfo(
- new StoredCacheData(val.cacheConfiguration()),
- val.cacheType(),
- val.sql(),
- val.flags()
- );
+ GridChangeGlobalStateFuture fut = stateChangeFut.get();
- cacheInfos.put(entry.getKey(), info);
- }
+ while (fut == null) {
+ fut = new GridChangeGlobalStateFuture(UUID.randomUUID(), activate, ctx);
- cacheData.putAll(cacheInfos);
+ if (stateChangeFut.compareAndSet(null, fut)) {
+ startedFut = fut;
- } // Receive data from inactive cluster.
- else if (data.commonData() instanceof Map) {
- Map<String, CacheInfo> data0 = (Map<String, CacheInfo>)data.commonData();
+ break;
+ }
+ else
+ fut = stateChangeFut.get();
+ }
- cacheData.putAll(data0);
+ if (startedFut == null) {
+ if (fut.activate != activate) {
+ return new GridFinishedFuture<>(new IgniteCheckedException("Failed to " + prettyStr(activate) +
+ ", because another state change operation is currently in progress: " + prettyStr(fut.activate)));
+ }
+ else
+ return fut;
}
- cacheData.putAll(localCacheData.caches());
- }
+ List<StoredCacheData> storedCfgs = null;
- /**
- * @param exchActions Requests.
- * @param topVer Exchange topology version.
- */
- public boolean changeGlobalState(
- ExchangeActions exchActions,
- AffinityTopologyVersion topVer
- ) {
- assert exchActions != null;
- assert topVer != null;
+ if (activate && sharedCtx.database().persistenceEnabled()) {
+ try {
+ Map<String, StoredCacheData> cfgs = ctx.cache().context().pageStore().readCacheConfigurations();
+
+ if (!F.isEmpty(cfgs))
+ storedCfgs = new ArrayList<>(cfgs.values());
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to read stored cache configurations: " + e, e);
+
+ startedFut.onDone(e);
- if (exchActions.newClusterState() != null) {
- ChangeGlobalStateContext cgsCtx = lastCgsCtx;
+ return startedFut;
+ }
+ }
- assert cgsCtx != null : topVer;
+ ChangeGlobalStateMessage msg = new ChangeGlobalStateMessage(startedFut.requestId,
+ ctx.localNodeId(),
+ storedCfgs,
+ activate);
- cgsCtx.topologyVersion(topVer);
+ try {
+ ctx.discovery().sendCustomEvent(msg);
- return true;
+ if (ctx.isStopping())
+ startedFut.onDone(new IgniteCheckedException("Failed to execute " + prettyStr(activate) + " request, " +
+ "node is stopping."));
}
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to send global state change request: " + activate, e);
- return false;
+ startedFut.onDone(e);
+ }
+
+ return startedFut;
}
/**
- * Invoke from exchange future.
+ * @param activate New cluster state.
+ * @param resFut State change future.
*/
- public Exception onChangeGlobalState() {
- GridChangeGlobalStateFuture f = cgsLocFut.get();
+ private void sendCompute(boolean activate, final GridFutureAdapter<Void> resFut) {
+ AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx();
- ChangeGlobalStateContext cgsCtx = lastCgsCtx;
+ IgniteCompute comp = ((ClusterGroupAdapter)ctx.cluster().get().forServers()).compute();
- assert cgsCtx != null;
+ if (log.isInfoEnabled()) {
+ log.info("Sending " + prettyStr(activate) + " request from node [id=" + ctx.localNodeId() +
+ ", topVer=" + topVer +
+ ", client=" + ctx.clientNode() +
+ ", daemon" + ctx.isDaemon() + "]");
+ }
- if (f != null)
- f.setRemaining(cgsCtx.topVer);
+ IgniteFuture<Void> fut = comp.runAsync(new ClientChangeGlobalStateComputeRequest(activate));
- return cgsCtx.activate ? onActivate(cgsCtx) : onDeActivate(cgsCtx);
+ fut.listen(new CI1<IgniteFuture>() {
+ @Override public void apply(IgniteFuture fut) {
+ try {
+ fut.get();
+
+ resFut.onDone();
+ }
+ catch (Exception e) {
+ resFut.onDone(e);
+ }
+ }
+ });
}
/**
- * @param exs Exs.
+ * @param errs Errors.
+ * @param req State change request.
*/
- public void onFullResponseMessage(Map<UUID, Exception> exs) {
- assert !F.isEmpty(exs);
-
- ChangeGlobalStateContext actx = lastCgsCtx;
-
- actx.setFail();
+ public void onStateChangeError(Map<UUID, Exception> errs, StateChangeRequest req) {
+ assert !F.isEmpty(errs);
- // Revert change if activation request fail.
- if (actx.activate) {
+ // Revert caches start if activation request fail.
+ if (req.activate()) {
try {
cacheProc.onKernalStopCaches(true);
@@ -674,22 +533,10 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
sharedCtx.affinity().removeAllCacheInfo();
- ctx.discovery().cleanCachesAndGroups();
-
- if (!ctx.clientNode()) {
- sharedCtx.database().onDeActivate(ctx);
-
- if (sharedCtx.pageStore() != null)
- sharedCtx.pageStore().onDeActivate(ctx);
-
- if (sharedCtx.wal() != null)
- sharedCtx.wal().onDeActivate(ctx);
- }
+ if (!ctx.clientNode())
+ sharedCtx.deactivate();
}
catch (Exception e) {
- for (Map.Entry<UUID, Exception> entry : exs.entrySet())
- e.addSuppressed(entry.getValue());
-
U.error(log, "Failed to revert activation request changes", e);
}
}
@@ -697,110 +544,33 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
//todo https://issues.apache.org/jira/browse/IGNITE-5480
}
- globalState = actx.activate ? INACTIVE : ACTIVE;
-
- GridChangeGlobalStateFuture af = cgsLocFut.get();
+ GridChangeGlobalStateFuture fut = changeStateFuture(req.initiatorNodeId(), req.requestId());
- if (af != null && af.requestId.equals(actx.requestId)) {
+ if (fut != null) {
IgniteCheckedException e = new IgniteCheckedException(
- "Fail " + prettyStr(actx.activate),
+ "Failed to " + prettyStr(req.activate()) + " cluster",
null,
false
);
- for (Map.Entry<UUID, Exception> entry : exs.entrySet())
+ for (Map.Entry<UUID, Exception> entry : errs.entrySet())
e.addSuppressed(entry.getValue());
- af.onDone(e);
- }
- }
-
- /**
- *
- */
- private Exception onActivate(ChangeGlobalStateContext cgsCtx) {
- final boolean client = ctx.clientNode();
-
- if (log.isInfoEnabled())
- log.info("Start activation process [nodeId=" + ctx.localNodeId() + ", client=" + client +
- ", topVer=" + cgsCtx.topVer + "]");
-
- try {
- if (!client)
- sharedCtx.database().lock();
-
- IgnitePageStoreManager pageStore = sharedCtx.pageStore();
-
- if (pageStore != null)
- pageStore.onActivate(ctx);
-
- if (sharedCtx.wal() != null)
- sharedCtx.wal().onActivate(ctx);
-
- sharedCtx.database().onActivate(ctx);
-
- sharedCtx.snapshot().onActivate(ctx);
-
- if (log.isInfoEnabled())
- log.info("Successfully activated persistence managers [nodeId="
- + ctx.localNodeId() + ", client=" + client + ", topVer=" + cgsCtx.topVer + "]");
-
- return null;
- }
- catch (Exception e) {
- U.error(log, "Failed to activate persistence managers [nodeId=" + ctx.localNodeId() + ", client=" + client +
- ", topVer=" + cgsCtx.topVer + "]", e);
-
- if (!client)
- sharedCtx.database().unLock();
-
- return e;
- }
- }
-
- /**
- *
- */
- public Exception onDeActivate(ChangeGlobalStateContext cgsCtx) {
- final boolean client = ctx.clientNode();
-
- if (log.isInfoEnabled())
- log.info("Starting deactivation [id=" + ctx.localNodeId() + ", client=" +
- client + ", topVer=" + cgsCtx.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=" + cgsCtx.topVer + "]");
-
- return null;
- }
- catch (Exception e) {
- U.error(log, "Failed to execute deactivation callback [nodeId=" + ctx.localNodeId() + ", client=" + client +
- ", topVer=" + cgsCtx.topVer + "]", e);
-
- return e;
+ fut.onDone(e);
}
}
/**
- *
+ * @param req State change request.
*/
- private void onFinalActivate(final ChangeGlobalStateContext cgsCtx) {
- IgniteInternalFuture<?> asyncActivateFut = ctx.closure().runLocalSafe(new Runnable() {
+ private void onFinalActivate(final StateChangeRequest req) {
+ ctx.closure().runLocalSafe(new Runnable() {
@Override public void run() {
boolean client = ctx.clientNode();
Exception e = null;
try {
- if (!ctx.config().isDaemon())
- ctx.cacheObjects().onUtilityCacheStarted();
-
ctx.service().onUtilityCacheStarted();
ctx.service().onActivate(ctx);
@@ -809,146 +579,114 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
if (log.isInfoEnabled())
log.info("Successfully performed final activation steps [nodeId="
- + ctx.localNodeId() + ", client=" + client + ", topVer=" + cgsCtx.topVer + "]");
+ + ctx.localNodeId() + ", client=" + client + ", topVer=" + req.topologyVersion() + "]");
}
catch (Exception ex) {
- e = ex;
+ e = new IgniteCheckedException("Failed to perform final activation steps", ex);
U.error(log, "Failed to perform final activation steps [nodeId=" + ctx.localNodeId() +
- ", client=" + client + ", topVer=" + lastCgsCtx.topVer + "]", ex);
+ ", client=" + client + ", topVer=" + req.topologyVersion() + "]", ex);
}
finally {
- globalState = ACTIVE;
-
- sendChangeGlobalStateResponse(cgsCtx.requestId, cgsCtx.initiatingNodeId, e);
+ globalState.setTransitionResult(req.requestId(), true);
- lastCgsCtx = null;
+ sendChangeGlobalStateResponse(req.requestId(), req.initiatorNodeId(), e);
}
}
});
-
- cgsCtx.setAsyncActivateFut(asyncActivateFut);
}
/**
- *
+ * @param req State change request.
*/
- public void onFinalDeActivate(ChangeGlobalStateContext cgsCtx) {
- final boolean client = ctx.clientNode();
-
- if (log.isInfoEnabled())
- log.info("Successfully performed final deactivation steps [nodeId="
- + ctx.localNodeId() + ", client=" + client + ", topVer=" + cgsCtx.topVer + "]");
-
- Exception ex = null;
-
- try {
- sharedCtx.snapshot().onDeActivate(ctx);
+ private void onFinalDeActivate(final StateChangeRequest req) {
+ globalState.setTransitionResult(req.requestId(), false);
- sharedCtx.database().onDeActivate(ctx);
-
- if (sharedCtx.pageStore() != null)
- sharedCtx.pageStore().onDeActivate(ctx);
-
- if (sharedCtx.wal() != null)
- sharedCtx.wal().onDeActivate(ctx);
-
- sharedCtx.affinity().removeAllCacheInfo();
- }
- catch (Exception e) {
- ex = e;
- }
- finally {
- globalState = INACTIVE;
- }
-
- sendChangeGlobalStateResponse(cgsCtx.requestId, cgsCtx.initiatingNodeId, ex);
-
- lastCgsCtx = null;
+ sendChangeGlobalStateResponse(req.requestId(), req.initiatorNodeId(), null);
}
/**
- *
+ * @param req State change request.
*/
- public void onExchangeDone() {
- ChangeGlobalStateContext cgsCtx = lastCgsCtx;
-
- assert cgsCtx != null;
-
- if (!cgsCtx.isFail()) {
- if (cgsCtx.activate)
- onFinalActivate(cgsCtx);
- else
- onFinalDeActivate(cgsCtx);
- }
+ public void onStateChangeExchangeDone(StateChangeRequest req) {
+ if (req.activate())
+ onFinalActivate(req);
else
- lastCgsCtx = null;
+ onFinalDeActivate(req);
}
/**
+ * @param reqId Request ID.
* @param initNodeId Initialize node id.
* @param ex Exception.
*/
- private void sendChangeGlobalStateResponse(UUID requestId, UUID initNodeId, Exception ex) {
- assert requestId != null;
+ private void sendChangeGlobalStateResponse(UUID reqId, UUID initNodeId, Exception ex) {
+ assert reqId != null;
assert initNodeId != null;
- try {
- GridChangeGlobalStateMessageResponse actResp = new GridChangeGlobalStateMessageResponse(requestId, ex);
+ GridChangeGlobalStateMessageResponse res = new GridChangeGlobalStateMessageResponse(reqId, ex);
+ try {
if (log.isDebugEnabled())
log.debug("Sending global state change response [nodeId=" + ctx.localNodeId() +
- ", topVer=" + ctx.discovery().topologyVersionEx() + ", response=" + actResp + "]");
+ ", topVer=" + ctx.discovery().topologyVersionEx() + ", res=" + res + "]");
if (ctx.localNodeId().equals(initNodeId))
- processChangeGlobalStateResponse(ctx.localNodeId(), actResp);
+ processChangeGlobalStateResponse(ctx.localNodeId(), res);
else
- sharedCtx.io().send(initNodeId, actResp, SYSTEM_POOL);
+ sharedCtx.io().send(initNodeId, res, SYSTEM_POOL);
+ }
+ catch (ClusterTopologyCheckedException e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to send change global state response, node left [node=" + initNodeId +
+ ", res=" + res + ']');
+ }
}
catch (IgniteCheckedException e) {
- log.error("Fail send change global state response to " + initNodeId, e);
+ U.error(log, "Failed to send change global state response [node=" + initNodeId + ", res=" + res + ']', e);
}
}
/**
+ * @param nodeId Node ID.
* @param msg Message.
*/
private void processChangeGlobalStateResponse(final UUID nodeId, final GridChangeGlobalStateMessageResponse msg) {
assert nodeId != null;
assert msg != null;
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Received activation response [requestId=" + msg.getRequestId() +
", nodeId=" + nodeId + "]");
-
- ClusterNode node = ctx.discovery().node(nodeId);
-
- if (node == null) {
- U.warn(log, "Received activation response from unknown node (will ignore) [requestId=" +
- msg.getRequestId() + ']');
-
- return;
}
UUID requestId = msg.getRequestId();
- final GridChangeGlobalStateFuture fut = cgsLocFut.get();
-
- if (fut != null && !fut.isDone() && requestId.equals(fut.requestId)) {
- fut.initFut.listen(new CI1<IgniteInternalFuture<?>>() {
- @Override public void apply(IgniteInternalFuture<?> f) {
- fut.onResponse(nodeId, msg);
- }
- });
+ final GridChangeGlobalStateFuture fut = stateChangeFut.get();
+
+ if (fut != null && requestId.equals(fut.requestId)) {
+ if (fut.initFut.isDone())
+ fut.onResponse(nodeId, msg);
+ else {
+ fut.initFut.listen(new CI1<IgniteInternalFuture<?>>() {
+ @Override public void apply(IgniteInternalFuture<?> f) {
+ // initFut is completed from discovery thread, process response from other thread.
+ ctx.getSystemExecutorService().execute(new Runnable() {
+ @Override public void run() {
+ fut.onResponse(nodeId, msg);
+ }
+ });
+ }
+ });
+ }
}
}
-
-
/**
* @param activate Activate.
+ * @return Activate flag string.
*/
- private String prettyStr(boolean activate) {
+ private static String prettyStr(boolean activate) {
return activate ? "activate" : "deactivate";
}
@@ -993,7 +731,9 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
private final IgniteLogger log;
/**
- *
+ * @param requestId State change request ID.
+ * @param activate New cluster state.
+ * @param ctx Context.
*/
GridChangeGlobalStateFuture(UUID requestId, boolean activate, GridKernalContext ctx) {
this.requestId = requestId;
@@ -1006,7 +746,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
/**
* @param event Event.
*/
- public void onDiscoveryEvent(DiscoveryEvent event) {
+ void onNodeLeft(DiscoveryEvent event) {
assert event != null;
if (isDone())
@@ -1024,29 +764,26 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
}
/**
- *
+ * @param nodesIds Node IDs.
+ * @param topVer Current topology version.
*/
- public void setRemaining(AffinityTopologyVersion topVer) {
- Collection<ClusterNode> nodes = ctx.discovery().nodes(topVer);
-
- List<UUID> ids = new ArrayList<>(nodes.size());
-
- for (ClusterNode n : nodes)
- ids.add(n.id());
-
- if (log.isDebugEnabled())
- log.debug("Setup remaining node [id=" + ctx.localNodeId() + ", client=" +
- ctx.clientNode() + ", topVer=" + ctx.discovery().topologyVersionEx() +
- ", nodes=" + Arrays.toString(ids.toArray()) + "]");
+ void setRemaining(Set<UUID> nodesIds, AffinityTopologyVersion topVer) {
+ if (log.isDebugEnabled()) {
+ log.debug("Setup remaining node [id=" + ctx.localNodeId() +
+ ", client=" + ctx.clientNode() +
+ ", topVer=" + topVer +
+ ", nodes=" + nodesIds + "]");
+ }
synchronized (mux) {
- remaining.addAll(ids);
+ remaining.addAll(nodesIds);
}
initFut.onDone();
}
/**
+ * @param nodeId Sender node ID.
* @param msg Activation message response.
*/
public void onResponse(UUID nodeId, GridChangeGlobalStateMessageResponse msg) {
@@ -1072,7 +809,7 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
*
*/
private void onAllReceived() {
- Throwable e = new Throwable();
+ IgniteCheckedException e = new IgniteCheckedException();
boolean fail = false;
@@ -1094,9 +831,13 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public boolean onDone(@Nullable Void res, @Nullable Throwable err) {
- ctx.state().cgsLocFut.set(null);
+ if (super.onDone(res, err)) {
+ ctx.state().stateChangeFut.compareAndSet(this, null);
+
+ return true;
+ }
- return super.onDone(res, err);
+ return false;
}
/** {@inheritDoc} */
@@ -1107,110 +848,65 @@ public class GridClusterStateProcessor extends GridProcessorAdapter {
/**
*
- *
*/
- private static class ChangeGlobalStateContext {
- /** Request id. */
- private final UUID requestId;
-
- /** Initiating node id. */
- private final UUID initiatingNodeId;
-
- /** Batch requests. */
- private final DynamicCacheChangeBatch batch;
+ private static class ClientChangeGlobalStateComputeRequest implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0L;
- /** Activate. */
+ /** */
private final boolean activate;
- /** Topology version. */
- private AffinityTopologyVersion topVer;
-
- /** Fail. */
- private boolean fail;
-
- /** Async activate future. */
- private IgniteInternalFuture<?> asyncActivateFut;
+ /** Ignite. */
+ @IgniteInstanceResource
+ private Ignite ignite;
/**
- *
+ * @param activate New cluster state.
*/
- ChangeGlobalStateContext(
- UUID requestId,
- UUID initiatingNodeId,
- DynamicCacheChangeBatch batch,
- boolean activate
- ) {
- this.requestId = requestId;
- this.batch = batch;
+ private ClientChangeGlobalStateComputeRequest(boolean activate) {
this.activate = activate;
- this.initiatingNodeId = initiatingNodeId;
- }
-
- /**
- * @param topVer Topology version.
- */
- public void topologyVersion(AffinityTopologyVersion topVer) {
- this.topVer = topVer;
- }
-
- /**
- *
- */
- private void setFail() {
- fail = true;
- }
-
- /**
- *
- */
- private boolean isFail() {
- return fail;
- }
-
- /**
- *
- */
- public IgniteInternalFuture<?> getAsyncActivateFut() {
- return asyncActivateFut;
- }
-
- /**
- * @param asyncActivateFut Async activate future.
- */
- public void setAsyncActivateFut(IgniteInternalFuture<?> asyncActivateFut) {
- this.asyncActivateFut = asyncActivateFut;
}
/** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ChangeGlobalStateContext.class, this);
+ @Override public void run() {
+ ignite.active(activate);
}
}
/**
*
*/
- private static class ClientChangeGlobalStateComputeRequest implements IgniteRunnable {
+ class TransitionOnJoinWaitFuture extends GridFutureAdapter<Boolean> {
/** */
- private static final long serialVersionUID = 0L;
-
- /** Activation. */
- private final boolean activation;
+ private DiscoveryDataClusterState transitionState;
- /** Ignite. */
- @IgniteInstanceResource
- private Ignite ignite;
+ /** */
+ private final Set<UUID> transitionNodes;
/**
- *
+ * @param state Current state.
+ * @param discoCache Discovery data cache.
*/
- private ClientChangeGlobalStateComputeRequest(boolean activation) {
- this.activation = activation;
+ TransitionOnJoinWaitFuture(DiscoveryDataClusterState state, DiscoCache discoCache) {
+ assert state.transition() : state;
+
+ transitionNodes = U.newHashSet(state.transitionNodes().size());
+
+ for (UUID nodeId : state.transitionNodes()) {
+ if (discoCache.node(nodeId) != null)
+ transitionNodes.add(nodeId);
+ }
}
/** {@inheritDoc} */
- @Override public void run() {
- ignite.active(activation);
+ @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) {
+ if (super.onDone(res, err)) {
+ joinFut = null;
+
+ return true;
+ }
+
+ return false;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 3dd9911..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) throws IgniteCheckedException;
+ public void onDeActivate(GridKernalContext kctx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 52cc9e9..4399fe2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -175,8 +175,8 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Override public void onKernalStart() throws IgniteCheckedException {
- if (ctx.config().isDaemon() || !ctx.state().active())
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
+ if (ctx.config().isDaemon() || !active)
return;
onKernalStart0();
@@ -278,7 +278,7 @@ public final class DataStructuresProcessor extends GridProcessorAdapter implemen
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext ctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext ctx) {
if (log.isDebugEnabled())
log.debug("DeActivate data structure processor [nodeId=" + ctx.localNodeId() +
" topVer=" + ctx.discovery().topologyVersionEx() + " ]");
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
index c54f801..0bc0c63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicLongImpl.java
@@ -368,7 +368,7 @@ public final class GridCacheAtomicLongImpl implements GridCacheAtomicLongEx, Ign
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index 64b68e3..42f16f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -299,7 +299,7 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
index 47fa49e..019de3c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicSequenceImpl.java
@@ -451,7 +451,7 @@ public final class GridCacheAtomicSequenceImpl implements GridCacheAtomicSequenc
/** {@inheritDoc} */
@Override public void onDeActivate(GridKernalContext kctx) {
-
+ // No-op.
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
index ac171a6..ed7a225 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicStampedImpl.java
@@ -343,7 +343,7 @@ public final class GridCacheAtomicStampedImpl<T, S> implements GridCacheAtomicSt
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
index 585cb20..7f331c3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheCountDownLatchImpl.java
@@ -340,7 +340,7 @@ public final class GridCacheCountDownLatchImpl implements GridCacheCountDownLatc
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
index 8d3a770..b798670 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
@@ -1477,8 +1477,8 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+ @Override public void onDeActivate(GridKernalContext kctx) {
+ // No-op.
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
index 2f6abb6..c567ac4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
@@ -37,7 +37,6 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteQueue;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index c76aec4..4abefc9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -968,7 +968,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Ignit
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
index e336474..c27770f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
@@ -35,7 +35,6 @@ import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSet;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheIteratorConverter;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index 8712756..7eb61d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -101,8 +101,6 @@ import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_DELETED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_DELETED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_READ;
import static org.apache.ignite.events.EventType.EVT_IGFS_META_UPDATED;
-import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
-import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.igfs.IgfsMode.PROXY;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 3c2f64d..244820f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -177,7 +177,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
if (ctx.config().isDaemon())
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 23ad63d..ce6c9fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -512,10 +512,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
cacheData.queryEntities(cacheDesc.schema().entities());
- CacheGroupDescriptor grpDesc = ctx.cache().cacheDescriptors().get(cacheData.config().getName()).groupDescriptor();
-
try {
- ctx.cache().context().pageStore().storeCacheData(grpDesc, cacheData);
+ ctx.cache().context().pageStore().storeCacheData(cacheData);
}
catch (IgniteCheckedException e) {
throw new IllegalStateException("Failed to persist cache data: " + cacheData.config().getName(), e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
index 716adf7..f528184 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/GridRestProcessor.java
@@ -503,7 +503,7 @@ public class GridRestProcessor extends GridProcessorAdapter {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
if (isRestEnabled()) {
for (GridRestProtocol proto : protos)
proto.onKernalStart();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridChangeStateCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridChangeStateCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridChangeStateCommandHandler.java
index 909b524..6236026 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridChangeStateCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cluster/GridChangeStateCommandHandler.java
@@ -64,7 +64,7 @@ public class GridChangeStateCommandHandler extends GridRestCommandHandlerAdapter
try {
if (req.command().equals(CLUSTER_CURRENT_STATE)) {
- Boolean currentState = ctx.state().active();
+ Boolean currentState = ctx.state().publicApiActiveState();
res.setResponse(currentState);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 12be63b..2eeee1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -211,8 +211,8 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Override public void onKernalStart() throws IgniteCheckedException {
- if (ctx.isDaemon() || !ctx.state().active())
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
+ if (ctx.isDaemon() || !active)
return;
onKernalStart0();
@@ -363,7 +363,7 @@ public class GridServiceProcessor extends GridProcessorAdapter implements Ignite
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
if (log.isDebugEnabled())
log.debug("DeActivate service processor [nodeId=" + ctx.localNodeId() +
" topVer=" + ctx.discovery().topologyVersionEx() + " ]");
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 7ac7b64..d0b88d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -153,7 +153,7 @@ public class GridTaskProcessor extends GridProcessorAdapter {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
tasksMetaCache = ctx.security().enabled() && !ctx.isDaemon() ?
ctx.cache().<GridTaskNameHashKey, String>utilityCache() : null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index d5bacdb..5dbfe6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -582,7 +582,8 @@ class ClientImpl extends TcpDiscoveryImpl {
* @param addr Address.
* @return Socket, connect response and client acknowledge support flag.
*/
- @Nullable private T3<SocketStream, Integer, Boolean> sendJoinRequest(boolean recon, InetSocketAddress addr) {
+ @Nullable private T3<SocketStream, Integer, Boolean> sendJoinRequest(boolean recon,
+ InetSocketAddress addr) {
assert addr != null;
if (log.isDebugEnabled())
@@ -603,6 +604,8 @@ class ClientImpl extends TcpDiscoveryImpl {
IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
+ DiscoveryDataPacket discoveryData = null;
+
while (true) {
boolean openSock = false;
@@ -645,9 +648,10 @@ class ClientImpl extends TcpDiscoveryImpl {
marshalCredentials(node);
}
- msg = new TcpDiscoveryJoinRequestMessage(
- node,
- spi.collectExchangeData(new DiscoveryDataPacket(getLocalNodeId())));
+ if (discoveryData == null)
+ discoveryData = spi.collectExchangeData(new DiscoveryDataPacket(getLocalNodeId()));
+
+ msg = new TcpDiscoveryJoinRequestMessage(node, discoveryData);
}
else
msg = new TcpDiscoveryClientReconnectMessage(getLocalNodeId(), rmtNodeId, lastMsgId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 03afff5..c2d9b7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -846,8 +846,10 @@ class ServerImpl extends TcpDiscoveryImpl {
// Marshal credentials for backward compatibility and security.
marshalCredentials(locNode, locCred);
+ DiscoveryDataPacket discoveryData = spi.collectExchangeData(new DiscoveryDataPacket(getLocalNodeId()));
+
while (true) {
- if (!sendJoinRequestMessage()) {
+ if (!sendJoinRequestMessage(discoveryData)) {
if (log.isDebugEnabled())
log.debug("Join request message has not been sent (local node is the first in the topology).");
@@ -973,13 +975,13 @@ class ServerImpl extends TcpDiscoveryImpl {
* Address is provided by {@link org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder} and message is
* sent to first node connection succeeded to.
*
+ * @param discoveryData Discovery data.
* @return {@code true} if send succeeded.
* @throws IgniteSpiException If any error occurs.
*/
@SuppressWarnings({"BusyWait"})
- private boolean sendJoinRequestMessage() throws IgniteSpiException {
- TcpDiscoveryAbstractMessage joinReq = new TcpDiscoveryJoinRequestMessage(locNode,
- spi.collectExchangeData(new DiscoveryDataPacket(getLocalNodeId())));
+ private boolean sendJoinRequestMessage(DiscoveryDataPacket discoveryData) throws IgniteSpiException {
+ TcpDiscoveryAbstractMessage joinReq = new TcpDiscoveryJoinRequestMessage(locNode, discoveryData);
// Time when it has been detected, that addresses from IP finder do not respond.
long noResStart = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
index 98d2553..ab61687 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
@@ -179,6 +179,16 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
/**
* @throws InterruptedException If interrupted.
*/
+ public void waitForBlocked() throws InterruptedException {
+ synchronized (this) {
+ while (blockedMsgs.isEmpty())
+ wait();
+ }
+ }
+
+ /**
+ * @throws InterruptedException If interrupted.
+ */
public void waitForRecorded() throws InterruptedException {
synchronized (this) {
while (recordedMsgs.isEmpty())
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
index 5e85b62..b88eef9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/GridManagerLocalMessageListenerSelfTest.java
@@ -128,7 +128,7 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT
mgr.start();
- mgr.onKernalStart();
+ mgr.onKernalStart(true);
assertTrue(mgr.enabled());
}
@@ -143,7 +143,7 @@ public class GridManagerLocalMessageListenerSelfTest extends GridCommonAbstractT
assertTrue(mgr.enabled());
- mgr.onKernalStart();
+ mgr.onKernalStart(true);
mgr.onKernalStop(false);
[2/7] ignite git commit: Reworked cluster activation/deactivation.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteActiveClusterTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteActiveClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteActiveClusterTest.java
deleted file mode 100644
index cf68767..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteActiveClusterTest.java
+++ /dev/null
@@ -1,182 +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;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- *
- */
-public class IgniteActiveClusterTest extends GridCommonAbstractTest {
- /** */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- private boolean client;
-
- /** */
- private boolean active = true;
-
- /** */
- private CacheConfiguration ccfg;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
-
- cfg.setClientMode(client);
-
- cfg.setActiveOnStart(active);
-
- if (ccfg != null) {
- cfg.setCacheConfiguration(ccfg);
-
- ccfg = null;
- }
-
- return cfg;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testActivate() throws Exception {
- active = false;
-
- for (int i = 0; i < 3; i++) {
- ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
-
- startGrid(i);
- }
-
- ignite(0).active(true);
-
- startGrid(3);
-
- for (int i = 0; i < 4; i++) {
- IgniteCache<Integer, Integer> cache = ignite(i).cache(DEFAULT_CACHE_NAME);
-
- for (int j = 0; j < 10; j++) {
- ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
- Integer key = rnd.nextInt(1000);
-
- cache.put(key, j);
-
- assertEquals((Integer)j, cache.get(key));
- }
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testJoinAndActivate() throws Exception {
- for (int iter = 0; iter < 3; iter++) {
- log.info("Iteration: " + iter);
-
- active = false;
-
- for (int i = 0; i < 3; i++) {
- ccfg = cacheConfiguration(DEFAULT_CACHE_NAME);
-
- startGrid(i);
- }
-
- final int START_NODES = 3;
-
- final CyclicBarrier b = new CyclicBarrier(START_NODES + 1);
-
- IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
- @Override public Void call() throws Exception {
- b.await();
-
- Thread.sleep(ThreadLocalRandom.current().nextLong(100) + 1);
-
- ignite(0).active(true);
-
- return null;
- }
- });
-
- final AtomicInteger nodeIdx = new AtomicInteger(3);
-
- IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
- @Override public Void call() throws Exception {
- int idx = nodeIdx.getAndIncrement();
-
- b.await();
-
- startGrid(idx);
-
- return null;
- }
- }, START_NODES, "start-node");
-
- fut1.get();
- fut2.get();
-
- for (int i = 0; i < 6; i++) {
- IgniteCache<Integer, Integer> cache = ignite(i).cache(DEFAULT_CACHE_NAME);
-
- for (int j = 0; j < 10; j++) {
- ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
- Integer key = rnd.nextInt(1000);
-
- cache.put(key, j);
-
- assertEquals((Integer)j, cache.get(key));
- }
- }
-
- stopAllGrids();
- }
- }
-
- /**
- * @param name Cache name.
- * @return Cache configuration.
- */
- private CacheConfiguration cacheConfiguration(String name) {
- CacheConfiguration ccfg = new CacheConfiguration(name);
-
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
- ccfg.setAtomicityMode(TRANSACTIONAL);
- ccfg.setBackups(3);
-
- return ccfg;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..8a604be
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTest.java
@@ -0,0 +1,1284 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteClientReconnectAbstractTest;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteClusterActivateDeactivateTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ static final String CACHE_NAME_PREFIX = "cache-";
+
+ /** */
+ boolean client;
+
+ /** */
+ private boolean active = true;
+
+ /** */
+ CacheConfiguration[] ccfgs;
+
+ /** */
+ private boolean testSpi;
+
+ /** */
+ private boolean testDiscoSpi;
+
+ /** */
+ private boolean testReconnectSpi;
+
+ /** */
+ private Class[] testSpiRecord;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ if (testReconnectSpi) {
+ TcpDiscoverySpi spi = new IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi();
+
+ cfg.setDiscoverySpi(spi);
+
+ spi.setJoinTimeout(2 * 60_000);
+ }
+ else if (testDiscoSpi)
+ cfg.setDiscoverySpi(new TestTcpDiscoverySpi());
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ cfg.setConsistentId(igniteInstanceName);
+
+ cfg.setClientMode(client);
+
+ cfg.setActiveOnStart(active);
+
+ if (ccfgs != null) {
+ cfg.setCacheConfiguration(ccfgs);
+
+ ccfgs = null;
+ }
+
+ MemoryConfiguration memCfg = new MemoryConfiguration();
+ memCfg.setPageSize(1024);
+ memCfg.setDefaultMemoryPolicySize(10 * 1024 * 1024);
+
+ cfg.setMemoryConfiguration(memCfg);
+
+ if (persistenceEnabled()) {
+ PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
+
+ pCfg.setWalMode(WALMode.LOG_ONLY);
+
+ cfg.setPersistentStoreConfiguration(pCfg);
+ }
+
+ if (testSpi) {
+ TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi();
+
+ if (testSpiRecord != null)
+ spi.record(testSpiRecord);
+
+ cfg.setCommunicationSpi(spi);
+ }
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /**
+ * @return {@code True} if test with persistence.
+ */
+ protected boolean persistenceEnabled() {
+ return false;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateSimple_SingleNode() throws Exception {
+ activateSimple(1, 0, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateSimple_5_Servers() throws Exception {
+ activateSimple(5, 0, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateSimple_5_Servers2() throws Exception {
+ activateSimple(5, 0, 4);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateSimple_5_Servers_5_Clients() throws Exception {
+ activateSimple(5, 4, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateSimple_5_Servers_5_Clients_FromClient() throws Exception {
+ activateSimple(5, 4, 6);
+ }
+
+ /**
+ * @param srvs Number of servers.
+ * @param clients Number of clients.
+ * @param activateFrom Index of node stating activation.
+ * @throws Exception If failed.
+ */
+ private void activateSimple(int srvs, int clients, int activateFrom) throws Exception {
+ active = false;
+
+ final int CACHES = 2;
+
+ for (int i = 0; i < srvs + clients; i++) {
+ client = i >= srvs;
+
+ ccfgs = cacheConfigurations1();
+
+ startGrid(i);
+
+ checkNoCaches(i);
+ }
+
+ for (int i = 0; i < srvs + clients; i++)
+ assertFalse(ignite(i).active());
+
+ ignite(activateFrom).active(false); // Should be no-op.
+
+ ignite(activateFrom).active(true);
+
+ for (int i = 0; i < srvs + clients; i++)
+ assertTrue(ignite(i).active());
+
+ for (int i = 0; i < srvs + clients; i++) {
+ for (int c = 0; c < 2; c++)
+ checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+
+ checkCache(ignite(i), CU.UTILITY_CACHE_NAME, true);
+ }
+
+ checkCaches(srvs + clients, CACHES);
+
+ client = false;
+
+ startGrid(srvs + clients);
+
+ for (int c = 0; c < 2; c++)
+ checkCache(ignite(srvs + clients), CACHE_NAME_PREFIX + c, true);
+
+ checkCaches(srvs + clients + 1, CACHES);
+
+ client = true;
+
+ startGrid(srvs + clients + 1);
+
+ for (int c = 0; c < 2; c++)
+ checkCache(ignite(srvs + clients + 1), CACHE_NAME_PREFIX + c, false);
+
+ checkCaches(srvs + clients + 2, CACHES);
+ }
+
+ /**
+ * @param nodes Number of nodes.
+ * @param caches Number of caches.
+ */
+ final void checkCaches(int nodes, int caches) {
+ for (int i = 0; i < nodes; i++) {
+ for (int c = 0; c < caches; c++) {
+ IgniteCache<Integer, Integer> cache = ignite(i).cache(CACHE_NAME_PREFIX + c);
+
+ for (int j = 0; j < 10; j++) {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ Integer key = rnd.nextInt(1000);
+
+ cache.put(key, j);
+
+ assertEquals((Integer)j, cache.get(key));
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWhileActivate1_Server() throws Exception {
+ joinWhileActivate1(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWhileActivate1_WithCache_Server() throws Exception {
+ joinWhileActivate1(false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWhileActivate1_Client() throws Exception {
+ joinWhileActivate1(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 joinWhileActivate1(final boolean startClient, final boolean withNewCache) throws Exception {
+ IgniteInternalFuture<?> activeFut = startNodesAndBlockStatusChange(2, 0, 0, false);
+
+ 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();
+
+ 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);
+ }
+
+ /**
+ * @param srvs Number of servers.
+ * @param clients Number of clients.
+ * @param stateChangeFrom Index of node initiating changes.
+ * @param initiallyActive If {@code true} start cluster in active state (otherwise in inactive).
+ * @param blockMsgNodes Nodes whcis block exchange messages.
+ * @return State change future.
+ * @throws Exception If failed.
+ */
+ private IgniteInternalFuture<?> startNodesAndBlockStatusChange(int srvs,
+ int clients,
+ final int stateChangeFrom,
+ final boolean initiallyActive,
+ int... blockMsgNodes) throws Exception {
+ active = initiallyActive;
+ testSpi = true;
+
+ startWithCaches1(srvs, clients);
+
+ if (initiallyActive && persistenceEnabled())
+ ignite(0).active(true);
+
+ if (blockMsgNodes.length == 0)
+ blockMsgNodes = new int[]{1};
+
+ final AffinityTopologyVersion STATE_CHANGE_TOP_VER = new AffinityTopologyVersion(srvs + clients, 1);
+
+ List<TestRecordingCommunicationSpi> spis = new ArrayList<>();
+
+ for (int idx : blockMsgNodes) {
+ TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(ignite(idx));
+
+ spis.add(spi);
+
+ blockExchangeSingleMessage(spi, STATE_CHANGE_TOP_VER);
+ }
+
+ IgniteInternalFuture<?> stateChangeFut = GridTestUtils.runAsync(new Runnable() {
+ @Override public void run() {
+ ignite(stateChangeFrom).active(!initiallyActive);
+ }
+ });
+
+ for (TestRecordingCommunicationSpi spi : spis)
+ spi.waitForBlocked();
+
+ U.sleep(500);
+
+ assertFalse(stateChangeFut.isDone());
+
+ return stateChangeFut;
+ }
+
+ /**
+ * @param spi SPI.
+ * @param topVer Exchange topology version.
+ */
+ private void blockExchangeSingleMessage(TestRecordingCommunicationSpi spi, final AffinityTopologyVersion topVer) {
+ spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+ @Override public boolean apply(ClusterNode clusterNode, Message msg) {
+ if (msg instanceof GridDhtPartitionsSingleMessage) {
+ GridDhtPartitionsSingleMessage pMsg = (GridDhtPartitionsSingleMessage)msg;
+
+ if (pMsg.exchangeId() != null && pMsg.exchangeId().topologyVersion().equals(topVer))
+ return true;
+ }
+
+ return false;
+ }
+ });
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWhileDeactivate1_Server() throws Exception {
+ 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, 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);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConcurrentJoinAndActivate() throws Exception {
+ for (int iter = 0; iter < 3; iter++) {
+ log.info("Iteration: " + iter);
+
+ active = false;
+
+ for (int i = 0; i < 3; i++) {
+ ccfgs = cacheConfigurations1();
+
+ startGrid(i);
+ }
+
+ final int START_NODES = 3;
+
+ final CyclicBarrier b = new CyclicBarrier(START_NODES + 1);
+
+ IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ b.await();
+
+ Thread.sleep(ThreadLocalRandom.current().nextLong(100) + 1);
+
+ ignite(0).active(true);
+
+ return null;
+ }
+ });
+
+ final AtomicInteger nodeIdx = new AtomicInteger(3);
+
+ IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ int idx = nodeIdx.getAndIncrement();
+
+ b.await();
+
+ startGrid(idx);
+
+ return null;
+ }
+ }, START_NODES, "start-node");
+
+ fut1.get();
+ fut2.get();
+
+ checkCaches(6, 2);
+
+ afterTest();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateSimple_SingleNode() throws Exception {
+ deactivateSimple(1, 0, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateSimple_5_Servers() throws Exception {
+ deactivateSimple(5, 0, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateSimple_5_Servers2() throws Exception {
+ deactivateSimple(5, 0, 4);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateSimple_5_Servers_5_Clients() throws Exception {
+ deactivateSimple(5, 4, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateSimple_5_Servers_5_Clients_FromClient() throws Exception {
+ deactivateSimple(5, 4, 6);
+ }
+
+ /**
+ * @param srvs Number of servers.
+ * @param clients Number of clients.
+ * @param deactivateFrom Index of node stating deactivation.
+ * @throws Exception If failed.
+ */
+ private void deactivateSimple(int srvs, int clients, int deactivateFrom) throws Exception {
+ active = true;
+
+ final int CACHES = 2;
+
+ for (int i = 0; i < srvs + clients; i++) {
+ client = i >= srvs;
+
+ ccfgs = cacheConfigurations1();
+
+ startGrid(i);
+ }
+
+ if (persistenceEnabled())
+ ignite(deactivateFrom).active(true);
+
+ ignite(deactivateFrom).active(true); // Should be no-op.
+
+ checkCaches(srvs + clients, CACHES);
+
+ for (int i = 0; i < srvs + clients; i++)
+ assertTrue(ignite(i).active());
+
+ ignite(deactivateFrom).active(false);
+
+ for (int i = 0; i < srvs + clients; i++)
+ assertFalse(ignite(i).active());
+
+ checkNoCaches(srvs + clients);
+
+ client = false;
+
+ startGrid(srvs + clients);
+
+ checkNoCaches(srvs + clients + 1);
+
+ client = true;
+
+ startGrid(srvs + clients + 1);
+
+ checkNoCaches(srvs + clients + 2);
+
+ for (int i = 0; i < srvs + clients + 2; i++)
+ assertFalse(ignite(i).active());
+
+ ignite(deactivateFrom).active(true);
+
+ for (int i = 0; i < srvs + clients + 2; i++) {
+ assertTrue(ignite(i).active());
+
+ checkCache(ignite(i), CU.UTILITY_CACHE_NAME, true);
+ }
+
+ for (int i = 0; i < srvs; i++) {
+ for (int c = 0; c < 2; c++)
+ checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+ }
+
+ checkCaches1(srvs + clients + 2);
+ }
+
+ /**
+ * @param srvs Number of servers.
+ * @param clients Number of clients.
+ * @throws Exception If failed.
+ */
+ private void startWithCaches1(int srvs, int clients) throws Exception {
+ for (int i = 0; i < srvs + clients; i++) {
+ ccfgs = cacheConfigurations1();
+
+ client = i >= srvs;
+
+ startGrid(i);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterActive() throws Exception {
+ testReconnectSpi = true;
+
+ ccfgs = cacheConfigurations1();
+
+ final int SRVS = 3;
+ final int CLIENTS = 3;
+
+ startWithCaches1(SRVS, CLIENTS);
+
+ if (persistenceEnabled())
+ ignite(0).active(true);
+
+ Ignite srv = ignite(0);
+ Ignite client = ignite(SRVS);
+
+ checkCache(client, CU.UTILITY_CACHE_NAME, true);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, srv, null);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ this.client = false;
+
+ startGrid(SRVS + CLIENTS);
+
+ this.client = true;
+
+ startGrid(SRVS + CLIENTS + 1);
+
+ checkCaches1(SRVS + CLIENTS + 2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterInactive() throws Exception {
+ testReconnectSpi = true;
+
+ active = false;
+
+ final int SRVS = 3;
+ final int CLIENTS = 3;
+
+ startWithCaches1(SRVS, CLIENTS);
+
+ Ignite srv = ignite(0);
+ Ignite client = ignite(SRVS);
+
+ checkNoCaches(SRVS + CLIENTS);
+
+ IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, srv, null);
+
+ checkNoCaches(SRVS + CLIENTS);
+
+ ignite(0).active(true);
+
+ checkCache(client, CU.UTILITY_CACHE_NAME, true);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ this.client = false;
+
+ startGrid(SRVS + CLIENTS);
+
+ this.client = true;
+
+ startGrid(SRVS + CLIENTS + 1);
+
+ checkCaches1(SRVS + CLIENTS);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterDeactivated() throws Exception {
+ clientReconnectClusterDeactivated(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterDeactivateInProgress() throws Exception {
+ clientReconnectClusterDeactivated(true);
+ }
+
+ /**
+ * @param transition If {@code true} client reconnects while cluster state transition is in progress.
+ * @throws Exception If failed.
+ */
+ private void clientReconnectClusterDeactivated(final boolean transition) throws Exception {
+ testReconnectSpi = true;
+ testSpi = transition;
+
+ final int SRVS = 3;
+ final int CLIENTS = 3;
+
+ startWithCaches1(SRVS, CLIENTS);
+
+ final Ignite srv = ignite(0);
+ Ignite client = ignite(SRVS);
+
+ if (persistenceEnabled())
+ ignite(0).active(true);
+
+ checkCache(client, CU.UTILITY_CACHE_NAME, true);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ final AffinityTopologyVersion STATE_CHANGE_TOP_VER = new AffinityTopologyVersion(SRVS + CLIENTS + 1, 1);
+
+ final TestRecordingCommunicationSpi spi1 = transition ? TestRecordingCommunicationSpi.spi(ignite(1)) : null;
+
+ final AtomicReference<IgniteInternalFuture> stateFut = new AtomicReference<>();
+
+ IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, srv, new Runnable() {
+ @Override public void run() {
+ if (transition) {
+ blockExchangeSingleMessage(spi1, STATE_CHANGE_TOP_VER);
+
+ stateFut.set(GridTestUtils.runAsync(new Runnable() {
+ @Override public void run() {
+ srv.active(false);
+ }
+ }, "deactivate"));
+
+ try {
+ U.sleep(500);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ else
+ srv.active(false);
+ }
+ });
+
+ checkCache(client, CACHE_NAME_PREFIX + 0, false);
+
+ if (transition) {
+ assertFalse(stateFut.get().isDone());
+
+ assertFalse(client.active());
+
+ spi1.waitForBlocked();
+
+ spi1.stopBlock();
+
+ stateFut.get().get();
+ }
+
+ checkNoCaches(SRVS + CLIENTS);
+
+ ignite(0).active(true);
+
+ checkCache(client, CU.UTILITY_CACHE_NAME, true);
+
+ assertTrue(client.active());
+
+ checkCaches1(SRVS + CLIENTS);
+
+ checkCache(client, CACHE_NAME_PREFIX + 0, true);
+
+ this.client = false;
+
+ startGrid(SRVS + CLIENTS);
+
+ this.client = true;
+
+ startGrid(SRVS + CLIENTS + 1);
+
+ checkCaches1(SRVS + CLIENTS + 2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterActivated() throws Exception {
+ clientReconnectClusterActivated(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClientReconnectClusterActivateInProgress() throws Exception {
+ clientReconnectClusterActivated(true);
+ }
+
+ /**
+ * @param transition If {@code true} client reconnects while cluster state transition is in progress.
+ * @throws Exception If failed.
+ */
+ private void clientReconnectClusterActivated(final boolean transition) throws Exception {
+ testReconnectSpi = true;
+ testSpi = transition;
+
+ active = false;
+
+ final int SRVS = 3;
+ final int CLIENTS = 3;
+
+ startWithCaches1(SRVS, CLIENTS);
+
+ final Ignite srv = ignite(0);
+ Ignite client = ignite(SRVS);
+
+ checkNoCaches(SRVS + CLIENTS);
+
+ final AffinityTopologyVersion STATE_CHANGE_TOP_VER = new AffinityTopologyVersion(SRVS + CLIENTS + 1, 1);
+
+ final TestRecordingCommunicationSpi spi1 = transition ? TestRecordingCommunicationSpi.spi(ignite(1)) : null;
+
+ final AtomicReference<IgniteInternalFuture> stateFut = new AtomicReference<>();
+
+ IgniteClientReconnectAbstractTest.reconnectClientNode(log, client, srv, new Runnable() {
+ @Override public void run() {
+ if (transition) {
+ blockExchangeSingleMessage(spi1, STATE_CHANGE_TOP_VER);
+
+ stateFut.set(GridTestUtils.runAsync(new Runnable() {
+ @Override public void run() {
+ srv.active(true);
+ }
+ }, "activate"));
+
+ try {
+ U.sleep(500);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ else
+ srv.active(true);
+ }
+ });
+
+ checkCache(client, CACHE_NAME_PREFIX + 0, !transition);
+
+ if (transition) {
+ assertFalse(stateFut.get().isDone());
+
+ assertFalse(client.active());
+
+ spi1.waitForBlocked();
+
+ spi1.stopBlock();
+
+ stateFut.get().get();
+ }
+
+ checkCache(client, CU.UTILITY_CACHE_NAME, true);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ checkCache(client, CACHE_NAME_PREFIX + 0, true);
+
+ this.client = false;
+
+ startGrid(SRVS + CLIENTS);
+
+ this.client = true;
+
+ startGrid(SRVS + CLIENTS + 1);
+
+ checkCaches1(SRVS + CLIENTS + 2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInactiveTopologyChanges() throws Exception {
+ testSpi = true;
+
+ testSpiRecord = new Class[]{GridDhtPartitionsSingleMessage.class, GridDhtPartitionsFullMessage.class};
+
+ active = false;
+
+ final int SRVS = 4;
+ final int CLIENTS = 4;
+
+ startWithCaches1(SRVS, CLIENTS);
+
+ checkRecordedMessages(false);
+
+ for (int i = 0; i < 2; i++) {
+ stopGrid(i);
+
+ client = false;
+
+ startGrid(i);
+ }
+
+ checkRecordedMessages(false);
+
+ for (int i = 0; i < 2; i++) {
+ stopGrid(SRVS + i);
+
+ client = true;
+
+ startGrid(SRVS + i);
+ }
+
+ checkRecordedMessages(false);
+
+ ignite(0).active(true);
+
+ checkCaches1(SRVS + CLIENTS);
+
+ checkRecordedMessages(true);
+
+ client = false;
+
+ startGrid(SRVS + CLIENTS);
+
+ client = true;
+
+ startGrid(SRVS + CLIENTS + 1);
+
+ checkRecordedMessages(true);
+
+ checkCaches1(SRVS + CLIENTS + 2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateFailover1() throws Exception {
+ stateChangeFailover1(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateFailover1() throws Exception {
+ stateChangeFailover1(false);
+ }
+
+ /**
+ * @param activate If {@code true} tests activation, otherwise deactivation.
+ * @throws Exception If failed.
+ */
+ private void stateChangeFailover1(boolean activate) throws Exception {
+ // Nodes 1 and 4 do not reply to coordinator.
+ IgniteInternalFuture<?> fut = startNodesAndBlockStatusChange(4, 4, 3, !activate, 1, 4);
+
+ client = false;
+
+ // Start one more node while transition is in progress.
+ IgniteInternalFuture startFut = GridTestUtils.runAsync(new Callable() {
+ @Override public Object call() throws Exception {
+ startGrid(8);
+
+ return null;
+ }
+ }, "start-node");
+
+ U.sleep(500);
+
+ stopGrid(getTestIgniteInstanceName(1), true, false);
+ stopGrid(getTestIgniteInstanceName(4), true, false);
+
+ fut.get();
+
+ startFut.get();
+
+ client = false;
+
+ startGrid(1);
+
+ client = true;
+
+ startGrid(4);
+
+ if (!activate) {
+ checkNoCaches(9);
+
+ ignite(0).active(true);
+ }
+
+ checkCaches1(9);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateFailover2() throws Exception {
+ stateChangeFailover2(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateFailover2() throws Exception {
+ stateChangeFailover2(false);
+ }
+
+ /**
+ * @param activate If {@code true} tests activation, otherwise deactivation.
+ * @throws Exception If failed.
+ */
+ private void stateChangeFailover2(boolean activate) throws Exception {
+ // Nodes 1 and 4 do not reply to coordinator.
+ IgniteInternalFuture<?> fut = startNodesAndBlockStatusChange(4, 4, 3, !activate, 1, 4);
+
+ client = false;
+
+ // Start one more nodes while transition is in progress.
+ IgniteInternalFuture startFut1 = GridTestUtils.runAsync(new Callable() {
+ @Override public Object call() throws Exception {
+ startGrid(8);
+
+ return null;
+ }
+ }, "start-node1");
+ IgniteInternalFuture startFut2 = GridTestUtils.runAsync(new Callable() {
+ @Override public Object call() throws Exception {
+ startGrid(9);
+
+ return null;
+ }
+ }, "start-node2");
+
+ U.sleep(500);
+
+ // Stop coordinator.
+ stopGrid(0);
+
+ stopGrid(getTestIgniteInstanceName(1), true, false);
+ stopGrid(getTestIgniteInstanceName(4), true, false);
+
+ fut.get();
+
+ startFut1.get();
+ startFut2.get();
+
+ client = false;
+
+ startGrid(0);
+ startGrid(1);
+
+ client = true;
+
+ startGrid(4);
+
+ if (!activate) {
+ checkNoCaches(10);
+
+ ignite(0).active(true);
+ }
+
+ checkCaches1(10);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateFailover3() throws Exception {
+ stateChangeFailover3(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDeactivateFailover3() throws Exception {
+ stateChangeFailover3(false);
+ }
+
+ /**
+ * @param activate If {@code true} tests activation, otherwise deactivation.
+ * @throws Exception If failed.
+ */
+ private void stateChangeFailover3(boolean activate) throws Exception {
+ testDiscoSpi = true;
+
+ startNodesAndBlockStatusChange(4, 0, 0, !activate);
+
+ 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 and not allow last node to finish exchange.
+ for (int i = 0; i < 4; i++)
+ ((TestTcpDiscoverySpi)ignite(i).configuration().getDiscoverySpi()).simulateNodeFailure();
+
+ 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);
+ }
+
+ /**
+ * @param exp If {@code true} there should be recorded messages.
+ */
+ private void checkRecordedMessages(boolean exp) {
+ for (Ignite node : G.allGrids()) {
+ List<Object> recorded =
+ TestRecordingCommunicationSpi.spi(node).recordedMessages(false);
+
+ if (exp)
+ assertFalse(F.isEmpty(recorded));
+ else
+ assertTrue(F.isEmpty(recorded));
+ }
+ }
+
+ /**
+ * @param nodes Expected nodes number.
+ */
+ private void checkCaches1(int nodes) {
+ checkCaches(nodes, 2);
+ }
+
+ /**
+ * @return Cache configurations.
+ */
+ final CacheConfiguration[] cacheConfigurations1() {
+ CacheConfiguration[] ccfgs = new CacheConfiguration[2];
+
+ ccfgs[0] = cacheConfiguration(CACHE_NAME_PREFIX + 0, ATOMIC);
+ ccfgs[1] = cacheConfiguration(CACHE_NAME_PREFIX + 1, TRANSACTIONAL);
+
+ return ccfgs;
+ }
+
+ /**
+ * @return Cache configurations.
+ */
+ final CacheConfiguration[] cacheConfigurations2() {
+ CacheConfiguration[] ccfgs = new CacheConfiguration[4];
+
+ ccfgs[0] = cacheConfiguration(CACHE_NAME_PREFIX + 0, ATOMIC);
+ ccfgs[1] = cacheConfiguration(CACHE_NAME_PREFIX + 1, TRANSACTIONAL);
+ ccfgs[2] = cacheConfiguration(CACHE_NAME_PREFIX + 2, ATOMIC);
+ ccfgs[3] = cacheConfiguration(CACHE_NAME_PREFIX + 3, TRANSACTIONAL);
+
+ return ccfgs;
+ }
+
+ /**
+ * @param name Cache name.
+ * @param atomicityMode Atomicity mode.
+ * @return Cache configuration.
+ */
+ protected final CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode) {
+ CacheConfiguration ccfg = new CacheConfiguration(name);
+
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setBackups(1);
+
+ return ccfg;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @param node Node.
+ * @param exp {@code True} if expect that cache is started on node.
+ */
+ void checkCache(Ignite node, String cacheName, boolean exp) {
+ GridCacheAdapter cache = ((IgniteKernal)node).context().cache().internalCache(cacheName);
+
+ if (exp)
+ assertNotNull("Cache not found [cache=" + cacheName + ", node=" + node.name() + ']', cache);
+ else
+ assertNull("Unexpected cache found [cache=" + cacheName + ", node=" + node.name() + ']', cache);
+ }
+
+ /**
+ * @param nodes Number of nodes.
+ */
+ final void checkNoCaches(int nodes) {
+ for (int i = 0; i < nodes; i++) {
+ GridCacheProcessor cache = ((IgniteKernal)ignite(i)).context().cache();
+
+ assertTrue(cache.caches().isEmpty());
+ assertTrue(cache.internalCaches().isEmpty());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java
new file mode 100644
index 0000000..4a19aa8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClusterActivateDeactivateTestWithPersistence.java
@@ -0,0 +1,197 @@
+/*
+ * 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;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ *
+ */
+public class IgniteClusterActivateDeactivateTestWithPersistence extends IgniteClusterActivateDeactivateTest {
+ /** {@inheritDoc} */
+ @Override protected boolean persistenceEnabled() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ GridTestUtils.deleteDbFiles();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ GridTestUtils.deleteDbFiles();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateCachesRestore_SingleNode() throws Exception {
+ activateCachesRestore(1, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateCachesRestore_SingleNode_WithNewCaches() throws Exception {
+ activateCachesRestore(1, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateCachesRestore_5_Servers() throws Exception {
+ activateCachesRestore(5, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateCachesRestore_5_Servers_WithNewCaches() throws Exception {
+ activateCachesRestore(5, false);
+ }
+
+ /**
+ * @param srvs Number of server nodes.
+ * @param withNewCaches If {@code true} then after restart has new caches in configuration.
+ * @throws Exception If failed.
+ */
+ private void activateCachesRestore(int srvs, boolean withNewCaches) throws Exception {
+ Ignite srv = startGrids(srvs);
+
+ srv.active(true);
+
+ srv.createCaches(Arrays.asList(cacheConfigurations1()));
+
+ Map<Integer, Integer> cacheData = new LinkedHashMap<>();
+
+ for (int i = 1; i <= 100; i++) {
+ for (CacheConfiguration ccfg : cacheConfigurations1()) {
+ srv.cache(ccfg.getName()).put(-i, i);
+
+ cacheData.put(-i, i);
+ }
+ }
+
+ stopAllGrids();
+
+ for (int i = 0; i < srvs; i++) {
+ if (withNewCaches)
+ ccfgs = cacheConfigurations2();
+
+ startGrid(i);
+ }
+
+ srv = ignite(0);
+
+ checkNoCaches(srvs);
+
+ srv.active(true);
+
+ final int CACHES = withNewCaches ? 4 : 2;
+
+ for (int i = 0; i < srvs; i++) {
+ for (int c = 0; c < CACHES; c++)
+ checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+ }
+
+ for (CacheConfiguration ccfg : cacheConfigurations1())
+ checkCacheData(cacheData, ccfg.getName());
+
+ checkCaches(srvs, CACHES);
+
+ int nodes = srvs;
+
+ client = false;
+
+ startGrid(nodes++);
+
+ for (int i = 0; i < nodes; i++) {
+ for (int c = 0; c < CACHES; c++)
+ checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+ }
+
+ checkCaches(nodes, CACHES);
+
+ client = true;
+
+ startGrid(nodes++);
+
+ for (int c = 0; c < CACHES; c++)
+ checkCache(ignite(nodes - 1), CACHE_NAME_PREFIX + c, false);
+
+ checkCaches(nodes, CACHES);
+
+ for (int i = 0; i < nodes; i++) {
+ for (int c = 0; c < CACHES; c++)
+ checkCache(ignite(i), CACHE_NAME_PREFIX + c, true);
+ }
+
+ for (CacheConfiguration ccfg : cacheConfigurations1())
+ checkCacheData(cacheData, ccfg.getName());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testActivateCacheRestoreConfigurationConflict() throws Exception {
+ final int SRVS = 3;
+
+ Ignite srv = startGrids(SRVS);
+
+ srv.active(true);
+
+ CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
+
+ srv.createCache(ccfg);
+
+ stopAllGrids();
+
+ ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME + 1);
+
+ ccfg.setGroupName(DEFAULT_CACHE_NAME);
+
+ ccfgs = new CacheConfiguration[]{ccfg};
+
+ startGrids(SRVS);
+
+ try {
+ ignite(0).active(true);
+
+ fail();
+ }
+ catch (IgniteException e) {
+ // Expected error.
+ }
+
+ for (int i = 0; i < SRVS; i++)
+ assertFalse(ignite(i).active());
+
+ checkNoCaches(SRVS);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java
index fdf5350..566860d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDaemonNodeMarshallerCacheTest.java
@@ -22,9 +22,6 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -107,13 +104,6 @@ public class IgniteDaemonNodeMarshallerCacheTest extends GridCommonAbstractTest
awaitPartitionMapExchange();
- // Workaround for IGNITE-1365.
- IgniteInternalFuture<?> fut = ((IgniteKernal) daemonNode).context().cache().context().exchange().
- affinityReadyFuture(new AffinityTopologyVersion(2, 0));
-
- if (fut != null)
- fut.get();
-
TestClass1 res1 = daemonNode.compute(daemonNode.cluster().forRemotes()).call(new TestCallable1());
assertNotNull(res1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java
index 4dfe69b..665bb56 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpPageStoreManager.java
@@ -152,11 +152,6 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager {
}
/** {@inheritDoc} */
- @Override public void onKernalStart(boolean reconnect) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
@Override public void onKernalStop(boolean cancel) {
// No-op.
}
@@ -177,8 +172,7 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager {
}
/** {@inheritDoc} */
- @Override public void storeCacheData(CacheGroupDescriptor grpDesc,
- StoredCacheData cacheData) throws IgniteCheckedException {
+ @Override public void storeCacheData(StoredCacheData cacheData) throws IgniteCheckedException {
// No-op.
}
@@ -189,11 +183,11 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager {
/** {@inheritDoc} */
@Override public void onActivate(GridKernalContext kctx) {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void onDeActivate(GridKernalContext kctx) {
-
+ // No-op.
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java
index 0ef593f..72450b8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/pagemem/NoOpWALManager.java
@@ -43,7 +43,7 @@ public class NoOpWALManager implements IgniteWriteAheadLogManager {
/** {@inheritDoc} */
@Override public void resumeLogging(WALPointer ptr) throws IgniteCheckedException {
-
+ // No-op.
}
/** {@inheritDoc} */
@@ -83,42 +83,37 @@ public class NoOpWALManager implements IgniteWriteAheadLogManager {
/** {@inheritDoc} */
@Override public void start(GridCacheSharedContext cctx) throws IgniteCheckedException {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void stop(boolean cancel) {
-
- }
-
- /** {@inheritDoc} */
- @Override public void onKernalStart(boolean reconnect) throws IgniteCheckedException {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void onKernalStop(boolean cancel) {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void onDisconnected(IgniteFuture reconnectFut) {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void printMemoryStats() {
-
+ // No-op.
}
/** {@inheritDoc} */
@Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+ // No-op.
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+ @Override public void onDeActivate(GridKernalContext kctx) {
+ // No-op.
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
index 9fa6f7c..675aca5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/AbstractNodeJoinTemplate.java
@@ -53,123 +53,160 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/** Cache 2. */
protected static final String cache2 = "cache2";
- //Todo Cache with node filter.
+ /** */
protected static final String cache3 = "cache3";
+ /** */
protected static final String cache4 = "cache4";
- protected static final String cache5 = "cache5";
+ /** */
+ private static final String cache5 = "cache5";
/** Caches info. */
- public static final String CACHES_INFO = "cachesInfo";
+ private static final String CACHES_INFO = "cachesInfo";
/** Registered caches. */
- public static final String REGISTERED_CACHES = "registeredCaches";
+ private static final String REGISTERED_CACHES = "registeredCaches";
/** Caches. */
public static final String CACHES = "caches";
/**
- * @param ig Ig.
+ * @param ig Node.
+ * @return Cache descriptors.
*/
protected static Map<String, DynamicCacheDescriptor> cacheDescriptors(IgniteEx ig) {
return field((Object)field(ig.context().cache(), CACHES_INFO), REGISTERED_CACHES);
}
/**
- * @param ig Ig.
+ * @param ig Node.
+ * @return Node caches.
*/
protected static Map<String, GridCacheAdapter> caches(IgniteEx ig){
return field(ig.context().cache(), CACHES);
}
/**
- *
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public abstract JoinNodeTestPlanBuilder withOutConfigurationTemplate() throws Exception;
/**
- *
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public abstract JoinNodeTestPlanBuilder staticCacheConfigurationOnJoinTemplate() throws Exception;
/**
- *
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public abstract JoinNodeTestPlanBuilder staticCacheConfigurationInClusterTemplate() throws Exception;
/**
- *
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public abstract JoinNodeTestPlanBuilder staticCacheConfigurationSameOnBothTemplate() throws Exception;
/**
- *
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public abstract JoinNodeTestPlanBuilder staticCacheConfigurationDifferentOnBothTemplate() throws Exception;
// Client node join.
+ /**
+ * @return Test builder.
+ * @throws Exception If failed.
+ */
public abstract JoinNodeTestPlanBuilder joinClientWithOutConfigurationTemplate() throws Exception;
+ /**
+ * @return Test builder.
+ * @throws Exception If failed.
+ */
public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationOnJoinTemplate() throws Exception;
+ /**
+ * @return Test builder.
+ * @throws Exception If failed.
+ */
public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationInClusterTemplate() throws Exception;
+ /**
+ * @return Test builder.
+ * @throws Exception If failed.
+ */
public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationSameOnBothTemplate() throws Exception;
+ /**
+ * @return Test builder.
+ * @throws Exception If failed.
+ */
public abstract JoinNodeTestPlanBuilder joinClientStaticCacheConfigurationDifferentOnBothTemplate() throws Exception;
/**
- *
+ * @throws Exception If failed.
*/
public abstract void testJoinWithOutConfiguration() throws Exception;
/**
- *
+ * @throws Exception If failed.
*/
public abstract void testStaticCacheConfigurationOnJoin() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testStaticCacheConfigurationInCluster() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testStaticCacheConfigurationSameOnBoth() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testStaticCacheConfigurationDifferentOnBoth() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testJoinClientWithOutConfiguration() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testJoinClientStaticCacheConfigurationOnJoin() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testJoinClientStaticCacheConfigurationInCluster() throws Exception;
/**
+ * @throws Exception If failed.
*
*/
public abstract void testJoinClientStaticCacheConfigurationSameOnBoth() throws Exception;
/**
- *
+ * @throws Exception If failed.
*/
public abstract void testJoinClientStaticCacheConfigurationDifferentOnBoth() throws Exception;
+ /** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
super.beforeTest();
@@ -178,6 +215,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
}
+ /** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();
@@ -188,6 +226,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param idx Index.
+ * @return Ignite instance name.
*/
protected String name(int idx) {
return getTestIgniteInstanceName(idx);
@@ -195,6 +234,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param name Name.
+ * @return Igntie configuration.
+ * @throws Exception If failed.
*/
protected IgniteConfiguration cfg(String name) throws Exception {
try {
@@ -206,7 +247,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Test builder.
*/
protected JoinNodeTestPlanBuilder builder() {
return JoinNodeTestPlanBuilder.builder();
@@ -214,13 +255,14 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param cfgs Cfgs.
+ * @return Configurations.
*/
- protected static <T> T[] buildConfiguration(T... cfgs) {
+ private static <T> T[] buildConfiguration(T... cfgs) {
return cfgs;
}
/**
- *
+ * @return Cache configuration.
*/
protected CacheConfiguration atomicCfg() {
return new CacheConfiguration(cache1)
@@ -228,6 +270,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
+ * @return Cache configuration.
*
*/
protected CacheConfiguration transactionCfg() {
@@ -236,7 +279,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Cache configurations.
*/
protected CacheConfiguration[] allCacheConfigurations() {
return buildConfiguration(atomicCfg(), transactionCfg());
@@ -309,6 +352,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/** After de activate. */
private Runnable afterDeActivate = Noop;
+ /** */
private IgniteCallable<List<CacheConfiguration>> dynamicCacheStart =
new IgniteCallable<List<CacheConfiguration>>() {
@Override public List<CacheConfiguration> call() throws Exception {
@@ -316,6 +360,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
};
+ /** */
private IgniteCallable<List<String>> dynamicCacheStop =
new IgniteCallable<List<String>>() {
@Override public List<String> call() throws Exception {
@@ -323,15 +368,19 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
};
+ /** */
private Runnable afterDynamicCacheStarted = Noop;
+ /** */
private Runnable afterDynamicCacheStopped = Noop;
/** End. */
private Runnable end = Noop;
/**
- *
+ * @param cfgs Configurations.
+ * @return Test builder.
+ * @throws Exception If failed.
*/
public JoinNodeTestPlanBuilder clusterConfiguration(IgniteConfiguration... cfgs) throws Exception {
clusterCfg = cfgs;
@@ -359,7 +408,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param cfg Configuration.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder nodeConfiguration(IgniteConfiguration cfg) {
nodeCfg = cfg;
@@ -382,6 +432,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param func Func.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder nodeConfiguration(
IgniteClosure<IgniteConfiguration, IgniteConfiguration> func
@@ -393,7 +444,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param r Cluster start callback.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder afterClusterStarted(Runnable r) {
strPlanBuilder.append("Check after cluster start\n");
@@ -404,7 +456,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param r Node join callback.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder afterNodeJoin(Runnable r) {
strPlanBuilder.append("Check after node join")
@@ -416,7 +469,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param state State after join.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder stateAfterJoin(boolean state) {
strPlanBuilder.append("Check state on all nodes after join, must be ")
@@ -429,7 +483,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param r Activate callback.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder afterActivate(Runnable r) {
strPlanBuilder.append("Check after activate")
@@ -441,7 +496,8 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @param r Deactivate callback.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder afterDeActivate(Runnable r) {
strPlanBuilder.append("Check after deActivate")
@@ -452,6 +508,10 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
return this;
}
+ /**
+ * @param caches Callback.
+ * @return Test builder.
+ */
public JoinNodeTestPlanBuilder dynamicCacheStart(IgniteCallable<List<CacheConfiguration>> caches){
strPlanBuilder.append("Dynamic caches start")
.append("\n");
@@ -461,6 +521,10 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
return this;
}
+ /**
+ * @param r Cache start callback.
+ * @return Test builder.
+ */
public JoinNodeTestPlanBuilder afterDynamicCacheStarted(Runnable r){
strPlanBuilder.append("Check after dynamic caches start")
.append("\n");
@@ -470,6 +534,10 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
return this;
}
+ /**
+ * @param caches Callback.
+ * @return Test builder.
+ */
public JoinNodeTestPlanBuilder dynamicCacheStop(IgniteCallable<List<String>> caches){
strPlanBuilder.append("Dynamic caches stop")
.append("\n");
@@ -479,6 +547,10 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
return this;
}
+ /**
+ * @param r Callback.
+ * @return Test builder.
+ */
public JoinNodeTestPlanBuilder afterDynamicCacheStopped(Runnable r){
strPlanBuilder.append("Check after dynamic caches stop")
.append("\n");
@@ -490,6 +562,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param end End.
+ * @return Test builder.
*/
public JoinNodeTestPlanBuilder setEnd(Runnable end) {
strPlanBuilder.append("Check before stop")
@@ -501,7 +574,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @throws Exception If failed.
*/
public void execute() throws Exception {
try {
@@ -611,12 +684,19 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
}
+ /**
+ * @param ig Node.
+ * @return Next minor version.
+ */
private AffinityTopologyVersion nextMinorVersion(IgniteEx ig){
AffinityTopologyVersion cur = ig.context().discovery().topologyVersionEx();
- return new AffinityTopologyVersion(cur.topologyVersion(), cur.minorTopologyVersion() + 1);
+ return cur.nextMinorVersion();
}
+ /**
+ * @param ver Version.
+ */
private void awaitTopologyVersion(final AffinityTopologyVersion ver){
onAllNode(new CI1<IgniteEx>() {
@Override public void apply(IgniteEx ig) {
@@ -643,7 +723,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Started nodes.
*/
protected List<IgniteEx> grids() {
List<IgniteEx> res = new ArrayList<>();
@@ -655,14 +735,14 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Test builder.
*/
public static JoinNodeTestPlanBuilder builder() {
return new JoinNodeTestPlanBuilder();
}
/**
- *
+ * @return Callback.
*/
public Runnable checkCacheOnlySystem() {
return onAllNode(new IgniteInClosure<IgniteEx>() {
@@ -686,15 +766,11 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Callback.
*/
public Runnable checkCacheEmpty() {
return onAllNode(new IgniteInClosure<IgniteEx>() {
@Override public void apply(IgniteEx ig) {
- Map<String, DynamicCacheDescriptor> desc = cacheDescriptors(ig);
-
- Assert.assertTrue(desc.isEmpty());
-
Assert.assertNull(ig.context().cache().cache(cache1));
Assert.assertNull(ig.context().cache().cache(cache2));
@@ -706,7 +782,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
}
/**
- *
+ * @return Callback.
*/
public Runnable checkCacheNotEmpty() {
return onAllNode(new IgniteInClosure<IgniteEx>() {
@@ -735,6 +811,7 @@ public abstract class AbstractNodeJoinTemplate extends GridCommonAbstractTest {
/**
* @param cls Closure.
+ * @return Callback.
*/
private Runnable onAllNode(final IgniteInClosure<IgniteEx> cls) {
return new Runnable() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateAbstractTest.java
index a06e0ce..4e575cc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateAbstractTest.java
@@ -47,13 +47,10 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
private static final String clientSuffix = "-client";
/** Primary ip finder. */
- protected final TcpDiscoveryIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true);
+ private final TcpDiscoveryIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true);
/** Back up ip finder. */
- protected final TcpDiscoveryIpFinder backUpIpFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** Consistent id count. */
- private int consistentIdCnt;
+ private final TcpDiscoveryIpFinder backUpIpFinder = new TcpDiscoveryVmIpFinder(true);
/** Nodes. */
protected Map<String, Ignite> nodes = new ConcurrentHashMap<>();
@@ -91,28 +88,28 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
}
/**
- *
+ * @return Number of server nodes in primary cluster.
*/
protected int primaryNodes() {
return 3;
}
/**
- *
+ * @return Number of client nodes in primary cluster.
*/
protected int primaryClientNodes() {
return 3;
}
/**
- *
+ * @return Number of server nodes in backup cluster.
*/
protected int backUpNodes() {
return 3;
}
/**
- *
+ * @return Number of client nodes in backup cluster.
*/
protected int backUpClientNodes() {
return 3;
@@ -120,6 +117,7 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param idx idx.
+ * @return Primary cluster node.
*/
protected Ignite primary(int idx) {
return nodes.get("node" + idx + primarySuffix);
@@ -127,29 +125,33 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param idx idx.
+ * @return Primary cluster client node.
*/
- protected Ignite primaryClient(int idx) {
+ Ignite primaryClient(int idx) {
return nodes.get("node" + idx + primarySuffix + clientSuffix);
}
/**
* @param idx idx.
+ * @return Backup cluster node.
*/
- protected Ignite backUp(int idx) {
+ Ignite backUp(int idx) {
return nodes.get("node" + idx + backUpSuffix);
}
/**
* @param idx idx.
+ * @return Backup cluster client node.
*/
- protected Ignite backUpClient(int idx) {
+ Ignite backUpClient(int idx) {
return nodes.get("node" + idx + backUpSuffix + clientSuffix);
}
/**
* @param cnt Count.
+ * @throws Exception If failed.
*/
- protected void startPrimaryNodes(int cnt) throws Exception {
+ private void startPrimaryNodes(int cnt) throws Exception {
for (int i = 0; i < cnt; i++)
startPrimary(i);
@@ -159,8 +161,9 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param idx Index.
+ * @throws Exception If failed.
*/
- protected void startPrimary(int idx) throws Exception {
+ private void startPrimary(int idx) throws Exception {
String node = "node" + idx;
String name = node + primarySuffix;
@@ -176,22 +179,26 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param cnt Count.
+ * @throws Exception If failed.
*/
- protected void startBackUpNodes(int cnt) throws Exception {
+ private void startBackUpNodes(int cnt) throws Exception {
for (int i = 0; i < cnt; i++)
startBackUp(i);
}
/**
* @param idx Index.
+ * @throws Exception If failed.
*/
- protected void startBackUp(int idx) throws Exception {
+ void startBackUp(int idx) throws Exception {
String node = "node" + idx;
String name = node + backUpSuffix;
IgniteConfiguration cfg = getConfiguration(name);
+
cfg.setConsistentId(node);
+
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(backUpIpFinder);
Ignite ig = startGrid(name, cfg);
@@ -201,16 +208,19 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param cnt Count.
+ * @throws Exception If failed.
*/
- protected void startPrimaryClientNodes(int cnt) throws Exception {
+ void startPrimaryClientNodes(int cnt) throws Exception {
for (int i = 0; i < cnt; i++) {
String node = "node" + i;
String name = node + primarySuffix + clientSuffix;
IgniteConfiguration cfg = getConfiguration(name);
+
cfg.setConsistentId(node);
cfg.setClientMode(true);
+
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(primaryIpFinder);
Ignite ig = startGrid(name, cfg);
@@ -221,8 +231,9 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param cnt Count.
+ * @throws Exception If failed.
*/
- protected void startBackUpClientNodes(int cnt) throws Exception {
+ private void startBackUpClientNodes(int cnt) throws Exception {
for (int i = 0; i < cnt; i++) {
String node = "node" + i;
@@ -241,9 +252,9 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
}
/**
- *
+ * @return All nodes from backup cluster.
*/
- protected Iterable<Ignite> allBackUpNodes() {
+ Iterable<Ignite> allBackUpNodes() {
List<Ignite> r = new ArrayList<>();
for (String name : this.nodes.keySet())
@@ -254,11 +265,10 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
}
/**
- *
+ * @param includeClient If {@code true} then allow to return client.
+ * @return Random node from backup topology.
*/
- protected Ignite randomBackUp(boolean includeClient) {
- int nodes = 0;
-
+ Ignite randomBackUp(boolean includeClient) {
List<Ignite> igs = new ArrayList<>();
for (String name : this.nodes.keySet())
@@ -281,7 +291,7 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
* @param i Idx.
*/
- protected void stopPrimary(int i) {
+ void stopPrimary(int i) {
String name = "node" + i + primarySuffix;
nodes.get(name).close();
@@ -292,7 +302,7 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
/**
*
*/
- protected void stopAllPrimary() {
+ void stopAllPrimary() {
stopAll(primarySuffix);
}
@@ -357,10 +367,9 @@ public abstract class IgniteChangeGlobalStateAbstractTest extends GridCommonAbst
}
/**
- *
+ * @return Test class name.
*/
protected String testName() {
return getClass().getSimpleName();
}
-
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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";
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
index d3e8298..16be316 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStreamerTest.java
@@ -36,10 +36,9 @@ public class IgniteChangeGlobalStateDataStreamerTest extends IgniteChangeGlobalS
}
/**
- *
+ * @throws Exception If failed.
*/
- public void testDeActivateAndActivateDataStreamer() throws InterruptedException {
-
+ public void testDeActivateAndActivateDataStreamer() throws Exception {
Ignite ig1 = primary(0);
Ignite ig2 = primary(1);
Ignite ig3 = primary(2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
index 9013226..8902a36 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/standbycluster/IgniteChangeGlobalStateDataStructureTest.java
@@ -35,9 +35,9 @@ import static org.apache.ignite.testframework.GridTestUtils.runAsync;
*/
public class IgniteChangeGlobalStateDataStructureTest extends IgniteChangeGlobalStateAbstractTest {
/**
- *
+ * @throws Exception If failed.
*/
- public void testDeActivateAndActivateAtomicLong() throws Exception{
+ public void testDeActivateAndActivateAtomicLong() throws Exception {
String lName = "myLong";
Ignite ig1 = primary(0);
@@ -106,7 +106,7 @@ public class IgniteChangeGlobalStateDataStructureTest extends IgniteChangeGlobal
}
/**
- *
+ * @throws Exception If failed.
*/
public void testDeActivateAndActivateCountDownLatch() throws Exception {
final AtomicInteger cnt = new AtomicInteger();
[4/7] ignite git commit: Reworked cluster activation/deactivation.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 a1926ee..cea758a 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
@@ -36,6 +36,7 @@ import java.util.concurrent.locks.ReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.events.CacheEvent;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
@@ -57,15 +58,14 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
import org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage;
import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor;
import org.apache.ignite.internal.processors.cache.CachePartitionExchangeWorkerTask;
-import org.apache.ignite.internal.processors.cache.ClusterState;
import org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch;
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.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.StateChangeRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFutureAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridClientPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
@@ -73,7 +73,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.cluster.GridClusterStateProcessor;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -214,9 +215,6 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
/** Change global state exceptions. */
private final Map<UUID, Exception> changeGlobalStateExceptions = new ConcurrentHashMap8<>();
- /** This exchange for change global state. */
- private boolean exchangeOnChangeGlobalState;
-
/** */
private ConcurrentMap<UUID, GridDhtPartitionsSingleMessage> msgs = new ConcurrentHashMap8<>();
@@ -463,10 +461,24 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
/**
- *
+ * @return {@code True} if cluster state change exchange.
+ */
+ private boolean stateChangeExchange() {
+ return exchActions != null && exchActions.stateChangeRequest() != null;
+ }
+
+ /**
+ * @return {@code True} if activate cluster exchange.
*/
- public ClusterState newClusterState() {
- return exchActions != null ? exchActions.newClusterState() : null;
+ public boolean activateCluster() {
+ return exchActions != null && exchActions.activate();
+ }
+
+ /**
+ * @return {@code True} if deactivate cluster exchange.
+ */
+ boolean deactivateCluster() {
+ return exchActions != null && exchActions.deactivate();
}
/**
@@ -519,6 +531,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
if (isDone())
return;
+ assert !cctx.kernalContext().isDaemon();
+
initTs = U.currentTimeMillis();
U.await(evtLatch);
@@ -557,7 +571,12 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
DiscoveryCustomMessage msg = ((DiscoveryCustomEvent)discoEvt).customMessage();
- if (msg instanceof DynamicCacheChangeBatch) {
+ if (msg instanceof ChangeGlobalStateMessage) {
+ assert exchActions != null && !exchActions.empty();
+
+ exchange = onClusterStateChangeRequest(crdNode);
+ }
+ else if (msg instanceof DynamicCacheChangeBatch) {
assert exchActions != null && !exchActions.empty();
exchange = onCacheChangeRequest(crdNode);
@@ -582,8 +601,26 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
cctx.affinity().initStartedCaches(crdNode, this, receivedCaches);
}
- else
- cctx.cache().startCachesOnLocalJoin(topVer);
+ else {
+ cctx.activate();
+
+ List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> caches =
+ cctx.cache().cachesToStartOnLocalJoin();
+
+ if (cctx.database().persistenceEnabled() &&
+ !cctx.kernalContext().clientNode()) {
+ List<DynamicCacheDescriptor> startDescs = new ArrayList<>();
+
+ if (caches != null) {
+ for (T2<DynamicCacheDescriptor, NearCacheConfiguration> c : caches)
+ startDescs.add(c.get1());
+ }
+
+ cctx.database().readCheckpointAndRestoreMemory(startDescs);
+ }
+
+ cctx.cache().startCachesOnLocalJoin(caches, topVer);
+ }
}
exchange = CU.clientNode(discoEvt.eventNode()) ?
@@ -710,21 +747,94 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
* @return Exchange type.
* @throws IgniteCheckedException If failed.
*/
- private ExchangeType onCacheChangeRequest(boolean crd) throws IgniteCheckedException {
+ private ExchangeType onClusterStateChangeRequest(boolean crd) throws IgniteCheckedException {
assert exchActions != null && !exchActions.empty() : this;
- GridClusterStateProcessor stateProc = cctx.kernalContext().state();
+ StateChangeRequest req = exchActions.stateChangeRequest();
+
+ assert req != null : exchActions;
+
+ if (req.activate()) {
+ if (log.isInfoEnabled()) {
+ log.info("Start activation process [nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]");
+ }
+
+ try {
+ cctx.activate();
+
+ if (cctx.database().persistenceEnabled() && !cctx.kernalContext().clientNode()) {
+ List<DynamicCacheDescriptor> startDescs = new ArrayList<>();
+
+ for (ExchangeActions.ActionData startReq : exchActions.cacheStartRequests())
+ startDescs.add(startReq.descriptor());
+
+ cctx.database().readCheckpointAndRestoreMemory(startDescs);
+ }
+
+ cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
- if (exchangeOnChangeGlobalState = stateProc.changeGlobalState(exchActions, topologyVersion())) {
- changeGlobalStateE = stateProc.onChangeGlobalState();
+ if (log.isInfoEnabled()) {
+ log.info("Successfully activated caches [nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]");
+ }
+ }
+ catch (Exception e) {
+ U.error(log, "Failed to activate node components [nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]", e);
- if (changeGlobalStateE != null) {
- if (crd)
- changeGlobalStateExceptions.put(cctx.localNodeId(), changeGlobalStateE);
+ changeGlobalStateE = e;
- return cctx.kernalContext().clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL;
+ if (crd) {
+ synchronized (this) {
+ changeGlobalStateExceptions.put(cctx.localNodeId(), e);
+ }
+ }
}
}
+ else {
+ if (log.isInfoEnabled()) {
+ log.info("Start deactivation process [nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]");
+ }
+
+ try {
+ cctx.kernalContext().dataStructures().onDeActivate(cctx.kernalContext());
+
+ cctx.kernalContext().service().onDeActivate(cctx.kernalContext());
+
+ cctx.affinity().onCacheChangeRequest(this, crd, exchActions);
+
+ if (log.isInfoEnabled()) {
+ log.info("Successfully deactivated data structures, services and caches [" +
+ "nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]");
+ }
+ }
+ catch (Exception e) {
+ U.error(log, "Failed to deactivate node components [nodeId=" + cctx.localNodeId() +
+ ", client=" + cctx.kernalContext().clientNode() +
+ ", topVer=" + topologyVersion() + "]", e);
+
+ changeGlobalStateE = e;
+ }
+ }
+
+ return cctx.kernalContext().clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL;
+ }
+
+ /**
+ * @param crd Coordinator flag.
+ * @return Exchange type.
+ * @throws IgniteCheckedException If failed.
+ */
+ private ExchangeType onCacheChangeRequest(boolean crd) throws IgniteCheckedException {
+ assert exchActions != null && !exchActions.empty() : this;
assert !exchActions.clientOnlyExchange() : exchActions;
@@ -1133,8 +1243,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
if (partHistReserved0 != null)
m.partitionHistoryCounters(partHistReserved0);
- if (exchangeOnChangeGlobalState && changeGlobalStateE != null)
- m.setException(changeGlobalStateE);
+ if (stateChangeExchange() && changeGlobalStateE != null)
+ m.setError(changeGlobalStateE);
if (log.isDebugEnabled())
log.debug("Sending local partitions [nodeId=" + node.id() + ", exchId=" + exchId + ", msg=" + m + ']');
@@ -1160,8 +1270,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
partHistSuppliers,
partsToReload);
- if (exchangeOnChangeGlobalState && !F.isEmpty(changeGlobalStateExceptions))
- m.setExceptionsMap(changeGlobalStateExceptions);
+ if (stateChangeExchange() && !F.isEmpty(changeGlobalStateExceptions))
+ m.setErrorsMap(changeGlobalStateExceptions);
return m;
}
@@ -1175,9 +1285,10 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
assert !nodes.contains(cctx.localNode());
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Sending full partition map [nodeIds=" + F.viewReadOnly(nodes, F.node2id()) +
", exchId=" + exchId + ", msg=" + m + ']');
+ }
for (ClusterNode node : nodes) {
try {
@@ -1291,8 +1402,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
if (exchActions != null && err == null)
exchActions.completeRequestFutures(cctx);
- if (exchangeOnChangeGlobalState && err == null)
- cctx.kernalContext().state().onExchangeDone();
+ if (stateChangeExchange() && err == null)
+ cctx.kernalContext().state().onStateChangeExchangeDone(exchActions.stateChangeRequest());
Map<T2<Integer, Integer>, Long> localReserved = partHistSuppliers.getReservations(cctx.localNodeId());
@@ -1368,6 +1479,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
crd = null;
partReleaseFut = null;
changeGlobalStateE = null;
+ exchActions = null;
}
/**
@@ -1444,8 +1556,8 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
pendingSingleUpdates++;
- if (exchangeOnChangeGlobalState && msg.getException() != null)
- changeGlobalStateExceptions.put(node.id(), msg.getException());
+ if (stateChangeExchange() && msg.getError() != null)
+ changeGlobalStateExceptions.put(node.id(), msg.getError());
allReceived = remaining.isEmpty();
}
@@ -1457,7 +1569,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
if (updateSingleMap) {
try {
// Do not update partition map, in case cluster transitioning to inactive state.
- if (!exchangeOnChangeGlobalState || exchActions.newClusterState() != ClusterState.INACTIVE)
+ if (!deactivateCluster())
updatePartitionSingleMap(node, msg);
}
finally {
@@ -1735,18 +1847,16 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
}
- if (discoEvt.type() == EVT_NODE_JOINED) {
- if (cctx.kernalContext().state().active())
- assignPartitionsStates();
- }
+ if (discoEvt.type() == EVT_NODE_JOINED)
+ assignPartitionsStates();
else if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
assert discoEvt instanceof DiscoveryCustomEvent;
+ if (activateCluster())
+ assignPartitionsStates();
+
if (((DiscoveryCustomEvent)discoEvt).customMessage() instanceof DynamicCacheChangeBatch) {
if (exchActions != null) {
- if (exchActions.newClusterState() == ClusterState.ACTIVE)
- assignPartitionsStates();
-
Set<String> caches = exchActions.cachesToResetLostPartitions();
if (!F.isEmpty(caches))
@@ -1783,13 +1893,34 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
nodes = new ArrayList<>(srvNodes);
}
+ IgniteCheckedException err = null;
+
+ if (stateChangeExchange()) {
+ StateChangeRequest req = exchActions.stateChangeRequest();
+
+ assert req != null : exchActions;
+
+ boolean stateChangeErr = false;
+
+ if (!F.isEmpty(changeGlobalStateExceptions)) {
+ stateChangeErr = true;
+
+ err = new IgniteCheckedException("Cluster state change failed.");
+
+ cctx.kernalContext().state().onStateChangeError(changeGlobalStateExceptions, req);
+ }
+
+ boolean active = !stateChangeErr && req.activate();
+
+ ChangeGlobalStateFinishMessage msg = new ChangeGlobalStateFinishMessage(req.requestId(), active);
+
+ cctx.discovery().sendCustomEvent(msg);
+ }
+
if (!nodes.isEmpty())
sendAllPartitions(nodes);
- if (exchangeOnChangeGlobalState && !F.isEmpty(changeGlobalStateExceptions))
- cctx.kernalContext().state().onFullResponseMessage(changeGlobalStateExceptions);
-
- onDone(exchangeId().topologyVersion());
+ onDone(exchangeId().topologyVersion(), err);
}
}
catch (IgniteCheckedException e) {
@@ -1898,7 +2029,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
* @param msg Message.
*/
private void processMessage(ClusterNode node, GridDhtPartitionsFullMessage msg) {
- assert msg.exchangeId().equals(exchId) : msg;
+ assert exchId.equals(msg.exchangeId()) : msg;
assert msg.lastVersion() != null : msg;
synchronized (this) {
@@ -1919,10 +2050,15 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
updatePartitionFullMap(msg);
- if (exchangeOnChangeGlobalState && !F.isEmpty(msg.getExceptionsMap()))
- cctx.kernalContext().state().onFullResponseMessage(msg.getExceptionsMap());
+ IgniteCheckedException err = null;
- onDone(exchId.topologyVersion());
+ if (stateChangeExchange() && !F.isEmpty(msg.getErrorsMap())) {
+ err = new IgniteCheckedException("Cluster state change failed");
+
+ cctx.kernalContext().state().onStateChangeError(msg.getErrorsMap(), exchActions.stateChangeRequest());
+ }
+
+ onDone(exchId.topologyVersion(), err);
}
/**
@@ -2143,7 +2279,7 @@ public class GridDhtPartitionsExchangeFuture extends GridDhtTopologyFutureAdapte
}
if (crd0.isLocal()) {
- if (exchangeOnChangeGlobalState && changeGlobalStateE != null)
+ if (stateChangeExchange() && changeGlobalStateE != null)
changeGlobalStateExceptions.put(crd0.id(), changeGlobalStateE);
if (allReceived) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 0beb935..75609b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -90,10 +90,10 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
/** Exceptions. */
@GridToStringInclude
@GridDirectTransient
- private Map<UUID, Exception> exs;
+ private Map<UUID, Exception> errs;
/** */
- private byte[] exsBytes;
+ private byte[] errsBytes;
/** */
@GridDirectTransient
@@ -224,17 +224,17 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
}
/**
- *
+ * @return Errors map.
*/
- public Map<UUID, Exception> getExceptionsMap() {
- return exs;
+ @Nullable Map<UUID, Exception> getErrorsMap() {
+ return errs;
}
/**
- * @param exs Exs.
+ * @param errs Errors map.
*/
- public void setExceptionsMap(Map<UUID, Exception> exs) {
- this.exs = new HashMap<>(exs);
+ void setErrorsMap(Map<UUID, Exception> errs) {
+ this.errs = new HashMap<>(errs);
}
/** {@inheritDoc} */
@@ -245,14 +245,14 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
(partCntrs != null && partCntrsBytes == null) ||
(partHistSuppliers != null && partHistSuppliersBytes == null) ||
(partsToReload != null && partsToReloadBytes == null) ||
- (exs != null && exsBytes == null);
+ (errs != null && errsBytes == null);
if (marshal) {
byte[] partsBytes0 = null;
byte[] partCntrsBytes0 = null;
byte[] partHistSuppliersBytes0 = null;
byte[] partsToReloadBytes0 = null;
- byte[] exsBytes0 = null;
+ byte[] errsBytes0 = null;
if (parts != null && partsBytes == null)
partsBytes0 = U.marshal(ctx, parts);
@@ -266,8 +266,8 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
if (partsToReload != null && partsToReloadBytes == null)
partsToReloadBytes0 = U.marshal(ctx, partsToReload);
- if (exs != null && exsBytes == null)
- exsBytes0 = U.marshal(ctx, exs);
+ if (errs != null && errsBytes == null)
+ errsBytes0 = U.marshal(ctx, errs);
if (compress) {
assert !compressed();
@@ -277,13 +277,13 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
byte[] partCntrsBytesZip = U.zip(partCntrsBytes0);
byte[] partHistSuppliersBytesZip = U.zip(partHistSuppliersBytes0);
byte[] partsToReloadBytesZip = U.zip(partsToReloadBytes0);
- byte[] exsBytesZip = U.zip(exsBytes0);
+ byte[] exsBytesZip = U.zip(errsBytes0);
partsBytes0 = partsBytesZip;
partCntrsBytes0 = partCntrsBytesZip;
partHistSuppliersBytes0 = partHistSuppliersBytesZip;
partsToReloadBytes0 = partsToReloadBytesZip;
- exsBytes0 = exsBytesZip;
+ errsBytes0 = exsBytesZip;
compressed(true);
}
@@ -296,7 +296,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
partCntrsBytes = partCntrsBytes0;
partHistSuppliersBytes = partHistSuppliersBytes0;
partsToReloadBytes = partsToReloadBytes0;
- exsBytes = exsBytes0;
+ errsBytes = errsBytes0;
}
}
@@ -379,15 +379,15 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
if (partCntrs == null)
partCntrs = new IgniteDhtPartitionCountersMap();
- if (exsBytes != null && exs == null) {
+ if (errsBytes != null && errs == null) {
if (compressed())
- exs = U.unmarshalZip(ctx.marshaller(), exsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ errs = U.unmarshalZip(ctx.marshaller(), errsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
else
- exs = U.unmarshal(ctx, exsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ errs = U.unmarshal(ctx, errsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
}
- if (exs == null)
- exs = new HashMap<>();
+ if (errs == null)
+ errs = new HashMap<>();
}
/** {@inheritDoc} */
@@ -412,7 +412,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
writer.incrementState();
case 6:
- if (!writer.writeByteArray("exsBytes", exsBytes))
+ if (!writer.writeByteArray("errsBytes", errsBytes))
return false;
writer.incrementState();
@@ -472,7 +472,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
reader.incrementState();
case 6:
- exsBytes = reader.readByteArray("exsBytes");
+ errsBytes = reader.readByteArray("errsBytes");
if (!reader.isLastRead())
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
index 1e5ea14..b4d25c4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsSingleMessage.java
@@ -76,10 +76,10 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
/** Exception. */
@GridToStringInclude
@GridDirectTransient
- private Exception ex;
+ private Exception err;
/** */
- private byte[] exBytes;
+ private byte[] errBytes;
/** */
private boolean client;
@@ -220,15 +220,15 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
/**
* @param ex Exception.
*/
- public void setException(Exception ex) {
- this.ex = ex;
+ public void setError(Exception ex) {
+ this.err = ex;
}
/**
- *
+ * @return Not null exception if exchange processing failed.
*/
- public Exception getException() {
- return ex;
+ @Nullable public Exception getError() {
+ return err;
}
/** {@inheritDoc}
@@ -239,13 +239,13 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
boolean marshal = (parts != null && partsBytes == null) ||
(partCntrs != null && partCntrsBytes == null) ||
(partHistCntrs != null && partHistCntrsBytes == null) ||
- (ex != null && exBytes == null);
+ (err != null && errBytes == null);
if (marshal) {
byte[] partsBytes0 = null;
byte[] partCntrsBytes0 = null;
byte[] partHistCntrsBytes0 = null;
- byte[] exBytes0 = null;
+ byte[] errBytes0 = null;
if (parts != null && partsBytes == null)
partsBytes0 = U.marshal(ctx, parts);
@@ -256,8 +256,8 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
if (partHistCntrs != null && partHistCntrsBytes == null)
partHistCntrsBytes0 = U.marshal(ctx, partHistCntrs);
- if (ex != null && exBytes == null)
- exBytes0 = U.marshal(ctx, ex);
+ if (err != null && errBytes == null)
+ errBytes0 = U.marshal(ctx, err);
if (compress) {
assert !compressed();
@@ -266,12 +266,12 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
byte[] partsBytesZip = U.zip(partsBytes0);
byte[] partCntrsBytesZip = U.zip(partCntrsBytes0);
byte[] partHistCntrsBytesZip = U.zip(partHistCntrsBytes0);
- byte[] exBytesZip = U.zip(exBytes0);
+ byte[] exBytesZip = U.zip(errBytes0);
partsBytes0 = partsBytesZip;
partCntrsBytes0 = partCntrsBytesZip;
partHistCntrsBytes0 = partHistCntrsBytesZip;
- exBytes0 = exBytesZip;
+ errBytes0 = exBytesZip;
compressed(true);
}
@@ -283,7 +283,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
partsBytes = partsBytes0;
partCntrsBytes = partCntrsBytes0;
partHistCntrsBytes = partHistCntrsBytes0;
- exBytes = exBytes0;
+ errBytes = errBytes0;
}
}
@@ -312,11 +312,11 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
partHistCntrs = U.unmarshal(ctx, partHistCntrsBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
}
- if (exBytes != null && ex == null) {
+ if (errBytes != null && err == null) {
if (compressed())
- ex = U.unmarshalZip(ctx.marshaller(), exBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ err = U.unmarshalZip(ctx.marshaller(), errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
else
- ex = U.unmarshal(ctx, exBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
+ err = U.unmarshal(ctx, errBytes, U.resolveClassLoader(ldr, ctx.gridConfig()));
}
if (dupPartsData != null) {
@@ -368,7 +368,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
writer.incrementState();
case 7:
- if (!writer.writeByteArray("exBytes", exBytes))
+ if (!writer.writeByteArray("errBytes", errBytes))
return false;
writer.incrementState();
@@ -424,7 +424,7 @@ public class GridDhtPartitionsSingleMessage extends GridDhtPartitionsAbstractMes
reader.incrementState();
case 7:
- exBytes = reader.readByteArray("exBytes");
+ errBytes = reader.readByteArray("errBytes");
if (!reader.isLastRead())
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 66b5987..2b18c24 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -183,7 +183,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
// No assignments for disabled preloader.
GridDhtPartitionTopology top = grp.topology();
- if (!grp.rebalanceEnabled() || !grp.shared().kernalContext().state().active())
+ if (!grp.rebalanceEnabled())
return new GridDhtPreloaderAssignments(exchFut, top.topologyVersion());
int partCnt = grp.affinity().partitions();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 062ff6c..a49812e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -45,8 +45,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.CacheDistribu
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
-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.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.GridLeanMap;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index 41e6d70..29c7aad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@ -26,7 +26,6 @@ import java.util.UUID;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 b3ab1cd..c700ef4 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,11 +99,13 @@ 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.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;
@@ -113,9 +114,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;
@@ -352,9 +350,9 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
/** {@inheritDoc} */
@Override protected void start0() throws IgniteCheckedException {
- snapshotMgr = cctx.snapshot();
+ super.start0();
- assert !cctx.kernalContext().state().active() : "Cluster with persistent must starting as inactive.";
+ snapshotMgr = cctx.snapshot();
if (!cctx.kernalContext().clientNode()) {
IgnitePageStoreManager store = cctx.pageStore();
@@ -371,15 +369,13 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
fileLockHolder = new FileLockHolder(storeMgr.workDir().getPath(), cctx.kernalContext(), log);
persStoreMetrics.wal(cctx.wal());
-
- registrateMetricsMBean();
}
}
/**
- *
+ * @throws IgniteCheckedException If failed.
*/
- @Override public void initDataBase() throws IgniteCheckedException {
+ private void initDataBase() throws IgniteCheckedException {
Long cpBufSize = persistenceCfg.getCheckpointingPageBufferSize();
if (persistenceCfg.getCheckpointingThreads() > 1)
@@ -432,8 +428,6 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
}
checkpointPageBufSize = cpBufSize;
-
- super.start0();
}
/** {@inheritDoc} */
@@ -442,58 +436,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
}
/** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- if (reconnect || cctx.kernalContext().clientNode() || !cctx.kernalContext().state().active())
- return;
-
- initDataBase();
-
- initCachesAndRestoreMemory();
- }
-
- /**
- *
- */
- private void initCachesAndRestoreMemory() throws IgniteCheckedException {
- Collection<String> cacheNames = new HashSet<>();
-
- // TODO IGNITE-5075 group descriptors.
- for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration()) {
- if (CU.isSystemCache(ccfg.getName())) {
- storeMgr.initializeForCache(
- cctx.cache().cacheDescriptors().get(ccfg.getName()).groupDescriptor(),
- new StoredCacheData(ccfg)
- );
-
- cacheNames.add(ccfg.getName());
- }
- }
-
- for (CacheConfiguration ccfg : cctx.kernalContext().config().getCacheConfiguration())
- if (!CU.isSystemCache(ccfg.getName())) {
- DynamicCacheDescriptor cacheDesc = cctx.cache().cacheDescriptors().get(ccfg.getName());
-
- if (cacheDesc != null)
- storeMgr.initializeForCache(
- cacheDesc.groupDescriptor(),
- new StoredCacheData(ccfg)
- );
-
- cacheNames.add(ccfg.getName());
- }
-
- for (StoredCacheData cacheData : cctx.pageStore().readCacheConfigurations().values()) {
- if (!cacheNames.contains(cacheData.config().getName()))
- storeMgr.initializeForCache(
- cctx.cache().cacheDescriptors().get(
- cacheData.config().getName()).groupDescriptor(), cacheData);
- }
-
- readCheckpointAndRestoreMemory();
- }
-
- /** {@inheritDoc} */
- @Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onActivate(GridKernalContext ctx) throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Activate database manager [id=" + cctx.localNodeId() +
" topVer=" + cctx.discovery().topologyVersionEx() + " ]");
@@ -504,16 +447,13 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
initDataBase();
registrateMetricsMBean();
-
- initCachesAndRestoreMemory();
}
- if (log.isDebugEnabled())
- log.debug("Restore state after activation [nodeId=" + cctx.localNodeId() + " ]");
+ super.onActivate(ctx);
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
if (log.isDebugEnabled())
log.debug("DeActivate database manager [id=" + cctx.localNodeId() +
" topVer=" + cctx.discovery().topologyVersionEx() + " ]");
@@ -530,7 +470,7 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
}
/**
- *
+ * @throws IgniteCheckedException If failed.
*/
private void registrateMetricsMBean() throws IgniteCheckedException {
try {
@@ -564,13 +504,18 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
}
}
- /**
- *
- */
- private void readCheckpointAndRestoreMemory() throws IgniteCheckedException {
+ /** {@inheritDoc} */
+ @Override public void readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart) throws IgniteCheckedException {
checkpointReadLock();
try {
+ if (!F.isEmpty(cachesToStart)) {
+ for (DynamicCacheDescriptor desc : cachesToStart) {
+ if (CU.affinityNode(cctx.localNode(), desc.cacheConfiguration().getNodeFilter()))
+ storeMgr.initializeForCache(desc.groupDescriptor(), new StoredCacheData(desc.cacheConfiguration()));
+ }
+ }
+
CheckpointStatus status = readCheckpointStatus();
// First, bring memory to the last consistent checkpoint state if needed.
@@ -774,13 +719,10 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
boolean isSrvNode = !cctx.kernalContext().clientNode();
- boolean clusterStatusActive = cctx.kernalContext().state().active();
-
- boolean clusterInTransitionStateToActive = fut.newClusterState() == ClusterState.ACTIVE;
+ boolean clusterInTransitionStateToActive = fut.activateCluster();
// Before local node join event.
- if (clusterInTransitionStateToActive ||
- (joinEvt && locNode && isSrvNode && clusterStatusActive))
+ if (clusterInTransitionStateToActive || (joinEvt && locNode && isSrvNode))
restoreState();
if (cctx.kernalContext().query().moduleEnabled()) {
@@ -1579,9 +1521,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())
+ 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/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index 4e322b9..7a38b61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -135,10 +135,7 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple
/** {@inheritDoc} */
@Override protected CacheDataStore createCacheDataStore0(final int p)
throws IgniteCheckedException {
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)ctx.database();
-
- boolean exists = ctx.pageStore() != null
- && ctx.pageStore().exists(grp.groupId(), p);
+ boolean exists = ctx.pageStore() != null && ctx.pageStore().exists(grp.groupId(), p);
return new GridCacheDataStore(p, exists);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 f04c278..c5f174c 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
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.management.JMException;
@@ -41,8 +42,10 @@ import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
import org.apache.ignite.internal.pagemem.PageMemory;
import org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl;
import org.apache.ignite.internal.processors.cache.CacheGroupContext;
+import org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor;
import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
import org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.persistence.evict.FairFifoPageEvictionTracker;
import org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker;
import org.apache.ignite.internal.processors.cache.persistence.evict.PageEvictionTracker;
@@ -51,7 +54,6 @@ import org.apache.ignite.internal.processors.cache.persistence.evict.RandomLruPa
import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList;
import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeListImpl;
import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.LT;
@@ -100,13 +102,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getMemoryConfiguration() == null)
return;
- init();
- }
-
- /**
- * @throws IgniteCheckedException If failed.
- */
- public void init() throws IgniteCheckedException {
MemoryConfiguration memCfg = cctx.kernalContext().config().getMemoryConfiguration();
assert memCfg != null;
@@ -114,14 +109,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
validateConfiguration(memCfg);
pageSize = memCfg.getPageSize();
-
- initPageMemoryPolicies(memCfg);
-
- registerMetricsMBeans();
-
- startMemoryPolicies();
-
- initPageMemoryDataStructures(memCfg);
}
/**
@@ -149,12 +136,12 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
) {
try {
U.registerMBean(
- cfg.getMBeanServer(),
- cfg.getIgniteInstanceName(),
- "MemoryMetrics",
- memPlcCfg.getName(),
- new MemoryMetricsMXBeanImpl(memMetrics, memPlcCfg),
- MemoryMetricsMXBean.class);
+ cfg.getMBeanServer(),
+ cfg.getIgniteInstanceName(),
+ "MemoryMetrics",
+ memPlcCfg.getName(),
+ new MemoryMetricsMXBeanImpl(memMetrics, memPlcCfg),
+ MemoryMetricsMXBean.class);
}
catch (JMException e) {
U.error(log, "Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'", e);
@@ -163,6 +150,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());
@@ -554,13 +542,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
}
/**
- * @throws IgniteCheckedException If failed.
- */
- public void initDataBase() throws IgniteCheckedException {
- // No-op.
- }
-
- /**
* @return collection of all configured {@link MemoryPolicy policies}.
*/
public Collection<MemoryPolicy> memoryPolicies() {
@@ -592,6 +573,14 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
}
/**
+ * @param cachesToStart Started caches.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void readCheckpointAndRestoreMemory(List<DynamicCacheDescriptor> cachesToStart) throws IgniteCheckedException {
+ // No-op.
+ }
+
+ /**
* @param memPlcName Name of {@link MemoryPolicy} to obtain {@link MemoryMetrics} for.
* @return {@link MemoryMetrics} snapshot for specified {@link MemoryPolicy} or {@code null} if
* no {@link MemoryPolicy} is configured for specified name.
@@ -947,11 +936,24 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
/** {@inheritDoc} */
@Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
- start0();
+ if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getMemoryConfiguration() == null)
+ return;
+
+ MemoryConfiguration memCfg = cctx.kernalContext().config().getMemoryConfiguration();
+
+ assert memCfg != null;
+
+ initPageMemoryPolicies(memCfg);
+
+ registerMetricsMBeans();
+
+ startMemoryPolicies();
+
+ initPageMemoryDataStructures(memCfg);
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
stop0(false);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheSnapshotManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheSnapshotManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheSnapshotManager.java
index ad804cb..cce6f55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheSnapshotManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/IgniteCacheSnapshotManager.java
@@ -124,7 +124,7 @@ public class IgniteCacheSnapshotManager extends GridCacheSharedManagerAdapter im
FullPageId fullId,
PageMemory pageMem
) throws IgniteCheckedException {
-
+ // No-op.
}
/**
@@ -135,14 +135,16 @@ public class IgniteCacheSnapshotManager extends GridCacheSharedManagerAdapter im
ByteBuffer pageBuf,
Integer tag
) throws IgniteCheckedException {
-
+ // No-op.
}
+ /** {@inheritDoc} */
@Override public void onActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+ // No-op.
}
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
-
+ /** {@inheritDoc} */
+ @Override public void onDeActivate(GridKernalContext kctx) {
+ // No-op.
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
index f908512..28bf6e4 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java
@@ -162,7 +162,7 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
}
/** {@inheritDoc} */
- @Override public void onDeActivate(GridKernalContext kctx) throws IgniteCheckedException {
+ @Override public void onDeActivate(GridKernalContext kctx) {
if (log.isDebugEnabled())
log.debug("DeActivate page store manager [id=" + cctx.localNodeId() +
" topVer=" + cctx.discovery().topologyVersionEx() + " ]");
@@ -208,18 +208,17 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
/** {@inheritDoc} */
@Override public void storeCacheData(
- CacheGroupDescriptor grpDesc,
StoredCacheData cacheData
) throws IgniteCheckedException {
- File cacheWorkDir = cacheWorkDirectory(grpDesc, cacheData.config());
+ File cacheWorkDir = cacheWorkDirectory(cacheData.config());
File file;
checkAndInitCacheWorkDir(cacheWorkDir);
assert cacheWorkDir.exists() : "Work directory does not exist: " + cacheWorkDir;
- if (grpDesc.sharedGroup())
+ if (cacheData.config().getGroupName() != null)
file = new File(cacheWorkDir, cacheData.config().getName() + CACHE_DATA_FILENAME);
else
file = new File(cacheWorkDir, CACHE_DATA_FILENAME);
@@ -333,14 +332,13 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
}
/**
- * @param grpDesc Cache group descriptor.
* @param ccfg Cache configuration.
* @return Cache work directory.
*/
- private File cacheWorkDirectory(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) {
+ private File cacheWorkDirectory(CacheConfiguration ccfg) {
String dirName;
- if (grpDesc.sharedGroup())
+ if (ccfg.getGroupName() != null)
dirName = CACHE_GRP_DIR_PREFIX + ccfg.getGroupName();
else
dirName = CACHE_DIR_PREFIX + ccfg.getName();
@@ -357,7 +355,7 @@ public class FilePageStoreManager extends GridCacheSharedManagerAdapter implemen
private CacheStoreHolder initForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException {
assert !grpDesc.sharedGroup() || ccfg.getGroupName() != null : ccfg.getName();
- File cacheWorkDir = cacheWorkDirectory(grpDesc, ccfg);
+ File cacheWorkDir = cacheWorkDirectory(ccfg);
boolean dirExisted = checkAndInitCacheWorkDir(cacheWorkDir);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index f877a14..8993112 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -288,14 +288,6 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter impl
}
}
- /** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- super.onKernalStart0(reconnect);
-
- if (!cctx.kernalContext().clientNode() && cctx.kernalContext().state().active())
- archiver.start();
- }
-
/**
* @return Consistent ID.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
index 63228a0..7f859a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheDistributedQueryManager.java
@@ -560,7 +560,7 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
final Object topic = topic(cctx.nodeId(), req.id());
- cctx.io().addOrderedCacheHandler(topic, resHnd);
+ cctx.io().addOrderedCacheHandler(cctx.shared(), topic, resHnd);
fut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override public void apply(IgniteInternalFuture<?> fut) {
@@ -744,7 +744,7 @@ public class GridCacheDistributedQueryManager<K, V> extends GridCacheQueryManage
final Object topic = topic(cctx.nodeId(), req.id());
- cctx.io().addOrderedCacheHandler(topic, resHnd);
+ cctx.io().addOrderedCacheHandler(cctx.shared(), topic, resHnd);
fut.listen(new CI1<IgniteInternalFuture<?>>() {
@Override public void apply(IgniteInternalFuture<?> fut) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index 62ead23..8ff2f5a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -34,7 +34,6 @@ import javax.cache.integration.CacheWriterException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cache.store.CacheStoreSession;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 bc2e49a..269925d 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
@@ -88,12 +88,6 @@ public class GridCacheVersionManager extends GridCacheSharedManagerAdapter {
}
/** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- for (ClusterNode n : cctx.discovery().remoteNodes())
- onReceived(n.id(), n.metrics().getLastDataVersion());
- }
-
- /** {@inheritDoc} */
@Override protected void stop0(boolean cancel) {
cctx.gridEvents().removeLocalEventListener(discoLsnr, EVT_NODE_METRICS_UPDATED);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index 1dd47ed..dad6728 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -44,11 +44,6 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
public void onContinuousProcessorStarted(GridKernalContext ctx) throws IgniteCheckedException;
/**
- * @throws IgniteCheckedException If failed.
- */
- public void onUtilityCacheStarted() throws IgniteCheckedException;
-
- /**
* @param typeName Type name.
* @return Type ID.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 67e14dc..70711e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -307,11 +307,6 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
}
/** {@inheritDoc} */
- @Override public void onUtilityCacheStarted() throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
@Override public int typeId(String typeName) {
return 0;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..0771198
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateFinishMessage.java
@@ -0,0 +1,86 @@
+/*
+ * 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.cluster;
+
+import java.util.UUID;
+import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public class ChangeGlobalStateFinishMessage implements DiscoveryCustomMessage {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** 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;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public DiscoveryCustomMessage ackMessage() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMutable() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ChangeGlobalStateFinishMessage.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..6579399
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ChangeGlobalStateMessage.java
@@ -0,0 +1,140 @@
+/*
+ * 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.cluster;
+
+import java.util.List;
+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;
+
+/**
+ * Message represent request for change cluster global state.
+ */
+public class ChangeGlobalStateMessage implements DiscoveryCustomMessage {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Custom message ID. */
+ private IgniteUuid id = IgniteUuid.randomUuid();
+
+ /** Request ID */
+ private UUID reqId;
+
+ /** Initiator node ID. */
+ private UUID initiatingNodeId;
+
+ /** If true activate else deactivate. */
+ private boolean activate;
+
+ /** Configurations read from persistent store. */
+ private List<StoredCacheData> storedCfgs;
+
+ /** */
+ @GridToStringExclude
+ private transient ExchangeActions exchangeActions;
+
+ /**
+ * @param reqId 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 reqId,
+ UUID initiatingNodeId,
+ @Nullable List<StoredCacheData> storedCfgs,
+ boolean activate
+ ) {
+ assert reqId != null;
+ assert initiatingNodeId != null;
+
+ this.reqId = reqId;
+ this.initiatingNodeId = initiatingNodeId;
+ this.storedCfgs = storedCfgs;
+ this.activate = activate;
+ }
+
+ /**
+ * @return Configurations read from persistent store..
+ */
+ @Nullable public List<StoredCacheData> storedCacheConfigurations() {
+ return storedCfgs;
+ }
+
+ /**
+ * @return Cache updates to be executed on exchange. If {@code null} exchange is not needed.
+ */
+ @Nullable public ExchangeActions exchangeActions() {
+ return exchangeActions;
+ }
+
+ /**
+ * @param exchangeActions Cache updates to be executed on exchange.
+ */
+ void exchangeActions(ExchangeActions exchangeActions) {
+ assert exchangeActions != null && !exchangeActions.empty() : exchangeActions;
+
+ this.exchangeActions = exchangeActions;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteUuid id() {
+ return id;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public DiscoveryCustomMessage ackMessage() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMutable() {
+ return false;
+ }
+
+ /**
+ * @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 reqId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ChangeGlobalStateMessage.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
index ad95a78..dc503fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
@@ -270,7 +270,6 @@ public class ClusterProcessor extends GridProcessorAdapter {
dataBag.addNodeSpecificData(CLUSTER_PROC.ordinal(), getDiscoveryData());
}
-
/**
* @return Discovery data.
*/
@@ -314,7 +313,7 @@ public class ClusterProcessor extends GridProcessorAdapter {
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
if (notifyEnabled.get()) {
try {
verChecker = new GridUpdateNotifier(ctx.igniteInstanceName(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..71bf90b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/DiscoveryDataClusterState.java
@@ -0,0 +1,157 @@
+/*
+ * 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.cluster;
+
+import java.io.Serializable;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Discovery data related to cluster state.
+ */
+public class DiscoveryDataClusterState implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final boolean active;
+
+ /** */
+ private final UUID transitionReqId;
+
+ /** Topology version for state change exchange. */
+ @GridToStringInclude
+ private final AffinityTopologyVersion transitionTopVer;
+
+ /** Nodes participating in state change exchange. */
+ @GridToStringExclude
+ private final Set<UUID> transitionNodes;
+
+ /** Local flag for state transition result (global state is updated asynchronously by custom message). */
+ private transient volatile Boolean transitionRes;
+
+ /**
+ * @param active Current status.
+ * @return State instance.
+ */
+ static DiscoveryDataClusterState createState(boolean active) {
+ return new DiscoveryDataClusterState(active, null, null, null);
+ }
+
+ /**
+ * @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) {
+ assert transitionReqId != null;
+ assert transitionTopVer != null;
+ assert !F.isEmpty(transitionNodes) : transitionNodes;
+
+ return new DiscoveryDataClusterState(active, transitionReqId, transitionTopVer, transitionNodes);
+ }
+
+ /**
+ * @param active New state.
+ * @param transitionReqId State change request ID.
+ * @param transitionTopVer State change topology version.
+ * @param transitionNodes Nodes participating in state change exchange.
+ */
+ private DiscoveryDataClusterState(boolean active,
+ @Nullable UUID transitionReqId,
+ @Nullable AffinityTopologyVersion transitionTopVer,
+ @Nullable Set<UUID> transitionNodes) {
+ this.active = active;
+ this.transitionReqId = transitionReqId;
+ this.transitionTopVer = transitionTopVer;
+ this.transitionNodes = transitionNodes;
+ }
+
+ /**
+ * @return Local flag for state transition result (global state is updated asynchronously by custom message).
+ */
+ @Nullable public Boolean transitionResult() {
+ return transitionRes;
+ }
+
+ /**
+ * Discovery cluster state is changed asynchronously by discovery message, this methods changes local status
+ * for public API calls.
+ *
+ * @param reqId Request ID.
+ * @param active New cluster state.
+ */
+ public void setTransitionResult(UUID reqId, boolean active) {
+ if (reqId.equals(transitionReqId)) {
+ assert transitionRes == null : this;
+
+ transitionRes = active;
+ }
+ }
+
+ /**
+ * @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;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DiscoveryDataClusterState.class, this);
+ }
+}
[5/7] ignite git commit: Reworked cluster activation/deactivation.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
index 6d5eaf3..2fd8780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
@@ -83,15 +83,15 @@ public class DynamicCacheChangeRequest implements Serializable {
/** */
private UUID rcvdFrom;
- /** Cache state. Set to non-null when global state is changed. */
- private ClusterState state;
-
/** Reset lost partitions flag. */
private boolean resetLostPartitions;
/** Dynamic schema. */
private QuerySchema schema;
+ /** */
+ private transient boolean locallyConfigured;
+
/**
* @param reqId Unique request ID.
* @param cacheName Cache stop name.
@@ -100,7 +100,6 @@ public class DynamicCacheChangeRequest implements Serializable {
public DynamicCacheChangeRequest(UUID reqId, String cacheName, UUID initiatingNodeId) {
assert reqId != null;
assert cacheName != null;
- assert initiatingNodeId != null;
this.reqId = reqId;
this.cacheName = cacheName;
@@ -108,21 +107,6 @@ public class DynamicCacheChangeRequest implements Serializable {
}
/**
- * @param reqId Unique request ID.
- * @param state New cluster state.
- * @param initiatingNodeId Initiating node ID.
- */
- public DynamicCacheChangeRequest(UUID reqId, ClusterState state, UUID initiatingNodeId) {
- assert reqId != null;
- assert state != null;
- assert initiatingNodeId != null;
-
- this.reqId = reqId;
- this.state = state;
- this.initiatingNodeId = initiatingNodeId;
- }
-
- /**
* @param ctx Context.
* @param cacheName Cache name.
* @return Request to reset lost partitions.
@@ -183,20 +167,6 @@ public class DynamicCacheChangeRequest implements Serializable {
}
/**
- * @return State.
- */
- public ClusterState state() {
- return state;
- }
-
- /**
- * @return {@code True} if global caches state is changes.
- */
- public boolean globalStateChange() {
- return state != null;
- }
-
- /**
* @param template {@code True} if this is request for adding template configuration.
*/
public void template(boolean template) {
@@ -253,7 +223,7 @@ public class DynamicCacheChangeRequest implements Serializable {
}
/**
- *
+ * @return Destroy flag.
*/
public boolean destroy(){
return destroy;
@@ -420,6 +390,20 @@ public class DynamicCacheChangeRequest implements Serializable {
this.schema = schema != null ? schema.copy() : null;
}
+ /**
+ * @return Locally configured flag.
+ */
+ public boolean locallyConfigured() {
+ return locallyConfigured;
+ }
+
+ /**
+ * @param locallyConfigured Locally configured flag.
+ */
+ public void locallyConfigured(boolean locallyConfigured) {
+ this.locallyConfigured = locallyConfigured;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return "DynamicCacheChangeRequest [cacheName=" + cacheName() +
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 9caf9aa..e9ece5a 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
@@ -50,7 +50,7 @@ public class ExchangeActions {
private Map<String, ActionData> cachesToResetLostParts;
/** */
- private ClusterState newState;
+ private StateChangeRequest stateChangeReq;
/**
* @param grpId Group ID.
@@ -89,7 +89,7 @@ public class ExchangeActions {
/**
* @return New caches start requests.
*/
- Collection<ActionData> cacheStartRequests() {
+ public Collection<ActionData> cacheStartRequests() {
return cachesToStart != null ? cachesToStart.values() : Collections.<ActionData>emptyList();
}
@@ -184,19 +184,31 @@ public class ExchangeActions {
}
/**
- * @param state New cluster state.
+ * @param stateChange Cluster state change request.
*/
- void newClusterState(ClusterState state) {
- assert state != null;
+ public void stateChangeRequest(StateChangeRequest stateChange) {
+ this.stateChangeReq = stateChange;
+ }
+
+ /**
+ * @return {@code True} if has deactivate request.
+ */
+ public boolean deactivate() {
+ return stateChangeReq != null && !stateChangeReq.activate();
+ }
- newState = state;
+ /**
+ * @return {@code True} if has activate request.
+ */
+ public boolean activate() {
+ return stateChangeReq != null && stateChangeReq.activate();
}
/**
- * @return New cluster state if state change was requested.
+ * @return Cluster state change request.
*/
- @Nullable public ClusterState newClusterState() {
- return newState;
+ @Nullable public StateChangeRequest stateChangeRequest() {
+ return stateChangeReq;
}
/**
@@ -328,13 +340,14 @@ public class ExchangeActions {
F.isEmpty(cachesToStop) &&
F.isEmpty(cacheGrpsToStart) &&
F.isEmpty(cacheGrpsToStop) &&
- F.isEmpty(cachesToResetLostParts);
+ F.isEmpty(cachesToResetLostParts) &&
+ stateChangeReq == null;
}
/**
*
*/
- static class ActionData {
+ public static class ActionData {
/** */
private final DynamicCacheChangeRequest req;
@@ -429,6 +442,6 @@ public class ExchangeActions {
", startGrps=" + startGrps +
", stopGrps=" + stopGrps +
", resetParts=" + (cachesToResetLostParts != null ? cachesToResetLostParts.keySet() : null) +
- ", newState=" + newState + ']';
+ ", stateChangeRequest=" + stateChangeReq + ']';
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
index a967305..a9692f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.UUID;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.CacheEvent;
-import org.apache.ignite.events.CacheRebalancingEvent;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.util.typedef.F;
@@ -32,7 +31,6 @@ import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_UNLOADED;
import static org.apache.ignite.events.EventType.EVT_CACHE_STARTED;
import static org.apache.ignite.events.EventType.EVT_CACHE_STOPPED;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 8ba10a2..7735f74 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.processors.cache;
import java.util.Collection;
-import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.eviction.EvictionFilter;
import org.apache.ignite.cache.eviction.EvictionPolicy;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 2de3808..f9d1114 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -1405,30 +1405,33 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
}
/**
+ * @param cctx Context.
* @param topic Topic.
* @param c Handler.
*/
- public void addOrderedCacheHandler(Object topic, IgniteBiInClosure<UUID, ? extends GridCacheIdMessage> c) {
- addOrderedHandler(false, topic, c);
+ public void addOrderedCacheHandler(GridCacheSharedContext cctx, Object topic, IgniteBiInClosure<UUID, ? extends GridCacheIdMessage> c) {
+ addOrderedHandler(cctx, false, topic, c);
}
/**
+ * @param cctx Context.
* @param topic Topic.
* @param c Handler.
*/
- public void addOrderedCacheGroupHandler(Object topic, IgniteBiInClosure<UUID, ? extends GridCacheGroupIdMessage> c) {
- addOrderedHandler(true, topic, c);
+ public void addOrderedCacheGroupHandler(GridCacheSharedContext cctx, Object topic, IgniteBiInClosure<UUID, ? extends GridCacheGroupIdMessage> c) {
+ addOrderedHandler(cctx, true, topic, c);
}
/**
* Adds ordered message handler.
*
+ * @param cctx Context.
* @param cacheGrp {@code True} if cache group message, {@code false} if cache message.
* @param topic Topic.
* @param c Handler.
*/
@SuppressWarnings({"unchecked"})
- private void addOrderedHandler(boolean cacheGrp, Object topic, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c) {
+ private void addOrderedHandler(GridCacheSharedContext cctx, boolean cacheGrp, Object topic, IgniteBiInClosure<UUID, ? extends GridCacheMessage> c) {
MessageHandlers msgHandlers = cacheGrp ? grpHandlers : cacheHandlers;
IgniteLogger log0 = log;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 24433de..a6907b9 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
@@ -274,10 +274,11 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
pendingExplicit = GridConcurrentFactory.newMap();
}
- /** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- if (!reconnect)
- cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
+ /**
+ * Cache futures listener must be registered after communication listener.
+ */
+ public void registerEventListener() {
+ cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 93310e3..22345d2 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
@@ -59,6 +59,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.events.DiscoveryCustomEvent;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
+import org.apache.ignite.internal.managers.discovery.DiscoveryLocalJoinData;
import org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener;
import org.apache.ignite.internal.pagemem.snapshot.StartSnapshotOperationAckDiscoveryMessage;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -81,6 +82,8 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Ign
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
import org.apache.ignite.internal.processors.query.schema.SchemaNodeLeaveExchangeWorkerTask;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.util.GridListSet;
@@ -192,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<>();
+
/** Discovery listener. */
private final DiscoveryEventListener discoLsnr = new DiscoveryEventListener() {
@Override public void onEvent(DiscoveryEvent evt, DiscoCache cache) {
@@ -199,109 +205,53 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
return;
try {
- ClusterNode loc = cctx.localNode();
-
- assert evt.type() == EVT_NODE_JOINED || evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED ||
- evt.type() == EVT_DISCOVERY_CUSTOM_EVT;
-
- final ClusterNode n = evt.eventNode();
-
- GridDhtPartitionExchangeId exchId = null;
- GridDhtPartitionsExchangeFuture exchFut = null;
-
- if (evt.type() != EVT_DISCOVERY_CUSTOM_EVT) {
- assert !loc.id().equals(n.id());
-
- if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) {
- assert cctx.discovery().node(n.id()) == null;
-
- // Avoid race b/w initial future add and discovery event.
- GridDhtPartitionsExchangeFuture initFut = null;
-
- if (readyTopVer.get().equals(AffinityTopologyVersion.NONE)) {
- initFut = exchangeFuture(initialExchangeId(), null, null, null, null);
-
- initFut.onNodeLeft(n);
- }
-
- for (GridDhtPartitionsExchangeFuture f : exchFuts.values()) {
- if (f != initFut)
- f.onNodeLeft(n);
- }
- }
+ if (evt.type() == EVT_DISCOVERY_CUSTOM_EVT &&
+ (((DiscoveryCustomEvent)evt).customMessage() instanceof ChangeGlobalStateMessage)) {
+ ChangeGlobalStateMessage stateChangeMsg =
+ (ChangeGlobalStateMessage)((DiscoveryCustomEvent)evt).customMessage();
- assert evt.type() != EVT_NODE_JOINED || n.order() > loc.order() :
- "Node joined with smaller-than-local " +
- "order [newOrder=" + n.order() + ", locOrder=" + loc.order() + ']';
+ if (stateChangeMsg.exchangeActions() == null)
+ return;
- exchId = exchangeId(n.id(),
- affinityTopologyVersion(evt),
- evt.type());
+ onDiscoveryEvent(evt, cache);
- exchFut = exchangeFuture(exchId, evt, cache,null, null);
+ return;
}
- else {
- DiscoveryCustomMessage customMsg = ((DiscoveryCustomEvent)evt).customMessage();
+ if (evt.type() == EVT_DISCOVERY_CUSTOM_EVT &&
+ (((DiscoveryCustomEvent)evt).customMessage() instanceof ChangeGlobalStateFinishMessage)) {
+ ChangeGlobalStateFinishMessage stateFinishMsg =
+ (ChangeGlobalStateFinishMessage)((DiscoveryCustomEvent)evt).customMessage();
- if (customMsg instanceof DynamicCacheChangeBatch) {
- DynamicCacheChangeBatch batch = (DynamicCacheChangeBatch)customMsg;
-
- ExchangeActions exchActions = batch.exchangeActions();
-
- if (exchActions != null) {
- exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+ if (stateFinishMsg.clusterActive()) {
+ for (PendingDiscoveryEvent pendingEvt : pendingEvts) {
+ if (log.isDebugEnabled())
+ log.debug("Process pending event: " + pendingEvt.event());
- exchFut = exchangeFuture(exchId, evt, cache, exchActions, null);
+ onDiscoveryEvent(pendingEvt.event(), pendingEvt.discoCache());
}
}
- else if (customMsg instanceof CacheAffinityChangeMessage) {
- CacheAffinityChangeMessage msg = (CacheAffinityChangeMessage)customMsg;
-
- if (msg.exchangeId() == null) {
- if (msg.exchangeNeeded()) {
- exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
-
- exchFut = exchangeFuture(exchId, evt, cache, null, msg);
- }
- }
- else if (msg.exchangeId().topologyVersion().topologyVersion() >= cctx.discovery().localJoinEvent().topologyVersion())
- exchangeFuture(msg.exchangeId(), null, null, null, null)
- .onAffinityChangeMessage(evt.eventNode(), msg);
+ else {
+ for (PendingDiscoveryEvent pendingEvt : pendingEvts)
+ processEventInactive(pendingEvt.event(), pendingEvt.discoCache());
}
- else if (customMsg instanceof StartSnapshotOperationAckDiscoveryMessage
- && ((StartSnapshotOperationAckDiscoveryMessage)customMsg).needExchange()) {
- exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
- exchFut = exchangeFuture(exchId, evt, null, null, null);
- }
- else {
- // Process event as custom discovery task if needed.
- CachePartitionExchangeWorkerTask task =
- cctx.cache().exchangeTaskForCustomDiscoveryMessage(customMsg);
+ pendingEvts.clear();
- if (task != null)
- exchWorker.addCustomTask(task);
- }
+ return;
}
- if (exchId != null) {
+ if (cache.state().transition()) {
if (log.isDebugEnabled())
- log.debug("Discovery event (will start exchange): " + exchId);
-
- // Event callback - without this callback future will never complete.
- exchFut.onEvent(exchId, evt, cache);
+ log.debug("Add pending event: " + evt);
- // Start exchange process.
- addFuture(exchFut);
- }
- else {
- if (log.isDebugEnabled())
- log.debug("Do not start exchange for discovery event: " + evt);
+ pendingEvts.add(new PendingDiscoveryEvent(evt, cache));
}
+ else if (cache.state().active())
+ onDiscoveryEvent(evt, cache);
+ else
+ processEventInactive(evt, cache);
- // Notify indexing engine about node leave so that we can re-map coordinator accordingly.
- if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED)
- exchWorker.addCustomTask(new SchemaNodeLeaveExchangeWorkerTask(evt.eventNode()));
+ notifyNodeFail(evt);
}
finally {
leaveBusy();
@@ -309,6 +259,29 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
};
+ /**
+ * @param evt Event.
+ */
+ private void notifyNodeFail(DiscoveryEvent evt) {
+ if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) {
+ final ClusterNode n = evt.eventNode();
+
+ assert cctx.discovery().node(n.id()) == null;
+
+ for (GridDhtPartitionsExchangeFuture f : exchFuts.values())
+ f.onNodeLeft(n);
+ }
+ }
+
+ /**
+ * @param evt Event.
+ * @param cache Discovery data cache.
+ */
+ private void processEventInactive(DiscoveryEvent evt, DiscoCache cache) {
+ if (log.isDebugEnabled())
+ log.debug("Ignore event, cluster is inactive: " + evt);
+ }
+
/** {@inheritDoc} */
@Override protected void start0() throws IgniteCheckedException {
super.start0();
@@ -338,12 +311,158 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
processSinglePartitionRequest(node, msg);
}
});
+
+ if (!cctx.kernalContext().clientNode()) {
+ for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) {
+ final int idx = cnt;
+
+ cctx.io().addOrderedCacheGroupHandler(cctx, rebalanceTopic(cnt), new CI2<UUID, GridCacheGroupIdMessage>() {
+ @Override public void apply(final UUID id, final GridCacheGroupIdMessage m) {
+ if (!enterBusy())
+ return;
+
+ try {
+ CacheGroupContext grp = cctx.cache().cacheGroup(m.groupId());
+
+ if (grp != null) {
+ if (m instanceof GridDhtPartitionSupplyMessage) {
+ grp.preloader().handleSupplyMessage(idx, id, (GridDhtPartitionSupplyMessage) m);
+
+ return;
+ }
+ else if (m instanceof GridDhtPartitionDemandMessage) {
+ grp.preloader().handleDemandMessage(idx, id, (GridDhtPartitionDemandMessage) m);
+
+ return;
+ }
+ }
+
+ U.error(log, "Unsupported message type: " + m.getClass().getName());
+ }
+ finally {
+ leaveBusy();
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Callback for local join event (needed since regular event for local join is not generated).
+ *
+ * @param evt Event.
+ * @param cache Cache.
+ */
+ public void onLocalJoin(DiscoveryEvent evt, DiscoCache cache) {
+ discoLsnr.onEvent(evt, cache);
+ }
+
+ /**
+ * @param evt Event.
+ * @param cache Discovery data cache.
+ */
+ private void onDiscoveryEvent(DiscoveryEvent evt, DiscoCache cache) {
+ ClusterNode loc = cctx.localNode();
+
+ assert evt.type() == EVT_NODE_JOINED || evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED ||
+ evt.type() == EVT_DISCOVERY_CUSTOM_EVT;
+
+ final ClusterNode n = evt.eventNode();
+
+ GridDhtPartitionExchangeId exchId = null;
+ GridDhtPartitionsExchangeFuture exchFut = null;
+
+ if (evt.type() != EVT_DISCOVERY_CUSTOM_EVT) {
+ assert evt.type() != EVT_NODE_JOINED || n.isLocal() || n.order() > loc.order() :
+ "Node joined with smaller-than-local " +
+ "order [newOrder=" + n.order() + ", locOrder=" + loc.order() + ']';
+
+ exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+
+ exchFut = exchangeFuture(exchId, evt, cache,null, null);
+ }
+ else {
+ DiscoveryCustomMessage customMsg = ((DiscoveryCustomEvent)evt).customMessage();
+
+ if (customMsg instanceof ChangeGlobalStateMessage) {
+ ChangeGlobalStateMessage stateChangeMsg = (ChangeGlobalStateMessage)customMsg;
+
+ ExchangeActions exchActions = stateChangeMsg.exchangeActions();
+
+ if (exchActions != null) {
+ exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+
+ exchFut = exchangeFuture(exchId, evt, cache, exchActions, null);
+ }
+ }
+ else if (customMsg instanceof DynamicCacheChangeBatch) {
+ DynamicCacheChangeBatch batch = (DynamicCacheChangeBatch)customMsg;
+
+ ExchangeActions exchActions = batch.exchangeActions();
+
+ if (exchActions != null) {
+ exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+
+ exchFut = exchangeFuture(exchId, evt, cache, exchActions, null);
+ }
+ }
+ else if (customMsg instanceof CacheAffinityChangeMessage) {
+ CacheAffinityChangeMessage msg = (CacheAffinityChangeMessage)customMsg;
+
+ if (msg.exchangeId() == null) {
+ if (msg.exchangeNeeded()) {
+ exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+
+ exchFut = exchangeFuture(exchId, evt, cache, null, msg);
+ }
+ }
+ else if (msg.exchangeId().topologyVersion().topologyVersion() >= cctx.discovery().localJoinEvent().topologyVersion())
+ exchangeFuture(msg.exchangeId(), null, null, null, null)
+ .onAffinityChangeMessage(evt.eventNode(), msg);
+ }
+ else if (customMsg instanceof StartSnapshotOperationAckDiscoveryMessage
+ && ((StartSnapshotOperationAckDiscoveryMessage)customMsg).needExchange()) {
+ exchId = exchangeId(n.id(), affinityTopologyVersion(evt), evt.type());
+
+ exchFut = exchangeFuture(exchId, evt, null, null, null);
+ }
+ else {
+ // Process event as custom discovery task if needed.
+ CachePartitionExchangeWorkerTask task =
+ cctx.cache().exchangeTaskForCustomDiscoveryMessage(customMsg);
+
+ if (task != null)
+ exchWorker.addCustomTask(task);
+ }
+ }
+
+ if (exchId != null) {
+ if (log.isDebugEnabled())
+ log.debug("Discovery event (will start exchange): " + exchId);
+
+ // Event callback - without this callback future will never complete.
+ exchFut.onEvent(exchId, evt, cache);
+
+ // Start exchange process.
+ addFuture(exchFut);
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Do not start exchange for discovery event: " + evt);
+ }
+
+ notifyNodeFail(evt);
+
+ // Notify indexing engine about node leave so that we can re-map coordinator accordingly.
+ if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED)
+ exchWorker.addCustomTask(new SchemaNodeLeaveExchangeWorkerTask(evt.eventNode()));
}
/**
* @param task Task to run in exchange worker thread.
*/
- public void addCustomTask(CachePartitionExchangeWorkerTask task) {
+ void addCustomTask(CachePartitionExchangeWorkerTask task) {
assert task != null;
exchWorker.addCustomTask(task);
@@ -371,9 +490,14 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
return exchangeId(cctx.localNode().id(), startTopVer, EVT_NODE_JOINED);
}
- /** {@inheritDoc} */
- @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- super.onKernalStart0(reconnect);
+ /**
+ * @param active Cluster state.
+ * @param reconnect Reconnect flag.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void onKernalStart(boolean active, boolean reconnect) throws IgniteCheckedException {
+ for (ClusterNode n : cctx.discovery().remoteNodes())
+ cctx.versions().onReceived(n.id(), n.metrics().getLastDataVersion());
ClusterNode loc = cctx.localNode();
@@ -381,79 +505,49 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
assert startTime > 0;
- // Generate dummy discovery event for local node joining.
- T2<DiscoveryEvent, DiscoCache> locJoin = cctx.discovery().localJoin();
-
- DiscoveryEvent discoEvt = locJoin.get1();
- DiscoCache discoCache = locJoin.get2();
-
- GridDhtPartitionExchangeId exchId = initialExchangeId();
+ DiscoveryLocalJoinData locJoin = cctx.discovery().localJoin();
- GridDhtPartitionsExchangeFuture fut = exchangeFuture(exchId, discoEvt, discoCache, null, null);
+ GridDhtPartitionsExchangeFuture fut = null;
if (reconnect)
reconnectExchangeFut = new GridFutureAdapter<>();
- exchWorker.addFirstExchangeFuture(fut);
-
- if (!cctx.kernalContext().clientNode()) {
- for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) {
- final int idx = cnt;
-
- cctx.io().addOrderedCacheGroupHandler(rebalanceTopic(cnt), new CI2<UUID, GridCacheGroupIdMessage>() {
- @Override public void apply(final UUID id, final GridCacheGroupIdMessage m) {
- if (!enterBusy())
- return;
-
- try {
- CacheGroupContext grp = cctx.cache().cacheGroup(m.groupId());
-
- if (grp != null) {
- if (m instanceof GridDhtPartitionSupplyMessage) {
- grp.preloader().handleSupplyMessage(idx, id, (GridDhtPartitionSupplyMessage) m);
-
- return;
- }
- else if (m instanceof GridDhtPartitionDemandMessage) {
- grp.preloader().handleDemandMessage(idx, id, (GridDhtPartitionDemandMessage) m);
+ if (active) {
+ DiscoveryEvent discoEvt = locJoin.event();
+ DiscoCache discoCache = locJoin.discoCache();
- return;
- }
- }
+ GridDhtPartitionExchangeId exchId = initialExchangeId();
- U.error(log, "Unsupported message type: " + m.getClass().getName());
- }
- finally {
- leaveBusy();
- }
- }
- });
- }
+ fut = exchangeFuture(exchId, discoEvt, discoCache, null, null);
}
+ else if (reconnect)
+ reconnectExchangeFut.onDone();
new IgniteThread(cctx.igniteInstanceName(), "exchange-worker", exchWorker).start();
if (reconnect) {
- fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
- @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
- try {
- fut.get();
+ if (fut != null) {
+ fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+ @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
+ try {
+ fut.get();
- for (CacheGroupContext grp : cctx.cache().cacheGroups())
- grp.preloader().onInitialExchangeComplete(null);
+ for (CacheGroupContext grp : cctx.cache().cacheGroups())
+ grp.preloader().onInitialExchangeComplete(null);
- reconnectExchangeFut.onDone();
- }
- catch (IgniteCheckedException e) {
- for (CacheGroupContext grp : cctx.cache().cacheGroups())
- grp.preloader().onInitialExchangeComplete(e);
+ reconnectExchangeFut.onDone();
+ }
+ catch (IgniteCheckedException e) {
+ for (CacheGroupContext grp : cctx.cache().cacheGroups())
+ grp.preloader().onInitialExchangeComplete(e);
- reconnectExchangeFut.onDone(e);
+ reconnectExchangeFut.onDone(e);
+ }
}
- }
- });
+ });
+ }
}
- else {
+ else if (fut != null) {
if (log.isDebugEnabled())
log.debug("Beginning to wait on local exchange future: " + fut);
@@ -489,10 +583,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
}
- AffinityTopologyVersion nodeStartVer = new AffinityTopologyVersion(discoEvt.topologyVersion(), 0);
-
for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
- if (nodeStartVer.equals(grp.localStartVersion()))
+ if (locJoin.joinTopologyVersion().equals(grp.localStartVersion()))
grp.preloader().onInitialExchangeComplete(null);
}
@@ -1669,28 +1761,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.
*/
@@ -1710,15 +1780,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
/**
- * Add first exchange future.
- *
- * @param exchFut Exchange future.
- */
- void addFirstExchangeFuture(GridDhtPartitionsExchangeFuture exchFut) {
- futQ.addFirst(exchFut);
- }
-
- /**
* @param exchFut Exchange future.
*/
void addExchangeFuture(GridDhtPartitionsExchangeFuture exchFut) {
@@ -1946,7 +2007,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
}
- if (!exchFut.skipPreload() && cctx.kernalContext().state().active()) {
+ if (!exchFut.skipPreload() ) {
assignsMap = new HashMap<>();
for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 0f859eb..624dec0 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
@@ -107,6 +107,9 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTransactio
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateFinishMessage;
+import org.apache.ignite.internal.processors.cluster.ChangeGlobalStateMessage;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
import org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor;
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.query.QuerySchema;
@@ -692,36 +695,27 @@ public class GridCacheProcessor extends GridProcessorAdapter {
for (GridCacheSharedManager mgr : sharedCtx.managers())
mgr.start(sharedCtx);
- if (ctx.config().isDaemon()) {
- ctx.state().cacheProcessorStarted(new CacheJoinNodeDiscoveryData(
- IgniteUuid.randomUuid(),
- Collections.<String, CacheInfo>emptyMap(),
- Collections.<String, CacheInfo>emptyMap(),
- false
- ));
-
- return;
- }
-
- Map<String, CacheInfo> caches = new HashMap<>();
+ if (!ctx.isDaemon()) {
+ Map<String, CacheInfo> caches = new HashMap<>();
- Map<String, CacheInfo> templates = new HashMap<>();
+ Map<String, CacheInfo> templates = new HashMap<>();
- addCacheOnJoinFromConfig(caches, templates);
+ addCacheOnJoinFromConfig(caches, templates);
- CacheJoinNodeDiscoveryData discoData = new CacheJoinNodeDiscoveryData(
- IgniteUuid.randomUuid(),
- caches,
- templates,
- startAllCachesOnClientStart()
- );
+ CacheJoinNodeDiscoveryData discoData = new CacheJoinNodeDiscoveryData(
+ IgniteUuid.randomUuid(),
+ caches,
+ templates,
+ startAllCachesOnClientStart()
+ );
- cachesInfo.onStart(discoData);
+ cachesInfo.onStart(discoData);
- if (log.isDebugEnabled())
- log.debug("Started cache processor.");
+ if (log.isDebugEnabled())
+ log.debug("Started cache processor.");
+ }
- ctx.state().cacheProcessorStarted(discoData);
+ ctx.state().cacheProcessorStarted();
}
/**
@@ -830,51 +824,38 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Override public void onKernalStart() throws IgniteCheckedException {
- boolean active = ctx.state().active();
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
+ if (ctx.isDaemon())
+ return;
try {
- boolean checkConsistency =
- !ctx.config().isDaemon() && !getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
+ boolean checkConsistency = !getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
if (checkConsistency)
checkConsistency();
- if (active && cachesInfo.onJoinCacheException() != null)
- throw new IgniteCheckedException(cachesInfo.onJoinCacheException());
-
cachesInfo.onKernalStart(checkConsistency);
- if (active && !ctx.clientNode() && !ctx.isDaemon())
- sharedCtx.database().lock();
-
- // Must start database before start first cache.
- sharedCtx.database().onKernalStart(false);
-
ctx.query().onCacheKernalStart();
- // In shared context, we start exchange manager and wait until processed local join
- // event, all caches which we get on join will be start.
- for (GridCacheSharedManager<?, ?> mgr : sharedCtx.managers()) {
- if (sharedCtx.database() != mgr)
- mgr.onKernalStart(false);
- }
+ sharedCtx.mvcc().registerEventListener();
+
+ sharedCtx.exchange().onKernalStart(active, false);
}
finally {
cacheStartedLatch.countDown();
}
+ if (!ctx.clientNode())
+ addRemovedItemsCleanupTask(Long.getLong(IGNITE_CACHE_REMOVED_ENTRIES_TTL, 10_000));
+
// Escape if cluster inactive.
if (!active)
return;
- if (!ctx.config().isDaemon())
- ctx.cacheObjects().onUtilityCacheStarted();
-
ctx.service().onUtilityCacheStarted();
- final AffinityTopologyVersion startTopVer =
- new AffinityTopologyVersion(ctx.discovery().localJoinEvent().topologyVersion(), 0);
+ final AffinityTopologyVersion startTopVer = ctx.discovery().localJoin().joinTopologyVersion();
final List<IgniteInternalFuture> syncFuts = new ArrayList<>(caches.size());
@@ -894,15 +875,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
});
- // Avoid iterator creation.
- //noinspection ForLoopReplaceableByForEach
for (int i = 0, size = syncFuts.size(); i < size; i++)
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));
}
/**
@@ -969,8 +943,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
for (CacheGroupContext grp : cacheGrps.values())
stopCacheGroup(grp.groupId());
-
- cachesInfo.clearCaches();
}
/**
@@ -1097,7 +1069,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
@Override public IgniteInternalFuture<?> onReconnected(boolean clusterRestarted) throws IgniteCheckedException {
List<GridCacheAdapter> reconnected = new ArrayList<>(caches.size());
- ClusterCachesReconnectResult reconnectRes = cachesInfo.onReconnected();
+ DiscoveryDataClusterState state = ctx.state().clusterState();
+
+ boolean active = state.active() && !state.transition();
+
+ ClusterCachesReconnectResult reconnectRes = cachesInfo.onReconnected(active, state.transition());
final List<GridCacheAdapter> stoppedCaches = new ArrayList<>();
@@ -1135,7 +1111,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
grp.onReconnected();
}
- sharedCtx.onReconnected();
+ sharedCtx.onReconnected(active);
for (GridCacheAdapter cache : reconnected)
cache.context().gate().reconnected(false);
@@ -1750,17 +1726,26 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * @return Caches to be started when this node starts.
+ */
+ public List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> cachesToStartOnLocalJoin() {
+ return cachesInfo.cachesToStartOnLocalJoin();
+ }
+
+ /**
+ * @param caches Caches to start.
* @param exchTopVer Current exchange version.
* @throws IgniteCheckedException If failed.
*/
- public void startCachesOnLocalJoin(AffinityTopologyVersion exchTopVer) throws IgniteCheckedException {
- List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> caches = cachesInfo.cachesToStartOnLocalJoin();
-
+ public void startCachesOnLocalJoin(List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> caches,
+ AffinityTopologyVersion exchTopVer)
+ throws IgniteCheckedException {
if (!F.isEmpty(caches)) {
for (T2<DynamicCacheDescriptor, NearCacheConfiguration> t : caches) {
DynamicCacheDescriptor desc = t.get1();
prepareCacheStart(
+ desc.cacheConfiguration(),
desc,
t.get2(),
exchTopVer
@@ -1787,6 +1772,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (CU.affinityNode(ctx.discovery().localNode(), filter)) {
prepareCacheStart(
+ desc.cacheConfiguration(),
desc,
null,
exchTopVer
@@ -1799,17 +1785,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * @param startCfg Cache configuration to use.
* @param desc Cache descriptor.
* @param reqNearCfg Near configuration if specified for client cache start request.
* @param exchTopVer Current exchange version.
* @throws IgniteCheckedException If failed.
*/
- public void prepareCacheStart(
+ void prepareCacheStart(
+ CacheConfiguration startCfg,
DynamicCacheDescriptor desc,
@Nullable NearCacheConfiguration reqNearCfg,
AffinityTopologyVersion exchTopVer
) throws IgniteCheckedException {
- CacheConfiguration startCfg = desc.cacheConfiguration();
assert !caches.containsKey(startCfg.getName()) : startCfg.getName();
CacheConfiguration ccfg = new CacheConfiguration(startCfg);
@@ -2003,7 +1990,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
sharedCtx.removeCacheContext(ctx);
- onKernalStop(cache, destroy);
+ onKernalStop(cache, true);
stopCache(cache, true, destroy);
@@ -2017,9 +2004,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @param startTopVer Cache start version.
* @param err Cache start error if any.
*/
- void initCacheProxies(
- AffinityTopologyVersion startTopVer, @Nullable
- Throwable err) {
+ void initCacheProxies(AffinityTopologyVersion startTopVer, @Nullable Throwable err) {
for (GridCacheAdapter<?, ?> cache : caches.values()) {
GridCacheContext<?, ?> cacheCtx = cache.context();
@@ -2122,7 +2107,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (exchActions == null)
return;
- if (exchActions.systemCachesStarting() && exchActions.newClusterState() == null)
+ if (exchActions.systemCachesStarting() && exchActions.stateChangeRequest() == null)
ctx.dataStructures().restoreStructuresState(ctx);
if (err == null) {
@@ -2143,9 +2128,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
try {
prepareCacheStop(action.request().cacheName(), action.request().destroy());
-
- if (exchActions.newClusterState() == null)
- ctx.state().onCacheStop(action.request());
}
finally {
sharedCtx.database().checkpointReadUnlock();
@@ -2166,6 +2148,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (!sharedCtx.kernalContext().clientNode())
sharedCtx.database().onCacheGroupsStopped(stoppedGroups);
+
+ if (exchActions.deactivate())
+ sharedCtx.deactivate();
}
}
@@ -2204,10 +2189,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
* @param req Request to complete future for.
+ * @param success Future result.
* @param err Error if any.
*/
void completeCacheStartFuture(DynamicCacheChangeRequest req, boolean success, @Nullable Throwable err) {
- if (req.initiatingNodeId().equals(ctx.localNodeId())) {
+ if (ctx.localNodeId().equals(req.initiatingNodeId())) {
DynamicCacheStartFuture fut = (DynamicCacheStartFuture)pendingFuts.get(req.requestId());
if (fut != null)
@@ -2304,30 +2290,35 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override public void collectGridNodeData(DiscoveryDataBag dataBag) {
- if (ctx.state().active())
- cachesInfo.collectGridNodeData(dataBag);
- else
- ctx.state().collectGridNodeData0(dataBag);
+ cachesInfo.collectGridNodeData(dataBag);
}
/** {@inheritDoc} */
@Override public void onJoiningNodeDataReceived(JoiningNodeDiscoveryData data) {
- if (ctx.state().active())
- cachesInfo.onJoiningNodeDataReceived(data);
-
- ctx.state().onJoiningNodeDataReceived0(data);
+ cachesInfo.onJoiningNodeDataReceived(data);
}
/** {@inheritDoc} */
@Override public void onGridDataReceived(GridDiscoveryData data) {
- if (ctx.state().active()) {
- if (!cachesInfo.disconnectedState())
- cachesInfo.addJoinInfo();
+ cachesInfo.onGridDataReceived(data);
+ }
- cachesInfo.onGridDataReceived(data);
- }
+ /**
+ * @param msg Message.
+ */
+ public void onStateChangeFinish(ChangeGlobalStateFinishMessage msg) {
+ cachesInfo.onStateChangeFinish(msg);
+ }
- ctx.state().onGridDataReceived0(data);
+ /**
+ * @param msg Message.
+ * @param topVer Current topology version.
+ * @throws IgniteCheckedException If configuration validation failed.
+ * @return Exchange actions.
+ */
+ public ExchangeActions onStateChangeRequest(ChangeGlobalStateMessage msg, AffinityTopologyVersion topVer)
+ throws IgniteCheckedException {
+ return cachesInfo.onStateChangeRequest(msg, topVer);
}
/**
@@ -2929,13 +2920,19 @@ 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, ClusterNode node, AffinityTopologyVersion topVer) {
+ public void onDiscoveryEvent(int type,
+ @Nullable DiscoveryCustomMessage customMsg,
+ ClusterNode node,
+ AffinityTopologyVersion topVer,
+ DiscoveryDataClusterState state) {
cachesInfo.onDiscoveryEvent(type, node, topVer);
- sharedCtx.affinity().onDiscoveryEvent(type, node, topVer);
+ sharedCtx.affinity().onDiscoveryEvent(type, customMsg, node, topVer, state);
}
/**
@@ -3214,7 +3211,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
proxy = new IgniteCacheProxy(cacheAdapter.context(), cacheAdapter, null, false);
}
- assert proxy != null;
+ assert proxy != null : name;
return proxy.internalProxy();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 75d03d7..9adca8d 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
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.cache;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -45,7 +46,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopolo
import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
import org.apache.ignite.internal.processors.cache.persistence.IgniteCacheSnapshotManager;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter;
import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
@@ -54,6 +54,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.transactions.TransactionMetricsAdapter;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
import org.apache.ignite.internal.util.GridIntList;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
@@ -156,6 +157,9 @@ public class GridCacheSharedContext<K, V> {
/** Concurrent DHT atomic updates counters. */
private AtomicIntegerArray dhtAtomicUpdCnt;
+ /** */
+ private final List<IgniteChangeGlobalStateSupport> stateAwareMgrs;
+
/**
* @param kernalCtx Context.
* @param txMgr Transaction manager.
@@ -207,6 +211,49 @@ public class GridCacheSharedContext<K, V> {
txFinishMsgLog = kernalCtx.log(CU.TX_MSG_FINISH_LOG_CATEGORY);
txLockMsgLog = kernalCtx.log(CU.TX_MSG_LOCK_LOG_CATEGORY);
txRecoveryMsgLog = kernalCtx.log(CU.TX_MSG_RECOVERY_LOG_CATEGORY);
+
+ stateAwareMgrs = new ArrayList<>();
+
+ if (pageStoreMgr != null)
+ stateAwareMgrs.add(pageStoreMgr);
+
+ if (walMgr != null)
+ stateAwareMgrs.add(walMgr);
+
+ stateAwareMgrs.add(dbMgr);
+
+ stateAwareMgrs.add(snpMgr);
+ }
+
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void activate() throws IgniteCheckedException {
+ if (!kernalCtx.clientNode())
+ dbMgr.lock();
+
+ boolean success = false;
+
+ try {
+ for (IgniteChangeGlobalStateSupport mgr : stateAwareMgrs)
+ mgr.onActivate(kernalCtx);
+
+ success = true;
+ }
+ finally {
+ if (!success) {
+ if (!kernalCtx.clientNode())
+ dbMgr.unLock();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void deactivate() {
+ for (int i = stateAwareMgrs.size() - 1; i >= 0; i--)
+ stateAwareMgrs.get(i).onDeActivate(kernalCtx);
}
/**
@@ -272,12 +319,15 @@ public class GridCacheSharedContext<K, V> {
if (restartOnDisconnect(mgr))
mgr.stop(true);
}
+
+ deactivate();
}
/**
+ * @param active Active flag.
* @throws IgniteCheckedException If failed.
*/
- void onReconnected() throws IgniteCheckedException {
+ void onReconnected(boolean active) throws IgniteCheckedException {
List<GridCacheSharedManager<K, V>> mgrs = new LinkedList<>();
setManagers(mgrs, txMgr,
@@ -303,8 +353,10 @@ public class GridCacheSharedContext<K, V> {
kernalCtx.query().onCacheReconnect();
- for (GridCacheSharedManager<?, ?> mgr : mgrs)
- mgr.onKernalStart(true);
+ if (!active)
+ affinity().removeAllCacheInfo();
+
+ exchMgr.onKernalStart(active, true);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManager.java
index e0e4090..bc1bbb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManager.java
@@ -40,12 +40,6 @@ public interface GridCacheSharedManager<K, V> {
public void stop(boolean cancel);
/**
- * @param reconnect {@code True} if manager restarted after client reconnect.
- * @throws IgniteCheckedException If failed.
- */
- public void onKernalStart(boolean reconnect) throws IgniteCheckedException;
-
- /**
* @param cancel Cancel flag.
*/
public void onKernalStop(boolean cancel);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManagerAdapter.java
index f6f79e4..90ae670 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedManagerAdapter.java
@@ -112,14 +112,6 @@ public class GridCacheSharedManagerAdapter<K, V> implements GridCacheSharedManag
}
/** {@inheritDoc} */
- @Override public final void onKernalStart(boolean reconnect) throws IgniteCheckedException {
- onKernalStart0(reconnect);
-
- if (!reconnect && log != null && log.isDebugEnabled())
- log.debug(kernalStartInfo());
- }
-
- /** {@inheritDoc} */
@Override public final void onKernalStop(boolean cancel) {
if (!starting.get())
// Ignoring attempt to stop manager that has never been started.
@@ -132,14 +124,6 @@ public class GridCacheSharedManagerAdapter<K, V> implements GridCacheSharedManag
}
/**
- * @param reconnect {@code True} if manager restarted after client reconnect.
- * @throws IgniteCheckedException If failed.
- */
- protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException {
- // No-op.
- }
-
- /**
* @param cancel Cancel flag.
*/
protected void onKernalStop0(boolean cancel) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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
new file mode 100644
index 0000000..b4274f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/PendingDiscoveryEvent.java
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.internal.managers.discovery.DiscoCache;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ *
+ */
+public class PendingDiscoveryEvent {
+ /** */
+ private final DiscoveryEvent evt;
+
+ /** */
+ private final DiscoCache cache;
+
+ /**
+ * @param evt Event.
+ * @param cache Discovery data cache.
+ */
+ public PendingDiscoveryEvent(DiscoveryEvent evt, DiscoCache cache) {
+ this.evt = evt;
+ 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/1337901f/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
new file mode 100644
index 0000000..2d35e81
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/StateChangeRequest.java
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+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;
+
+/**
+ *
+ */
+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) {
+ this.msg = msg;
+ this.topVer = topVer;
+ }
+
+ /**
+ * @return State change exchange version.
+ */
+ public AffinityTopologyVersion topologyVersion() {
+ return topVer;
+ }
+
+ /**
+ * @return State change request ID.
+ */
+ public UUID requestId() {
+ return msg.requestId();
+ }
+
+ /**
+ * @return New state.
+ */
+ public boolean activate() {
+ return msg.activate();
+ }
+
+ /**
+ * @return Node initiated state change process.
+ */
+ 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/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index c2c71ea..0065e41 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -258,8 +258,8 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
- @Override public void onKernalStart() throws IgniteCheckedException {
- super.onKernalStart();
+ @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
+ super.onKernalStart(active);
discoveryStarted = true;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
index 1c97de2..d6b45b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
@@ -29,7 +29,6 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.cache.GridCacheCompoundIdentityFuture;
-import org.apache.ignite.internal.processors.cache.GridCacheFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.util.GridLeanMap;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 38d0108..960b91a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -50,7 +50,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
-import org.apache.ignite.internal.processors.cache.GridCacheMapEntryFactory;
import org.apache.ignite.internal.processors.cache.GridCachePreloader;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 123d26b..0ea48e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -27,7 +27,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
index 6392d0a..439bb9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
@@ -19,13 +19,11 @@ package org.apache.ignite.internal.processors.cache.distributed.dht;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/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 c205c3b..57ce323 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;
@@ -424,11 +423,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
throws IgniteCheckedException {
DiscoveryEvent discoEvt = exchFut.discoveryEvent();
- ClusterState newState = exchFut.newClusterState();
-
- treatAllPartAsLoc = (newState != null && newState == ClusterState.ACTIVE)
- || (ctx.kernalContext().state().active()
- && discoEvt.type() == EventType.EVT_NODE_JOINED
+ treatAllPartAsLoc = exchFut.activateCluster()
+ || (discoEvt.type() == EventType.EVT_NODE_JOINED
&& discoEvt.eventNode().isLocal()
&& !ctx.kernalContext().clientNode()
);
@@ -611,7 +607,7 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
if (locPart != null) {
GridDhtPartitionState state = locPart.state();
- if (state == MOVING && ctx.kernalContext().state().active()) {
+ if (state == MOVING) {
locPart.rent(false);
updateSeq = updateLocal(p, locPart.state(), updateSeq);
@@ -1773,9 +1769,6 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
* @return Checks if any of the local partitions need to be evicted.
*/
private boolean checkEvictions(long updateSeq, List<List<ClusterNode>> aff) {
- if (!ctx.kernalContext().state().active())
- return false;
-
boolean changed = false;
UUID locId = ctx.localNodeId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
index e70f383..d04870a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFutureAdapter.java
@@ -80,7 +80,7 @@ public abstract class GridDhtTopologyFutureAdapter extends GridFutureAdapter<Aff
if (err != null)
return err;
- if (!cctx.shared().kernalContext().state().active())
+ if (!cctx.shared().kernalContext().state().publicApiActiveState())
return new CacheInvalidStateException(
"Failed to perform cache operation (cluster is not activated): " + cctx.name());
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index cfecb1c..d66afca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -18,16 +18,13 @@
package org.apache.ignite.internal.processors.cache.distributed.dht;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.IgniteDiagnosticAware;
-import org.apache.ignite.internal.IgniteDiagnosticMessage;
import org.apache.ignite.internal.IgniteDiagnosticPrepareContext;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
index 1bd8ec5..6fe96a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateFuture.java
@@ -46,7 +46,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheReturn;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
index 763b43b..fe216a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1337901f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 774f0ce..e7e95b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -161,6 +161,8 @@ public class GridDhtPartitionDemander {
lastExchangeFut = null;
lastTimeoutObj.set(null);
+
+ syncFut.onDone();
}
/**