You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2016/09/30 17:01:44 UTC

[3/3] ignite git commit: reviewing changes

reviewing changes


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

Branch: refs/heads/ignite-3897-pr1059
Commit: c75f6fc14b7b309e49ce9b3ee96cecf5ddee2da8
Parents: f41f5a8
Author: yzhdanov <yz...@gridgain.com>
Authored: Fri Sep 30 18:27:45 2016 +0200
Committer: yzhdanov <yz...@gridgain.com>
Committed: Fri Sep 30 18:27:45 2016 +0200

----------------------------------------------------------------------
 .../GridCacheRebalancingAggregationTest.java    | 87 +++++++++++++-------
 1 file changed, 55 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c75f6fc1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAggregationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAggregationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAggregationTest.java
index 1d566e9..d5020f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAggregationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAggregationTest.java
@@ -53,11 +53,16 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
 
     /** Keys of entries under test. */
     private static final Set<Integer> KEYS;
+
+    /*
+     *
+     */
     static {
         final Set<Integer> keys = new LinkedHashSet<>();
-        for (int i = 0; i < ENTRY_COUNT; i++) {
+
+        for (int i = 0; i < ENTRY_COUNT; i++)
             keys.add(i);
-        }
+
         KEYS = Collections.unmodifiableSet(keys);
     }
 
@@ -71,29 +76,26 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
     private volatile int totalUpdateCount;
 
     /** {@inheritDoc} */
-    @Override
-    public int serverCount() {
+    @Override public int serverCount() {
         return 3;
     }
 
     /** {@inheritDoc} */
-    @Override
-    public int getMaxRestarts() {
+    @Override public int getMaxRestarts() {
         return MAX_RESTARTS;
     }
 
     /** {@inheritDoc} */
-    @Override
-    protected long getTestTimeout() {
+    @Override protected long getTestTimeout() {
         return 1000 * 60 * 5;
     }
 
     /** {@inheritDoc} */
     @Override protected CacheConfiguration<?, ?> getCacheConfiguration() {
         return new CacheConfiguration<Integer, Integer>(CACHE_NAME)
-                        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
-                        .setCacheMode(CacheMode.PARTITIONED)
-                        .setBackups(1);
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL)
+            .setCacheMode(CacheMode.PARTITIONED)
+            .setBackups(1);
     }
 
     /** {@inheritDoc} */
@@ -120,18 +122,21 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
         throws InterruptedException {
 
         startUpdateThread();
+
         RollingRestartThread restartThread = super.rollingRestartThread;
 
         int totalAggregationCount = 0;
         int checksumFailures = 0;
+
         do {
-            if (!checksumCache()) {
+            if (!checksumCache())
                 checksumFailures++;
-            }
 
             totalAggregationCount++;
+
             this.aggregationCount++;
-        } while (restartThread.isAlive());
+        }
+        while (restartThread.isAlive());
 
         grid(0).log().info("Total successful aggregations during the test were: " + totalAggregationCount);
         grid(0).log().info("Total successful updates during the test were: " + this.totalUpdateCount);
@@ -148,8 +153,10 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
      */
     private void startUpdateThread() {
         UpdateCacheThread updateThread = new UpdateCacheThread();
-        updateThread.start();
+
         this.updateThread = updateThread;
+
+        updateThread.start();
     }
 
     /**
@@ -160,36 +167,43 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
      */
     private boolean checksumCache() {
         final Ignite ignite = grid(0);
+
         Cache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
+
         Throwable e = null;
+
         for (int i = 0, c = 20; i <= c; ++i) {
             try (Transaction tx = ignite.transactions().txStart()) {
-                tx.timeout(2*60*1000l);
+                tx.timeout(2 * 60 * 1000L);
 
                 Integer ceiling = cache.get(CEILING_KEY);
-                if (ceiling == null) {
+
+                if (ceiling == null)
                     return Boolean.TRUE;
-                }
+
                 int floor = ceiling - ENTRY_COUNT + 1;
+
                 Map<Integer, Integer> results = cache.getAll(KEYS);
+
                 tx.commit();
 
                 int sum = 0;
-                for (Integer j : results.values()) {
+
+                for (Integer j : results.values())
                     sum += j;
-                }
 
-                if (sum == calculateSum(floor, ceiling)) {
+                if (sum == calculateSum(floor, ceiling))
                     return Boolean.TRUE;
-                }
 
                 grid(0).log().info("Failed testing that sum of " + sum + " equals sum(" + floor + "," + ceiling + ")");
+
                 return Boolean.FALSE;
             }
             catch (Throwable ee) {
                 e = ee;
             }
         }
+
         throw new RuntimeException("Failed to commit transaction after " + 20 + " retries", e);
     }
 
@@ -198,32 +212,40 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
      */
     private void updateCache() {
         final Ignite ignite = grid(0);
+
         Cache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
+
         Throwable e = null;
+
         for (int i = 0, c = 20; i <= c; ++i) {
             try (Transaction tx = ignite.transactions().txStart()) {
-                tx.timeout(2*60*1000l);
+                tx.timeout(2 * 60 * 1000L);
+
+                Integer curCeiling = cache.get(CEILING_KEY);
+
+                int newCeiling = curCeiling == null ? ENTRY_COUNT - 1 : curCeiling + ENTRY_COUNT;
+                int value = curCeiling == null ? 0 : curCeiling + 1;
 
-                Integer currentCeiling = cache.get(CEILING_KEY);
-                int newCeiling = currentCeiling == null ? ENTRY_COUNT - 1 : currentCeiling + ENTRY_COUNT;
-                int value = currentCeiling == null ? 0 : currentCeiling + 1;
                 Map<Integer, Integer> entries = new TreeMap<>();
-                for (Integer key : KEYS) {
+
+                for (Integer key : KEYS)
                     entries.put(key, value++);
-                }
+
                 cache.putAll(entries);
                 cache.put(CEILING_KEY, newCeiling);
 
                 GridCacheRebalancingAggregationTest.this.totalUpdateCount++;
-                 if (!tx.isRollbackOnly()) {
-                     tx.commit();
-                 }
+
+                if (!tx.isRollbackOnly())
+                    tx.commit();
+
                 return;
             }
             catch (Throwable ee) {
                 e = ee;
             }
         }
+
         throw new RuntimeException("Failed to commit transaction after " + 20 + " retries", e);
     }
 
@@ -246,7 +268,7 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
         /**
          * Default Constructor sets this thread to run as a daemon.
          */
-        public UpdateCacheThread() {
+        UpdateCacheThread() {
             setDaemon(true);
             setName(UpdateCacheThread.class.getSimpleName());
         }
@@ -254,6 +276,7 @@ public class GridCacheRebalancingAggregationTest extends GridRollingRestartAbstr
         /** {@inheritDoc} */
         @Override public void run() {
             RollingRestartThread restartThread =  GridCacheRebalancingAggregationTest.this.rollingRestartThread;
+
             do {
                 GridCacheRebalancingAggregationTest.this.updateCache();
             }