ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/12] incubator-ignite git commit: # ignite-sprint-4 Fixed simple error in GridAffinityAssignmentCache.initialize
Date Tue, 21 Apr 2015 11:22:42 GMT
# ignite-sprint-4 Fixed simple error in GridAffinityAssignmentCache.initialize


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

Branch: refs/heads/ignite-446
Commit: d7e8b59924265d9a1eb8e832d93d054d33ef4c9a
Parents: bc025d9
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Apr 21 11:42:00 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Apr 21 12:27:26 2015 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignmentCache.java   |  7 +++-
 .../IgniteCachePutGetRestartAbstractTest.java   | 39 ++++++++++++++------
 .../IgniteCacheTxFairAffinityNodeJoinTest.java  | 35 ++++++++++++++++++
 .../IgniteCacheFailoverTestSuite.java           |  3 +-
 4 files changed, 70 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e8b599/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 2d98ee0..409419c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -116,8 +116,13 @@ public class GridAffinityAssignmentCache {
         head.set(assignment);
 
         for (Map.Entry<AffinityTopologyVersion, AffinityReadyFuture> entry : readyFuts.entrySet())
{
-            if (entry.getKey().compareTo(topVer) >= 0)
+            if (entry.getKey().compareTo(topVer) <= 0) {
+                if (log.isDebugEnabled())
+                    log.debug("Completing topology ready future (initialized affinity) "
+
+                        "[locNodeId=" + ctx.localNodeId() + ", futVer=" + entry.getKey()
+ ", topVer=" + topVer + ']');
+
                 entry.getValue().onDone(topVer);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e8b599/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java
index d2066ed..a56b0fa 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCachePutGetRestartAbstractTest.java
@@ -49,7 +49,7 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
     private final Object mux = new Object();
 
     /** */
-    private CountDownLatch latch = new CountDownLatch(1);
+    private volatile CountDownLatch latch = new CountDownLatch(1);
 
     /** {@inheritDoc} */
     @Override protected int gridCount() {
@@ -70,7 +70,7 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        if (gridName.equals(getTestGridName(0)))
+        if (gridName.equals(getTestGridName(gridCount() - 1)))
             cfg.setClientMode(true);
 
         cfg.setPeerClassLoadingEnabled(false);
@@ -96,9 +96,13 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
      * @throws Exception If failed.
      */
     public void testTxPutGetRestart() throws Exception {
-        final IgniteTransactions txs = ignite(0).transactions();
+        int clientGrid = gridCount() - 1;
 
-        final IgniteCache<Integer, Integer> cache = jcache(0);
+        assertTrue(ignite(clientGrid).configuration().isClientMode());
+
+        final IgniteTransactions txs = ignite(clientGrid).transactions();
+
+        final IgniteCache<Integer, Integer> cache = jcache(clientGrid);
 
         updateCache(cache, txs);
 
@@ -106,6 +110,8 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
 
         IgniteInternalFuture<?> updateFut = GridTestUtils.runAsync(new Callable<Void>()
{
             @Override public Void call() throws Exception {
+                Thread.currentThread().setName("update-thread");
+
                 assertTrue(latch.await(30_000, TimeUnit.MILLISECONDS));
 
                 int iter = 0;
@@ -128,18 +134,26 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
 
         IgniteInternalFuture<?> restartFut = GridTestUtils.runAsync(new Callable<Void>()
{
             @Override public Void call() throws Exception {
-                assertTrue(latch.await(30_000, TimeUnit.MILLISECONDS));
+                Thread.currentThread().setName("restart-thread");
+
+                ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
                 while (!stop.get()) {
-                    log.info("Stop node.");
+                    assertTrue(latch.await(30_000, TimeUnit.MILLISECONDS));
 
-                    stopGrid(1);
+                    int node = rnd.nextInt(0, gridCount() - 1);
+
+                    log.info("Stop node: " + node);
+
+                    stopGrid(node);
 
                     U.sleep(100);
 
-                    log.info("Start node.");
+                    log.info("Start node: " + node);
 
-                    startGrid(1);
+                    startGrid(node);
+
+                    latch = new CountDownLatch(1);
 
                     U.sleep(100);
                 }
@@ -153,7 +167,7 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
         try {
             int iter = 0;
 
-            while (System.currentTimeMillis() < endTime) {
+            while (System.currentTimeMillis() < endTime && !updateFut.isDone()
&& !restartFut.isDone()) {
                 try {
                     log.info("Start get: " + iter);
 
@@ -164,14 +178,15 @@ public abstract class IgniteCachePutGetRestartAbstractTest extends IgniteCacheAb
                     log.info("End get: " + iter++);
                 }
                 finally {
-                    if (latch.getCount() > 0)
-                        latch.countDown();
+                    latch.countDown();
                 }
             }
 
             log.info("Get iterations: " + iter);
         }
         finally {
+            latch.countDown();
+
             stop.set(true);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e8b599/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxFairAffinityNodeJoinTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxFairAffinityNodeJoinTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxFairAffinityNodeJoinTest.java
new file mode 100644
index 0000000..1efaf02
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheTxFairAffinityNodeJoinTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.distributed;
+
+import org.apache.ignite.cache.affinity.fair.*;
+import org.apache.ignite.configuration.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxFairAffinityNodeJoinTest extends IgniteCacheTxNodeJoinTest {
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
+        CacheConfiguration ccfg = super.cacheConfiguration(gridName);
+
+        ccfg.setAffinity(new FairAffinityFunction(128));
+
+        return ccfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7e8b599/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
index 9c1c57c..32e4134 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite.java
@@ -59,8 +59,9 @@ public class IgniteCacheFailoverTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteCacheAtomicNodeJoinTest.class);
         suite.addTestSuite(IgniteCacheTxNodeJoinTest.class);
+        suite.addTestSuite(IgniteCacheTxFairAffinityNodeJoinTest.class);
 
-        suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class);
+        //suite.addTestSuite(IgniteCacheTxNearDisabledPutGetRestartTest.class);
 
         return suite;
     }


Mime
View raw message