tom

Renamed *Instance to *Node for better readability and to avoid conflict with not…

…ion of Karaf instance.
Added cluster service and trivial store implementations.
Showing 24 changed files with 369 additions and 51 deletions
1 +package org.onlab.onos.cli;
2 +
3 +import org.apache.karaf.shell.commands.Command;
4 +import org.onlab.onos.cluster.ClusterService;
5 +import org.onlab.onos.cluster.ControllerNode;
6 +
7 +import java.util.Collections;
8 +import java.util.Comparator;
9 +import java.util.List;
10 +
11 +import static com.google.common.collect.Lists.newArrayList;
12 +
13 +/**
14 + * Lists all controller cluster nodes.
15 + */
16 +@Command(scope = "onos", name = "nodes",
17 + description = "Lists all controller cluster nodes")
18 +public class NodesListCommand extends AbstractShellCommand {
19 +
20 + private static final String FMT =
21 + "id=%s, ip=%s, state=%s %s";
22 +
23 + protected static final Comparator<ControllerNode> ID_COMPARATOR =
24 + new Comparator<ControllerNode>() {
25 + @Override
26 + public int compare(ControllerNode ci1, ControllerNode ci2) {
27 + return ci1.id().toString().compareTo(ci2.id().toString());
28 + }
29 + };
30 +
31 + @Override
32 + protected Object doExecute() throws Exception {
33 + ClusterService service = getService(ClusterService.class);
34 + List<ControllerNode> nodes = newArrayList(service.getNodes());
35 + Collections.sort(nodes, ID_COMPARATOR);
36 + ControllerNode self = service.getLocalNode();
37 + for (ControllerNode node : nodes) {
38 + print(FMT, node.id(), node.ip(),
39 + service.getState(node.id()),
40 + node.equals(self) ? "*" : "");
41 + }
42 + return null;
43 + }
44 +
45 +}
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
2 2
3 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> 3 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
4 <command> 4 <command>
5 + <action class="org.onlab.onos.cli.NodesListCommand"/>
6 + </command>
7 + <command>
5 <action class="org.onlab.onos.cli.net.FlowsListCommand"/> 8 <action class="org.onlab.onos.cli.net.FlowsListCommand"/>
6 </command> 9 </command>
7 <command> 10 <command>
......
...@@ -5,7 +5,7 @@ import org.onlab.onos.event.AbstractEvent; ...@@ -5,7 +5,7 @@ import org.onlab.onos.event.AbstractEvent;
5 /** 5 /**
6 * Describes cluster-related event. 6 * Describes cluster-related event.
7 */ 7 */
8 -public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerInstance> { 8 +public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerNode> {
9 9
10 /** 10 /**
11 * Type of cluster-related events. 11 * Type of cluster-related events.
...@@ -39,7 +39,7 @@ public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerIns ...@@ -39,7 +39,7 @@ public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerIns
39 * @param type cluster event type 39 * @param type cluster event type
40 * @param instance cluster device subject 40 * @param instance cluster device subject
41 */ 41 */
42 - public ClusterEvent(Type type, ControllerInstance instance) { 42 + public ClusterEvent(Type type, ControllerNode instance) {
43 super(type, instance); 43 super(type, instance);
44 } 44 }
45 45
...@@ -50,7 +50,7 @@ public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerIns ...@@ -50,7 +50,7 @@ public class ClusterEvent extends AbstractEvent<ClusterEvent.Type, ControllerIns
50 * @param instance event device subject 50 * @param instance event device subject
51 * @param time occurrence time 51 * @param time occurrence time
52 */ 52 */
53 - public ClusterEvent(Type type, ControllerInstance instance, long time) { 53 + public ClusterEvent(Type type, ControllerNode instance, long time) {
54 super(type, instance, time); 54 super(type, instance, time);
55 } 55 }
56 56
......
...@@ -3,24 +3,40 @@ package org.onlab.onos.cluster; ...@@ -3,24 +3,40 @@ package org.onlab.onos.cluster;
3 import java.util.Set; 3 import java.util.Set;
4 4
5 /** 5 /**
6 - * Service for obtaining information about the individual instances within 6 + * Service for obtaining information about the individual nodes within
7 * the controller cluster. 7 * the controller cluster.
8 */ 8 */
9 public interface ClusterService { 9 public interface ClusterService {
10 10
11 /** 11 /**
12 + * Returns the local controller node.
13 + *
14 + * @return local controller node
15 + */
16 + ControllerNode getLocalNode();
17 +
18 + /**
12 * Returns the set of current cluster members. 19 * Returns the set of current cluster members.
13 * 20 *
14 * @return set of cluster members 21 * @return set of cluster members
15 */ 22 */
16 - Set<ControllerInstance> getInstances(); 23 + Set<ControllerNode> getNodes();
24 +
25 + /**
26 + * Returns the specified controller node.
27 + *
28 + * @param nodeId controller node identifier
29 + * @return controller node
30 + */
31 + ControllerNode getNode(NodeId nodeId);
17 32
18 /** 33 /**
19 - * Returns the availability state of the specified controller instance. 34 + * Returns the availability state of the specified controller node.
20 * 35 *
36 + * @param nodeId controller node identifier
21 * @return availability state 37 * @return availability state
22 */ 38 */
23 - ControllerInstance.State getState(ControllerInstance instance); 39 + ControllerNode.State getState(NodeId nodeId);
24 40
25 /** 41 /**
26 * Adds the specified cluster event listener. 42 * Adds the specified cluster event listener.
......
1 +package org.onlab.onos.cluster;
2 +
3 +import java.util.Set;
4 +
5 +/**
6 + * Manages inventory of controller cluster nodes; not intended for direct use.
7 + */
8 +public interface ClusterStore {
9 +
10 + /**
11 + * Returns the local controller instance.
12 + *
13 + * @return local controller instance
14 + */
15 + ControllerNode getLocalNode();
16 +
17 + /**
18 + * Returns the set of current cluster members.
19 + *
20 + * @return set of cluster members
21 + */
22 + Set<ControllerNode> getNodes();
23 +
24 + /**
25 + * Returns the specified controller instance.
26 + *
27 + * @param nodeId controller instance identifier
28 + * @return controller instance
29 + */
30 + ControllerNode getNode(NodeId nodeId);
31 +
32 + /**
33 + * Returns the availability state of the specified controller instance.
34 + *
35 + * @param nodeId controller instance identifier
36 + * @return availability state
37 + */
38 + ControllerNode.State getState(NodeId nodeId);
39 +
40 +}
...@@ -5,7 +5,7 @@ import org.onlab.packet.IpPrefix; ...@@ -5,7 +5,7 @@ import org.onlab.packet.IpPrefix;
5 /** 5 /**
6 * Represents a controller instance as a member in a cluster. 6 * Represents a controller instance as a member in a cluster.
7 */ 7 */
8 -public interface ControllerInstance { 8 +public interface ControllerNode {
9 9
10 /** Represents the operational state of the instance. */ 10 /** Represents the operational state of the instance. */
11 public enum State { 11 public enum State {
...@@ -26,7 +26,7 @@ public interface ControllerInstance { ...@@ -26,7 +26,7 @@ public interface ControllerInstance {
26 * 26 *
27 * @return instance identifier 27 * @return instance identifier
28 */ 28 */
29 - InstanceId id(); 29 + NodeId id();
30 30
31 /** 31 /**
32 * Returns the IP address of the controller instance. 32 * Returns the IP address of the controller instance.
......
1 +package org.onlab.onos.cluster;
2 +
3 +import org.onlab.packet.IpPrefix;
4 +
5 +import java.util.Objects;
6 +
7 +import static com.google.common.base.MoreObjects.toStringHelper;
8 +
9 +/**
10 + * Default implementation of a controller instance descriptor.
11 + */
12 +public class DefaultControllerNode implements ControllerNode {
13 +
14 + private final NodeId id;
15 + private final IpPrefix ip;
16 +
17 + /**
18 + * Creates a new instance with the specified id and IP address.
19 + *
20 + * @param id instance identifier
21 + * @param ip instance IP address
22 + */
23 + public DefaultControllerNode(NodeId id, IpPrefix ip) {
24 + this.id = id;
25 + this.ip = ip;
26 + }
27 +
28 + @Override
29 + public NodeId id() {
30 + return id;
31 + }
32 +
33 + @Override
34 + public IpPrefix ip() {
35 + return ip;
36 + }
37 +
38 + @Override
39 + public int hashCode() {
40 + return Objects.hash(id);
41 + }
42 +
43 + @Override
44 + public boolean equals(Object o) {
45 + if (this == o) {
46 + return true;
47 + }
48 + if (o instanceof DefaultControllerNode) {
49 + DefaultControllerNode that = (DefaultControllerNode) o;
50 + return Objects.equals(this.id, that.id);
51 + }
52 + return false;
53 + }
54 +
55 + @Override
56 + public String toString() {
57 + return toStringHelper(this).add("id", id).add("ip", ip).toString();
58 + }
59 +
60 +}
...@@ -15,6 +15,6 @@ public interface MastershipAdminService { ...@@ -15,6 +15,6 @@ public interface MastershipAdminService {
15 * @param deviceId device identifier 15 * @param deviceId device identifier
16 * @param role requested role 16 * @param role requested role
17 */ 17 */
18 - void setRole(InstanceId instance, DeviceId deviceId, MastershipRole role); 18 + void setRole(NodeId instance, DeviceId deviceId, MastershipRole role);
19 19
20 } 20 }
......
...@@ -8,7 +8,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -8,7 +8,7 @@ import org.onlab.onos.net.DeviceId;
8 */ 8 */
9 public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> { 9 public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
10 10
11 - InstanceId master; 11 + NodeId master;
12 12
13 /** 13 /**
14 * Type of mastership events. 14 * Type of mastership events.
...@@ -28,7 +28,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -28,7 +28,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
28 * @param device event device subject 28 * @param device event device subject
29 * @param master master ID subject 29 * @param master master ID subject
30 */ 30 */
31 - protected MastershipEvent(Type type, DeviceId device, InstanceId master) { 31 + protected MastershipEvent(Type type, DeviceId device, NodeId master) {
32 super(type, device); 32 super(type, device);
33 this.master = master; 33 this.master = master;
34 } 34 }
...@@ -42,7 +42,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -42,7 +42,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
42 * @param master master ID subject 42 * @param master master ID subject
43 * @param time occurrence time 43 * @param time occurrence time
44 */ 44 */
45 - protected MastershipEvent(Type type, DeviceId device, InstanceId master, long time) { 45 + protected MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
46 super(type, device, time); 46 super(type, device, time);
47 this.master = master; 47 this.master = master;
48 } 48 }
...@@ -52,7 +52,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -52,7 +52,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
52 * 52 *
53 * @return master ID subject 53 * @return master ID subject
54 */ 54 */
55 - public InstanceId master() { 55 + public NodeId master() {
56 return master; 56 return master;
57 } 57 }
58 } 58 }
......
...@@ -19,15 +19,15 @@ public interface MastershipService { ...@@ -19,15 +19,15 @@ public interface MastershipService {
19 * @param deviceId the identifier of the device 19 * @param deviceId the identifier of the device
20 * @return the ID of the master controller for the device 20 * @return the ID of the master controller for the device
21 */ 21 */
22 - InstanceId getMasterFor(DeviceId deviceId); 22 + NodeId getMasterFor(DeviceId deviceId);
23 23
24 /** 24 /**
25 * Returns the devices for which a controller is master. 25 * Returns the devices for which a controller is master.
26 * 26 *
27 - * @param instanceId the ID of the controller 27 + * @param nodeId the ID of the controller
28 * @return a set of device IDs 28 * @return a set of device IDs
29 */ 29 */
30 - Set<DeviceId> getDevicesOf(InstanceId instanceId); 30 + Set<DeviceId> getDevicesOf(NodeId nodeId);
31 31
32 /** 32 /**
33 * Returns the mastership status of this controller for a given device. 33 * Returns the mastership status of this controller for a given device.
......
...@@ -6,11 +6,12 @@ import org.onlab.onos.net.DeviceId; ...@@ -6,11 +6,12 @@ import org.onlab.onos.net.DeviceId;
6 import org.onlab.onos.net.MastershipRole; 6 import org.onlab.onos.net.MastershipRole;
7 7
8 /** 8 /**
9 - * Manages inventory of mastership roles for devices, across controller instances. 9 + * Manages inventory of mastership roles for devices, across controller
10 + * instances; not intended for direct use.
10 */ 11 */
11 public interface MastershipStore { 12 public interface MastershipStore {
12 13
13 - // three things to map: InstanceId, DeviceId, MastershipRole 14 + // three things to map: NodeId, DeviceId, MastershipRole
14 15
15 /** 16 /**
16 * Sets a device's role for a specified controller instance. 17 * Sets a device's role for a specified controller instance.
...@@ -20,7 +21,7 @@ public interface MastershipStore { ...@@ -20,7 +21,7 @@ public interface MastershipStore {
20 * @param role new role 21 * @param role new role
21 * @return a mastership event 22 * @return a mastership event
22 */ 23 */
23 - MastershipEvent setRole(InstanceId instance, DeviceId deviceId, 24 + MastershipEvent setRole(NodeId instance, DeviceId deviceId,
24 MastershipRole role); 25 MastershipRole role);
25 26
26 /** 27 /**
...@@ -31,7 +32,7 @@ public interface MastershipStore { ...@@ -31,7 +32,7 @@ public interface MastershipStore {
31 * @param role new role 32 * @param role new role
32 * @return a mastership event 33 * @return a mastership event
33 */ 34 */
34 - MastershipEvent addOrUpdateDevice(InstanceId instance, DeviceId deviceId, 35 + MastershipEvent addOrUpdateDevice(NodeId instance, DeviceId deviceId,
35 MastershipRole role); 36 MastershipRole role);
36 37
37 /** 38 /**
...@@ -40,22 +41,22 @@ public interface MastershipStore { ...@@ -40,22 +41,22 @@ public interface MastershipStore {
40 * @param deviceId the device identifier 41 * @param deviceId the device identifier
41 * @return the instance identifier of the master 42 * @return the instance identifier of the master
42 */ 43 */
43 - InstanceId getMaster(DeviceId deviceId); 44 + NodeId getMaster(DeviceId deviceId);
44 45
45 /** 46 /**
46 * Returns the devices that a controller instance is master of. 47 * Returns the devices that a controller instance is master of.
47 * 48 *
48 - * @param instanceId the instance identifier 49 + * @param nodeId the instance identifier
49 * @return a set of device identifiers 50 * @return a set of device identifiers
50 */ 51 */
51 - Set<DeviceId> getDevices(InstanceId instanceId); 52 + Set<DeviceId> getDevices(NodeId nodeId);
52 53
53 /** 54 /**
54 * Returns the role of a device for a specific controller instance. 55 * Returns the role of a device for a specific controller instance.
55 * 56 *
56 - * @param instanceId the instance identifier 57 + * @param nodeId the instance identifier
57 * @param deviceId the device identifiers 58 * @param deviceId the device identifiers
58 * @return the role 59 * @return the role
59 */ 60 */
60 - MastershipRole getRole(InstanceId instanceId, DeviceId deviceId); 61 + MastershipRole getRole(NodeId nodeId, DeviceId deviceId);
61 } 62 }
......
...@@ -2,26 +2,24 @@ package org.onlab.onos.cluster; ...@@ -2,26 +2,24 @@ package org.onlab.onos.cluster;
2 2
3 import java.util.Objects; 3 import java.util.Objects;
4 4
5 -import static com.google.common.base.MoreObjects.toStringHelper;
6 -
7 /** 5 /**
8 * Controller cluster identity. 6 * Controller cluster identity.
9 */ 7 */
10 -public class InstanceId { 8 +public class NodeId {
11 9
12 private final String id; 10 private final String id;
13 11
14 // Default constructor for serialization 12 // Default constructor for serialization
15 - protected InstanceId() { 13 + protected NodeId() {
16 id = null; 14 id = null;
17 } 15 }
18 16
19 /** 17 /**
20 - * Creates a new cluster instance identifier from the specified string. 18 + * Creates a new cluster node identifier from the specified string.
21 * 19 *
22 * @param id string identifier 20 * @param id string identifier
23 */ 21 */
24 - public InstanceId(String id) { 22 + public NodeId(String id) {
25 this.id = id; 23 this.id = id;
26 } 24 }
27 25
...@@ -35,8 +33,8 @@ public class InstanceId { ...@@ -35,8 +33,8 @@ public class InstanceId {
35 if (this == obj) { 33 if (this == obj) {
36 return true; 34 return true;
37 } 35 }
38 - if (obj instanceof InstanceId) { 36 + if (obj instanceof NodeId) {
39 - final InstanceId other = (InstanceId) obj; 37 + final NodeId other = (NodeId) obj;
40 return Objects.equals(this.id, other.id); 38 return Objects.equals(this.id, other.id);
41 } 39 }
42 return false; 40 return false;
...@@ -44,7 +42,7 @@ public class InstanceId { ...@@ -44,7 +42,7 @@ public class InstanceId {
44 42
45 @Override 43 @Override
46 public String toString() { 44 public String toString() {
47 - return toStringHelper(this).add("id", id).toString(); 45 + return id;
48 } 46 }
49 47
50 } 48 }
......
...@@ -10,7 +10,7 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -10,7 +10,7 @@ import org.onlab.onos.net.provider.ProviderId;
10 import java.util.List; 10 import java.util.List;
11 11
12 /** 12 /**
13 - * Manages inventory of infrastructure devices. 13 + * Manages inventory of infrastructure devices; not intended for direct use.
14 */ 14 */
15 public interface DeviceStore { 15 public interface DeviceStore {
16 16
......
...@@ -3,7 +3,7 @@ package org.onlab.onos.net.flow; ...@@ -3,7 +3,7 @@ package org.onlab.onos.net.flow;
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 4
5 /** 5 /**
6 - * Manages inventory of flow rules. 6 + * Manages inventory of flow rules; not intended for direct use.
7 */ 7 */
8 public interface FlowRuleStore { 8 public interface FlowRuleStore {
9 9
......
...@@ -12,8 +12,7 @@ import org.onlab.packet.VlanId; ...@@ -12,8 +12,7 @@ import org.onlab.packet.VlanId;
12 import java.util.Set; 12 import java.util.Set;
13 13
14 /** 14 /**
15 - * Manages inventory of end-station hosts. It may do so using whatever 15 + * Manages inventory of end-station hosts; not intended for direct use.
16 - * means are appropriate.
17 */ 16 */
18 public interface HostStore { 17 public interface HostStore {
19 18
......
...@@ -8,8 +8,7 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -8,8 +8,7 @@ import org.onlab.onos.net.provider.ProviderId;
8 import java.util.Set; 8 import java.util.Set;
9 9
10 /** 10 /**
11 - * Manages inventory of infrastructure links. It may do so using whatever 11 + * Manages inventory of infrastructure links; not intended for direct use.
12 - * means are appropriate.
13 */ 12 */
14 public interface LinkStore { 13 public interface LinkStore {
15 14
......
...@@ -11,8 +11,7 @@ import java.util.List; ...@@ -11,8 +11,7 @@ import java.util.List;
11 import java.util.Set; 11 import java.util.Set;
12 12
13 /** 13 /**
14 - * Manages inventory of topology snapshots. It may do so using whatever 14 + * Manages inventory of topology snapshots; not intended for direct use.
15 - * means appropriate.
16 */ 15 */
17 public interface TopologyStore { 16 public interface TopologyStore {
18 17
......
1 +package org.onlab.onos.cluster.impl;
2 +
3 +import org.apache.felix.scr.annotations.Activate;
4 +import org.apache.felix.scr.annotations.Component;
5 +import org.apache.felix.scr.annotations.Deactivate;
6 +import org.apache.felix.scr.annotations.Reference;
7 +import org.apache.felix.scr.annotations.ReferenceCardinality;
8 +import org.apache.felix.scr.annotations.Service;
9 +import org.onlab.onos.cluster.ClusterEvent;
10 +import org.onlab.onos.cluster.ClusterEventListener;
11 +import org.onlab.onos.cluster.ClusterService;
12 +import org.onlab.onos.cluster.ClusterStore;
13 +import org.onlab.onos.cluster.ControllerNode;
14 +import org.onlab.onos.cluster.NodeId;
15 +import org.onlab.onos.event.AbstractListenerRegistry;
16 +import org.onlab.onos.event.EventDeliveryService;
17 +import org.slf4j.Logger;
18 +
19 +import java.util.Set;
20 +
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +import static org.slf4j.LoggerFactory.getLogger;
23 +
24 +/**
25 + * Implementation of the cluster service.
26 + */
27 +@Component(immediate = true)
28 +@Service
29 +public class ClusterManager implements ClusterService {
30 +
31 + public static final String INSTANCE_ID_NULL = "Instance ID cannot be null";
32 + private final Logger log = getLogger(getClass());
33 +
34 + protected final AbstractListenerRegistry<ClusterEvent, ClusterEventListener>
35 + listenerRegistry = new AbstractListenerRegistry<>();
36 +
37 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
38 + protected ClusterStore store;
39 +
40 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
41 + protected EventDeliveryService eventDispatcher;
42 +
43 + @Activate
44 + public void activate() {
45 + eventDispatcher.addSink(ClusterEvent.class, listenerRegistry);
46 + log.info("Started");
47 + }
48 +
49 + @Deactivate
50 + public void deactivate() {
51 + eventDispatcher.removeSink(ClusterEvent.class);
52 + log.info("Stopped");
53 + }
54 +
55 + @Override
56 + public ControllerNode getLocalNode() {
57 + return store.getLocalNode();
58 + }
59 +
60 + @Override
61 + public Set<ControllerNode> getNodes() {
62 + return store.getNodes();
63 + }
64 +
65 + @Override
66 + public ControllerNode getNode(NodeId nodeId) {
67 + checkNotNull(nodeId, INSTANCE_ID_NULL);
68 + return store.getNode(nodeId);
69 + }
70 +
71 + @Override
72 + public ControllerNode.State getState(NodeId nodeId) {
73 + checkNotNull(nodeId, INSTANCE_ID_NULL);
74 + return store.getState(nodeId);
75 + }
76 +
77 + @Override
78 + public void addListener(ClusterEventListener listener) {
79 + listenerRegistry.addListener(listener);
80 + }
81 +
82 + @Override
83 + public void removeListener(ClusterEventListener listener) {
84 + listenerRegistry.removeListener(listener);
85 + }
86 +}
...@@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkNotNull; ...@@ -33,7 +33,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
33 import static org.slf4j.LoggerFactory.getLogger; 33 import static org.slf4j.LoggerFactory.getLogger;
34 34
35 /** 35 /**
36 - * Provides basic implementation of the device SB &amp; NB APIs. 36 + * Provides implementation of the device SB &amp; NB APIs.
37 */ 37 */
38 @Component(immediate = true) 38 @Component(immediate = true)
39 @Service 39 @Service
......
...@@ -33,6 +33,9 @@ import org.slf4j.Logger; ...@@ -33,6 +33,9 @@ import org.slf4j.Logger;
33 33
34 import com.google.common.collect.Lists; 34 import com.google.common.collect.Lists;
35 35
36 +/**
37 + * Provides implementation of the flow NB &amp; SB APIs.
38 + */
36 @Component(immediate = true) 39 @Component(immediate = true)
37 @Service 40 @Service
38 public class FlowRuleManager 41 public class FlowRuleManager
......
1 +package org.onlab.onos.net.trivial.impl;
2 +
3 +import com.google.common.collect.ImmutableSet;
4 +import org.apache.felix.scr.annotations.Activate;
5 +import org.apache.felix.scr.annotations.Component;
6 +import org.apache.felix.scr.annotations.Deactivate;
7 +import org.apache.felix.scr.annotations.Service;
8 +import org.onlab.onos.cluster.ClusterStore;
9 +import org.onlab.onos.cluster.ControllerNode;
10 +import org.onlab.onos.cluster.DefaultControllerNode;
11 +import org.onlab.onos.cluster.NodeId;
12 +import org.onlab.packet.IpPrefix;
13 +import org.slf4j.Logger;
14 +
15 +import java.util.Set;
16 +
17 +import static org.slf4j.LoggerFactory.getLogger;
18 +
19 +/**
20 + * Manages inventory of infrastructure DEVICES using trivial in-memory
21 + * structures implementation.
22 + */
23 +@Component(immediate = true)
24 +@Service
25 +public class SimpleClusterStore implements ClusterStore {
26 +
27 + public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
28 +
29 + private final Logger log = getLogger(getClass());
30 +
31 + private ControllerNode instance;
32 +
33 + @Activate
34 + public void activate() {
35 + instance = new DefaultControllerNode(new NodeId("local"), LOCALHOST);
36 + log.info("Started");
37 + }
38 +
39 + @Deactivate
40 + public void deactivate() {
41 + log.info("Stopped");
42 + }
43 +
44 +
45 + @Override
46 + public ControllerNode getLocalNode() {
47 + return instance;
48 + }
49 +
50 + @Override
51 + public Set<ControllerNode> getNodes() {
52 + return ImmutableSet.of(instance);
53 + }
54 +
55 + @Override
56 + public ControllerNode getNode(NodeId nodeId) {
57 + return instance.id().equals(nodeId) ? instance : null;
58 + }
59 +
60 + @Override
61 + public ControllerNode.State getState(NodeId nodeId) {
62 + return ControllerNode.State.ACTIVE;
63 + }
64 +
65 +}
...@@ -35,7 +35,7 @@ import static org.onlab.onos.net.device.DeviceEvent.Type.*; ...@@ -35,7 +35,7 @@ import static org.onlab.onos.net.device.DeviceEvent.Type.*;
35 import static org.slf4j.LoggerFactory.getLogger; 35 import static org.slf4j.LoggerFactory.getLogger;
36 36
37 /** 37 /**
38 - * Manages inventory of infrastructure DEVICES using trivial in-memory 38 + * Manages inventory of infrastructure devices using trivial in-memory
39 * structures implementation. 39 * structures implementation.
40 */ 40 */
41 @Component(immediate = true) 41 @Component(immediate = true)
......
...@@ -392,7 +392,7 @@ ...@@ -392,7 +392,7 @@
392 <group> 392 <group>
393 <title>Core Subsystems</title> 393 <title>Core Subsystems</title>
394 <packages> 394 <packages>
395 - org.onlab.onos.net.device.impl:org.onlab.onos.net.link.impl:org.onlab.onos.net.host.impl:org.onlab.onos.net.topology.impl:org.onlab.onos.net.packet.impl:org.onlab.onos.net.flow.impl:org.onlab.onos.net.trivial.*:org.onlab.onos.net.*.impl:org.onlab.onos.impl:org.onlab.onos.event.impl:org.onlab.onos.store.* 395 + org.onlab.onos.net.device.impl:org.onlab.onos.net.link.impl:org.onlab.onos.net.host.impl:org.onlab.onos.net.topology.impl:org.onlab.onos.net.packet.impl:org.onlab.onos.net.flow.impl:org.onlab.onos.net.trivial.*:org.onlab.onos.net.*.impl:org.onlab.onos.cluster:org.onlab.onos.event.impl:org.onlab.onos.store.*
396 </packages> 396 </packages>
397 </group> 397 </group>
398 <group> 398 <group>
......
...@@ -34,15 +34,15 @@ cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_DIST/etc ...@@ -34,15 +34,15 @@ cp -r $ONOS_ROOT/tools/package/etc/* $KARAF_DIST/etc
34 mkdir -p $KARAF_DIST/system/org/onlab 34 mkdir -p $KARAF_DIST/system/org/onlab
35 cp -r $M2_REPO/org/onlab $KARAF_DIST/system/org/ 35 cp -r $M2_REPO/org/onlab $KARAF_DIST/system/org/
36 36
37 -# Wrapper & Cellar Patching ---------------------------------------------------- 37 +# Cellar Patching --------------------------------------------------------------
38 38
39 # Patch the Apache Karaf distribution file to add Cellar features repository 39 # Patch the Apache Karaf distribution file to add Cellar features repository
40 -perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.apache.karaf.cellar/apache-karaf-cellar/3.0.0/xml/features|" \ 40 +#perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.apache.karaf.cellar/apache-karaf-cellar/3.0.0/xml/features|" \
41 - $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 41 +# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
42 42
43 # Patch the Apache Karaf distribution file to load ONOS features 43 # Patch the Apache Karaf distribution file to load ONOS features
44 -perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \ 44 +#perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \
45 - $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 45 +# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
46 46
47 # ONOS Patching ---------------------------------------------------------------- 47 # ONOS Patching ----------------------------------------------------------------
48 48
...@@ -50,6 +50,10 @@ perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \ ...@@ -50,6 +50,10 @@ perl -pi.old -e 's|^(featuresBoot=.*)|\1,cellar|' \
50 perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \ 50 perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-features/$ONOS_VERSION/xml/features|" \
51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
52 52
53 +# Patch the Apache Karaf distribution file to load ONOS features
54 +perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue,onos-app-fwd|' \
55 + $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
56 +
53 # Patch the Apache Karaf distribution with ONOS branding bundle 57 # Patch the Apache Karaf distribution with ONOS branding bundle
54 cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ 58 cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \
55 $ONOS_STAGE/$KARAF_DIST/lib 59 $ONOS_STAGE/$KARAF_DIST/lib
......