IGNITE-10108: Refactored a test to avoid passing anonymous classes on compute. Put the method back to GridCommonAbstractTest. - Fixes #5329.
Signed-off-by: Dmitriy Pavlov <dpavlov@apache.org>
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 c931a0d..0910292 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
@@ -78,12 +78,12 @@
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
-import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
-import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
-import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
import org.apache.ignite.internal.processors.cache.local.GridLocalCache;
import org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager;
@@ -946,7 +946,7 @@
}
/**
- * Use method for manual rebalaincing cache on all nodes. Note that using
+ * Use method for manual rebalancing cache on all nodes. Note that using
* <pre name="code" class="java">
* for (int i = 0; i < G.allGrids(); i++)
* grid(i).cache(CACHE_NAME).rebalance().get();
@@ -964,34 +964,7 @@
return;
IgniteFuture<Void> fut =
- ignite.compute().withTimeout(5_000).broadcastAsync(new IgniteRunnable() {
- /** */
- @LoggerResource
- IgniteLogger log;
-
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @Override public void run() {
- IgniteCache<?, ?> cache = ignite.cache(cacheName);
-
- assertNotNull(cache);
-
- while (!(Boolean)cache.rebalance().get()) {
- try {
- U.sleep(100);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new IgniteException(e);
- }
- }
-
- if (log.isInfoEnabled())
- log.info("Manual rebalance finished [node=" + ignite.name() + ", cache=" + cacheName + "]");
- }
- });
+ ignite.compute().withTimeout(5_000).broadcastAsync(new ManualRebalancer(cacheName));
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
@@ -1001,6 +974,45 @@
}
/**
+ *
+ */
+ private static class ManualRebalancer implements IgniteRunnable {
+ /** */
+ @LoggerResource
+ IgniteLogger log;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ private final String cacheName;
+
+ public ManualRebalancer(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ IgniteCache<?, ?> cache = ignite.cache(cacheName);
+
+ assertNotNull(cache);
+
+ while (!cache.rebalance().get()) {
+ try {
+ U.sleep(100);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new IgniteException(e);
+ }
+ }
+
+ if (log.isInfoEnabled())
+ log.info("Manual rebalance finished [node=" + ignite.name() + ", cache=" + cacheName + "]");
+ }
+ }
+
+ /**
* @param ignite Node.
*/
public void dumpCacheDebugInfo(Ignite ignite) {