use of org.apache.ignite.internal.visor.node.VisorNodeDataCollectorTaskArg in project ignite by apache.
the class CacheGroupsMetricsRebalanceTest method testRebalanceProgressUnderLoad.
/**
* @throws Exception If failed.
*/
@Test
public void testRebalanceProgressUnderLoad() throws Exception {
Ignite ignite = startGrids(4);
IgniteCache<Object, Object> cache1 = ignite.cache(CACHE1);
Random r = new Random();
GridTestUtils.runAsync(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 100_000; i++) {
int next = r.nextInt();
cache1.put(next, CACHE1 + "-" + next);
}
}
});
IgniteEx ig = startGrid(4);
GridTestUtils.runAsync(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 100_000; i++) {
int next = r.nextInt();
cache1.put(next, CACHE1 + "-" + next);
}
}
});
CountDownLatch latch = new CountDownLatch(1);
ig.events().localListen(new IgnitePredicate<Event>() {
@Override
public boolean apply(Event evt) {
latch.countDown();
return false;
}
}, EventType.EVT_CACHE_REBALANCE_STOPPED);
latch.await();
VisorNodeDataCollectorTaskArg taskArg = new VisorNodeDataCollectorTaskArg();
taskArg.setCacheGroups(Collections.emptySet());
VisorTaskArgument<VisorNodeDataCollectorTaskArg> arg = new VisorTaskArgument<>(Collections.singletonList(ignite.cluster().localNode().id()), taskArg, false);
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
VisorNodeDataCollectorTaskResult res = ignite.compute().execute(VisorNodeDataCollectorTask.class, arg);
CacheMetrics snapshot = ig.cache(CACHE1).metrics();
return snapshot.getRebalancedKeys() > snapshot.getEstimatedRebalancingKeys() && Double.compare(res.getRebalance().get(ignite.cluster().localNode().id()), 1.0) == 0 && snapshot.getRebalancingPartitionsCount() == 0;
}
}, 5000);
}
Aggregations