Refactored a test to avoid passing anonymous classes on compute. Put the method back to GridCommonAbstractTest. - Fixes
@@ -78,12 +78,12 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
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 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
}
/**
- * 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,7 +964,19 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
return;
IgniteFuture<Void> fut =
- ignite.compute().withTimeout(5_000).broadcastAsync(new IgniteRunnable() {
+ ignite.compute().withTimeout(5_000).broadcastAsync(new ManualRebalancer(cacheName));
+
+ assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return fut.isDone();
+ }
+ }, 5_000));
+ }
+
+ /**
+ *
+ */
+ private static class ManualRebalancer implements IgniteRunnable {
/** */
@LoggerResource
IgniteLogger log;
@@ -973,13 +985,20 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
@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 (!(Boolean)cache.rebalance().get()) {
+ while (!cache.rebalance().get()) {
try {
U.sleep(100);
}
@@ -991,13 +1010,6 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
if (log.isInfoEnabled())
log.info("Manual rebalance finished [node=" + ignite.name() + ", cache=" + cacheName + "]");
}
- });
-
- assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- return fut.isDone();
- }
- }, 5_000));
}
/**
