To work with the local node, you need to get the local ClusterGroup:
public class LocalNodes {
public static void main(String[] args) {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setPeerClassLoadingEnabled(true);
try (Ignite ignite = Ignition.start(cfg)) {
IgniteCluster cluster = ignite.cluster();
//Get local server group
ClusterGroup forLocal = cluster.forLocal();
//Get a compute task for local servers
IgniteCompute compute = ignite.compute(forLocal);
//broadcast the computation to local nodes
compute.broadcast(() -> {
System.out.println("******** Local Only *********");
});
}
}
}
It prints the message to the local program console only: