use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridProjectionForCachesOnDaemonNodeSelfTest method testForClientNodes.
/**
* @throws Exception If failed.
*/
@Test
public void testForClientNodes() throws Exception {
ClusterGroup grp = ignite.cluster().forClientNodes(DEFAULT_CACHE_NAME);
assertTrue(grp.nodes().isEmpty());
try {
daemon.cluster().forClientNodes(DEFAULT_CACHE_NAME);
} catch (IllegalStateException ignored) {
return;
}
fail();
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgniteUtils method broadcastToNodesWithFilterAsync.
/**
* Broadcasts given job to nodes that match filter.
*
* @param kctx Kernal context.
* @param job Ignite job.
* @param srvrsOnly Broadcast only on server nodes.
* @param nodeFilter Node filter.
*/
public static IgniteFuture<Void> broadcastToNodesWithFilterAsync(GridKernalContext kctx, IgniteRunnable job, boolean srvrsOnly, IgnitePredicate<ClusterNode> nodeFilter) {
ClusterGroup cl = kctx.grid().cluster();
if (srvrsOnly)
cl = cl.forServers();
ClusterGroup grp = nodeFilter != null ? cl.forPredicate(nodeFilter) : cl;
if (grp.nodes().isEmpty())
return new IgniteFinishedFutureImpl<>();
IgniteCompute compute = kctx.grid().compute(grp);
return compute.broadcastAsync(job);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridCacheBinaryObjectMetadataExchangeMultinodeTest method testClientRequestsUpToDateMetadata.
/**
* Verifies that client is able to detect obsolete metadata situation and request up-to-date from the cluster.
*/
@Test
public void testClientRequestsUpToDateMetadata() throws Exception {
final IgniteEx ignite0 = startGrid(0);
final IgniteEx ignite1 = startGrid(1);
ignite0.executorService().submit(new Runnable() {
@Override
public void run() {
addIntField(ignite0, "f1", 101, 1);
}
}).get();
final Ignite client = startDeafClient("client");
ClusterGroup clientGrp = client.cluster().forClients();
final String strVal = "strVal101";
ignite1.executorService().submit(new Runnable() {
@Override
public void run() {
addStringField(ignite1, "f2", strVal, 1);
}
}).get();
String res = client.compute(clientGrp).call(new IgniteCallable<String>() {
@Override
public String call() throws Exception {
return ((BinaryObject) client.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(1)).field("f2");
}
});
assertEquals(strVal, res);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class GridCacheBinaryObjectMetadataExchangeMultinodeTest method testClientRequestsUpToDateMetadataOneNodeDies.
/**
* Verifies that client resends request for up-to-date metadata in case of failure on server received first request.
*/
@Test
public void testClientRequestsUpToDateMetadataOneNodeDies() throws Exception {
final Ignite srv0 = startGrid(0);
replaceWithStoppingMappingRequestListener(((GridKernalContext) U.field(srv0, "ctx")).io(), 0);
final Ignite srv1 = startGrid(1);
replaceWithCountingMappingRequestListener(((GridKernalContext) U.field(srv1, "ctx")).io());
final Ignite srv2 = startGrid(2);
replaceWithCountingMappingRequestListener(((GridKernalContext) U.field(srv2, "ctx")).io());
final Ignite client = startDeafClient("client");
ClusterGroup clientGrp = client.cluster().forClients();
srv0.executorService().submit(new Runnable() {
@Override
public void run() {
addStringField(srv0, "f2", "strVal101", 0);
}
}).get();
client.compute(clientGrp).call(new IgniteCallable<String>() {
@Override
public String call() throws Exception {
return ((BinaryObject) client.cache(DEFAULT_CACHE_NAME).withKeepBinary().get(0)).field("f2");
}
});
assertEquals(metadataReqsCounter.get(), 2);
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class BinaryMetadataUpdatesFlowTest method startComputation.
/**
* Starts computation job.
*
* @param idx Grid index on which computation job should start.
* @param restartIdx The index of the node to be restarted.
* @param workersCntr The current number of computation threads.
*/
private void startComputation(int idx, AtomicInteger restartIdx, AtomicInteger workersCntr) {
Ignite ignite = grid(idx);
ClusterGroup cg = ignite.cluster().forLocal();
ignite.compute(cg).callAsync(new BinaryObjectAdder(startLatch, idx, updatesQueue, restartIdx, workersCntr));
}
Aggregations