use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
return;
System.out.println();
System.out.println("Compute example started.");
IgniteCluster cluster = ignite.cluster();
// Say hello to all nodes in the cluster, including local node.
sayHello(ignite, cluster);
// Say hello to all remote nodes.
sayHello(ignite, cluster.forRemotes());
// Pick random node out of remote nodes.
ClusterGroup randomNode = cluster.forRemotes().forRandom();
// Say hello to a random node.
sayHello(ignite, randomNode);
// Say hello to all nodes residing on the same host with random node.
sayHello(ignite, cluster.forHost(randomNode.node()));
// Say hello to all nodes that have current CPU load less than 50%.
sayHello(ignite, cluster.forPredicate(new IgnitePredicate<ClusterNode>() {
@Override
public boolean apply(ClusterNode n) {
return n.metrics().getCurrentCpuLoad() < 0.5;
}
}));
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class ClusterGroupExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
return;
System.out.println();
System.out.println("Compute example started.");
IgniteCluster cluster = ignite.cluster();
// Say hello to all nodes in the cluster, including local node.
sayHello(ignite, cluster);
// Say hello to all remote nodes.
sayHello(ignite, cluster.forRemotes());
// Pick random node out of remote nodes.
ClusterGroup randomNode = cluster.forRemotes().forRandom();
// Say hello to a random node.
sayHello(ignite, randomNode);
// Say hello to all nodes residing on the same host with random node.
sayHello(ignite, cluster.forHost(randomNode.node()));
// Say hello to all nodes that have current CPU load less than 50%.
sayHello(ignite, cluster.forPredicate(n -> n.metrics().getCurrentCpuLoad() < 0.5));
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class MessagingExample method main.
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
return;
System.out.println();
System.out.println(">>> Messaging example started.");
// Group for remote nodes.
ClusterGroup rmtGrp = ignite.cluster().forRemotes();
// Listen for messages from remote nodes to make sure that they received all the messages.
int msgCnt = rmtGrp.nodes().size() * MESSAGES_NUM;
CountDownLatch orderedLatch = new CountDownLatch(msgCnt);
CountDownLatch unorderedLatch = new CountDownLatch(msgCnt);
localListen(ignite.message(ignite.cluster().forLocal()), orderedLatch, unorderedLatch);
// Register listeners on all cluster nodes.
startListening(ignite, ignite.message(rmtGrp));
// Send unordered messages to all remote nodes.
for (int i = 0; i < MESSAGES_NUM; i++) ignite.message(rmtGrp).send(TOPIC.UNORDERED, Integer.toString(i));
System.out.println(">>> Finished sending unordered messages.");
// Send ordered messages to all remote nodes.
for (int i = 0; i < MESSAGES_NUM; i++) ignite.message(rmtGrp).sendOrdered(TOPIC.ORDERED, Integer.toString(i), 0);
System.out.println(">>> Finished sending ordered messages.");
System.out.println(">>> Check output on all nodes for message printouts.");
System.out.println(">>> Will wait for messages acknowledgements from all remote nodes.");
orderedLatch.await();
unorderedLatch.await();
System.out.println(">>> Messaging example finished.");
}
}
use of org.apache.ignite.cluster.ClusterGroup in project ignite by apache.
the class IgfsMetaManager method clientCompute.
/**
* Get compute facade for client tasks.
*
* @return Compute facade.
*/
private IgniteCompute clientCompute() {
assert client;
IgniteCompute cliCompute0 = cliCompute;
if (cliCompute0 == null) {
IgniteEx ignite = igfsCtx.kernalContext().grid();
ClusterGroup cluster = ignite.cluster().forIgfsMetadataDataNodes(cfg.getName(), metaCacheName);
cliCompute0 = ignite.compute(cluster);
cliCompute = cliCompute0;
}
assert cliCompute0 != null;
return cliCompute0;
}
use of org.apache.ignite.cluster.ClusterGroup in project camel by apache.
the class IgniteEventsEndpoint method createIgniteEvents.
private IgniteEvents createIgniteEvents() {
Ignite ignite = ignite();
IgniteEvents events;
if (clusterGroupExpression == null) {
LOG.info("Ignite Events endpoint for event types {} using no Cluster Group.", this.events);
events = ignite.events();
} else {
ClusterGroup group = clusterGroupExpression.getClusterGroup(ignite);
LOG.info("Ignite Events endpoint for event types {} using Cluster Group: {}.", this.events, group);
events = ignite.events(group);
}
return events;
}
Aggregations