Preparing for change in ClusterService/Store implementation.
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ClusterAdminService.java b/core/api/src/main/java/org/onlab/onos/cluster/ClusterAdminService.java
index 4f98804..73137e1 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ClusterAdminService.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ClusterAdminService.java
@@ -1,11 +1,23 @@
package org.onlab.onos.cluster;
+import org.onlab.packet.IpPrefix;
+
/**
* Service for administering the cluster node membership.
*/
public interface ClusterAdminService {
/**
+ * Adds a new controller node to the cluster.
+ *
+ * @param nodeId controller node identifier
+ * @param ip node IP listen address
+ * @param tcpPort tcp listen port
+ * @return newly added node
+ */
+ ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort);
+
+ /**
* Removes the specified node from the cluster node list.
*
* @param nodeId controller node identifier
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ClusterStore.java b/core/api/src/main/java/org/onlab/onos/cluster/ClusterStore.java
index ea5bbd3..3725706 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ClusterStore.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ClusterStore.java
@@ -1,6 +1,7 @@
package org.onlab.onos.cluster;
import org.onlab.onos.store.Store;
+import org.onlab.packet.IpPrefix;
import java.util.Set;
@@ -40,6 +41,16 @@
ControllerNode.State getState(NodeId nodeId);
/**
+ * Adds a new controller node to the cluster.
+ *
+ * @param nodeId controller node identifier
+ * @param ip node IP listen address
+ * @param tcpPort tcp listen port
+ * @return newly added node
+ */
+ ControllerNode addNode(NodeId nodeId, IpPrefix ip, int tcpPort);
+
+ /**
* Removes the specified node from the inventory of cluster nodes.
*
* @param nodeId controller instance identifier
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java b/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
index c6f0cb3..33fe1c9 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
@@ -35,4 +35,12 @@
*/
IpPrefix ip();
+
+ /**
+ * Returns the TCP port on which the node listens for connections.
+ *
+ * @return TCP port
+ */
+ int tcpPort();
+
}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java b/core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
index 86ea14c..d23b7a3 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
@@ -11,13 +11,17 @@
*/
public class DefaultControllerNode implements ControllerNode {
+ private static final int DEFAULT_PORT = 9876;
+
private final NodeId id;
private final IpPrefix ip;
+ private final int tcpPort;
// For serialization
private DefaultControllerNode() {
this.id = null;
this.ip = null;
+ this.tcpPort = 0;
}
/**
@@ -27,8 +31,19 @@
* @param ip instance IP address
*/
public DefaultControllerNode(NodeId id, IpPrefix ip) {
+ this(id, ip, DEFAULT_PORT);
+ }
+
+ /**
+ * Creates a new instance with the specified id and IP address and TCP port.
+ *
+ * @param id instance identifier
+ * @param ip instance IP address
+ */
+ public DefaultControllerNode(NodeId id, IpPrefix ip, int tcpPort) {
this.id = id;
this.ip = ip;
+ this.tcpPort = tcpPort;
}
@Override
@@ -42,6 +57,11 @@
}
@Override
+ public int tcpPort() {
+ return tcpPort;
+ }
+
+ @Override
public int hashCode() {
return Objects.hash(id);
}
@@ -60,7 +80,8 @@
@Override
public String toString() {
- return toStringHelper(this).add("id", id).add("ip", ip).toString();
+ return toStringHelper(this).add("id", id)
+ .add("ip", ip).add("tcpPort", tcpPort).toString();
}
}