ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/15] incubator-ignite git commit: IGNITE-383 Pull on public API forceRebalancing() method.
Date Thu, 12 Mar 2015 09:10:39 GMT
IGNITE-383 Pull on public API forceRebalancing() method.


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

Branch: refs/heads/ignite-443
Commit: de619d9c8042e6957093c0ef9404f067ca1af397
Parents: dc04e98
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Mon Mar 2 19:17:54 2015 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Mon Mar 2 19:17:54 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     | 24 ++++++++++++++++++++
 .../processors/cache/IgniteCacheProxy.java      |  7 ++++++
 ...tAllUpdateNonPreloadedPartitionSelfTest.java |  2 +-
 ...dCacheQueueMultiNodeConsistencySelfTest.java |  2 +-
 .../IgniteTxPreloadAbstractTest.java            |  2 +-
 .../dht/GridCacheDhtPreloadDelayedSelfTest.java |  6 ++---
 6 files changed, 37 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 195a304..3e199eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -20,6 +20,8 @@ package org.apache.ignite;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
 import org.apache.ignite.cache.store.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
@@ -456,6 +458,28 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K,
V>, IgniteAsyncS
         IgniteEntryProcessor<K, V, T> entryProcessor, Object... args);
 
     /**
+     * Forces this cache node to re-balance its partitions. This method is usually used when
+     * {@link CacheConfiguration#getRebalancePartitionedDelay()} configuration parameter
has non-zero value.
+     * When many nodes are started or stopped almost concurrently, it is more efficient to
delay
+     * rebalancing until the node topology is stable to make sure that no redundant re-partitioning
+     * happens.
+     * <p>
+     * In case of{@link CacheMode#PARTITIONED} caches, for better efficiency user should
+     * usually make sure that new nodes get placed on the same place of consistent hash ring
as
+     * the left nodes, and that nodes are restarted before
+     * {@link CacheConfiguration#getRebalancePartitionedDelay() rebalanceDelay} expires.
To place nodes
+     * on the same place in consistent hash ring, use
+     * {@link CacheConsistentHashAffinityFunction#setHashIdResolver(CacheAffinityNodeHashResolver)}
to make sure that
+     * a node maps to the same hash ID if re-started.
+     * <p>
+     * See {@link CacheConfiguration#getRebalancePartitionedDelay()} for more information
on how to configure
+     * rebalance re-partition delay.
+     * <p>
+     * @return Future that will be completed when rebalancing is finished.
+     */
+    public IgniteFuture<?> forceRebalancing();
+
+    /**
      * Gets snapshot metrics (statistics) for this cache.
      *
      * @return Cache metrics.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index b77b8db..f010ac8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -1443,6 +1443,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
     }
 
     /** {@inheritDoc} */
+    @Override public IgniteFuture<?> forceRebalancing() {
+        ctx.preloader().forcePreload();
+
+        return new IgniteFutureImpl<>(ctx.preloader().syncFuture());
+    }
+
+    /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgniteCacheProxy.class, this);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java
index bd09833..e0b71b1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgnitePutAllUpdateNonPreloadedPartitionSelfTest.java
@@ -74,7 +74,7 @@ public class IgnitePutAllUpdateNonPreloadedPartitionSelfTest extends GridCommonA
 
         try {
             for (int i = 0; i < GRID_CNT - 1; i++)
-                ((IgniteKernal)grid(i)).cache(null).forceRepartition().get();
+                grid(i).jcache(null).forceRebalancing().get();
 
             startGrid(GRID_CNT - 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java
index 8e2a288..72f34c5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueMultiNodeConsistencySelfTest.java
@@ -150,7 +150,7 @@ public class GridCacheQueueMultiNodeConsistencySelfTest extends IgniteCollection
 
         if (forceRepartition)
             for (int i = 0; i < GRID_CNT; i++)
-                cache(i).forceRepartition();
+                jcache(i).forceRebalancing();
 
         Ignite newIgnite = startGrid(GRID_CNT + 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
index 8436ad4..6583410 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
@@ -121,7 +121,7 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
 
         for (int i = 0; i < GRID_CNT; i++)
             // Wait for preloader.
-            cache(i).forceRepartition().get();
+            jcache(i).forceRebalancing().get();
 
         for (int i = 0; i < GRID_CNT; i++) {
             for (String key : keys)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/de619d9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
index c9dd9ee..a2d81c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
@@ -149,7 +149,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest
{
         checkMaps(false, d0, d1, d2);
 
         // Force preload.
-        internalCache(c1).forceRepartition();
+        c1.forceRebalancing();
 
         l1.await();
 
@@ -160,7 +160,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest
{
         info("Beginning to wait for cache2 repartition.");
 
         // Force preload.
-        internalCache(c2).forceRepartition();
+        c2.forceRebalancing();
 
         l2.await();
 
@@ -352,7 +352,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest
{
 
             long start = System.currentTimeMillis();
 
-            internalCache(g.jcache(null)).forceRepartition().get();
+            g.jcache(null).forceRebalancing().get();
 
             info(">>> Finished preloading of empty cache in " + (System.currentTimeMillis()
- start) + "ms.");
         }


Mime
View raw message