use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridJobExecutionLoadTestClientSemaphore method call.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public Object call() throws Exception {
final IgniteInClosure<IgniteFuture<?>> lsnr = new CI1<IgniteFuture<?>>() {
@Override
public void apply(IgniteFuture<?> t) {
tasksSem.release();
}
};
ClusterGroup rmts = g.cluster().forRemotes();
while (!finish) {
tasksSem.acquire();
g.compute(rmts).executeAsync(GridJobExecutionLoadTestTask.class, null).listen(lsnr);
txCnt.increment();
}
return null;
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class PlatformDotNetEntityFrameworkCacheExtension method startBackgroundCleanup.
/**
* Starts the background cleanup of old cache entries.
*
* @param grid Grid.
* @param metaCache Meta cache.
* @param dataCacheName Data cache name.
* @param currentVersions Current versions.
*/
private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) {
if (cleanupFlags.containsKey(dataCacheName))
// Current node already performs cleanup.
return;
if (!trySetGlobalCleanupFlag(grid, metaCache))
return;
cleanupFlags.put(dataCacheName, true);
final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName);
IgniteFuture f = grid.compute(dataNodes).broadcastAsync(new RemoveOldEntriesRunnable(dataCacheName, currentVersions));
f.listen(new CleanupCompletionListener(metaCache, dataCacheName));
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridJobStealingSelfTest method testSingleNodeProjection.
/**
* Tests that a job is not cancelled if there are no
* available thief nodes in projection.
*
* @throws Exception If failed.
*/
@Test
public void testSingleNodeProjection() throws Exception {
ClusterGroup prj = ignite1.cluster().forNodeIds(Collections.singleton(ignite1.cluster().localNode().id()));
executeAsync(compute(prj), new JobStealingSpreadTask(2), null).get(TASK_EXEC_TIMEOUT_MS);
assertEquals(1, jobDistrMap.keySet().size());
assertEquals(2, jobDistrMap.get(ignite1.cluster().localNode().id()).size());
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridFailoverTaskWithPredicateSelfTest method testJobNotFailedOverWithStaticProjection.
/**
* Tests that in case of failover our predicate is intersected with projection
* (logical AND is performed).
*
* @throws Exception If error happens.
*/
@Test
public void testJobNotFailedOverWithStaticProjection() throws Exception {
failed.set(false);
routed.set(false);
try {
Ignite ignite1 = startGrid(NODE1);
Ignite ignite2 = startGrid(NODE2);
Ignite ignite3 = startGrid(NODE3);
assert ignite1 != null;
assert ignite2 != null;
assert ignite3 != null;
// Get projection only for first 2 nodes.
ClusterGroup nodes = ignite1.cluster().forNodeIds(Arrays.asList(ignite1.cluster().localNode().id(), ignite2.cluster().localNode().id()));
// On failover NODE3 shouldn't be taken into account.
Integer res = (Integer) compute(nodes.forPredicate(p)).withTimeout(10000).execute(JobFailTask.class.getName(), "1");
assert res == 1;
} catch (ClusterTopologyException ignored) {
failed.set(true);
} finally {
assertTrue(failed.get());
assertFalse(routed.get());
stopGrid(NODE1);
stopGrid(NODE2);
stopGrid(NODE3);
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteCountDownLatchAbstractSelfTest method testLatchBroadcast.
/**
* @throws Exception If failed.
*/
@Test
public void testLatchBroadcast() throws Exception {
Ignite ignite = grid(0);
ClusterGroup srvsGrp = ignite.cluster().forServers();
int numOfSrvs = srvsGrp.nodes().size();
ignite.destroyCache("testCache");
IgniteCache<Object, Object> cache = ignite.createCache("testCache");
for (ClusterNode node : srvsGrp.nodes()) cache.put(String.valueOf(node.id()), 0);
for (int i = 0; i < 500; i++) {
IgniteCountDownLatch latch1 = createLatch1(ignite, numOfSrvs);
IgniteCountDownLatch latch2 = createLatch2(ignite, numOfSrvs);
ignite.compute(srvsGrp).broadcast(new IgniteRunnableJob(latch1, latch2, i));
assertTrue(latch2.await(10000));
}
}
Aggregations