// looking for nodes and check if exist
Set<Node> recipientList;
if (nodeIds != null && !nodeIds.isEmpty()) {
recipientList = new HashSet<Node>();
for (String nodeId : nodeIds) {
Node node = clusterManager.findNodeById(nodeId);
if (node == null) {
System.err.println("Cluster node " + nodeId + " doesn't exist");
} else {
recipientList.add(node);
}
}
} else {
recipientList = clusterManager.listNodes();
}
if (recipientList.size() < 1) {
return null;
}
command.setDestination(recipientList);
command.setStatus(status);
Map<Node, ConsumerSwitchResult> results = executionContext.execute(command);
if (results == null || results.isEmpty()) {
System.out.println("No result received within given timeout");
} else {
System.out.println(String.format(HEADER_FORMAT, "Node", "Status"));
for (Node node : results.keySet()) {
ConsumerSwitchResult result = results.get(node);
String statusString = "OFF";
if (result.getStatus()) {
statusString = "ON";
}
System.out.println(String.format(OUTPUT_FORMAT, node.getId(), statusString));
}
}
return null;
}