[KARAF-1286] Add node alias support
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java b/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
index 926e05b..20e9eb7 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/ClusterManager.java
@@ -79,6 +79,22 @@
public Node findNodeById(String id);
/**
+ * Get a node identified by a given alias.
+ *
+ * @param alias the alias of the node to look for.
+ * @return the node.
+ */
+ public Node findNodeByAlias(String alias);
+
+ /**
+ * Get a node identified by a given ID or alias.
+ *
+ * @param idOrAlias the ID or alias of the node to look for.
+ * @return the node.
+ */
+ public Node findNodeByIdOrAlias(String idOrAlias);
+
+ /**
* Get the local node.
*
* @return the local node.
@@ -86,6 +102,13 @@
public Node getNode();
/**
+ * Set an alias for the local node.
+ *
+ * @param alias The node alias.
+ */
+ public void setNodeAlias(String alias);
+
+ /**
* Generate an unique ID across the cluster.
*
* @return a unique ID across the cluster.
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/Node.java b/core/src/main/java/org/apache/karaf/cellar/core/Node.java
index c05d6b2..670b6e1 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/Node.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/Node.java
@@ -41,4 +41,11 @@
*/
public int getPort();
+ /**
+ * Get the alias of the node.
+ *
+ * @return the node alias.
+ */
+ public String getAlias();
+
}
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarGroupMBean.java b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarGroupMBean.java
index 8d48da6..99b6566 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarGroupMBean.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarGroupMBean.java
@@ -40,19 +40,19 @@
* Join a node in a cluster group.
*
* @param name the cluster group name.
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of join failure.
*/
- void join(String name, String nodeId) throws Exception;
+ void join(String name, String nodeIdOrAlias) throws Exception;
/**
* Quit a node from a cluster group.
*
* @param name the cluster group name.
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of quit failure.
*/
- void quit(String name, String nodeId) throws Exception;
+ void quit(String name, String nodeIdOrAlias) throws Exception;
/**
* Get the list of cluster groups.
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarMBean.java b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarMBean.java
index 6cbe895..8d180b3 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarMBean.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarMBean.java
@@ -38,18 +38,18 @@
/**
* Start a cluster event consumer on a node.
*
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of start failure.
*/
- void consumerStart(String nodeId) throws Exception;
+ void consumerStart(String nodeIdOrAlias) throws Exception;
/**
* Stop a cluster event consumer on a node.
*
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of stop failure.
*/
- void consumerStop(String nodeId) throws Exception;
+ void consumerStop(String nodeIdOrAlias) throws Exception;
/**
* Get the status of the cluster event handlers.
@@ -63,19 +63,19 @@
* Start a cluster event handler on a node.
*
* @param handlerId the cluster event handler ID.
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of start failure.
*/
- void handlerStart(String handlerId, String nodeId) throws Exception;
+ void handlerStart(String handlerId, String nodeIdOrAlias) throws Exception;
/**
* Stop a cluster event handler on a node.
*
* @param handlerId the cluster event handler ID.
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of stop failure.
*/
- void handlerStop(String handlerId, String nodeId) throws Exception;
+ void handlerStop(String handlerId, String nodeIdOrAlias) throws Exception;
/**
* Get the status of the cluster event producers.
@@ -88,17 +88,17 @@
/**
* Start a cluster event producer on a node.
*
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of start failure.
*/
- void producerStart(String nodeId) throws Exception;
+ void producerStart(String nodeIdOrAlias) throws Exception;
/**
* Stop a cluster event producer on a node.
*
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @throws Exception in case of stop failure.
*/
- void producerStop(String nodeId) throws Exception;
+ void producerStop(String nodeIdOrAlias) throws Exception;
}
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarNodeMBean.java b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarNodeMBean.java
index 237c7c1..7324346 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/management/CellarNodeMBean.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/management/CellarNodeMBean.java
@@ -23,11 +23,36 @@
/**
* Ping a node.
*
- * @param nodeId the node ID.
+ * @param nodeIdOrAlias the node ID or alias.
* @return the time (in milliseconds) to reach the node.
* @throws Exception in case of ping failure.
*/
- long pingNode(String nodeId) throws Exception;
+ long pingNode(String nodeIdOrAlias) throws Exception;
+
+ /**
+ * Set the alias of the local node.
+ *
+ * @param alias The node alias.
+ * @throws Exception in case of failure.
+ */
+ void setAlias(String alias) throws Exception;
+
+ /**
+ * Get the alias for a given node ID.
+ *
+ * @param id the node ID or null for the local node.
+ * @return the corresponding alias (or null).
+ * @throws Exception in case of failure.
+ */
+ String getAlias(String id) throws Exception;
+
+ /**
+ * Get the node ID for a given alias.
+ * @param alias The node alias.
+ * @return The node ID.
+ * @throws Exception in case of failure.
+ */
+ String getId(String alias) throws Exception;
/**
* Get the list of nodes.
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
index a2b85a5..e124751 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/AllNodeCompleter.java
@@ -33,4 +33,10 @@
return true;
}
+ @Override
+ protected boolean addId() { return true; }
+
+ @Override
+ protected boolean addAlias() { return true; }
+
}
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeAliasCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeAliasCompleter.java
new file mode 100644
index 0000000..46b7971
--- /dev/null
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeAliasCompleter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.core.shell.completer;
+
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Service
+public class NodeAliasCompleter extends NodeCompleterSupport {
+
+ @Override
+ protected boolean acceptsNode(Node node) {
+ return true;
+ }
+
+ @Override
+ protected boolean addId() { return false; }
+
+ @Override
+ protected boolean addAlias() { return true; }
+
+}
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
index 2269315..6cba828 100644
--- a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeCompleterSupport.java
@@ -37,9 +37,17 @@
try {
for (Node node : clusterManager.listNodes()) {
if (acceptsNode(node)) {
- String id = node.getId();
- if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
- delegate.getStrings().add(id);
+ if (addId()) {
+ String id = node.getId();
+ if (delegate.getStrings() != null && !delegate.getStrings().contains(id)) {
+ delegate.getStrings().add(id);
+ }
+ }
+ if (addAlias()) {
+ String alias = node.getAlias();
+ if (delegate.getStrings() != null && !delegate.getStrings().contains(alias)) {
+ delegate.getStrings().add(alias);
+ }
}
}
}
@@ -51,6 +59,10 @@
protected abstract boolean acceptsNode(Node node);
+ protected abstract boolean addId();
+
+ protected abstract boolean addAlias();
+
public ClusterManager getClusterManager() {
return clusterManager;
}
diff --git a/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeIdCompleter.java b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeIdCompleter.java
new file mode 100644
index 0000000..139cd36
--- /dev/null
+++ b/core/src/main/java/org/apache/karaf/cellar/core/shell/completer/NodeIdCompleter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.core.shell.completer;
+
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Service
+public class NodeIdCompleter extends NodeCompleterSupport {
+
+ @Override
+ protected boolean acceptsNode(Node node) {
+ return true;
+ }
+
+ @Override
+ protected boolean addId() { return true; }
+
+ @Override
+ protected boolean addAlias() { return false; }
+
+}
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
index f6bc9b9..73f8b7c 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastClusterManager.java
@@ -146,6 +146,47 @@
return null;
}
+ @Override
+ public Node findNodeByAlias(String alias) {
+ if (alias != null) {
+ Cluster cluster = instance.getCluster();
+ if (cluster != null) {
+ Set<Member> members = cluster.getMembers();
+ if (members != null && !members.isEmpty()) {
+ for (Member member : members) {
+ HazelcastNode node = new HazelcastNode(member);
+ if (alias.equals(node.getAlias())) {
+ return node;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Node findNodeByIdOrAlias(String idOrAlias) {
+ if (idOrAlias != null) {
+ Cluster cluster = instance.getCluster();
+ if (cluster != null) {
+ Set<Member> members = cluster.getMembers();
+ if (members != null && !members.isEmpty()) {
+ for (Member member : members) {
+ HazelcastNode node = new HazelcastNode(member);
+ if (idOrAlias.equals(node.getId())) {
+ return node;
+ }
+ if (idOrAlias.equals(node.getAlias())) {
+ return node;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
/**
* List the nodes in a given cluster group.
*
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
index 2e668d4..17edd35 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastInstanceAware.java
@@ -48,6 +48,14 @@
}
}
+ public void setNodeAlias(String alias) {
+ Cluster cluster = instance.getCluster();
+ if (cluster != null) {
+ Member member = cluster.getLocalMember();
+ member.setStringAttribute("alias", alias);
+ }
+ }
+
public HazelcastInstance getInstance() {
return instance;
}
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
index a9bc3ff..530552a 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/HazelcastNode.java
@@ -25,9 +25,9 @@
public class HazelcastNode implements Node {
private String id;
-
private String host;
private int port;
+ private String alias;
public HazelcastNode(Member member) {
InetSocketAddress address = member.getSocketAddress();
@@ -35,6 +35,7 @@
this.port = address.getPort();
StringBuilder builder = new StringBuilder();
this.id = builder.append(host).append(":").append(port).toString();
+ this.alias = member.getStringAttribute("alias");
}
static String getHostString(InetSocketAddress socketAddress) {
@@ -66,6 +67,15 @@
}
@Override
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarGroupMBeanImpl.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarGroupMBeanImpl.java
index d959848..8c011f9 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarGroupMBeanImpl.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarGroupMBeanImpl.java
@@ -104,15 +104,15 @@
}
@Override
- public void join(String groupName, String nodeId) throws Exception {
+ public void join(String groupName, String nodeIdOrAlias) throws Exception {
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
}
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
Set<Node> nodes = new HashSet<Node>();
@@ -127,15 +127,15 @@
}
@Override
- public void quit(String groupName, String nodeId) throws Exception {
+ public void quit(String groupName, String nodeIdOrAlias) throws Exception {
Group group = groupManager.findGroupByName(groupName);
if (group == null) {
throw new IllegalArgumentException("Cluster group " + groupName + " doesn't exist");
}
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
Set<Node> nodes = new HashSet<Node>();
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarMBeanImpl.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarMBeanImpl.java
index 027e6be..33a5c30 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarMBeanImpl.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarMBeanImpl.java
@@ -143,17 +143,17 @@
}
@Override
- public void handlerStart(String handlerId, String nodeId) throws Exception {
+ public void handlerStart(String handlerId, String nodeIdOrAlias) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
nodes.add(node);
}
@@ -164,16 +164,16 @@
}
@Override
- public void handlerStop(String handlerId, String nodeId) throws Exception {
+ public void handlerStop(String handlerId, String nodeIdOrAlias) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
nodes.add(node);
}
@@ -211,17 +211,17 @@
}
@Override
- public void consumerStart(String nodeId) throws Exception {
+ public void consumerStart(String nodeIdOrAlias) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
nodes.add(node);
}
@@ -232,17 +232,17 @@
}
@Override
- public void consumerStop(String nodeId) throws Exception {
+ public void consumerStop(String nodeIdOrAlias) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
nodes.add(node);
}
@@ -280,17 +280,17 @@
}
@Override
- public void producerStop(String nodeId) throws Exception {
+ public void producerStop(String nodeIdOrAlias) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist");
}
nodes.add(node);
}
@@ -301,17 +301,17 @@
}
@Override
- public void producerStart(String nodeId) throws Exception {
+ public void producerStart(String nodeIdOrAlias) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
Set<Node> nodes = new HashSet<Node>();
- if (nodeId == null || nodeId.isEmpty()) {
+ if (nodeIdOrAlias == null || nodeIdOrAlias.isEmpty()) {
nodes.add(clusterManager.getNode());
} else {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster node " + nodeId + " doesn't exist)");
+ throw new IllegalArgumentException("Cluster node " + nodeIdOrAlias + " doesn't exist)");
}
nodes.add(node);
}
diff --git a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarNodeMBeanImpl.java b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarNodeMBeanImpl.java
index 4a4260a..327ba38 100644
--- a/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarNodeMBeanImpl.java
+++ b/hazelcast/src/main/java/org/apache/karaf/cellar/hazelcast/management/internal/CellarNodeMBeanImpl.java
@@ -53,10 +53,10 @@
}
@Override
- public long pingNode(String nodeId) throws Exception {
- Node node = clusterManager.findNodeById(nodeId);
+ public long pingNode(String nodeIdOrAlias) throws Exception {
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- throw new IllegalArgumentException("Cluster group " + nodeId + " doesn't exist");
+ throw new IllegalArgumentException("Cluster group " + nodeIdOrAlias + " doesn't exist");
}
Long start = System.currentTimeMillis();
Ping ping = new Ping(clusterManager.generateId());
@@ -67,12 +67,41 @@
}
@Override
+ public void setAlias(String alias) throws Exception {
+ if (alias == null) {
+ throw new IllegalArgumentException("Alias is null");
+ }
+ if (clusterManager.findNodeByAlias(alias) != null) {
+ throw new IllegalArgumentException("Alias " + alias + " already exists");
+ }
+ clusterManager.setNodeAlias(alias);
+ }
+
+ @Override
+ public String getAlias(String id) throws Exception {
+ Node node = clusterManager.findNodeById(id);
+ if (node != null) {
+ return node.getAlias();
+ }
+ return null;
+ }
+
+ @Override
+ public String getId(String alias) throws Exception {
+ Node node = clusterManager.findNodeByAlias(alias);
+ if (node != null) {
+ return node.getId();
+ }
+ return null;
+ }
+
+ @Override
public TabularData getNodes() throws Exception {
CompositeType nodeType = new CompositeType("Node", "Karaf Cellar cluster node",
- new String[]{ "id", "hostname", "port", "local" },
- new String[]{ "ID of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" },
- new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
+ new String[]{ "id", "alias", "hostname", "port", "local" },
+ new String[]{ "ID of the node", "Alias of the node", "Hostname of the node", "Port number of the node", "Flag defining if the node is local" },
+ new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.BOOLEAN });
TabularType tableType = new TabularType("Nodes", "Table of all Karaf Cellar nodes", nodeType, new String[]{ "id" });
@@ -83,8 +112,8 @@
for (Node node : nodes) {
boolean local = (node.equals(clusterManager.getNode()));
CompositeData data = new CompositeDataSupport(nodeType,
- new String[]{ "id", "hostname", "port", "local" },
- new Object[]{ node.getId(), node.getHost(), node.getPort(), local });
+ new String[]{ "id", "alias", "hostname", "port", "local" },
+ new Object[]{ node.getId(), node.getAlias(), node.getHost(), node.getPort(), local });
table.put(data);
}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/NodeAliasCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/NodeAliasCommand.java
new file mode 100644
index 0000000..ed4d8a9
--- /dev/null
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/NodeAliasCommand.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.cellar.shell;
+
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.shell.completer.NodeAliasCompleter;
+import org.apache.karaf.cellar.core.shell.completer.NodeIdCompleter;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "cluster", name = "node-alias", description = "Set or get node alias")
+@Service
+public class NodeAliasCommand extends ClusterCommandSupport {
+
+ @Argument(index = 0, name = "alias", description = "The alias to set", required = false, multiValued = false)
+ String alias;
+
+ @Option(name = "--id", description = "Look for the alias for a given node ID", required = false, multiValued = false)
+ @Completion(NodeIdCompleter.class)
+ String idLookup;
+
+ @Option(name = "--alias", description = "Look for the node ID for a given alias", required = false, multiValued = false)
+ @Completion(NodeAliasCompleter.class)
+ String aliasLookup;
+
+ @Override
+ protected Object doExecute() throws Exception {
+ if (idLookup != null) {
+ Node node = clusterManager.findNodeById(idLookup);
+ System.out.println(node.getAlias());
+ return null;
+ }
+ if (aliasLookup != null) {
+ Node node = clusterManager.findNodeByAlias(aliasLookup);
+ System.out.println(node.getId());
+ return null;
+ }
+ if (alias != null) {
+ if (clusterManager.findNodeByAlias(alias) != null) {
+ System.err.println("Alias " + alias + " already exists");
+ return null;
+ }
+ clusterManager.setNodeAlias(alias);
+ } else {
+ Node node = clusterManager.getNode();
+ if (node.getAlias() == null) {
+ System.out.println("");
+ } else {
+ System.out.println(node.getAlias());
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
index d42cfb6..fecf0ef 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/NodePingCommand.java
@@ -30,9 +30,9 @@
private static Long TIMEOUT = 10000L;
- @Argument(index = 0, name = "node", description = "The ID of the node to ping", required = true, multiValued = false)
+ @Argument(index = 0, name = "node", description = "The ID or alias of the node to ping", required = true, multiValued = false)
@Completion(AllNodeCompleter.class)
- String nodeId;
+ String nodeIdOrAlias;
@Argument(index = 1, name = "iterations", description = "The number of iterations to perform", required = false, multiValued = false)
Integer iterations = 10;
@@ -42,9 +42,9 @@
@Override
protected Object doExecute() throws Exception {
- Node node = clusterManager.findNodeById(nodeId);
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- System.out.println("Cluster node " + nodeId + " doesn't exist");
+ System.out.println("Cluster node " + nodeIdOrAlias + " doesn't exist");
return null;
}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
index 44ee352..29c6aa8 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/NodesListCommand.java
@@ -31,13 +31,14 @@
ShellTable table = new ShellTable();
table.column(" ");
table.column("Id");
+ table.column("Alias");
table.column("Host Name");
table.column("Port");
for (Node node : nodes) {
String local = "";
if (node.equals(clusterManager.getNode()))
local = "x";
- table.addRow().addContent(local, node.getId(), node.getHost(), node.getPort());
+ table.addRow().addContent(local, node.getId(), node.getAlias(), node.getHost(), node.getPort());
}
table.print(System.out);
} else {
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
index 6a719e1..c96073b 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStartCommand.java
@@ -26,7 +26,7 @@
@Service
public class ConsumerStartCommand extends ConsumerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
index b436870..f465dc8 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStatusCommand.java
@@ -25,7 +25,7 @@
@Service
public class ConsumerStatusCommand extends ConsumerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
index 992e5e0..16edcae 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerStopCommand.java
@@ -26,7 +26,7 @@
@Service
public class ConsumerStopCommand extends ConsumerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID.", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
index 4b3b769..e717648 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/consumer/ConsumerSupport.java
@@ -30,18 +30,18 @@
*/
public abstract class ConsumerSupport extends ClusterCommandSupport {
- protected Object doExecute(List<String> nodeIds, SwitchStatus status) throws Exception {
+ protected Object doExecute(List<String> nodeIdsOrAliases, SwitchStatus status) throws Exception {
ConsumerSwitchCommand command = new ConsumerSwitchCommand(clusterManager.generateId());
command.setTimeout(timeout * 1000);
// looking for nodes and check if exist
Set<Node> recipientList = new HashSet<Node>();
- if (nodeIds != null && !nodeIds.isEmpty()) {
- for (String nodeId : nodeIds) {
- Node node = clusterManager.findNodeById(nodeId);
+ if (nodeIdsOrAliases != null && !nodeIdsOrAliases.isEmpty()) {
+ for (String nodeIdOrAlias : nodeIdsOrAliases) {
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- System.err.println("Cluster node " + nodeId + " doesn't exist");
+ System.err.println("Cluster node " + nodeIdOrAlias + " doesn't exist");
} else {
recipientList.add(node);
}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
index f1dab58..2833470 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
@@ -32,7 +32,7 @@
@Completion(AllGroupsCompleter.class)
String groupName;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
index d346fb6..f84d037 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
@@ -26,7 +26,7 @@
@Service
public class GroupListCommand extends GroupSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
index 4bd3cb3..9e5d9d2 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
@@ -32,7 +32,7 @@
@Completion(AllGroupsCompleter.class)
String groupName;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
index e7362b8..be6ef05 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
@@ -32,7 +32,7 @@
@Completion(AllGroupsCompleter.class)
String groupName;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
index 71b16eb..261588a 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
@@ -40,23 +40,23 @@
*
* @param action the group action to perform.
* @param group the cluster group name.
- * @param nodeIds the node IDs.
+ * @param nodeIdsOrAliases the node IDs.
* @param suppressOutput true to display command output, false else.
* @return the Object resulting of the command execution.
* @throws Exception in case of execution failure.
*/
- protected Object doExecute(ManageGroupAction action, String group, Group source, Collection<String> nodeIds, Boolean suppressOutput) throws Exception {
+ protected Object doExecute(ManageGroupAction action, String group, Group source, Collection<String> nodeIdsOrAliases, Boolean suppressOutput) throws Exception {
ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId());
command.setTimeout(timeout * 1000);
// looking for nodes and check if exist
Set<Node> recipientList = new HashSet<Node>();
- if (nodeIds != null && !nodeIds.isEmpty()) {
- for (String nodeId : nodeIds) {
- Node node = clusterManager.findNodeById(nodeId);
+ if (nodeIdsOrAliases != null && !nodeIdsOrAliases.isEmpty()) {
+ for (String nodeIdOrAlias : nodeIdsOrAliases) {
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- System.err.println("Cluster node " + nodeId + " doesn't exist");
+ System.err.println("Cluster node " + nodeIdOrAlias + " doesn't exist");
} else {
recipientList.add(node);
}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
index 6618402..7a6c090 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
@@ -28,7 +28,7 @@
@Argument(index = 0, name = "handler", description = "The cluster event handler ID", required = true, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
index 7717df6..326bd0d 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
@@ -28,7 +28,7 @@
@Argument(index = 0, name = "handler", description = "The cluster event handler", required = false, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
index 68b13f6..5799e84 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
@@ -28,7 +28,7 @@
@Argument(index = 0, name = "handler", description = "The event handler", required = true, multiValued = false)
String handler;
- @Argument(index = 1, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 1, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
index e9fbb4b..495183e 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
@@ -29,18 +29,18 @@
*/
public abstract class HandlersSupport extends ClusterCommandSupport {
- protected Object doExecute(String handlerName, List<String> nodeIds, Boolean status) throws Exception {
+ protected Object doExecute(String handlerName, List<String> nodeIdsOrAliases, Boolean status) throws Exception {
ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
command.setTimeout(timeout * 1000);
// looking for nodes and check if exist
Set<Node> recipientList = new HashSet<Node>();
- if (nodeIds != null && !nodeIds.isEmpty()) {
- for (String nodeId : nodeIds) {
- Node node = clusterManager.findNodeById(nodeId);
+ if (nodeIdsOrAliases != null && !nodeIdsOrAliases.isEmpty()) {
+ for (String nodeIdOrAlias : nodeIdsOrAliases) {
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- System.err.println("Cluster node " + nodeId + " doesn't exist");
+ System.err.println("Cluster node " + nodeIdOrAlias + " doesn't exist");
} else {
recipientList.add(node);
}
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
index 6ea606c..1e25a50 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
@@ -26,7 +26,7 @@
@Service
public class ProducerStartCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
index eb87744..c6b41c5 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
@@ -25,7 +25,7 @@
@Service
public class ProducerStatusCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
index bb1291e..9db7c77 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
@@ -26,7 +26,7 @@
@Service
public class ProducerStopCommand extends ProducerSupport {
- @Argument(index = 0, name = "node", description = "The node(s) ID", required = false, multiValued = true)
+ @Argument(index = 0, name = "node", description = "The node(s) ID or alias", required = false, multiValued = true)
@Completion(AllNodeCompleter.class)
List<String> nodes;
diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
index 947cc79..91c1245 100644
--- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
+++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
@@ -30,18 +30,18 @@
*/
public abstract class ProducerSupport extends ClusterCommandSupport {
- protected Object doExecute(List<String> nodeIds, SwitchStatus status) throws Exception {
+ protected Object doExecute(List<String> nodeIdsOrAliases, SwitchStatus status) throws Exception {
ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
command.setTimeout(timeout * 1000);
// looking for nodes and check if exist
Set<Node> recipientList = new HashSet<Node>();
- if (nodeIds != null && !nodeIds.isEmpty()) {
- for (String nodeId : nodeIds) {
- Node node = clusterManager.findNodeById(nodeId);
+ if (nodeIdsOrAliases != null && !nodeIdsOrAliases.isEmpty()) {
+ for (String nodeIdOrAlias : nodeIdsOrAliases) {
+ Node node = clusterManager.findNodeByIdOrAlias(nodeIdOrAlias);
if (node == null) {
- System.err.println("Cluster node " + nodeId + " doesn't exist");
+ System.err.println("Cluster node " + nodeIdOrAlias + " doesn't exist");
} else {
recipientList.add(node);
}