props.setProperty("galaxy.port", Integer.toString(7050 + peerNum));
props.setProperty("galaxy.slave_port", Integer.toString(8050 + peerNum));
props.setProperty("galaxy.multicast.address", "225.0.0.1");
props.setProperty("galaxy.multicast.port", Integer.toString(7050));
final Grid grid = Grid.getInstance(pathToResource(configpeerxml), props);
grid.goOnline();
final SettableFuture<Short> future = SettableFuture.create();
grid.cluster().addNodeChangeListener(new NodeChangeListener() {
@Override
public void nodeAdded(short id) {
if (id > grid.cluster().getMyNodeId()) {
System.out.println("Larger peer added !!");
future.set(id);
}
}
@Override
public void nodeSwitched(short id) {
}
@Override
public void nodeRemoved(short id) {
}
});
for (Short node : grid.cluster().getNodes()) {
if (node > grid.cluster().getMyNodeId()) {
System.out.println("Larger peer have already up !!");
return node;
}
}
return future.get();