Renamed *Instance to *Node for better readability and to avoid conflict with notion of Karaf instance.
Added cluster service and trivial store implementations.
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ClusterEvent.java b/core/api/src/main/java/org/onlab/onos/cluster/ClusterEvent.java
index 300a143..a47c43f 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ClusterEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ClusterEvent.java
@@ -5,7 +5,7 @@
/**
* Describes cluster-related event.
*/
-public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerInstance> {
+public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerNode> {
/**
* Type of cluster-related events.
@@ -39,7 +39,7 @@
* @param type cluster event type
* @param instance cluster device subject
*/
- public ClusterEvent(Type type, ControllerInstance instance) {
+ public ClusterEvent(Type type, ControllerNode instance) {
super(type, instance);
}
@@ -50,7 +50,7 @@
* @param instance event device subject
* @param time occurrence time
*/
- public ClusterEvent(Type type, ControllerInstance instance, long time) {
+ public ClusterEvent(Type type, ControllerNode instance, long time) {
super(type, instance, time);
}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ClusterService.java b/core/api/src/main/java/org/onlab/onos/cluster/ClusterService.java
index 017ccd2..9c0af8f 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ClusterService.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ClusterService.java
@@ -3,24 +3,40 @@
import java.util.Set;
/**
- * Service for obtaining information about the individual instances within
+ * Service for obtaining information about the individual nodes within
* the controller cluster.
*/
public interface ClusterService {
/**
+ * Returns the local controller node.
+ *
+ * @return local controller node
+ */
+ ControllerNode getLocalNode();
+
+ /**
* Returns the set of current cluster members.
*
* @return set of cluster members
*/
- Set<ControllerInstance> getInstances();
+ Set<ControllerNode> getNodes();
/**
- * Returns the availability state of the specified controller instance.
+ * Returns the specified controller node.
*
+ * @param nodeId controller node identifier
+ * @return controller node
+ */
+ ControllerNode getNode(NodeId nodeId);
+
+ /**
+ * Returns the availability state of the specified controller node.
+ *
+ * @param nodeId controller node identifier
* @return availability state
*/
- ControllerInstance.State getState(ControllerInstance instance);
+ ControllerNode.State getState(NodeId nodeId);
/**
* Adds the specified cluster event listener.
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
new file mode 100644
index 0000000..7d4b71f
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ClusterStore.java
@@ -0,0 +1,40 @@
+package org.onlab.onos.cluster;
+
+import java.util.Set;
+
+/**
+ * Manages inventory of controller cluster nodes; not intended for direct use.
+ */
+public interface ClusterStore {
+
+ /**
+ * Returns the local controller instance.
+ *
+ * @return local controller instance
+ */
+ ControllerNode getLocalNode();
+
+ /**
+ * Returns the set of current cluster members.
+ *
+ * @return set of cluster members
+ */
+ Set<ControllerNode> getNodes();
+
+ /**
+ * Returns the specified controller instance.
+ *
+ * @param nodeId controller instance identifier
+ * @return controller instance
+ */
+ ControllerNode getNode(NodeId nodeId);
+
+ /**
+ * Returns the availability state of the specified controller instance.
+ *
+ * @param nodeId controller instance identifier
+ * @return availability state
+ */
+ ControllerNode.State getState(NodeId nodeId);
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/ControllerInstance.java b/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
similarity index 92%
rename from core/api/src/main/java/org/onlab/onos/cluster/ControllerInstance.java
rename to core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
index 9255175..c6f0cb3 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/ControllerInstance.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/ControllerNode.java
@@ -5,7 +5,7 @@
/**
* Represents a controller instance as a member in a cluster.
*/
-public interface ControllerInstance {
+public interface ControllerNode {
/** Represents the operational state of the instance. */
public enum State {
@@ -26,7 +26,7 @@
*
* @return instance identifier
*/
- InstanceId id();
+ NodeId id();
/**
* Returns the IP address of the controller instance.
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
new file mode 100644
index 0000000..9735fdb
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/cluster/DefaultControllerNode.java
@@ -0,0 +1,60 @@
+package org.onlab.onos.cluster;
+
+import org.onlab.packet.IpPrefix;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Default implementation of a controller instance descriptor.
+ */
+public class DefaultControllerNode implements ControllerNode {
+
+ private final NodeId id;
+ private final IpPrefix ip;
+
+ /**
+ * Creates a new instance with the specified id and IP address.
+ *
+ * @param id instance identifier
+ * @param ip instance IP address
+ */
+ public DefaultControllerNode(NodeId id, IpPrefix ip) {
+ this.id = id;
+ this.ip = ip;
+ }
+
+ @Override
+ public NodeId id() {
+ return id;
+ }
+
+ @Override
+ public IpPrefix ip() {
+ return ip;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o instanceof DefaultControllerNode) {
+ DefaultControllerNode that = (DefaultControllerNode) o;
+ return Objects.equals(this.id, that.id);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("ip", ip).toString();
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/MastershipAdminService.java b/core/api/src/main/java/org/onlab/onos/cluster/MastershipAdminService.java
index 6c58020..907b3f8 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/MastershipAdminService.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/MastershipAdminService.java
@@ -15,6 +15,6 @@
* @param deviceId device identifier
* @param role requested role
*/
- void setRole(InstanceId instance, DeviceId deviceId, MastershipRole role);
+ void setRole(NodeId instance, DeviceId deviceId, MastershipRole role);
}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java b/core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java
index a835449..2a5e62e 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/MastershipEvent.java
@@ -8,7 +8,7 @@
*/
public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
- InstanceId master;
+ NodeId master;
/**
* Type of mastership events.
@@ -28,7 +28,7 @@
* @param device event device subject
* @param master master ID subject
*/
- protected MastershipEvent(Type type, DeviceId device, InstanceId master) {
+ protected MastershipEvent(Type type, DeviceId device, NodeId master) {
super(type, device);
this.master = master;
}
@@ -42,7 +42,7 @@
* @param master master ID subject
* @param time occurrence time
*/
- protected MastershipEvent(Type type, DeviceId device, InstanceId master, long time) {
+ protected MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
super(type, device, time);
this.master = master;
}
@@ -52,7 +52,7 @@
*
* @return master ID subject
*/
- public InstanceId master() {
+ public NodeId master() {
return master;
}
}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java b/core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
index bc5f19c..6a9b60e 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/MastershipService.java
@@ -19,15 +19,15 @@
* @param deviceId the identifier of the device
* @return the ID of the master controller for the device
*/
- InstanceId getMasterFor(DeviceId deviceId);
+ NodeId getMasterFor(DeviceId deviceId);
/**
* Returns the devices for which a controller is master.
*
- * @param instanceId the ID of the controller
+ * @param nodeId the ID of the controller
* @return a set of device IDs
*/
- Set<DeviceId> getDevicesOf(InstanceId instanceId);
+ Set<DeviceId> getDevicesOf(NodeId nodeId);
/**
* Returns the mastership status of this controller for a given device.
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java b/core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
index 67eeff5..728e77d 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/MastershipStore.java
@@ -6,11 +6,12 @@
import org.onlab.onos.net.MastershipRole;
/**
- * Manages inventory of mastership roles for devices, across controller instances.
+ * Manages inventory of mastership roles for devices, across controller
+ * instances; not intended for direct use.
*/
public interface MastershipStore {
- // three things to map: InstanceId, DeviceId, MastershipRole
+ // three things to map: NodeId, DeviceId, MastershipRole
/**
* Sets a device's role for a specified controller instance.
@@ -20,7 +21,7 @@
* @param role new role
* @return a mastership event
*/
- MastershipEvent setRole(InstanceId instance, DeviceId deviceId,
+ MastershipEvent setRole(NodeId instance, DeviceId deviceId,
MastershipRole role);
/**
@@ -31,7 +32,7 @@
* @param role new role
* @return a mastership event
*/
- MastershipEvent addOrUpdateDevice(InstanceId instance, DeviceId deviceId,
+ MastershipEvent addOrUpdateDevice(NodeId instance, DeviceId deviceId,
MastershipRole role);
/**
@@ -40,22 +41,22 @@
* @param deviceId the device identifier
* @return the instance identifier of the master
*/
- InstanceId getMaster(DeviceId deviceId);
+ NodeId getMaster(DeviceId deviceId);
/**
* Returns the devices that a controller instance is master of.
*
- * @param instanceId the instance identifier
+ * @param nodeId the instance identifier
* @return a set of device identifiers
*/
- Set<DeviceId> getDevices(InstanceId instanceId);
+ Set<DeviceId> getDevices(NodeId nodeId);
/**
* Returns the role of a device for a specific controller instance.
*
- * @param instanceId the instance identifier
+ * @param nodeId the instance identifier
* @param deviceId the device identifiers
* @return the role
*/
- MastershipRole getRole(InstanceId instanceId, DeviceId deviceId);
+ MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
}
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java b/core/api/src/main/java/org/onlab/onos/cluster/NodeId.java
similarity index 62%
rename from core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java
rename to core/api/src/main/java/org/onlab/onos/cluster/NodeId.java
index 14f1eda..2430d52 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/InstanceId.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/NodeId.java
@@ -2,26 +2,24 @@
import java.util.Objects;
-import static com.google.common.base.MoreObjects.toStringHelper;
-
/**
* Controller cluster identity.
*/
-public class InstanceId {
+public class NodeId {
private final String id;
// Default constructor for serialization
- protected InstanceId() {
+ protected NodeId() {
id = null;
}
/**
- * Creates a new cluster instance identifier from the specified string.
+ * Creates a new cluster node identifier from the specified string.
*
* @param id string identifier
*/
- public InstanceId(String id) {
+ public NodeId(String id) {
this.id = id;
}
@@ -35,8 +33,8 @@
if (this == obj) {
return true;
}
- if (obj instanceof InstanceId) {
- final InstanceId other = (InstanceId) obj;
+ if (obj instanceof NodeId) {
+ final NodeId other = (NodeId) obj;
return Objects.equals(this.id, other.id);
}
return false;
@@ -44,7 +42,7 @@
@Override
public String toString() {
- return toStringHelper(this).add("id", id).toString();
+ return id;
}
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java b/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
index 851fbc1..3ed477b 100644
--- a/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
@@ -10,7 +10,7 @@
import java.util.List;
/**
- * Manages inventory of infrastructure devices.
+ * Manages inventory of infrastructure devices; not intended for direct use.
*/
public interface DeviceStore {
diff --git a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleStore.java b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleStore.java
index 0698721..f00b595 100644
--- a/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/flow/FlowRuleStore.java
@@ -3,7 +3,7 @@
import org.onlab.onos.net.DeviceId;
/**
- * Manages inventory of flow rules.
+ * Manages inventory of flow rules; not intended for direct use.
*/
public interface FlowRuleStore {
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java b/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
index 94c4585..ea316b2 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
@@ -12,8 +12,7 @@
import java.util.Set;
/**
- * Manages inventory of end-station hosts. It may do so using whatever
- * means are appropriate.
+ * Manages inventory of end-station hosts; not intended for direct use.
*/
public interface HostStore {
diff --git a/core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java b/core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java
index 4391471..dbe4877 100644
--- a/core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/link/LinkStore.java
@@ -8,8 +8,7 @@
import java.util.Set;
/**
- * Manages inventory of infrastructure links. It may do so using whatever
- * means are appropriate.
+ * Manages inventory of infrastructure links; not intended for direct use.
*/
public interface LinkStore {
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyStore.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyStore.java
index 5e8b19d..adc6145 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyStore.java
@@ -11,8 +11,7 @@
import java.util.Set;
/**
- * Manages inventory of topology snapshots. It may do so using whatever
- * means appropriate.
+ * Manages inventory of topology snapshots; not intended for direct use.
*/
public interface TopologyStore {