Ayaka Koshibe

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 31 changed files with 830 additions and 420 deletions
1 +package org.onlab.onos.net.device;
2 +
3 +import org.onlab.onos.net.Device;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.MastershipRole;
6 +import org.onlab.onos.net.Port;
7 +import org.onlab.onos.net.PortNumber;
8 +import org.onlab.onos.net.provider.ProviderId;
9 +
10 +import java.util.List;
11 +
12 +/**
13 + * Manages inventory of infrastructure devices. It may do so using whatever
14 + * means are appropriate.
15 + */
16 +public interface DeviceStore {
17 +
18 + /**
19 + * Returns the number of devices known to the system.
20 + *
21 + * @return number of devices
22 + */
23 + int getDeviceCount();
24 +
25 + /**
26 + * Returns an iterable collection of all devices known to the system.
27 + *
28 + * @return device collection
29 + */
30 + Iterable<Device> getDevices();
31 +
32 + /**
33 + * Returns the device with the specified identifier.
34 + *
35 + * @param deviceId device identifier
36 + * @return device
37 + */
38 + Device getDevice(DeviceId deviceId);
39 +
40 + /**
41 + * Creates a new infrastructure device, or updates an existing one using
42 + * the supplied device description.
43 + *
44 + * @param providerId provider identifier
45 + * @param deviceId device identifier
46 + * @param deviceDescription device description
47 + * @return ready to send event describing what occurred; null if no change
48 + */
49 + DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
50 + DeviceDescription deviceDescription);
51 +
52 + /**
53 + * Removes the specified infrastructure device.
54 + *
55 + * @param deviceId device identifier
56 + * @return ready to send event describing what occurred; null if no change
57 + */
58 + DeviceEvent markOffline(DeviceId deviceId);
59 +
60 + /**
61 + * Updates the ports of the specified infrastructure device using the given
62 + * list of port descriptions. The list is assumed to be comprehensive.
63 + *
64 + * @param deviceId device identifier
65 + * @param portDescriptions list of port descriptions
66 + * @return ready to send events describing what occurred; empty list if no change
67 + */
68 + List<DeviceEvent> updatePorts(DeviceId deviceId,
69 + List<PortDescription> portDescriptions);
70 +
71 + /**
72 + * Updates the port status of the specified infrastructure device using the
73 + * given port description.
74 + *
75 + * @param deviceId device identifier
76 + * @param portDescription port description
77 + * @return ready to send event describing what occurred; null if no change
78 + */
79 + DeviceEvent updatePortStatus(DeviceId deviceId,
80 + PortDescription portDescription);
81 +
82 + /**
83 + * Returns the list of ports that belong to the specified device.
84 + *
85 + * @param deviceId device identifier
86 + * @return list of device ports
87 + */
88 + List<Port> getPorts(DeviceId deviceId);
89 +
90 + /**
91 + * Returns the specified device port.
92 + *
93 + * @param deviceId device identifier
94 + * @param portNumber port number
95 + * @return device port
96 + */
97 + Port getPort(DeviceId deviceId, PortNumber portNumber);
98 +
99 + /**
100 + * Indicates whether the specified device is available/online.
101 + *
102 + * @param deviceId device identifier
103 + * @return true if device is available
104 + */
105 + boolean isAvailable(DeviceId deviceId);
106 +
107 + /**
108 + * Returns the mastership role determined for this device.
109 + *
110 + * @param deviceId device identifier
111 + * @return mastership role
112 + */
113 + MastershipRole getRole(DeviceId deviceId);
114 +
115 + /**
116 + * Administratively sets the role of the specified device.
117 + *
118 + * @param deviceId device identifier
119 + * @param role mastership role to apply
120 + * @return mastership role change event or null if no change
121 + */
122 + DeviceEvent setRole(DeviceId deviceId, MastershipRole role);
123 +
124 + /**
125 + * Administratively removes the specified device from the store.
126 + *
127 + * @param deviceId device to be removed
128 + */
129 + DeviceEvent removeDevice(DeviceId deviceId);
130 +}
...@@ -33,9 +33,8 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide ...@@ -33,9 +33,8 @@ public interface FlowRuleProviderService extends ProviderService<FlowRuleProvide
33 * Pushes the collection of flow entries currently applied on the given 33 * Pushes the collection of flow entries currently applied on the given
34 * device. 34 * device.
35 * 35 *
36 - * @param deviceId device identifier 36 + * @param flowRules collection of flow rules
37 - * @return collection of flow entries
38 */ 37 */
39 - void pushFlowMetrics(Iterable<FlowRule> flowEntries); 38 + void pushFlowMetrics(Iterable<FlowRule> flowRules);
40 39
41 } 40 }
......
...@@ -31,7 +31,7 @@ public final class Criteria { ...@@ -31,7 +31,7 @@ public final class Criteria {
31 * Creates a match on ETH_SRC field using the specified value. This value 31 * Creates a match on ETH_SRC field using the specified value. This value
32 * may be a wildcard mask. 32 * may be a wildcard mask.
33 * 33 *
34 - * @param macValue MAC address value or wildcard mask 34 + * @param mac MAC address value or wildcard mask
35 * @return match criterion 35 * @return match criterion
36 */ 36 */
37 public static Criterion matchEthSrc(MacAddress mac) { 37 public static Criterion matchEthSrc(MacAddress mac) {
...@@ -42,7 +42,7 @@ public final class Criteria { ...@@ -42,7 +42,7 @@ public final class Criteria {
42 * Creates a match on ETH_DST field using the specified value. This value 42 * Creates a match on ETH_DST field using the specified value. This value
43 * may be a wildcard mask. 43 * may be a wildcard mask.
44 * 44 *
45 - * @param macValue MAC address value or wildcard mask 45 + * @param mac MAC address value or wildcard mask
46 * @return match criterion 46 * @return match criterion
47 */ 47 */
48 public static Criterion matchEthDst(MacAddress mac) { 48 public static Criterion matchEthDst(MacAddress mac) {
......
...@@ -5,7 +5,6 @@ import org.onlab.packet.VlanId; ...@@ -5,7 +5,6 @@ import org.onlab.packet.VlanId;
5 5
6 /** 6 /**
7 * Abstraction of a single traffic treatment step. 7 * Abstraction of a single traffic treatment step.
8 - * @param <T> the type parameter for the instruction
9 */ 8 */
10 public abstract class L2ModificationInstruction implements Instruction { 9 public abstract class L2ModificationInstruction implements Instruction {
11 10
......
...@@ -4,7 +4,6 @@ import org.onlab.packet.IpAddress; ...@@ -4,7 +4,6 @@ import org.onlab.packet.IpAddress;
4 4
5 /** 5 /**
6 * Abstraction of a single traffic treatment step. 6 * Abstraction of a single traffic treatment step.
7 - * @param <T> the type parameter for the instruction
8 */ 7 */
9 public abstract class L3ModificationInstruction implements Instruction { 8 public abstract class L3ModificationInstruction implements Instruction {
10 9
......
1 +package org.onlab.onos.net.host;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Host;
6 +import org.onlab.onos.net.HostId;
7 +import org.onlab.onos.net.provider.ProviderId;
8 +import org.onlab.packet.IpAddress;
9 +import org.onlab.packet.MacAddress;
10 +import org.onlab.packet.VlanId;
11 +
12 +import java.util.Set;
13 +
14 +/**
15 + * Manages inventory of end-station hosts. It may do so using whatever
16 + * means are appropriate.
17 + */
18 +public interface HostStore {
19 +
20 + /**
21 + * Creates a new host or updates the existing one based on the specified
22 + * description.
23 + *
24 + * @param providerId provider identification
25 + * @param hostId host identification
26 + * @param hostDescription host description data
27 + * @return appropriate event or null if no change resulted
28 + */
29 + HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
30 + HostDescription hostDescription);
31 +
32 + /**
33 + * Removes the specified host from the inventory.
34 + *
35 + * @param hostId host identification
36 + * @return remove event or null if host was not found
37 + */
38 + HostEvent removeHost(HostId hostId);
39 +
40 + /**
41 + * Returns the number of hosts in the store.
42 + *
43 + * @return host count
44 + */
45 + int getHostCount();
46 +
47 + /**
48 + * Returns a collection of all hosts in the store.
49 + *
50 + * @return iterable collection of all hosts
51 + */
52 + Iterable<Host> getHosts();
53 +
54 + /**
55 + * Returns the host with the specified identifer.
56 + *
57 + * @param hostId host identification
58 + * @return host or null if not found
59 + */
60 + Host getHost(HostId hostId);
61 +
62 + /**
63 + * Returns the set of all hosts within the specified VLAN.
64 + *
65 + * @param vlanId vlan id
66 + * @return set of hosts in the vlan
67 + */
68 + Set<Host> getHosts(VlanId vlanId);
69 +
70 + /**
71 + * Returns the set of hosts with the specified MAC address.
72 + *
73 + * @param mac mac address
74 + * @return set of hosts with the given mac
75 + */
76 + Set<Host> getHosts(MacAddress mac);
77 +
78 + /**
79 + * Returns the set of hosts with the specified IP address.
80 + *
81 + * @param ip ip address
82 + * @return set of hosts with the given IP
83 + */
84 + Set<Host> getHosts(IpAddress ip);
85 +
86 + /**
87 + * Returns the set of hosts whose location falls on the given connection point.
88 + *
89 + * @param connectPoint connection point
90 + * @return set of hosts
91 + */
92 + Set<Host> getConnectedHosts(ConnectPoint connectPoint);
93 +
94 + /**
95 + * Returns the set of hosts whose location falls on the given device.
96 + *
97 + * @param deviceId infrastructure device identifier
98 + * @return set of hosts
99 + */
100 + Set<Host> getConnectedHosts(DeviceId deviceId);
101 +
102 +}
1 +package org.onlab.onos.net.link;
2 +
3 +import org.onlab.onos.net.ConnectPoint;
4 +import org.onlab.onos.net.DeviceId;
5 +import org.onlab.onos.net.Link;
6 +import org.onlab.onos.net.provider.ProviderId;
7 +
8 +import java.util.Set;
9 +
10 +/**
11 + * Manages inventory of infrastructure links. It may do so using whatever
12 + * means are appropriate.
13 + */
14 +public interface LinkStore {
15 +
16 + /**
17 + * Returns the number of links in the store.
18 + *
19 + * @return number of links
20 + */
21 + int getLinkCount();
22 +
23 + /**
24 + * Returns an iterable collection of all links in the inventory.
25 + *
26 + * @return collection of all links
27 + */
28 + Iterable<Link> getLinks();
29 +
30 + /**
31 + * Returns all links egressing from the specified device.
32 + *
33 + * @param deviceId device identifier
34 + * @return set of device links
35 + */
36 + Set<Link> getDeviceEgressLinks(DeviceId deviceId);
37 +
38 + /**
39 + * Returns all links ingressing from the specified device.
40 + *
41 + * @param deviceId device identifier
42 + * @return set of device links
43 + */
44 + Set<Link> getDeviceIngressLinks(DeviceId deviceId);
45 +
46 + /**
47 + * Returns the link between the two end-points.
48 + *
49 + * @param src source connection point
50 + * @param dst destination connection point
51 + * @return link or null if one not found between the end-points
52 + */
53 + Link getLink(ConnectPoint src, ConnectPoint dst);
54 +
55 + /**
56 + * Returns all links egressing from the specified connection point.
57 + *
58 + * @param src source connection point
59 + * @return set of connection point links
60 + */
61 + Set<Link> getEgressLinks(ConnectPoint src);
62 +
63 + /**
64 + * Returns all links ingressing to the specified connection point.
65 + *
66 + * @param dst destination connection point
67 + * @return set of connection point links
68 + */
69 + Set<Link> getIngressLinks(ConnectPoint dst);
70 +
71 + /**
72 + * Creates a new link, or updates an existing one, based on the given
73 + * information.
74 + *
75 + * @param providerId provider identity
76 + * @param linkDescription link description
77 + * @return create or update link event, or null if no change resulted
78 + */
79 + public LinkEvent createOrUpdateLink(ProviderId providerId,
80 + LinkDescription linkDescription);
81 +
82 + /**
83 + * Removes the link based on the specified information.
84 + *
85 + * @param src link source
86 + * @param dst link destination
87 + * @return remove link event, or null if no change resulted
88 + */
89 + LinkEvent removeLink(ConnectPoint src, ConnectPoint dst);
90 +
91 +}
1 +package org.onlab.onos.net.topology;
2 +
3 +import org.onlab.onos.event.Event;
4 +import org.onlab.onos.net.ConnectPoint;
5 +import org.onlab.onos.net.DeviceId;
6 +import org.onlab.onos.net.Link;
7 +import org.onlab.onos.net.Path;
8 +import org.onlab.onos.net.provider.ProviderId;
9 +
10 +import java.util.List;
11 +import java.util.Set;
12 +
13 +/**
14 + * Manages inventory of topology snapshots. It may do so using whatever
15 + * means appropriate.
16 + */
17 +public interface TopologyStore {
18 +
19 + /**
20 + * Returns the current topology snapshot.
21 + *
22 + * @return current topology descriptor
23 + */
24 + Topology currentTopology();
25 +
26 + /**
27 + * Indicates whether the topology is the latest.
28 + *
29 + * @param topology topology descriptor
30 + * @return true if topology is the most recent one
31 + */
32 + boolean isLatest(Topology topology);
33 +
34 + /**
35 + * Returns the immutable graph view of the current topology.
36 + *
37 + * @param topology topology descriptor
38 + * @return graph view
39 + */
40 + TopologyGraph getGraph(Topology topology);
41 +
42 + /**
43 + * Returns the set of topology SCC clusters.
44 + *
45 + * @param topology topology descriptor
46 + * @return set of clusters
47 + */
48 + Set<TopologyCluster> getClusters(Topology topology);
49 +
50 + /**
51 + * Returns the cluster of the specified topology.
52 + *
53 + * @param topology topology descriptor
54 + * @param clusterId cluster identity
55 + * @return topology cluster
56 + */
57 + TopologyCluster getCluster(Topology topology, ClusterId clusterId);
58 +
59 + /**
60 + * Returns the cluster of the specified topology.
61 + *
62 + * @param topology topology descriptor
63 + * @param cluster topology cluster
64 + * @return set of cluster links
65 + */
66 + Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster);
67 +
68 + /**
69 + * Returns the cluster of the specified topology.
70 + *
71 + * @param topology topology descriptor
72 + * @param cluster topology cluster
73 + * @return set of cluster links
74 + */
75 + Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
76 +
77 + /**
78 + * Returns the set of pre-computed shortest paths between src and dest.
79 + *
80 + * @param topology topology descriptor
81 + * @param src source device
82 + * @param dst destination device
83 + * @return set of shortest paths
84 + */
85 + Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst);
86 +
87 + /**
88 + * Computes and returns the set of shortest paths between src and dest.
89 + *
90 + * @param topology topology descriptor
91 + * @param src source device
92 + * @param dst destination device
93 + * @param weight link weight function
94 + * @return set of shortest paths
95 + */
96 + Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
97 + LinkWeight weight);
98 +
99 + /**
100 + * Indicates whether the given connect point is part of the network fabric.
101 + *
102 + * @param topology topology descriptor
103 + * @param connectPoint connection point
104 + * @return true if infrastructure; false otherwise
105 + */
106 + boolean isInfrastructure(Topology topology, ConnectPoint connectPoint);
107 +
108 + /**
109 + * Indicates whether broadcast is allowed for traffic received on the
110 + * given connection point.
111 + *
112 + * @param topology topology descriptor
113 + * @param connectPoint connection point
114 + * @return true if broadcast allowed; false otherwise
115 + */
116 + boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint);
117 +
118 + /**
119 + * Generates a new topology snapshot from the specified description.
120 + *
121 + * @param providerId provider identification
122 + * @param graphDescription topology graph description
123 + * @param reasons list of events that triggered the update
124 + * @return topology update event or null if the description is old
125 + */
126 + TopologyEvent updateTopology(ProviderId providerId,
127 + GraphDescription graphDescription,
128 + List<Event> reasons);
129 +}
...@@ -21,6 +21,7 @@ import org.onlab.onos.net.device.DeviceProvider; ...@@ -21,6 +21,7 @@ import org.onlab.onos.net.device.DeviceProvider;
21 import org.onlab.onos.net.device.DeviceProviderRegistry; 21 import org.onlab.onos.net.device.DeviceProviderRegistry;
22 import org.onlab.onos.net.device.DeviceProviderService; 22 import org.onlab.onos.net.device.DeviceProviderService;
23 import org.onlab.onos.net.device.DeviceService; 23 import org.onlab.onos.net.device.DeviceService;
24 +import org.onlab.onos.net.device.DeviceStore;
24 import org.onlab.onos.net.device.PortDescription; 25 import org.onlab.onos.net.device.PortDescription;
25 import org.onlab.onos.net.provider.AbstractProviderRegistry; 26 import org.onlab.onos.net.provider.AbstractProviderRegistry;
26 import org.onlab.onos.net.provider.AbstractProviderService; 27 import org.onlab.onos.net.provider.AbstractProviderService;
...@@ -36,7 +37,7 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -36,7 +37,7 @@ import static org.slf4j.LoggerFactory.getLogger;
36 */ 37 */
37 @Component(immediate = true) 38 @Component(immediate = true)
38 @Service 39 @Service
39 -public class SimpleDeviceManager 40 +public class DeviceManager
40 extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService> 41 extends AbstractProviderRegistry<DeviceProvider, DeviceProviderService>
41 implements DeviceService, DeviceAdminService, DeviceProviderRegistry { 42 implements DeviceService, DeviceAdminService, DeviceProviderRegistry {
42 43
...@@ -51,7 +52,8 @@ public class SimpleDeviceManager ...@@ -51,7 +52,8 @@ public class SimpleDeviceManager
51 protected final AbstractListenerRegistry<DeviceEvent, DeviceListener> 52 protected final AbstractListenerRegistry<DeviceEvent, DeviceListener>
52 listenerRegistry = new AbstractListenerRegistry<>(); 53 listenerRegistry = new AbstractListenerRegistry<>();
53 54
54 - private final SimpleDeviceStore store = new SimpleDeviceStore(); 55 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
56 + protected DeviceStore store;
55 57
56 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 protected EventDeliveryService eventDispatcher; 59 protected EventDeliveryService eventDispatcher;
......
1 package org.onlab.onos.net.trivial.device.impl; 1 package org.onlab.onos.net.trivial.device.impl;
2 2
3 import com.google.common.collect.ImmutableList; 3 import com.google.common.collect.ImmutableList;
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;
4 import org.onlab.onos.net.DefaultDevice; 8 import org.onlab.onos.net.DefaultDevice;
5 import org.onlab.onos.net.DefaultPort; 9 import org.onlab.onos.net.DefaultPort;
6 import org.onlab.onos.net.Device; 10 import org.onlab.onos.net.Device;
...@@ -10,8 +14,10 @@ import org.onlab.onos.net.Port; ...@@ -10,8 +14,10 @@ import org.onlab.onos.net.Port;
10 import org.onlab.onos.net.PortNumber; 14 import org.onlab.onos.net.PortNumber;
11 import org.onlab.onos.net.device.DeviceDescription; 15 import org.onlab.onos.net.device.DeviceDescription;
12 import org.onlab.onos.net.device.DeviceEvent; 16 import org.onlab.onos.net.device.DeviceEvent;
17 +import org.onlab.onos.net.device.DeviceStore;
13 import org.onlab.onos.net.device.PortDescription; 18 import org.onlab.onos.net.device.PortDescription;
14 import org.onlab.onos.net.provider.ProviderId; 19 import org.onlab.onos.net.provider.ProviderId;
20 +import org.slf4j.Logger;
15 21
16 import java.util.ArrayList; 22 import java.util.ArrayList;
17 import java.util.Collections; 23 import java.util.Collections;
...@@ -26,12 +32,17 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -26,12 +32,17 @@ import java.util.concurrent.ConcurrentHashMap;
26 32
27 import static com.google.common.base.Preconditions.checkArgument; 33 import static com.google.common.base.Preconditions.checkArgument;
28 import static org.onlab.onos.net.device.DeviceEvent.Type.*; 34 import static org.onlab.onos.net.device.DeviceEvent.Type.*;
35 +import static org.slf4j.LoggerFactory.getLogger;
29 36
30 /** 37 /**
31 * Manages inventory of infrastructure DEVICES using trivial in-memory 38 * Manages inventory of infrastructure DEVICES using trivial in-memory
32 * structures implementation. 39 * structures implementation.
33 */ 40 */
34 -class SimpleDeviceStore { 41 +@Component(immediate = true)
42 +@Service
43 +public class SimpleDeviceStore implements DeviceStore {
44 +
45 + private final Logger log = getLogger(getClass());
35 46
36 public static final String DEVICE_NOT_FOUND = "Device with ID %s not found"; 47 public static final String DEVICE_NOT_FOUND = "Device with ID %s not found";
37 48
...@@ -40,44 +51,33 @@ class SimpleDeviceStore { ...@@ -40,44 +51,33 @@ class SimpleDeviceStore {
40 private final Set<DeviceId> availableDevices = new HashSet<>(); 51 private final Set<DeviceId> availableDevices = new HashSet<>();
41 private final Map<DeviceId, Map<PortNumber, Port>> devicePorts = new HashMap<>(); 52 private final Map<DeviceId, Map<PortNumber, Port>> devicePorts = new HashMap<>();
42 53
43 - /** 54 + @Activate
44 - * Returns the number of devices known to the system. 55 + public void activate() {
45 - * 56 + log.info("Started");
46 - * @return number of devices 57 + }
47 - */ 58 +
48 - int getDeviceCount() { 59 + @Deactivate
60 + public void deactivate() {
61 + log.info("Stopped");
62 + }
63 +
64 + @Override
65 + public int getDeviceCount() {
49 return devices.size(); 66 return devices.size();
50 } 67 }
51 68
52 - /** 69 + @Override
53 - * Returns an iterable collection of all devices known to the system. 70 + public Iterable<Device> getDevices() {
54 - *
55 - * @return device collection
56 - */
57 - Iterable<Device> getDevices() {
58 return Collections.unmodifiableSet(new HashSet<Device>(devices.values())); 71 return Collections.unmodifiableSet(new HashSet<Device>(devices.values()));
59 } 72 }
60 73
61 - /** 74 + @Override
62 - * Returns the device with the specified identifier. 75 + public Device getDevice(DeviceId deviceId) {
63 - *
64 - * @param deviceId device identifier
65 - * @return device
66 - */
67 - Device getDevice(DeviceId deviceId) {
68 return devices.get(deviceId); 76 return devices.get(deviceId);
69 } 77 }
70 78
71 - /** 79 + @Override
72 - * Creates a new infrastructure device, or updates an existing one using 80 + public DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
73 - * the supplied device description.
74 - *
75 - * @param providerId provider identifier
76 - * @param deviceId device identifier
77 - * @param deviceDescription device description
78 - * @return ready to send event describing what occurred; null if no change
79 - */
80 - DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
81 DeviceDescription deviceDescription) { 81 DeviceDescription deviceDescription) {
82 DefaultDevice device = devices.get(deviceId); 82 DefaultDevice device = devices.get(deviceId);
83 if (device == null) { 83 if (device == null) {
...@@ -130,13 +130,8 @@ class SimpleDeviceStore { ...@@ -130,13 +130,8 @@ class SimpleDeviceStore {
130 } 130 }
131 } 131 }
132 132
133 - /** 133 + @Override
134 - * Removes the specified infrastructure device. 134 + public DeviceEvent markOffline(DeviceId deviceId) {
135 - *
136 - * @param deviceId device identifier
137 - * @return ready to send event describing what occurred; null if no change
138 - */
139 - DeviceEvent markOffline(DeviceId deviceId) {
140 synchronized (this) { 135 synchronized (this) {
141 Device device = devices.get(deviceId); 136 Device device = devices.get(deviceId);
142 boolean removed = device != null && availableDevices.remove(deviceId); 137 boolean removed = device != null && availableDevices.remove(deviceId);
...@@ -145,15 +140,8 @@ class SimpleDeviceStore { ...@@ -145,15 +140,8 @@ class SimpleDeviceStore {
145 } 140 }
146 } 141 }
147 142
148 - /** 143 + @Override
149 - * Updates the ports of the specified infrastructure device using the given 144 + public List<DeviceEvent> updatePorts(DeviceId deviceId,
150 - * list of port descriptions. The list is assumed to be comprehensive.
151 - *
152 - * @param deviceId device identifier
153 - * @param portDescriptions list of port descriptions
154 - * @return ready to send events describing what occurred; empty list if no change
155 - */
156 - List<DeviceEvent> updatePorts(DeviceId deviceId,
157 List<PortDescription> portDescriptions) { 145 List<PortDescription> portDescriptions) {
158 List<DeviceEvent> events = new ArrayList<>(); 146 List<DeviceEvent> events = new ArrayList<>();
159 synchronized (this) { 147 synchronized (this) {
...@@ -230,15 +218,8 @@ class SimpleDeviceStore { ...@@ -230,15 +218,8 @@ class SimpleDeviceStore {
230 return ports; 218 return ports;
231 } 219 }
232 220
233 - /** 221 + @Override
234 - * Updates the port status of the specified infrastructure device using the 222 + public DeviceEvent updatePortStatus(DeviceId deviceId,
235 - * given port description.
236 - *
237 - * @param deviceId device identifier
238 - * @param portDescription port description
239 - * @return ready to send event describing what occurred; null if no change
240 - */
241 - DeviceEvent updatePortStatus(DeviceId deviceId,
242 PortDescription portDescription) { 223 PortDescription portDescription) {
243 synchronized (this) { 224 synchronized (this) {
244 Device device = devices.get(deviceId); 225 Device device = devices.get(deviceId);
...@@ -249,58 +230,31 @@ class SimpleDeviceStore { ...@@ -249,58 +230,31 @@ class SimpleDeviceStore {
249 } 230 }
250 } 231 }
251 232
252 - /** 233 + @Override
253 - * Returns the list of ports that belong to the specified device. 234 + public List<Port> getPorts(DeviceId deviceId) {
254 - *
255 - * @param deviceId device identifier
256 - * @return list of device ports
257 - */
258 - List<Port> getPorts(DeviceId deviceId) {
259 Map<PortNumber, Port> ports = devicePorts.get(deviceId); 235 Map<PortNumber, Port> ports = devicePorts.get(deviceId);
260 return ports == null ? new ArrayList<Port>() : ImmutableList.copyOf(ports.values()); 236 return ports == null ? new ArrayList<Port>() : ImmutableList.copyOf(ports.values());
261 } 237 }
262 238
263 - /** 239 + @Override
264 - * Returns the specified device port. 240 + public Port getPort(DeviceId deviceId, PortNumber portNumber) {
265 - *
266 - * @param deviceId device identifier
267 - * @param portNumber port number
268 - * @return device port
269 - */
270 - Port getPort(DeviceId deviceId, PortNumber portNumber) {
271 Map<PortNumber, Port> ports = devicePorts.get(deviceId); 241 Map<PortNumber, Port> ports = devicePorts.get(deviceId);
272 return ports == null ? null : ports.get(portNumber); 242 return ports == null ? null : ports.get(portNumber);
273 } 243 }
274 244
275 - /** 245 + @Override
276 - * Indicates whether the specified device is available/online. 246 + public boolean isAvailable(DeviceId deviceId) {
277 - *
278 - * @param deviceId device identifier
279 - * @return true if device is available
280 - */
281 - boolean isAvailable(DeviceId deviceId) {
282 return availableDevices.contains(deviceId); 247 return availableDevices.contains(deviceId);
283 } 248 }
284 249
285 - /** 250 + @Override
286 - * Returns the mastership role determined for this device. 251 + public MastershipRole getRole(DeviceId deviceId) {
287 - *
288 - * @param deviceId device identifier
289 - * @return mastership role
290 - */
291 - MastershipRole getRole(DeviceId deviceId) {
292 MastershipRole role = roles.get(deviceId); 252 MastershipRole role = roles.get(deviceId);
293 return role != null ? role : MastershipRole.NONE; 253 return role != null ? role : MastershipRole.NONE;
294 } 254 }
295 255
296 - /** 256 + @Override
297 - * Administratively sets the role of the specified device. 257 + public DeviceEvent setRole(DeviceId deviceId, MastershipRole role) {
298 - *
299 - * @param deviceId device identifier
300 - * @param role mastership role to apply
301 - * @return mastership role change event or null if no change
302 - */
303 - DeviceEvent setRole(DeviceId deviceId, MastershipRole role) {
304 synchronized (this) { 258 synchronized (this) {
305 Device device = getDevice(deviceId); 259 Device device = getDevice(deviceId);
306 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); 260 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
...@@ -310,12 +264,8 @@ class SimpleDeviceStore { ...@@ -310,12 +264,8 @@ class SimpleDeviceStore {
310 } 264 }
311 } 265 }
312 266
313 - /** 267 + @Override
314 - * Administratively removes the specified device from the store. 268 + public DeviceEvent removeDevice(DeviceId deviceId) {
315 - *
316 - * @param deviceId device to be removed
317 - */
318 - DeviceEvent removeDevice(DeviceId deviceId) {
319 synchronized (this) { 269 synchronized (this) {
320 roles.remove(deviceId); 270 roles.remove(deviceId);
321 Device device = devices.remove(deviceId); 271 Device device = devices.remove(deviceId);
......
...@@ -20,6 +20,7 @@ import org.onlab.onos.net.host.HostProvider; ...@@ -20,6 +20,7 @@ import org.onlab.onos.net.host.HostProvider;
20 import org.onlab.onos.net.host.HostProviderRegistry; 20 import org.onlab.onos.net.host.HostProviderRegistry;
21 import org.onlab.onos.net.host.HostProviderService; 21 import org.onlab.onos.net.host.HostProviderService;
22 import org.onlab.onos.net.host.HostService; 22 import org.onlab.onos.net.host.HostService;
23 +import org.onlab.onos.net.host.HostStore;
23 import org.onlab.onos.net.provider.AbstractProviderRegistry; 24 import org.onlab.onos.net.provider.AbstractProviderRegistry;
24 import org.onlab.onos.net.provider.AbstractProviderService; 25 import org.onlab.onos.net.provider.AbstractProviderService;
25 import org.onlab.packet.IpAddress; 26 import org.onlab.packet.IpAddress;
...@@ -47,7 +48,8 @@ public class SimpleHostManager ...@@ -47,7 +48,8 @@ public class SimpleHostManager
47 private final AbstractListenerRegistry<HostEvent, HostListener> 48 private final AbstractListenerRegistry<HostEvent, HostListener>
48 listenerRegistry = new AbstractListenerRegistry<>(); 49 listenerRegistry = new AbstractListenerRegistry<>();
49 50
50 - private final SimpleHostStore store = new SimpleHostStore(); 51 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
52 + protected HostStore store;
51 53
52 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 54 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
53 protected EventDeliveryService eventDispatcher; 55 protected EventDeliveryService eventDispatcher;
......
...@@ -4,6 +4,7 @@ import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED; ...@@ -4,6 +4,7 @@ import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED;
4 import static org.onlab.onos.net.host.HostEvent.Type.HOST_MOVED; 4 import static org.onlab.onos.net.host.HostEvent.Type.HOST_MOVED;
5 import static org.onlab.onos.net.host.HostEvent.Type.HOST_REMOVED; 5 import static org.onlab.onos.net.host.HostEvent.Type.HOST_REMOVED;
6 import static org.onlab.onos.net.host.HostEvent.Type.HOST_UPDATED; 6 import static org.onlab.onos.net.host.HostEvent.Type.HOST_UPDATED;
7 +import static org.slf4j.LoggerFactory.getLogger;
7 8
8 import java.util.Collections; 9 import java.util.Collections;
9 import java.util.HashSet; 10 import java.util.HashSet;
...@@ -11,6 +12,10 @@ import java.util.Map; ...@@ -11,6 +12,10 @@ import java.util.Map;
11 import java.util.Set; 12 import java.util.Set;
12 import java.util.concurrent.ConcurrentHashMap; 13 import java.util.concurrent.ConcurrentHashMap;
13 14
15 +import org.apache.felix.scr.annotations.Activate;
16 +import org.apache.felix.scr.annotations.Component;
17 +import org.apache.felix.scr.annotations.Deactivate;
18 +import org.apache.felix.scr.annotations.Service;
14 import org.onlab.onos.net.ConnectPoint; 19 import org.onlab.onos.net.ConnectPoint;
15 import org.onlab.onos.net.DefaultHost; 20 import org.onlab.onos.net.DefaultHost;
16 import org.onlab.onos.net.DeviceId; 21 import org.onlab.onos.net.DeviceId;
...@@ -18,6 +23,7 @@ import org.onlab.onos.net.Host; ...@@ -18,6 +23,7 @@ import org.onlab.onos.net.Host;
18 import org.onlab.onos.net.HostId; 23 import org.onlab.onos.net.HostId;
19 import org.onlab.onos.net.host.HostDescription; 24 import org.onlab.onos.net.host.HostDescription;
20 import org.onlab.onos.net.host.HostEvent; 25 import org.onlab.onos.net.host.HostEvent;
26 +import org.onlab.onos.net.host.HostStore;
21 import org.onlab.onos.net.provider.ProviderId; 27 import org.onlab.onos.net.provider.ProviderId;
22 import org.onlab.packet.IpAddress; 28 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.MacAddress; 29 import org.onlab.packet.MacAddress;
...@@ -26,29 +32,37 @@ import org.onlab.packet.VlanId; ...@@ -26,29 +32,37 @@ import org.onlab.packet.VlanId;
26 import com.google.common.collect.HashMultimap; 32 import com.google.common.collect.HashMultimap;
27 import com.google.common.collect.ImmutableSet; 33 import com.google.common.collect.ImmutableSet;
28 import com.google.common.collect.Multimap; 34 import com.google.common.collect.Multimap;
35 +import org.slf4j.Logger;
29 36
30 /** 37 /**
31 * Manages inventory of end-station hosts using trivial in-memory 38 * Manages inventory of end-station hosts using trivial in-memory
32 * implementation. 39 * implementation.
33 */ 40 */
34 -public class SimpleHostStore { 41 +@Component(immediate = true)
42 +@Service
43 +public class SimpleHostStore implements HostStore {
35 44
45 + private final Logger log = getLogger(getClass());
46 +
47 + // Host inventory
36 private final Map<HostId, Host> hosts = new ConcurrentHashMap<>(); 48 private final Map<HostId, Host> hosts = new ConcurrentHashMap<>();
37 49
38 - // hosts sorted based on their location 50 + // Hosts tracked by their location
39 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create(); 51 private final Multimap<ConnectPoint, Host> locations = HashMultimap.create();
40 52
41 - /** 53 + @Activate
42 - * Creates a new host or updates the existing one based on the specified 54 + public void activate() {
43 - * description. 55 + log.info("Started");
44 - * 56 + }
45 - * @param providerId provider identification 57 +
46 - * @param hostId host identification 58 + @Deactivate
47 - * @param hostDescription host description data 59 + public void deactivate() {
48 - * @return appropriate event or null if no change resulted 60 + log.info("Stopped");
49 - */ 61 + }
50 - HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, 62 +
51 - HostDescription hostDescription) { 63 + @Override
64 + public HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId,
65 + HostDescription hostDescription) {
52 Host host = hosts.get(hostId); 66 Host host = hosts.get(hostId);
53 if (host == null) { 67 if (host == null) {
54 return createHost(providerId, hostId, hostDescription); 68 return createHost(providerId, hostId, hostDescription);
...@@ -102,13 +116,8 @@ public class SimpleHostStore { ...@@ -102,13 +116,8 @@ public class SimpleHostStore {
102 return event; 116 return event;
103 } 117 }
104 118
105 - /** 119 + @Override
106 - * Removes the specified host from the inventory. 120 + public HostEvent removeHost(HostId hostId) {
107 - *
108 - * @param hostId host identification
109 - * @return remove event or null if host was not found
110 - */
111 - HostEvent removeHost(HostId hostId) {
112 synchronized (this) { 121 synchronized (this) {
113 Host host = hosts.remove(hostId); 122 Host host = hosts.remove(hostId);
114 if (host != null) { 123 if (host != null) {
...@@ -119,41 +128,23 @@ public class SimpleHostStore { ...@@ -119,41 +128,23 @@ public class SimpleHostStore {
119 } 128 }
120 } 129 }
121 130
122 - /** 131 + @Override
123 - * Returns the number of hosts in the store. 132 + public int getHostCount() {
124 - *
125 - * @return host count
126 - */
127 - int getHostCount() {
128 return hosts.size(); 133 return hosts.size();
129 } 134 }
130 135
131 - /** 136 + @Override
132 - * Returns a collection of all hosts in the store. 137 + public Iterable<Host> getHosts() {
133 - *
134 - * @return iterable collection of all hosts
135 - */
136 - Iterable<Host> getHosts() {
137 return Collections.unmodifiableSet(new HashSet<>(hosts.values())); 138 return Collections.unmodifiableSet(new HashSet<>(hosts.values()));
138 } 139 }
139 140
140 - /** 141 + @Override
141 - * Returns the host with the specified identifer. 142 + public Host getHost(HostId hostId) {
142 - *
143 - * @param hostId host identification
144 - * @return host or null if not found
145 - */
146 - Host getHost(HostId hostId) {
147 return hosts.get(hostId); 143 return hosts.get(hostId);
148 } 144 }
149 145
150 - /** 146 + @Override
151 - * Returns the set of all hosts within the specified VLAN. 147 + public Set<Host> getHosts(VlanId vlanId) {
152 - *
153 - * @param vlanId vlan id
154 - * @return set of hosts in the vlan
155 - */
156 - Set<Host> getHosts(VlanId vlanId) {
157 Set<Host> vlanset = new HashSet<>(); 148 Set<Host> vlanset = new HashSet<>();
158 for (Host h : hosts.values()) { 149 for (Host h : hosts.values()) {
159 if (h.vlan().equals(vlanId)) { 150 if (h.vlan().equals(vlanId)) {
...@@ -163,13 +154,8 @@ public class SimpleHostStore { ...@@ -163,13 +154,8 @@ public class SimpleHostStore {
163 return vlanset; 154 return vlanset;
164 } 155 }
165 156
166 - /** 157 + @Override
167 - * Returns the set of hosts with the specified MAC address. 158 + public Set<Host> getHosts(MacAddress mac) {
168 - *
169 - * @param mac mac address
170 - * @return set of hosts with the given mac
171 - */
172 - Set<Host> getHosts(MacAddress mac) {
173 Set<Host> macset = new HashSet<>(); 159 Set<Host> macset = new HashSet<>();
174 for (Host h : hosts.values()) { 160 for (Host h : hosts.values()) {
175 if (h.mac().equals(mac)) { 161 if (h.mac().equals(mac)) {
...@@ -179,13 +165,8 @@ public class SimpleHostStore { ...@@ -179,13 +165,8 @@ public class SimpleHostStore {
179 return macset; 165 return macset;
180 } 166 }
181 167
182 - /** 168 + @Override
183 - * Returns the set of hosts with the specified IP address. 169 + public Set<Host> getHosts(IpAddress ip) {
184 - *
185 - * @param ip ip address
186 - * @return set of hosts with the given IP
187 - */
188 - Set<Host> getHosts(IpAddress ip) {
189 Set<Host> ipset = new HashSet<>(); 170 Set<Host> ipset = new HashSet<>();
190 for (Host h : hosts.values()) { 171 for (Host h : hosts.values()) {
191 if (h.ipAddresses().contains(ip)) { 172 if (h.ipAddresses().contains(ip)) {
...@@ -195,22 +176,12 @@ public class SimpleHostStore { ...@@ -195,22 +176,12 @@ public class SimpleHostStore {
195 return ipset; 176 return ipset;
196 } 177 }
197 178
198 - /** 179 + @Override
199 - * Returns the set of hosts whose location falls on the given connection point. 180 + public Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
200 - *
201 - * @param connectPoint connection point
202 - * @return set of hosts
203 - */
204 - Set<Host> getConnectedHosts(ConnectPoint connectPoint) {
205 return ImmutableSet.copyOf(locations.get(connectPoint)); 181 return ImmutableSet.copyOf(locations.get(connectPoint));
206 } 182 }
207 183
208 - /** 184 + @Override
209 - * Returns the set of hosts whose location falls on the given device.
210 - *
211 - * @param deviceId infrastructure device identifier
212 - * @return set of hosts
213 - */
214 public Set<Host> getConnectedHosts(DeviceId deviceId) { 185 public Set<Host> getConnectedHosts(DeviceId deviceId) {
215 Set<Host> hostset = new HashSet<>(); 186 Set<Host> hostset = new HashSet<>();
216 for (ConnectPoint p : locations.keySet()) { 187 for (ConnectPoint p : locations.keySet()) {
......
...@@ -27,6 +27,7 @@ import org.onlab.onos.net.link.LinkProvider; ...@@ -27,6 +27,7 @@ import org.onlab.onos.net.link.LinkProvider;
27 import org.onlab.onos.net.link.LinkProviderRegistry; 27 import org.onlab.onos.net.link.LinkProviderRegistry;
28 import org.onlab.onos.net.link.LinkProviderService; 28 import org.onlab.onos.net.link.LinkProviderService;
29 import org.onlab.onos.net.link.LinkService; 29 import org.onlab.onos.net.link.LinkService;
30 +import org.onlab.onos.net.link.LinkStore;
30 import org.onlab.onos.net.provider.AbstractProviderRegistry; 31 import org.onlab.onos.net.provider.AbstractProviderRegistry;
31 import org.onlab.onos.net.provider.AbstractProviderService; 32 import org.onlab.onos.net.provider.AbstractProviderService;
32 import org.slf4j.Logger; 33 import org.slf4j.Logger;
...@@ -38,7 +39,7 @@ import com.google.common.collect.Sets; ...@@ -38,7 +39,7 @@ import com.google.common.collect.Sets;
38 */ 39 */
39 @Component(immediate = true) 40 @Component(immediate = true)
40 @Service 41 @Service
41 -public class SimpleLinkManager 42 +public class LinkManager
42 extends AbstractProviderRegistry<LinkProvider, LinkProviderService> 43 extends AbstractProviderRegistry<LinkProvider, LinkProviderService>
43 implements LinkService, LinkAdminService, LinkProviderRegistry { 44 implements LinkService, LinkAdminService, LinkProviderRegistry {
44 45
...@@ -51,10 +52,12 @@ public class SimpleLinkManager ...@@ -51,10 +52,12 @@ public class SimpleLinkManager
51 protected final AbstractListenerRegistry<LinkEvent, LinkListener> 52 protected final AbstractListenerRegistry<LinkEvent, LinkListener>
52 listenerRegistry = new AbstractListenerRegistry<>(); 53 listenerRegistry = new AbstractListenerRegistry<>();
53 54
54 - private final SimpleLinkStore store = new SimpleLinkStore();
55 private final DeviceListener deviceListener = new InnerDeviceListener(); 55 private final DeviceListener deviceListener = new InnerDeviceListener();
56 56
57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 57 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 + protected LinkStore store;
59 +
60 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
58 protected DeviceService deviceService; 61 protected DeviceService deviceService;
59 62
60 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 63 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......
...@@ -3,13 +3,19 @@ package org.onlab.onos.net.trivial.link.impl; ...@@ -3,13 +3,19 @@ package org.onlab.onos.net.trivial.link.impl;
3 import com.google.common.collect.HashMultimap; 3 import com.google.common.collect.HashMultimap;
4 import com.google.common.collect.ImmutableSet; 4 import com.google.common.collect.ImmutableSet;
5 import com.google.common.collect.Multimap; 5 import com.google.common.collect.Multimap;
6 +import org.apache.felix.scr.annotations.Activate;
7 +import org.apache.felix.scr.annotations.Component;
8 +import org.apache.felix.scr.annotations.Deactivate;
9 +import org.apache.felix.scr.annotations.Service;
6 import org.onlab.onos.net.ConnectPoint; 10 import org.onlab.onos.net.ConnectPoint;
7 import org.onlab.onos.net.DefaultLink; 11 import org.onlab.onos.net.DefaultLink;
8 import org.onlab.onos.net.DeviceId; 12 import org.onlab.onos.net.DeviceId;
9 import org.onlab.onos.net.Link; 13 import org.onlab.onos.net.Link;
10 import org.onlab.onos.net.link.LinkDescription; 14 import org.onlab.onos.net.link.LinkDescription;
11 import org.onlab.onos.net.link.LinkEvent; 15 import org.onlab.onos.net.link.LinkEvent;
16 +import org.onlab.onos.net.link.LinkStore;
12 import org.onlab.onos.net.provider.ProviderId; 17 import org.onlab.onos.net.provider.ProviderId;
18 +import org.slf4j.Logger;
13 19
14 import java.util.Collections; 20 import java.util.Collections;
15 import java.util.HashSet; 21 import java.util.HashSet;
...@@ -20,15 +26,18 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -20,15 +26,18 @@ import java.util.concurrent.ConcurrentHashMap;
20 26
21 import static org.onlab.onos.net.Link.Type.DIRECT; 27 import static org.onlab.onos.net.Link.Type.DIRECT;
22 import static org.onlab.onos.net.Link.Type.INDIRECT; 28 import static org.onlab.onos.net.Link.Type.INDIRECT;
23 -import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED; 29 +import static org.onlab.onos.net.link.LinkEvent.Type.*;
24 -import static org.onlab.onos.net.link.LinkEvent.Type.LINK_REMOVED; 30 +import static org.slf4j.LoggerFactory.getLogger;
25 -import static org.onlab.onos.net.link.LinkEvent.Type.LINK_UPDATED;
26 31
27 /** 32 /**
28 * Manages inventory of infrastructure links using trivial in-memory structures 33 * Manages inventory of infrastructure links using trivial in-memory structures
29 * implementation. 34 * implementation.
30 */ 35 */
31 -class SimpleLinkStore { 36 +@Component(immediate = true)
37 +@Service
38 +public class SimpleLinkStore implements LinkStore {
39 +
40 + private final Logger log = getLogger(getClass());
32 41
33 // Link inventory 42 // Link inventory
34 private final Map<LinkKey, DefaultLink> links = new ConcurrentHashMap<>(); 43 private final Map<LinkKey, DefaultLink> links = new ConcurrentHashMap<>();
...@@ -37,64 +46,45 @@ class SimpleLinkStore { ...@@ -37,64 +46,45 @@ class SimpleLinkStore {
37 private final Multimap<DeviceId, Link> srcLinks = HashMultimap.create(); 46 private final Multimap<DeviceId, Link> srcLinks = HashMultimap.create();
38 private final Multimap<DeviceId, Link> dstLinks = HashMultimap.create(); 47 private final Multimap<DeviceId, Link> dstLinks = HashMultimap.create();
39 48
40 - private static final Set<Link> EMPTY = ImmutableSet.copyOf(new Link[]{}); 49 + private static final Set<Link> EMPTY = ImmutableSet.of();
50 +
51 + @Activate
52 + public void activate() {
53 + log.info("Started");
54 + }
55 +
56 + @Deactivate
57 + public void deactivate() {
58 + log.info("Stopped");
59 + }
41 60
42 - /** 61 + @Override
43 - * Returns the number of links in the store. 62 + public int getLinkCount() {
44 - *
45 - * @return number of links
46 - */
47 - int getLinkCount() {
48 return links.size(); 63 return links.size();
49 } 64 }
50 65
51 - /** 66 + @Override
52 - * Returns an iterable collection of all links in the inventory. 67 + public Iterable<Link> getLinks() {
53 - *
54 - * @return collection of all links
55 - */
56 - Iterable<Link> getLinks() {
57 return Collections.unmodifiableSet(new HashSet<Link>(links.values())); 68 return Collections.unmodifiableSet(new HashSet<Link>(links.values()));
58 } 69 }
59 70
60 - /** 71 + @Override
61 - * Returns all links egressing from the specified device. 72 + public Set<Link> getDeviceEgressLinks(DeviceId deviceId) {
62 - *
63 - * @param deviceId device identifier
64 - * @return set of device links
65 - */
66 - Set<Link> getDeviceEgressLinks(DeviceId deviceId) {
67 return ImmutableSet.copyOf(srcLinks.get(deviceId)); 73 return ImmutableSet.copyOf(srcLinks.get(deviceId));
68 } 74 }
69 75
70 - /** 76 + @Override
71 - * Returns all links ingressing from the specified device. 77 + public Set<Link> getDeviceIngressLinks(DeviceId deviceId) {
72 - *
73 - * @param deviceId device identifier
74 - * @return set of device links
75 - */
76 - Set<Link> getDeviceIngressLinks(DeviceId deviceId) {
77 return ImmutableSet.copyOf(dstLinks.get(deviceId)); 78 return ImmutableSet.copyOf(dstLinks.get(deviceId));
78 } 79 }
79 80
80 - /** 81 + @Override
81 - * Returns the link between the two end-points. 82 + public Link getLink(ConnectPoint src, ConnectPoint dst) {
82 - *
83 - * @param src source connection point
84 - * @param dst destination connection point
85 - * @return link or null if one not found between the end-points
86 - */
87 - Link getLink(ConnectPoint src, ConnectPoint dst) {
88 return links.get(new LinkKey(src, dst)); 83 return links.get(new LinkKey(src, dst));
89 } 84 }
90 85
91 - /** 86 + @Override
92 - * Returns all links egressing from the specified connection point. 87 + public Set<Link> getEgressLinks(ConnectPoint src) {
93 - *
94 - * @param src source connection point
95 - * @return set of connection point links
96 - */
97 - Set<Link> getEgressLinks(ConnectPoint src) {
98 Set<Link> egress = new HashSet<>(); 88 Set<Link> egress = new HashSet<>();
99 for (Link link : srcLinks.get(src.deviceId())) { 89 for (Link link : srcLinks.get(src.deviceId())) {
100 if (link.src().equals(src)) { 90 if (link.src().equals(src)) {
...@@ -104,13 +94,8 @@ class SimpleLinkStore { ...@@ -104,13 +94,8 @@ class SimpleLinkStore {
104 return egress; 94 return egress;
105 } 95 }
106 96
107 - /** 97 + @Override
108 - * Returns all links ingressing to the specified connection point. 98 + public Set<Link> getIngressLinks(ConnectPoint dst) {
109 - *
110 - * @param dst destination connection point
111 - * @return set of connection point links
112 - */
113 - Set<Link> getIngressLinks(ConnectPoint dst) {
114 Set<Link> ingress = new HashSet<>(); 99 Set<Link> ingress = new HashSet<>();
115 for (Link link : dstLinks.get(dst.deviceId())) { 100 for (Link link : dstLinks.get(dst.deviceId())) {
116 if (link.dst().equals(dst)) { 101 if (link.dst().equals(dst)) {
...@@ -120,14 +105,7 @@ class SimpleLinkStore { ...@@ -120,14 +105,7 @@ class SimpleLinkStore {
120 return ingress; 105 return ingress;
121 } 106 }
122 107
123 - /** 108 + @Override
124 - * Creates a new link, or updates an existing one, based on the given
125 - * information.
126 - *
127 - * @param providerId provider identity
128 - * @param linkDescription link description
129 - * @return create or update link event, or null if no change resulted
130 - */
131 public LinkEvent createOrUpdateLink(ProviderId providerId, 109 public LinkEvent createOrUpdateLink(ProviderId providerId,
132 LinkDescription linkDescription) { 110 LinkDescription linkDescription) {
133 LinkKey key = new LinkKey(linkDescription.src(), linkDescription.dst()); 111 LinkKey key = new LinkKey(linkDescription.src(), linkDescription.dst());
...@@ -171,14 +149,8 @@ class SimpleLinkStore { ...@@ -171,14 +149,8 @@ class SimpleLinkStore {
171 return null; 149 return null;
172 } 150 }
173 151
174 - /** 152 + @Override
175 - * Removes the link based on the specified information. 153 + public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
176 - *
177 - * @param src link source
178 - * @param dst link destination
179 - * @return remove link event, or null if no change resulted
180 - */
181 - LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
182 synchronized (this) { 154 synchronized (this) {
183 Link link = links.remove(new LinkKey(src, dst)); 155 Link link = links.remove(new LinkKey(src, dst));
184 if (link != null) { 156 if (link != null) {
......
...@@ -41,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -41,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger;
41 */ 41 */
42 @Component(immediate = true) 42 @Component(immediate = true)
43 @Service 43 @Service
44 -public class SimplePathManager implements PathService { 44 +public class PathManager implements PathService {
45 45
46 private static final String ELEMENT_ID_NULL = "Element ID cannot be null"; 46 private static final String ELEMENT_ID_NULL = "Element ID cannot be null";
47 47
......
1 package org.onlab.onos.net.trivial.topology.impl; 1 package org.onlab.onos.net.trivial.topology.impl;
2 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.Service;
3 import org.onlab.onos.event.Event; 7 import org.onlab.onos.event.Event;
4 import org.onlab.onos.net.ConnectPoint; 8 import org.onlab.onos.net.ConnectPoint;
5 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
...@@ -13,151 +17,96 @@ import org.onlab.onos.net.topology.Topology; ...@@ -13,151 +17,96 @@ import org.onlab.onos.net.topology.Topology;
13 import org.onlab.onos.net.topology.TopologyCluster; 17 import org.onlab.onos.net.topology.TopologyCluster;
14 import org.onlab.onos.net.topology.TopologyEvent; 18 import org.onlab.onos.net.topology.TopologyEvent;
15 import org.onlab.onos.net.topology.TopologyGraph; 19 import org.onlab.onos.net.topology.TopologyGraph;
20 +import org.onlab.onos.net.topology.TopologyStore;
21 +import org.slf4j.Logger;
16 22
17 import java.util.List; 23 import java.util.List;
18 import java.util.Set; 24 import java.util.Set;
19 25
26 +import static org.slf4j.LoggerFactory.getLogger;
27 +
20 /** 28 /**
21 * Manages inventory of topology snapshots using trivial in-memory 29 * Manages inventory of topology snapshots using trivial in-memory
22 * structures implementation. 30 * structures implementation.
23 */ 31 */
24 -class SimpleTopologyStore { 32 +@Component(immediate = true)
33 +@Service
34 +public class SimpleTopologyStore implements TopologyStore {
35 +
36 + private final Logger log = getLogger(getClass());
25 37
26 private volatile DefaultTopology current; 38 private volatile DefaultTopology current;
27 39
28 - /** 40 + @Activate
29 - * Returns the current topology snapshot. 41 + public void activate() {
30 - * 42 + log.info("Started");
31 - * @return current topology descriptor 43 + }
32 - */ 44 +
33 - Topology currentTopology() { 45 + @Deactivate
46 + public void deactivate() {
47 + log.info("Stopped");
48 + }
49 + @Override
50 + public Topology currentTopology() {
34 return current; 51 return current;
35 } 52 }
36 53
37 - /** 54 + @Override
38 - * Indicates whether the topology is the latest. 55 + public boolean isLatest(Topology topology) {
39 - *
40 - * @param topology topology descriptor
41 - * @return true if topology is the most recent one
42 - */
43 - boolean isLatest(Topology topology) {
44 // Topology is current only if it is the same as our current topology 56 // Topology is current only if it is the same as our current topology
45 return topology == current; 57 return topology == current;
46 } 58 }
47 59
48 - /** 60 + @Override
49 - * Returns the immutable graph view of the current topology. 61 + public TopologyGraph getGraph(Topology topology) {
50 - * 62 + return defaultTopology(topology).getGraph();
51 - * @param topology topology descriptor
52 - * @return graph view
53 - */
54 - TopologyGraph getGraph(DefaultTopology topology) {
55 - return topology.getGraph();
56 } 63 }
57 64
58 - /** 65 + @Override
59 - * Returns the set of topology SCC clusters. 66 + public Set<TopologyCluster> getClusters(Topology topology) {
60 - * 67 + return defaultTopology(topology).getClusters();
61 - * @param topology topology descriptor
62 - * @return set of clusters
63 - */
64 - Set<TopologyCluster> getClusters(DefaultTopology topology) {
65 - return topology.getClusters();
66 } 68 }
67 69
68 - /** 70 + @Override
69 - * Returns the cluster of the specified topology. 71 + public TopologyCluster getCluster(Topology topology, ClusterId clusterId) {
70 - * 72 + return defaultTopology(topology).getCluster(clusterId);
71 - * @param topology topology descriptor
72 - * @param clusterId cluster identity
73 - * @return topology cluster
74 - */
75 - TopologyCluster getCluster(DefaultTopology topology, ClusterId clusterId) {
76 - return topology.getCluster(clusterId);
77 } 73 }
78 74
79 - /** 75 + @Override
80 - * Returns the cluster of the specified topology. 76 + public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
81 - * 77 + return defaultTopology(topology).getClusterDevices(cluster);
82 - * @param topology topology descriptor
83 - * @param cluster topology cluster
84 - * @return set of cluster links
85 - */
86 - Set<DeviceId> getClusterDevices(DefaultTopology topology, TopologyCluster cluster) {
87 - return topology.getClusterDevices(cluster);
88 } 78 }
89 79
90 - /** 80 + @Override
91 - * Returns the cluster of the specified topology. 81 + public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
92 - * 82 + return defaultTopology(topology).getClusterLinks(cluster);
93 - * @param topology topology descriptor
94 - * @param cluster topology cluster
95 - * @return set of cluster links
96 - */
97 - Set<Link> getClusterLinks(DefaultTopology topology, TopologyCluster cluster) {
98 - return topology.getClusterLinks(cluster);
99 } 83 }
100 84
101 - /** 85 + @Override
102 - * Returns the set of pre-computed shortest paths between src and dest. 86 + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst) {
103 - * 87 + return defaultTopology(topology).getPaths(src, dst);
104 - * @param topology topology descriptor
105 - * @param src source device
106 - * @param dst destination device
107 - * @return set of shortest paths
108 - */
109 - Set<Path> getPaths(DefaultTopology topology, DeviceId src, DeviceId dst) {
110 - return topology.getPaths(src, dst);
111 } 88 }
112 89
113 - /** 90 + @Override
114 - * Computes and returns the set of shortest paths between src and dest. 91 + public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst,
115 - * 92 + LinkWeight weight) {
116 - * @param topology topology descriptor 93 + return defaultTopology(topology).getPaths(src, dst, weight);
117 - * @param src source device
118 - * @param dst destination device
119 - * @param weight link weight function
120 - * @return set of shortest paths
121 - */
122 - Set<Path> getPaths(DefaultTopology topology, DeviceId src, DeviceId dst,
123 - LinkWeight weight) {
124 - return topology.getPaths(src, dst, weight);
125 } 94 }
126 95
127 - /** 96 + @Override
128 - * Indicates whether the given connect point is part of the network fabric. 97 + public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
129 - * 98 + return defaultTopology(topology).isInfrastructure(connectPoint);
130 - * @param topology topology descriptor
131 - * @param connectPoint connection point
132 - * @return true if infrastructure; false otherwise
133 - */
134 - boolean isInfrastructure(DefaultTopology topology, ConnectPoint connectPoint) {
135 - return topology.isInfrastructure(connectPoint);
136 } 99 }
137 100
138 - /** 101 + @Override
139 - * Indicates whether broadcast is allowed for traffic received on the 102 + public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) {
140 - * given connection point. 103 + return defaultTopology(topology).isBroadcastPoint(connectPoint);
141 - *
142 - * @param topology topology descriptor
143 - * @param connectPoint connection point
144 - * @return true if broadcast allowed; false otherwise
145 - */
146 - boolean isBroadcastPoint(DefaultTopology topology, ConnectPoint connectPoint) {
147 - return topology.isBroadcastPoint(connectPoint);
148 } 104 }
149 105
150 - /** 106 + @Override
151 - * Generates a new topology snapshot from the specified description. 107 + public TopologyEvent updateTopology(ProviderId providerId,
152 - * 108 + GraphDescription graphDescription,
153 - * @param providerId provider identification 109 + List<Event> reasons) {
154 - * @param graphDescription topology graph description
155 - * @param reasons list of events that triggered the update
156 - * @return topology update event or null if the description is old
157 - */
158 - TopologyEvent updateTopology(ProviderId providerId,
159 - GraphDescription graphDescription,
160 - List<Event> reasons) {
161 // First off, make sure that what we're given is indeed newer than 110 // First off, make sure that what we're given is indeed newer than
162 // what we already have. 111 // what we already have.
163 if (current != null && graphDescription.timestamp() < current.time()) { 112 if (current != null && graphDescription.timestamp() < current.time()) {
...@@ -175,4 +124,13 @@ class SimpleTopologyStore { ...@@ -175,4 +124,13 @@ class SimpleTopologyStore {
175 } 124 }
176 } 125 }
177 126
127 + // Validates the specified topology and returns it as a default
128 + private DefaultTopology defaultTopology(Topology topology) {
129 + if (topology instanceof DefaultTopology) {
130 + return (DefaultTopology) topology;
131 + }
132 + throw new IllegalArgumentException("Topology class " + topology.getClass() +
133 + " not supported");
134 + }
135 +
178 } 136 }
......
...@@ -27,6 +27,7 @@ import org.onlab.onos.net.topology.TopologyProvider; ...@@ -27,6 +27,7 @@ import org.onlab.onos.net.topology.TopologyProvider;
27 import org.onlab.onos.net.topology.TopologyProviderRegistry; 27 import org.onlab.onos.net.topology.TopologyProviderRegistry;
28 import org.onlab.onos.net.topology.TopologyProviderService; 28 import org.onlab.onos.net.topology.TopologyProviderService;
29 import org.onlab.onos.net.topology.TopologyService; 29 import org.onlab.onos.net.topology.TopologyService;
30 +import org.onlab.onos.net.topology.TopologyStore;
30 import org.slf4j.Logger; 31 import org.slf4j.Logger;
31 32
32 import java.util.List; 33 import java.util.List;
...@@ -40,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -40,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger;
40 */ 41 */
41 @Component(immediate = true) 42 @Component(immediate = true)
42 @Service 43 @Service
43 -public class SimpleTopologyManager 44 +public class TopologyManager
44 extends AbstractProviderRegistry<TopologyProvider, TopologyProviderService> 45 extends AbstractProviderRegistry<TopologyProvider, TopologyProviderService>
45 implements TopologyService, TopologyProviderRegistry { 46 implements TopologyService, TopologyProviderRegistry {
46 47
...@@ -55,7 +56,8 @@ public class SimpleTopologyManager ...@@ -55,7 +56,8 @@ public class SimpleTopologyManager
55 private final AbstractListenerRegistry<TopologyEvent, TopologyListener> 56 private final AbstractListenerRegistry<TopologyEvent, TopologyListener>
56 listenerRegistry = new AbstractListenerRegistry<>(); 57 listenerRegistry = new AbstractListenerRegistry<>();
57 58
58 - private final SimpleTopologyStore store = new SimpleTopologyStore(); 59 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
60 + protected TopologyStore store;
59 61
60 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 62 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
61 protected EventDeliveryService eventDispatcher; 63 protected EventDeliveryService eventDispatcher;
...@@ -81,49 +83,40 @@ public class SimpleTopologyManager ...@@ -81,49 +83,40 @@ public class SimpleTopologyManager
81 @Override 83 @Override
82 public boolean isLatest(Topology topology) { 84 public boolean isLatest(Topology topology) {
83 checkNotNull(topology, TOPOLOGY_NULL); 85 checkNotNull(topology, TOPOLOGY_NULL);
84 - return store.isLatest(defaultTopology(topology)); 86 + return store.isLatest(topology);
85 - }
86 -
87 - // Validates the specified topology and returns it as a default
88 - private DefaultTopology defaultTopology(Topology topology) {
89 - if (topology instanceof DefaultTopology) {
90 - return (DefaultTopology) topology;
91 - }
92 - throw new IllegalArgumentException("Topology class " + topology.getClass() +
93 - " not supported");
94 } 87 }
95 88
96 @Override 89 @Override
97 public Set<TopologyCluster> getClusters(Topology topology) { 90 public Set<TopologyCluster> getClusters(Topology topology) {
98 checkNotNull(topology, TOPOLOGY_NULL); 91 checkNotNull(topology, TOPOLOGY_NULL);
99 - return store.getClusters(defaultTopology(topology)); 92 + return store.getClusters(topology);
100 } 93 }
101 94
102 @Override 95 @Override
103 public TopologyCluster getCluster(Topology topology, ClusterId clusterId) { 96 public TopologyCluster getCluster(Topology topology, ClusterId clusterId) {
104 checkNotNull(topology, TOPOLOGY_NULL); 97 checkNotNull(topology, TOPOLOGY_NULL);
105 checkNotNull(topology, CLUSTER_ID_NULL); 98 checkNotNull(topology, CLUSTER_ID_NULL);
106 - return store.getCluster(defaultTopology(topology), clusterId); 99 + return store.getCluster(topology, clusterId);
107 } 100 }
108 101
109 @Override 102 @Override
110 public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) { 103 public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
111 checkNotNull(topology, TOPOLOGY_NULL); 104 checkNotNull(topology, TOPOLOGY_NULL);
112 checkNotNull(topology, CLUSTER_NULL); 105 checkNotNull(topology, CLUSTER_NULL);
113 - return store.getClusterDevices(defaultTopology(topology), cluster); 106 + return store.getClusterDevices(topology, cluster);
114 } 107 }
115 108
116 @Override 109 @Override
117 public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) { 110 public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
118 checkNotNull(topology, TOPOLOGY_NULL); 111 checkNotNull(topology, TOPOLOGY_NULL);
119 checkNotNull(topology, CLUSTER_NULL); 112 checkNotNull(topology, CLUSTER_NULL);
120 - return store.getClusterLinks(defaultTopology(topology), cluster); 113 + return store.getClusterLinks(topology, cluster);
121 } 114 }
122 115
123 @Override 116 @Override
124 public TopologyGraph getGraph(Topology topology) { 117 public TopologyGraph getGraph(Topology topology) {
125 checkNotNull(topology, TOPOLOGY_NULL); 118 checkNotNull(topology, TOPOLOGY_NULL);
126 - return store.getGraph(defaultTopology(topology)); 119 + return store.getGraph(topology);
127 } 120 }
128 121
129 @Override 122 @Override
...@@ -131,7 +124,7 @@ public class SimpleTopologyManager ...@@ -131,7 +124,7 @@ public class SimpleTopologyManager
131 checkNotNull(topology, TOPOLOGY_NULL); 124 checkNotNull(topology, TOPOLOGY_NULL);
132 checkNotNull(src, DEVICE_ID_NULL); 125 checkNotNull(src, DEVICE_ID_NULL);
133 checkNotNull(dst, DEVICE_ID_NULL); 126 checkNotNull(dst, DEVICE_ID_NULL);
134 - return store.getPaths(defaultTopology(topology), src, dst); 127 + return store.getPaths(topology, src, dst);
135 } 128 }
136 129
137 @Override 130 @Override
...@@ -140,21 +133,21 @@ public class SimpleTopologyManager ...@@ -140,21 +133,21 @@ public class SimpleTopologyManager
140 checkNotNull(src, DEVICE_ID_NULL); 133 checkNotNull(src, DEVICE_ID_NULL);
141 checkNotNull(dst, DEVICE_ID_NULL); 134 checkNotNull(dst, DEVICE_ID_NULL);
142 checkNotNull(weight, "Link weight cannot be null"); 135 checkNotNull(weight, "Link weight cannot be null");
143 - return store.getPaths(defaultTopology(topology), src, dst, weight); 136 + return store.getPaths(topology, src, dst, weight);
144 } 137 }
145 138
146 @Override 139 @Override
147 public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) { 140 public boolean isInfrastructure(Topology topology, ConnectPoint connectPoint) {
148 checkNotNull(topology, TOPOLOGY_NULL); 141 checkNotNull(topology, TOPOLOGY_NULL);
149 checkNotNull(connectPoint, CONNECTION_POINT_NULL); 142 checkNotNull(connectPoint, CONNECTION_POINT_NULL);
150 - return store.isInfrastructure(defaultTopology(topology), connectPoint); 143 + return store.isInfrastructure(topology, connectPoint);
151 } 144 }
152 145
153 @Override 146 @Override
154 public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) { 147 public boolean isBroadcastPoint(Topology topology, ConnectPoint connectPoint) {
155 checkNotNull(topology, TOPOLOGY_NULL); 148 checkNotNull(topology, TOPOLOGY_NULL);
156 checkNotNull(connectPoint, CONNECTION_POINT_NULL); 149 checkNotNull(connectPoint, CONNECTION_POINT_NULL);
157 - return store.isBroadcastPoint(defaultTopology(topology), connectPoint); 150 + return store.isBroadcastPoint(topology, connectPoint);
158 } 151 }
159 152
160 @Override 153 @Override
......
...@@ -36,7 +36,7 @@ import static org.onlab.onos.net.device.DeviceEvent.Type.*; ...@@ -36,7 +36,7 @@ import static org.onlab.onos.net.device.DeviceEvent.Type.*;
36 /** 36 /**
37 * Test codifying the device service & device provider service contracts. 37 * Test codifying the device service & device provider service contracts.
38 */ 38 */
39 -public class SimpleDeviceManagerTest { 39 +public class DeviceManagerTest {
40 40
41 private static final ProviderId PID = new ProviderId("of", "foo"); 41 private static final ProviderId PID = new ProviderId("of", "foo");
42 private static final DeviceId DID1 = deviceId("of:foo"); 42 private static final DeviceId DID1 = deviceId("of:foo");
...@@ -51,8 +51,7 @@ public class SimpleDeviceManagerTest { ...@@ -51,8 +51,7 @@ public class SimpleDeviceManagerTest {
51 private static final PortNumber P2 = PortNumber.portNumber(2); 51 private static final PortNumber P2 = PortNumber.portNumber(2);
52 private static final PortNumber P3 = PortNumber.portNumber(3); 52 private static final PortNumber P3 = PortNumber.portNumber(3);
53 53
54 - 54 + private DeviceManager mgr;
55 - private SimpleDeviceManager mgr;
56 55
57 protected DeviceService service; 56 protected DeviceService service;
58 protected DeviceAdminService admin; 57 protected DeviceAdminService admin;
...@@ -63,10 +62,11 @@ public class SimpleDeviceManagerTest { ...@@ -63,10 +62,11 @@ public class SimpleDeviceManagerTest {
63 62
64 @Before 63 @Before
65 public void setUp() { 64 public void setUp() {
66 - mgr = new SimpleDeviceManager(); 65 + mgr = new DeviceManager();
67 service = mgr; 66 service = mgr;
68 admin = mgr; 67 admin = mgr;
69 registry = mgr; 68 registry = mgr;
69 + mgr.store = new SimpleDeviceStore();
70 mgr.eventDispatcher = new TestEventDispatcher(); 70 mgr.eventDispatcher = new TestEventDispatcher();
71 mgr.activate(); 71 mgr.activate();
72 72
......
...@@ -73,6 +73,7 @@ public class SimpleHostManagerTest { ...@@ -73,6 +73,7 @@ public class SimpleHostManagerTest {
73 @Before 73 @Before
74 public void setUp() { 74 public void setUp() {
75 mgr = new SimpleHostManager(); 75 mgr = new SimpleHostManager();
76 + mgr.store = new SimpleHostStore();
76 mgr.eventDispatcher = new TestEventDispatcher(); 77 mgr.eventDispatcher = new TestEventDispatcher();
77 registry = mgr; 78 registry = mgr;
78 mgr.activate(); 79 mgr.activate();
......
...@@ -22,7 +22,7 @@ import org.onlab.onos.net.link.LinkService; ...@@ -22,7 +22,7 @@ import org.onlab.onos.net.link.LinkService;
22 import org.onlab.onos.net.provider.AbstractProvider; 22 import org.onlab.onos.net.provider.AbstractProvider;
23 import org.onlab.onos.net.provider.ProviderId; 23 import org.onlab.onos.net.provider.ProviderId;
24 import org.onlab.onos.event.impl.TestEventDispatcher; 24 import org.onlab.onos.event.impl.TestEventDispatcher;
25 -import org.onlab.onos.net.trivial.device.impl.SimpleDeviceManager; 25 +import org.onlab.onos.net.trivial.device.impl.DeviceManager;
26 26
27 import java.util.ArrayList; 27 import java.util.ArrayList;
28 import java.util.Iterator; 28 import java.util.Iterator;
...@@ -38,7 +38,7 @@ import static org.onlab.onos.net.link.LinkEvent.Type.*; ...@@ -38,7 +38,7 @@ import static org.onlab.onos.net.link.LinkEvent.Type.*;
38 /** 38 /**
39 * Test codifying the link service & link provider service contracts. 39 * Test codifying the link service & link provider service contracts.
40 */ 40 */
41 -public class SimpleLinkManagerTest { 41 +public class LinkManagerTest {
42 42
43 private static final ProviderId PID = new ProviderId("of", "foo"); 43 private static final ProviderId PID = new ProviderId("of", "foo");
44 private static final DeviceId DID1 = deviceId("of:foo"); 44 private static final DeviceId DID1 = deviceId("of:foo");
...@@ -50,7 +50,7 @@ public class SimpleLinkManagerTest { ...@@ -50,7 +50,7 @@ public class SimpleLinkManagerTest {
50 private static final PortNumber P3 = PortNumber.portNumber(3); 50 private static final PortNumber P3 = PortNumber.portNumber(3);
51 51
52 52
53 - private SimpleLinkManager mgr; 53 + private LinkManager mgr;
54 54
55 protected LinkService service; 55 protected LinkService service;
56 protected LinkAdminService admin; 56 protected LinkAdminService admin;
...@@ -61,12 +61,13 @@ public class SimpleLinkManagerTest { ...@@ -61,12 +61,13 @@ public class SimpleLinkManagerTest {
61 61
62 @Before 62 @Before
63 public void setUp() { 63 public void setUp() {
64 - mgr = new SimpleLinkManager(); 64 + mgr = new LinkManager();
65 service = mgr; 65 service = mgr;
66 admin = mgr; 66 admin = mgr;
67 registry = mgr; 67 registry = mgr;
68 + mgr.store = new SimpleLinkStore();
68 mgr.eventDispatcher = new TestEventDispatcher(); 69 mgr.eventDispatcher = new TestEventDispatcher();
69 - mgr.deviceService = new SimpleDeviceManager(); 70 + mgr.deviceService = new DeviceManager();
70 mgr.activate(); 71 mgr.activate();
71 72
72 service.addListener(listener); 73 service.addListener(listener);
......
...@@ -15,8 +15,8 @@ import org.onlab.onos.net.topology.GraphDescription; ...@@ -15,8 +15,8 @@ import org.onlab.onos.net.topology.GraphDescription;
15 import org.onlab.onos.net.topology.TopologyProvider; 15 import org.onlab.onos.net.topology.TopologyProvider;
16 import org.onlab.onos.net.topology.TopologyProviderRegistry; 16 import org.onlab.onos.net.topology.TopologyProviderRegistry;
17 import org.onlab.onos.net.topology.TopologyProviderService; 17 import org.onlab.onos.net.topology.TopologyProviderService;
18 -import org.onlab.onos.net.trivial.device.impl.SimpleDeviceManager; 18 +import org.onlab.onos.net.trivial.device.impl.DeviceManager;
19 -import org.onlab.onos.net.trivial.link.impl.SimpleLinkManager; 19 +import org.onlab.onos.net.trivial.link.impl.LinkManager;
20 20
21 import java.util.List; 21 import java.util.List;
22 import java.util.Set; 22 import java.util.Set;
...@@ -27,8 +27,8 @@ import static org.junit.Assert.assertNotNull; ...@@ -27,8 +27,8 @@ import static org.junit.Assert.assertNotNull;
27 import static org.onlab.junit.TestTools.assertAfter; 27 import static org.onlab.junit.TestTools.assertAfter;
28 import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_ADDED; 28 import static org.onlab.onos.net.device.DeviceEvent.Type.DEVICE_ADDED;
29 import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED; 29 import static org.onlab.onos.net.link.LinkEvent.Type.LINK_ADDED;
30 -import static org.onlab.onos.net.trivial.topology.impl.SimpleTopologyManagerTest.device; 30 +import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.device;
31 -import static org.onlab.onos.net.trivial.topology.impl.SimpleTopologyManagerTest.link; 31 +import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.link;
32 32
33 /** 33 /**
34 * Test of the default topology provider implementation. 34 * Test of the default topology provider implementation.
...@@ -122,7 +122,7 @@ public class DefaultTopologyProviderTest { ...@@ -122,7 +122,7 @@ public class DefaultTopologyProviderTest {
122 } 122 }
123 } 123 }
124 124
125 - private class TestDeviceService extends SimpleDeviceManager { 125 + private class TestDeviceService extends DeviceManager {
126 TestDeviceService() { 126 TestDeviceService() {
127 eventDispatcher = new TestEventDispatcher(); 127 eventDispatcher = new TestEventDispatcher();
128 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry); 128 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
...@@ -140,7 +140,7 @@ public class DefaultTopologyProviderTest { ...@@ -140,7 +140,7 @@ public class DefaultTopologyProviderTest {
140 } 140 }
141 } 141 }
142 142
143 - private class TestLinkService extends SimpleLinkManager { 143 + private class TestLinkService extends LinkManager {
144 TestLinkService() { 144 TestLinkService() {
145 eventDispatcher = new TestEventDispatcher(); 145 eventDispatcher = new TestEventDispatcher();
146 eventDispatcher.addSink(LinkEvent.class, listenerRegistry); 146 eventDispatcher.addSink(LinkEvent.class, listenerRegistry);
......
...@@ -21,8 +21,8 @@ import static com.google.common.collect.ImmutableSet.of; ...@@ -21,8 +21,8 @@ import static com.google.common.collect.ImmutableSet.of;
21 import static org.junit.Assert.*; 21 import static org.junit.Assert.*;
22 import static org.onlab.onos.net.DeviceId.deviceId; 22 import static org.onlab.onos.net.DeviceId.deviceId;
23 import static org.onlab.onos.net.PortNumber.portNumber; 23 import static org.onlab.onos.net.PortNumber.portNumber;
24 -import static org.onlab.onos.net.trivial.topology.impl.SimpleTopologyManagerTest.device; 24 +import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.device;
25 -import static org.onlab.onos.net.trivial.topology.impl.SimpleTopologyManagerTest.link; 25 +import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.link;
26 26
27 /** 27 /**
28 * Test of the default topology implementation. 28 * Test of the default topology implementation.
......
...@@ -41,11 +41,11 @@ import static org.onlab.onos.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED; ...@@ -41,11 +41,11 @@ import static org.onlab.onos.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED;
41 /** 41 /**
42 * Test of the topology subsystem. 42 * Test of the topology subsystem.
43 */ 43 */
44 -public class SimpleTopologyManagerTest { 44 +public class TopologyManagerTest {
45 45
46 private static final ProviderId PID = new ProviderId("of", "foo"); 46 private static final ProviderId PID = new ProviderId("of", "foo");
47 47
48 - private SimpleTopologyManager mgr; 48 + private TopologyManager mgr;
49 49
50 protected TopologyService service; 50 protected TopologyService service;
51 protected TopologyProviderRegistry registry; 51 protected TopologyProviderRegistry registry;
...@@ -55,10 +55,11 @@ public class SimpleTopologyManagerTest { ...@@ -55,10 +55,11 @@ public class SimpleTopologyManagerTest {
55 55
56 @Before 56 @Before
57 public void setUp() { 57 public void setUp() {
58 - mgr = new SimpleTopologyManager(); 58 + mgr = new TopologyManager();
59 service = mgr; 59 service = mgr;
60 registry = mgr; 60 registry = mgr;
61 61
62 + mgr.store = new SimpleTopologyStore();
62 mgr.eventDispatcher = new TestEventDispatcher(); 63 mgr.eventDispatcher = new TestEventDispatcher();
63 mgr.activate(); 64 mgr.activate();
64 65
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
28 <br> 28 <br>
29 <img src="doc-files/onos-subsystem.png" alt="ONOS subsystem structure"><br> 29 <img src="doc-files/onos-subsystem.png" alt="ONOS subsystem structure"><br>
30 For example, the device-subsystem comprises of a core 30 For example, the device-subsystem comprises of a core
31 - {@link org.onlab.onos.net.trivial.device.impl.SimpleDeviceManager DeviceManager}, 31 + {@link org.onlab.onos.net.trivial.device.impl.DeviceManager},
32 which exposes a north-bound 32 which exposes a north-bound
33 {@link org.onlab.onos.net.device.DeviceService} through which applications or other core components 33 {@link org.onlab.onos.net.device.DeviceService} through which applications or other core components
34 can learn about the global infrastructure device inventory and through 34 can learn about the global infrastructure device inventory and through
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
39 </p> 39 </p>
40 40
41 <p> 41 <p>
42 - On the south-bound side, the core {@link org.onlab.onos.net.trivial.device.impl.SimpleDeviceManager DeviceManager} 42 + On the south-bound side, the core {@link org.onlab.onos.net.trivial.device.impl.DeviceManager}
43 exposes a {@link org.onlab.onos.net.device.DeviceProviderRegistry} through which any number of 43 exposes a {@link org.onlab.onos.net.device.DeviceProviderRegistry} through which any number of
44 {@link org.onlab.onos.net.device.DeviceProvider} entities can register and in turn obtain a 44 {@link org.onlab.onos.net.device.DeviceProvider} entities can register and in turn obtain a
45 {@link org.onlab.onos.net.device.DeviceProviderService}. Device and port information can then be 45 {@link org.onlab.onos.net.device.DeviceProviderService}. Device and port information can then be
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
52 <p> 52 <p>
53 Within the core, the tasks of indexing, persisting and synchronizing the 53 Within the core, the tasks of indexing, persisting and synchronizing the
54 global device and port state with the cluster peers falls on the 54 global device and port state with the cluster peers falls on the
55 - {@link org.onlab.onos.net.trivial.device.impl.SimpleDeviceStore DeviceStore}. 55 + {@link org.onlab.onos.net.device.DeviceStore}.
56 </p> 56 </p>
57 57
58 <p> 58 <p>
......
...@@ -50,8 +50,8 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature ...@@ -50,8 +50,8 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature
50 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 50 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
51 51
52 # Patch the Apache Karaf distribution file to load ONOS features 52 # Patch the Apache Karaf distribution file to load ONOS features
53 -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|' \ 53 +#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|' \
54 - $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 54 +# $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
55 55
56 # Patch the Apache Karaf distribution with ONOS branding bundle 56 # Patch the Apache Karaf distribution with ONOS branding bundle
57 cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \ 57 cp $M2_REPO/org/onlab/onos/onos-branding/$ONOS_VERSION/onos-branding-*.jar \
......
...@@ -45,20 +45,35 @@ alias gui='open http://localhost:8181/onos/tvue' ...@@ -45,20 +45,35 @@ alias gui='open http://localhost:8181/onos/tvue'
45 45
46 # Test related conveniences 46 # Test related conveniences
47 47
48 -# Default virtual box ONOS instances 1,2 & 3
49 -export OC1="192.168.56.101"
50 -export OC2="192.168.56.102"
51 -export OC3="192.168.56.103"
52 -
53 -# Default instance is #1
54 -export OCI="$OC1"
55 -
56 # SSH to a specified ONOS instance 48 # SSH to a specified ONOS instance
57 function sshctl { 49 function sshctl {
58 [ -n "$1" ] && OCI=$1 && shift 50 [ -n "$1" ] && OCI=$1 && shift
59 ssh -Y sdn@$OCI "$@" 51 ssh -Y sdn@$OCI "$@"
60 } 52 }
61 53
54 +# Applies the settings in the specified cell file or lists current cell definition
55 +# if no cell file is given.
56 +function cell {
57 + if [ -n "$1" ]; then
58 + [ ! -f $ONOS_ROOT/tools/test/cells/$1 ] && \
59 + echo "No such cell: $1" >&2 && return 1
60 + . $ONOS_ROOT/tools/test/cells/$1
61 + export OCI=$OC1
62 + export ONOS_CELL=$1
63 + cell
64 + else
65 + env | egrep "ONOS_CELL"
66 + env | egrep "OCI"
67 + env | egrep "OC[0-9]+" | sort
68 + fi
69 +}
70 +
71 +cell local >/dev/null # Default cell is the local VMs
72 +
73 +# Lists available cells
74 +function cells {
75 + ls -1 $ONOS_ROOT/tools/test/cells
76 +}
62 77
63 # Miscellaneous 78 # Miscellaneous
64 function spy { 79 function spy {
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
38 </aws> 38 </aws>
39 </join> 39 </join>
40 <interfaces enabled="true"> 40 <interfaces enabled="true">
41 - <interface>10.1.9.*</interface> 41 + <interface>192.168.56.*</interface>
42 </interfaces> 42 </interfaces>
43 <ssl enabled="false"/> 43 <ssl enabled="false"/>
44 <socket-interceptor enabled="false"/> 44 <socket-interceptor enabled="false"/>
......
...@@ -7,22 +7,60 @@ ...@@ -7,22 +7,60 @@
7 . $ONOS_ROOT/tools/build/envDefaults 7 . $ONOS_ROOT/tools/build/envDefaults
8 8
9 # If the first option is -f attempt uninstall first. 9 # If the first option is -f attempt uninstall first.
10 -[ "$1" = "-f" ] && shift && onos-uninstall ${1:-$OCI} 10 +[ "$1" = "-f" ] && shift && echo 'Uninstalling...' && onos-uninstall ${1:-$OCI}
11 11
12 remote=$ONOS_USER@${1:-$OCI} 12 remote=$ONOS_USER@${1:-$OCI}
13 13
14 scp -q $ONOS_TAR $remote:/tmp 14 scp -q $ONOS_TAR $remote:/tmp
15 15
16 +LOG=$ONOS_INSTALL_DIR/install.log
17 +onos=$ONOS_INSTALL_DIR/bin/onos
18 +
16 ssh $remote " 19 ssh $remote "
17 [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1 20 [ -d $ONOS_INSTALL_DIR/bin ] && echo \"ONOS is already installed\" && exit 1
18 21
19 # Prepare a landing zone and unroll the bits 22 # Prepare a landing zone and unroll the bits
23 + echo 'Unpacking...'
20 sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $ONOS_INSTALL_DIR 24 sudo mkdir -p $ONOS_INSTALL_DIR && sudo chown sdn:sdn $ONOS_INSTALL_DIR
21 tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1 25 tar zxmf /tmp/$ONOS_BITS.tar.gz -C $ONOS_INSTALL_DIR --strip-components=1
22 26
23 # Make a link to the log file directory. 27 # Make a link to the log file directory.
24 - ln -s /opt/onos/$KARAF_DIST/data/log /opt/onos/log 28 + ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
25 29
26 # TODO: Setup ONOS to run as a daemon; for now we at least startup 30 # TODO: Setup ONOS to run as a daemon; for now we at least startup
27 - nohup /opt/onos/bin/onos-ctl server </dev/null 1>/opt/onos/svc.log 2>&1 & 31 + echo 'Starting...'
32 + nohup $ONOS_INSTALL_DIR/bin/onos-ctl server </dev/null | 1>/opt/onos/svc.log 2>&1 &
33 +
34 + # Wait until we reach the run-level 100
35 + echo 'Waiting for cluster bootstrap...'
36 + running=""
37 + while [ -z \$running ]; do
38 + $onos bundle:list 2>>$LOG | grep -q 'START LEVEL 100' && running=1 || sleep 2
39 + done
40 +
41 + # Now create group onos and join it, while quitting the default one
42 + if ! $onos cluster:group-list 2>>$LOG | cut -d \\ -f3 | grep -q onos; then
43 + echo 'Creating ONOS group...'
44 + installRole=primary
45 + $onos cluster:group-create onos 1>>$LOG 2>&1
46 + fi
47 +
48 + echo 'Configuring group membership...'
49 + node=\$($onos cluster:node-list 2>>$LOG | grep '^x' | cut -d \\ -f3)
50 + $onos cluster:group-join onos \$node 1>>$LOG 2>&1
51 + $onos cluster:group-quit default \$node 1>>$LOG 2>&1
52 +
53 + if [ X\$installRole = Xprimary ]; then
54 + echo 'Installing ONOS bundles...'
55 + $onos cluster:feature-install onos onos-api 1>>$LOG 2>&1
56 + $onos cluster:feature-install onos onos-core 1>>$LOG 2>&1
57 + $onos cluster:feature-install onos onos-openflow 1>>$LOG 2>&1
58 + $onos cluster:feature-install onoe onos-cli 1>>$LOG 2>&1
59 + # $onos cluster:feature-install onos onos-gui 1>>$LOG 2>&1
60 + # $onos cluster:feature-install onos onos-rest 1>>$LOG 2>&1
61 + $onos cluster:feature-install onos onos-app-tvue 1>>$LOG 2>&1
62 + $onos cluster:feature-install onos onos-app-fwd 1>>$LOG 2>&1
63 + fi
64 +
65 + echo 'Started...'
28 " 66 "
......
1 +# Default virtual box ONOS instances 1,2 & 3
2 +
3 +export OC1="192.168.56.101"
4 +export OC2="192.168.56.102"
5 +export OC3="192.168.56.103"
6 +
7 +
...@@ -234,6 +234,30 @@ public final class IpAddress { ...@@ -234,6 +234,30 @@ public final class IpAddress {
234 return mask() != 0; 234 return mask() != 0;
235 } 235 }
236 236
237 + /**
238 + * Determines whether a given address is contained within this IpAddress'
239 + * network.
240 + *
241 + * @param other another IP address that could be contained in this network
242 + * @return true if the other IP address is contained in this address'
243 + * network, otherwise false
244 + */
245 + public boolean contains(IpAddress other) {
246 + if (this.netmask <= other.netmask) {
247 + // Special case where they're both /32 addresses
248 + if (this.netmask == MAX_INET_MASK) {
249 + return Arrays.equals(octets, other.octets);
250 + }
251 +
252 + // Mask the other address with our network mask
253 + IpAddress otherMasked =
254 + IpAddress.valueOf(other.octets, netmask).network();
255 +
256 + return network().equals(otherMasked);
257 + }
258 + return false;
259 + }
260 +
237 @Override 261 @Override
238 public int hashCode() { 262 public int hashCode() {
239 final int prime = 31; 263 final int prime = 31;
......
1 package org.onlab.packet; 1 package org.onlab.packet;
2 2
3 import static org.junit.Assert.assertEquals; 3 import static org.junit.Assert.assertEquals;
4 +import static org.junit.Assert.assertFalse;
4 import static org.junit.Assert.assertTrue; 5 import static org.junit.Assert.assertTrue;
5 6
6 import java.util.Arrays; 7 import java.util.Arrays;
...@@ -73,4 +74,26 @@ public class IPAddressTest { ...@@ -73,4 +74,26 @@ public class IPAddressTest {
73 assertTrue("incorrect netmask", 74 assertTrue("incorrect netmask",
74 Arrays.equals(IpAddress.ANY, ip2.netmask().toOctets())); 75 Arrays.equals(IpAddress.ANY, ip2.netmask().toOctets()));
75 } 76 }
77 +
78 + @Test
79 + public void testContains() {
80 + IpAddress slash31 = IpAddress.valueOf(BYTES1, 31);
81 + IpAddress slash32 = IpAddress.valueOf(BYTES1, 32);
82 + IpAddress differentSlash32 = IpAddress.valueOf(BYTES2, 32);
83 +
84 + assertTrue(slash31.contains(differentSlash32));
85 + assertFalse(differentSlash32.contains(slash31));
86 +
87 + assertTrue(slash31.contains(slash32));
88 + assertFalse(slash32.contains(differentSlash32));
89 + assertFalse(differentSlash32.contains(slash32));
90 +
91 + IpAddress zero = IpAddress.valueOf("0.0.0.0/0");
92 + assertTrue(zero.contains(differentSlash32));
93 + assertFalse(differentSlash32.contains(zero));
94 +
95 + IpAddress slash8 = IpAddress.valueOf("10.0.0.0/8");
96 + assertTrue(slash8.contains(slash31));
97 + assertFalse(slash31.contains(slash8));
98 + }
76 } 99 }
......