tom

Restructured to separate stores and managers into different bundles. Reactive fo…

…rwarding does not seem to work; will investigate.
Showing 34 changed files with 151 additions and 100 deletions
...@@ -10,8 +10,7 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -10,8 +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. It may do so using whatever 13 + * Manages inventory of infrastructure devices.
14 - * means are appropriate.
15 */ 14 */
16 public interface DeviceStore { 15 public interface DeviceStore {
17 16
......
1 +package org.onlab.onos.net.flow;
2 +
3 +import org.onlab.onos.net.DeviceId;
4 +
5 +/**
6 + * Manages inventory of flow rules.
7 + */
8 +public interface FlowRuleStore {
9 +
10 + /**
11 + * Returns the flow entries associated with a device.
12 + *
13 + * @param deviceId the device ID
14 + * @return the flow entries
15 + */
16 + Iterable<FlowRule> getFlowEntries(DeviceId deviceId);
17 +
18 + /**
19 + * Stores a new flow rule, and generates a FlowRule for it.
20 + *
21 + * @param rule the flow rule to add
22 + * @return a flow entry
23 + */
24 + FlowRule storeFlowRule(FlowRule rule);
25 +
26 + /**
27 + * Stores a new flow rule, or updates an existing entry.
28 + *
29 + * @param rule the flow rule to add or update
30 + * @return flow_added event, or null if just an update
31 + */
32 + FlowRuleEvent addOrUpdateFlowRule(FlowRule rule);
33 +
34 + /**
35 + * @param rule the flow rule to remove
36 + * @return flow_removed event, or null if nothing removed
37 + */
38 + FlowRuleEvent removeFlowRule(FlowRule rule);
39 +
40 +}
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology;
2 2
3 import com.google.common.collect.ImmutableSet; 3 import com.google.common.collect.ImmutableSet;
4 import com.google.common.collect.Maps; 4 import com.google.common.collect.Maps;
...@@ -6,16 +6,13 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -6,16 +6,13 @@ import org.onlab.onos.net.ConnectPoint;
6 import org.onlab.onos.net.Device; 6 import org.onlab.onos.net.Device;
7 import org.onlab.onos.net.DeviceId; 7 import org.onlab.onos.net.DeviceId;
8 import org.onlab.onos.net.Link; 8 import org.onlab.onos.net.Link;
9 -import org.onlab.onos.net.topology.GraphDescription;
10 -import org.onlab.onos.net.topology.TopologyEdge;
11 -import org.onlab.onos.net.topology.TopologyVertex;
12 9
13 import java.util.Map; 10 import java.util.Map;
14 11
15 /** 12 /**
16 * Default implementation of an immutable topology graph data carrier. 13 * Default implementation of an immutable topology graph data carrier.
17 */ 14 */
18 -class DefaultGraphDescription implements GraphDescription { 15 +public class DefaultGraphDescription implements GraphDescription {
19 16
20 private final long nanos; 17 private final long nanos;
21 private final ImmutableSet<TopologyVertex> vertexes; 18 private final ImmutableSet<TopologyVertex> vertexes;
...@@ -32,7 +29,7 @@ class DefaultGraphDescription implements GraphDescription { ...@@ -32,7 +29,7 @@ class DefaultGraphDescription implements GraphDescription {
32 * @param devices collection of infrastructure devices 29 * @param devices collection of infrastructure devices
33 * @param links collection of infrastructure links 30 * @param links collection of infrastructure links
34 */ 31 */
35 - DefaultGraphDescription(long nanos, Iterable<Device> devices, Iterable<Link> links) { 32 + public DefaultGraphDescription(long nanos, Iterable<Device> devices, Iterable<Link> links) {
36 this.nanos = nanos; 33 this.nanos = nanos;
37 this.vertexes = buildVertexes(devices); 34 this.vertexes = buildVertexes(devices);
38 this.edges = buildEdges(links); 35 this.edges = buildEdges(links);
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology;
2 2
3 import org.onlab.onos.net.Link; 3 import org.onlab.onos.net.Link;
4 -import org.onlab.onos.net.topology.TopologyEdge;
5 -import org.onlab.onos.net.topology.TopologyVertex;
6 4
7 import java.util.Objects; 5 import java.util.Objects;
8 6
...@@ -11,7 +9,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; ...@@ -11,7 +9,7 @@ import static com.google.common.base.MoreObjects.toStringHelper;
11 /** 9 /**
12 * Implementation of the topology edge backed by a link. 10 * Implementation of the topology edge backed by a link.
13 */ 11 */
14 -class DefaultTopologyEdge implements TopologyEdge { 12 +public class DefaultTopologyEdge implements TopologyEdge {
15 13
16 private final Link link; 14 private final Link link;
17 private final TopologyVertex src; 15 private final TopologyVertex src;
...@@ -24,7 +22,7 @@ class DefaultTopologyEdge implements TopologyEdge { ...@@ -24,7 +22,7 @@ class DefaultTopologyEdge implements TopologyEdge {
24 * @param dst destination vertex 22 * @param dst destination vertex
25 * @param link infrastructure link 23 * @param link infrastructure link
26 */ 24 */
27 - DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) { 25 + public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) {
28 this.src = src; 26 this.src = src;
29 this.dst = dst; 27 this.dst = dst;
30 this.link = link; 28 this.link = link;
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology;
2 2
3 import org.onlab.onos.net.DeviceId; 3 import org.onlab.onos.net.DeviceId;
4 -import org.onlab.onos.net.topology.TopologyVertex;
5 4
6 import java.util.Objects; 5 import java.util.Objects;
7 6
8 /** 7 /**
9 * Implementation of the topology vertex backed by a device id. 8 * Implementation of the topology vertex backed by a device id.
10 */ 9 */
11 -class DefaultTopologyVertex implements TopologyVertex { 10 +public class DefaultTopologyVertex implements TopologyVertex {
12 11
13 private final DeviceId deviceId; 12 private final DeviceId deviceId;
14 13
...@@ -17,7 +16,7 @@ class DefaultTopologyVertex implements TopologyVertex { ...@@ -17,7 +16,7 @@ class DefaultTopologyVertex implements TopologyVertex {
17 * 16 *
18 * @param deviceId backing infrastructure device identifier 17 * @param deviceId backing infrastructure device identifier
19 */ 18 */
20 - DefaultTopologyVertex(DeviceId deviceId) { 19 + public DefaultTopologyVertex(DeviceId deviceId) {
21 this.deviceId = deviceId; 20 this.deviceId = deviceId;
22 } 21 }
23 22
......
...@@ -21,6 +21,14 @@ ...@@ -21,6 +21,14 @@
21 <groupId>org.onlab.onos</groupId> 21 <groupId>org.onlab.onos</groupId>
22 <artifactId>onos-api</artifactId> 22 <artifactId>onos-api</artifactId>
23 </dependency> 23 </dependency>
24 +
25 + <dependency>
26 + <groupId>org.onlab.onos</groupId>
27 + <artifactId>onos-core-trivial</artifactId>
28 + <version>${project.version}</version>
29 + <scope>test</scope>
30 + </dependency>
31 +
24 <dependency> 32 <dependency>
25 <groupId>org.apache.felix</groupId> 33 <groupId>org.apache.felix</groupId>
26 <artifactId>org.apache.felix.scr.annotations</artifactId> 34 <artifactId>org.apache.felix.scr.annotations</artifactId>
......
1 -package org.onlab.onos.net.trivial.device.impl; 1 +package org.onlab.onos.net.device.impl;
2 2
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
......
1 -package org.onlab.onos.net.trivial.flow.impl; 1 +package org.onlab.onos.net.flow.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
...@@ -24,6 +24,7 @@ import org.onlab.onos.net.flow.FlowRuleProvider; ...@@ -24,6 +24,7 @@ import org.onlab.onos.net.flow.FlowRuleProvider;
24 import org.onlab.onos.net.flow.FlowRuleProviderRegistry; 24 import org.onlab.onos.net.flow.FlowRuleProviderRegistry;
25 import org.onlab.onos.net.flow.FlowRuleProviderService; 25 import org.onlab.onos.net.flow.FlowRuleProviderService;
26 import org.onlab.onos.net.flow.FlowRuleService; 26 import org.onlab.onos.net.flow.FlowRuleService;
27 +import org.onlab.onos.net.flow.FlowRuleStore;
27 import org.onlab.onos.net.provider.AbstractProviderRegistry; 28 import org.onlab.onos.net.provider.AbstractProviderRegistry;
28 import org.onlab.onos.net.provider.AbstractProviderService; 29 import org.onlab.onos.net.provider.AbstractProviderService;
29 import org.slf4j.Logger; 30 import org.slf4j.Logger;
...@@ -31,16 +32,17 @@ import org.slf4j.Logger; ...@@ -31,16 +32,17 @@ import org.slf4j.Logger;
31 @Component(immediate = true) 32 @Component(immediate = true)
32 @Service 33 @Service
33 public class SimpleFlowRuleManager 34 public class SimpleFlowRuleManager
34 -extends AbstractProviderRegistry<FlowRuleProvider, FlowRuleProviderService> 35 + extends AbstractProviderRegistry<FlowRuleProvider, FlowRuleProviderService>
35 -implements FlowRuleService, FlowRuleProviderRegistry { 36 + implements FlowRuleService, FlowRuleProviderRegistry {
36 37
37 public static final String FLOW_RULE_NULL = "FlowRule cannot be null"; 38 public static final String FLOW_RULE_NULL = "FlowRule cannot be null";
38 private final Logger log = getLogger(getClass()); 39 private final Logger log = getLogger(getClass());
39 40
40 private final AbstractListenerRegistry<FlowRuleEvent, FlowRuleListener> 41 private final AbstractListenerRegistry<FlowRuleEvent, FlowRuleListener>
41 - listenerRegistry = new AbstractListenerRegistry<>(); 42 + listenerRegistry = new AbstractListenerRegistry<>();
42 43
43 - private final SimpleFlowRuleStore store = new SimpleFlowRuleStore(); 44 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
45 + protected FlowRuleStore store;
44 46
45 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 47 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
46 protected EventDeliveryService eventDispatcher; 48 protected EventDeliveryService eventDispatcher;
...@@ -109,8 +111,8 @@ implements FlowRuleService, FlowRuleProviderRegistry { ...@@ -109,8 +111,8 @@ implements FlowRuleService, FlowRuleProviderRegistry {
109 } 111 }
110 112
111 private class InternalFlowRuleProviderService 113 private class InternalFlowRuleProviderService
112 - extends AbstractProviderService<FlowRuleProvider> 114 + extends AbstractProviderService<FlowRuleProvider>
113 - implements FlowRuleProviderService { 115 + implements FlowRuleProviderService {
114 116
115 protected InternalFlowRuleProviderService(FlowRuleProvider provider) { 117 protected InternalFlowRuleProviderService(FlowRuleProvider provider) {
116 super(provider); 118 super(provider);
......
1 /** 1 /**
2 * Core subsystem for tracking and manipulating global flow state. 2 * Core subsystem for tracking and manipulating global flow state.
3 */ 3 */
4 -package org.onlab.onos.net.trivial.flow.impl; 4 +package org.onlab.onos.net.flow.impl;
......
1 -package org.onlab.onos.net.trivial.host.impl; 1 +package org.onlab.onos.net.host.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
......
1 -package org.onlab.onos.net.trivial.host.impl; 1 +package org.onlab.onos.net.host.impl;
2 2
3 import java.util.HashSet; 3 import java.util.HashSet;
4 import java.util.Set; 4 import java.util.Set;
......
1 /** 1 /**
2 * Core subsystem for tracking global inventory of end-station hosts. 2 * Core subsystem for tracking global inventory of end-station hosts.
3 */ 3 */
4 -package org.onlab.onos.net.trivial.host.impl; 4 +package org.onlab.onos.net.host.impl;
......
1 -package org.onlab.onos.net.trivial.link.impl; 1 +package org.onlab.onos.net.link.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
......
1 -package org.onlab.onos.net.trivial.packet.impl; 1 +package org.onlab.onos.net.packet.impl;
2 2
3 import static com.google.common.base.Preconditions.checkNotNull; 3 import static com.google.common.base.Preconditions.checkNotNull;
4 import static org.slf4j.LoggerFactory.getLogger; 4 import static org.slf4j.LoggerFactory.getLogger;
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
3 * Processing of inbound packets is always in the local context only, but 3 * Processing of inbound packets is always in the local context only, but
4 * emitting outbound packets allows for cluster-wide operation. 4 * emitting outbound packets allows for cluster-wide operation.
5 */ 5 */
6 -package org.onlab.onos.net.trivial.packet.impl; 6 +package org.onlab.onos.net.packet.impl;
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology.impl;
2 2
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
...@@ -16,6 +16,7 @@ import org.onlab.onos.net.link.LinkListener; ...@@ -16,6 +16,7 @@ import org.onlab.onos.net.link.LinkListener;
16 import org.onlab.onos.net.link.LinkService; 16 import org.onlab.onos.net.link.LinkService;
17 import org.onlab.onos.net.provider.AbstractProvider; 17 import org.onlab.onos.net.provider.AbstractProvider;
18 import org.onlab.onos.net.provider.ProviderId; 18 import org.onlab.onos.net.provider.ProviderId;
19 +import org.onlab.onos.net.topology.DefaultGraphDescription;
19 import org.onlab.onos.net.topology.GraphDescription; 20 import org.onlab.onos.net.topology.GraphDescription;
20 import org.onlab.onos.net.topology.TopologyProvider; 21 import org.onlab.onos.net.topology.TopologyProvider;
21 import org.onlab.onos.net.topology.TopologyProviderRegistry; 22 import org.onlab.onos.net.topology.TopologyProviderRegistry;
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology.impl;
2 2
3 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
4 import com.google.common.collect.Sets; 4 import com.google.common.collect.Sets;
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology.impl;
2 2
3 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
......
1 /** 1 /**
2 * Core subsystem for tracking global &amp; consistent topology graph views. 2 * Core subsystem for tracking global &amp; consistent topology graph views.
3 */ 3 */
4 -package org.onlab.onos.net.trivial.topology.impl; 4 +package org.onlab.onos.net.topology.impl;
......
1 -package org.onlab.onos.net.trivial.device.impl; 1 +package org.onlab.onos.net.device.impl;
2 2
3 import org.junit.After; 3 import org.junit.After;
4 import org.junit.Before; 4 import org.junit.Before;
...@@ -23,6 +23,7 @@ import org.onlab.onos.net.device.PortDescription; ...@@ -23,6 +23,7 @@ import org.onlab.onos.net.device.PortDescription;
23 import org.onlab.onos.net.provider.AbstractProvider; 23 import org.onlab.onos.net.provider.AbstractProvider;
24 import org.onlab.onos.net.provider.ProviderId; 24 import org.onlab.onos.net.provider.ProviderId;
25 import org.onlab.onos.event.impl.TestEventDispatcher; 25 import org.onlab.onos.event.impl.TestEventDispatcher;
26 +import org.onlab.onos.net.trivial.device.impl.SimpleDeviceStore;
26 27
27 import java.util.ArrayList; 28 import java.util.ArrayList;
28 import java.util.Iterator; 29 import java.util.Iterator;
......
1 -package org.onlab.onos.net.trivial.flow.impl; 1 +package org.onlab.onos.net.flow.impl;
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.assertFalse;
...@@ -40,6 +40,7 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -40,6 +40,7 @@ import org.onlab.onos.net.provider.ProviderId;
40 40
41 import com.google.common.collect.Lists; 41 import com.google.common.collect.Lists;
42 import com.google.common.collect.Sets; 42 import com.google.common.collect.Sets;
43 +import org.onlab.onos.net.trivial.flow.impl.SimpleFlowRuleStore;
43 44
44 /** 45 /**
45 * Test codifying the flow rule service & flow rule provider service contracts. 46 * Test codifying the flow rule service & flow rule provider service contracts.
...@@ -62,6 +63,7 @@ public class SimpleFlowRuleManagerTest { ...@@ -62,6 +63,7 @@ public class SimpleFlowRuleManagerTest {
62 @Before 63 @Before
63 public void setUp() { 64 public void setUp() {
64 mgr = new SimpleFlowRuleManager(); 65 mgr = new SimpleFlowRuleManager();
66 + mgr.store = new SimpleFlowRuleStore();
65 mgr.eventDispatcher = new TestEventDispatcher(); 67 mgr.eventDispatcher = new TestEventDispatcher();
66 mgr.deviceService = new TestDeviceService(); 68 mgr.deviceService = new TestDeviceService();
67 service = mgr; 69 service = mgr;
......
1 -package org.onlab.onos.net.trivial.host.impl; 1 +package org.onlab.onos.net.host.impl;
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.assertFalse;
...@@ -28,6 +28,7 @@ import org.onlab.onos.net.host.HostProviderRegistry; ...@@ -28,6 +28,7 @@ import org.onlab.onos.net.host.HostProviderRegistry;
28 import org.onlab.onos.net.host.HostProviderService; 28 import org.onlab.onos.net.host.HostProviderService;
29 import org.onlab.onos.net.provider.AbstractProvider; 29 import org.onlab.onos.net.provider.AbstractProvider;
30 import org.onlab.onos.net.provider.ProviderId; 30 import org.onlab.onos.net.provider.ProviderId;
31 +import org.onlab.onos.net.trivial.host.impl.SimpleHostStore;
31 import org.onlab.packet.IpPrefix; 32 import org.onlab.packet.IpPrefix;
32 import org.onlab.packet.MacAddress; 33 import org.onlab.packet.MacAddress;
33 import org.onlab.packet.VlanId; 34 import org.onlab.packet.VlanId;
......
1 -package org.onlab.onos.net.trivial.link.impl; 1 +package org.onlab.onos.net.link.impl;
2 2
3 import com.google.common.collect.ImmutableSet; 3 import com.google.common.collect.ImmutableSet;
4 import org.junit.After; 4 import org.junit.After;
...@@ -22,7 +22,8 @@ import org.onlab.onos.net.link.LinkService; ...@@ -22,7 +22,8 @@ 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.DeviceManager; 25 +import org.onlab.onos.net.device.impl.DeviceManager;
26 +import org.onlab.onos.net.trivial.link.impl.SimpleLinkStore;
26 27
27 import java.util.ArrayList; 28 import java.util.ArrayList;
28 import java.util.Iterator; 29 import java.util.Iterator;
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology.impl;
2 2
3 +import com.google.common.collect.ImmutableSet;
3 import org.junit.After; 4 import org.junit.After;
4 import org.junit.Before; 5 import org.junit.Before;
5 import org.junit.Test; 6 import org.junit.Test;
...@@ -8,27 +9,24 @@ import org.onlab.onos.event.impl.TestEventDispatcher; ...@@ -8,27 +9,24 @@ import org.onlab.onos.event.impl.TestEventDispatcher;
8 import org.onlab.onos.net.Device; 9 import org.onlab.onos.net.Device;
9 import org.onlab.onos.net.Link; 10 import org.onlab.onos.net.Link;
10 import org.onlab.onos.net.device.DeviceEvent; 11 import org.onlab.onos.net.device.DeviceEvent;
12 +import org.onlab.onos.net.device.impl.DeviceManager;
11 import org.onlab.onos.net.link.LinkEvent; 13 import org.onlab.onos.net.link.LinkEvent;
14 +import org.onlab.onos.net.link.impl.LinkManager;
12 import org.onlab.onos.net.provider.AbstractProviderService; 15 import org.onlab.onos.net.provider.AbstractProviderService;
13 import org.onlab.onos.net.provider.ProviderId; 16 import org.onlab.onos.net.provider.ProviderId;
14 import org.onlab.onos.net.topology.GraphDescription; 17 import org.onlab.onos.net.topology.GraphDescription;
15 import org.onlab.onos.net.topology.TopologyProvider; 18 import org.onlab.onos.net.topology.TopologyProvider;
16 import org.onlab.onos.net.topology.TopologyProviderRegistry; 19 import org.onlab.onos.net.topology.TopologyProviderRegistry;
17 import org.onlab.onos.net.topology.TopologyProviderService; 20 import org.onlab.onos.net.topology.TopologyProviderService;
18 -import org.onlab.onos.net.trivial.device.impl.DeviceManager;
19 -import org.onlab.onos.net.trivial.link.impl.LinkManager;
20 21
21 import java.util.List; 22 import java.util.List;
22 import java.util.Set; 23 import java.util.Set;
23 24
24 -import static com.google.common.collect.ImmutableSet.of;
25 import static org.junit.Assert.assertEquals; 25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull; 26 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.TopologyManagerTest.device;
31 -import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.link;
32 30
33 /** 31 /**
34 * Test of the default topology provider implementation. 32 * Test of the default topology provider implementation.
...@@ -81,8 +79,8 @@ public class DefaultTopologyProviderTest { ...@@ -81,8 +79,8 @@ public class DefaultTopologyProviderTest {
81 @Override 79 @Override
82 public void run() { 80 public void run() {
83 validateSubmission(); 81 validateSubmission();
84 - deviceService.post(new DeviceEvent(DEVICE_ADDED, device("z"), null)); 82 + deviceService.post(new DeviceEvent(DEVICE_ADDED, TopologyManagerTest.device("z"), null));
85 - linkService.post(new LinkEvent(LINK_ADDED, link("z", 1, "a", 4))); 83 + linkService.post(new LinkEvent(LINK_ADDED, TopologyManagerTest.link("z", 1, "a", 4)));
86 validateSubmission(); 84 validateSubmission();
87 } 85 }
88 }); 86 });
...@@ -130,9 +128,9 @@ public class DefaultTopologyProviderTest { ...@@ -130,9 +128,9 @@ public class DefaultTopologyProviderTest {
130 128
131 @Override 129 @Override
132 public Iterable<Device> getDevices() { 130 public Iterable<Device> getDevices() {
133 - return of(device("a"), device("b"), 131 + return ImmutableSet.of(TopologyManagerTest.device("a"), TopologyManagerTest.device("b"),
134 - device("c"), device("d"), 132 + TopologyManagerTest.device("c"), TopologyManagerTest.device("d"),
135 - device("e"), device("f")); 133 + TopologyManagerTest.device("e"), TopologyManagerTest.device("f"));
136 } 134 }
137 135
138 void post(DeviceEvent event) { 136 void post(DeviceEvent event) {
...@@ -148,11 +146,11 @@ public class DefaultTopologyProviderTest { ...@@ -148,11 +146,11 @@ public class DefaultTopologyProviderTest {
148 146
149 @Override 147 @Override
150 public Iterable<Link> getLinks() { 148 public Iterable<Link> getLinks() {
151 - return of(link("a", 1, "b", 1), link("b", 1, "a", 1), 149 + return ImmutableSet.of(TopologyManagerTest.link("a", 1, "b", 1), TopologyManagerTest.link("b", 1, "a", 1),
152 - link("b", 2, "c", 1), link("c", 1, "b", 2), 150 + TopologyManagerTest.link("b", 2, "c", 1), TopologyManagerTest.link("c", 1, "b", 2),
153 - link("c", 2, "d", 1), link("d", 1, "c", 2), 151 + TopologyManagerTest.link("c", 2, "d", 1), TopologyManagerTest.link("d", 1, "c", 2),
154 - link("d", 2, "a", 2), link("a", 2, "d", 2), 152 + TopologyManagerTest.link("d", 2, "a", 2), TopologyManagerTest.link("a", 2, "d", 2),
155 - link("e", 1, "f", 1), link("f", 1, "e", 1)); 153 + TopologyManagerTest.link("e", 1, "f", 1), TopologyManagerTest.link("f", 1, "e", 1));
156 } 154 }
157 155
158 void post(LinkEvent event) { 156 void post(LinkEvent event) {
......
1 -package org.onlab.onos.net.trivial.topology.impl; 1 +package org.onlab.onos.net.topology.impl;
2 2
3 import org.junit.After; 3 import org.junit.After;
4 import org.junit.Before; 4 import org.junit.Before;
...@@ -14,6 +14,7 @@ import org.onlab.onos.net.Link; ...@@ -14,6 +14,7 @@ import org.onlab.onos.net.Link;
14 import org.onlab.onos.net.Path; 14 import org.onlab.onos.net.Path;
15 import org.onlab.onos.net.provider.AbstractProvider; 15 import org.onlab.onos.net.provider.AbstractProvider;
16 import org.onlab.onos.net.provider.ProviderId; 16 import org.onlab.onos.net.provider.ProviderId;
17 +import org.onlab.onos.net.topology.DefaultGraphDescription;
17 import org.onlab.onos.net.topology.GraphDescription; 18 import org.onlab.onos.net.topology.GraphDescription;
18 import org.onlab.onos.net.topology.LinkWeight; 19 import org.onlab.onos.net.topology.LinkWeight;
19 import org.onlab.onos.net.topology.Topology; 20 import org.onlab.onos.net.topology.Topology;
...@@ -26,6 +27,7 @@ import org.onlab.onos.net.topology.TopologyProvider; ...@@ -26,6 +27,7 @@ import org.onlab.onos.net.topology.TopologyProvider;
26 import org.onlab.onos.net.topology.TopologyProviderRegistry; 27 import org.onlab.onos.net.topology.TopologyProviderRegistry;
27 import org.onlab.onos.net.topology.TopologyProviderService; 28 import org.onlab.onos.net.topology.TopologyProviderService;
28 import org.onlab.onos.net.topology.TopologyService; 29 import org.onlab.onos.net.topology.TopologyService;
30 +import org.onlab.onos.net.trivial.topology.impl.SimpleTopologyStore;
29 31
30 import java.util.ArrayList; 32 import java.util.ArrayList;
31 import java.util.List; 33 import java.util.List;
...@@ -183,20 +185,20 @@ public class TopologyManagerTest { ...@@ -183,20 +185,20 @@ public class TopologyManagerTest {
183 } 185 }
184 186
185 // Short-hand for creating a link. 187 // Short-hand for creating a link.
186 - static Link link(String src, int sp, String dst, int dp) { 188 + public static Link link(String src, int sp, String dst, int dp) {
187 return new DefaultLink(PID, new ConnectPoint(did(src), portNumber(sp)), 189 return new DefaultLink(PID, new ConnectPoint(did(src), portNumber(sp)),
188 new ConnectPoint(did(dst), portNumber(dp)), 190 new ConnectPoint(did(dst), portNumber(dp)),
189 Link.Type.DIRECT); 191 Link.Type.DIRECT);
190 } 192 }
191 193
192 // Crates a new device with the specified id 194 // Crates a new device with the specified id
193 - static Device device(String id) { 195 + public static Device device(String id) {
194 return new DefaultDevice(PID, did(id), Device.Type.SWITCH, 196 return new DefaultDevice(PID, did(id), Device.Type.SWITCH,
195 "mfg", "1.0", "1.1", "1234"); 197 "mfg", "1.0", "1.1", "1234");
196 } 198 }
197 199
198 // Short-hand for producing a device id from a string 200 // Short-hand for producing a device id from a string
199 - static DeviceId did(String id) { 201 + public static DeviceId did(String id) {
200 return deviceId("of:" + id); 202 return deviceId("of:" + id);
201 } 203 }
202 204
......
1 package org.onlab.onos.net.trivial.flow.impl; 1 package org.onlab.onos.net.trivial.flow.impl;
2 2
3 +import com.google.common.collect.HashMultimap;
4 +import com.google.common.collect.ImmutableSet;
5 +import com.google.common.collect.Multimap;
3 import org.onlab.onos.net.DeviceId; 6 import org.onlab.onos.net.DeviceId;
4 import org.onlab.onos.net.flow.DefaultFlowRule; 7 import org.onlab.onos.net.flow.DefaultFlowRule;
5 import org.onlab.onos.net.flow.FlowRule; 8 import org.onlab.onos.net.flow.FlowRule;
6 import org.onlab.onos.net.flow.FlowRuleEvent; 9 import org.onlab.onos.net.flow.FlowRuleEvent;
10 +import org.onlab.onos.net.flow.FlowRuleStore;
7 11
8 -import com.google.common.collect.HashMultimap; 12 +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_ADDED;
9 -import com.google.common.collect.ImmutableSet; 13 +import static org.onlab.onos.net.flow.FlowRuleEvent.Type.RULE_REMOVED;
10 -import com.google.common.collect.Multimap;
11 -
12 -import static org.onlab.onos.net.flow.FlowRuleEvent.Type.*;
13 14
14 /** 15 /**
15 * Manages inventory of flow rules using trivial in-memory implementation. 16 * Manages inventory of flow rules using trivial in-memory implementation.
16 */ 17 */
17 -public class SimpleFlowRuleStore { 18 +public class SimpleFlowRuleStore implements FlowRuleStore {
18 19
19 // store entries as a pile of rules, no info about device tables 20 // store entries as a pile of rules, no info about device tables
20 private final Multimap<DeviceId, FlowRule> flowEntries = HashMultimap.create(); 21 private final Multimap<DeviceId, FlowRule> flowEntries = HashMultimap.create();
21 22
22 - /** 23 + @Override
23 - * Returns the flow entries associated with a device. 24 + public Iterable<FlowRule> getFlowEntries(DeviceId deviceId) {
24 - *
25 - * @param deviceId the device ID
26 - * @return the flow entries
27 - */
28 - Iterable<FlowRule> getFlowEntries(DeviceId deviceId) {
29 return ImmutableSet.copyOf(flowEntries.get(deviceId)); 25 return ImmutableSet.copyOf(flowEntries.get(deviceId));
30 } 26 }
31 27
32 - /** 28 + @Override
33 - * Stores a new flow rule, and generates a FlowRule for it. 29 + public FlowRule storeFlowRule(FlowRule rule) {
34 - *
35 - * @param rule the flow rule to add
36 - * @return a flow entry
37 - */
38 - FlowRule storeFlowRule(FlowRule rule) {
39 DeviceId did = rule.deviceId(); 30 DeviceId did = rule.deviceId();
40 FlowRule entry = new DefaultFlowRule(did, 31 FlowRule entry = new DefaultFlowRule(did,
41 - rule.selector(), rule.treatment(), rule.priority()); 32 + rule.selector(), rule.treatment(), rule.priority());
42 flowEntries.put(did, entry); 33 flowEntries.put(did, entry);
43 return entry; 34 return entry;
44 } 35 }
45 36
46 - /** 37 + @Override
47 - * Stores a new flow rule, or updates an existing entry. 38 + public FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) {
48 - *
49 - * @param rule the flow rule to add or update
50 - * @return flow_added event, or null if just an update
51 - */
52 - FlowRuleEvent addOrUpdateFlowRule(FlowRule rule) {
53 DeviceId did = rule.deviceId(); 39 DeviceId did = rule.deviceId();
54 40
55 // check if this new rule is an update to an existing entry 41 // check if this new rule is an update to an existing entry
...@@ -63,13 +49,8 @@ public class SimpleFlowRuleStore { ...@@ -63,13 +49,8 @@ public class SimpleFlowRuleStore {
63 return new FlowRuleEvent(RULE_ADDED, rule); 49 return new FlowRuleEvent(RULE_ADDED, rule);
64 } 50 }
65 51
66 - /** 52 + @Override
67 - * 53 + public FlowRuleEvent removeFlowRule(FlowRule rule) {
68 - * @param rule the flow rule to remove
69 - * @return flow_removed event, or null if nothing removed
70 - */
71 - FlowRuleEvent removeFlowRule(FlowRule rule) {
72 -
73 synchronized (this) { 54 synchronized (this) {
74 if (flowEntries.remove(rule.deviceId(), rule)) { 55 if (flowEntries.remove(rule.deviceId(), rule)) {
75 return new FlowRuleEvent(RULE_REMOVED, rule); 56 return new FlowRuleEvent(RULE_REMOVED, rule);
......
...@@ -15,6 +15,7 @@ import org.onlab.onos.net.Path; ...@@ -15,6 +15,7 @@ import org.onlab.onos.net.Path;
15 import org.onlab.onos.net.provider.ProviderId; 15 import org.onlab.onos.net.provider.ProviderId;
16 import org.onlab.onos.net.topology.ClusterId; 16 import org.onlab.onos.net.topology.ClusterId;
17 import org.onlab.onos.net.topology.DefaultTopologyCluster; 17 import org.onlab.onos.net.topology.DefaultTopologyCluster;
18 +import org.onlab.onos.net.topology.DefaultTopologyVertex;
18 import org.onlab.onos.net.topology.GraphDescription; 19 import org.onlab.onos.net.topology.GraphDescription;
19 import org.onlab.onos.net.topology.LinkWeight; 20 import org.onlab.onos.net.topology.LinkWeight;
20 import org.onlab.onos.net.topology.Topology; 21 import org.onlab.onos.net.topology.Topology;
......
...@@ -3,6 +3,8 @@ package org.onlab.onos.net.trivial.topology.impl; ...@@ -3,6 +3,8 @@ package org.onlab.onos.net.trivial.topology.impl;
3 import org.junit.Before; 3 import org.junit.Before;
4 import org.junit.Test; 4 import org.junit.Test;
5 import org.onlab.onos.net.ConnectPoint; 5 import org.onlab.onos.net.ConnectPoint;
6 +import org.onlab.onos.net.DefaultDevice;
7 +import org.onlab.onos.net.DefaultLink;
6 import org.onlab.onos.net.Device; 8 import org.onlab.onos.net.Device;
7 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
8 import org.onlab.onos.net.Link; 10 import org.onlab.onos.net.Link;
...@@ -10,6 +12,7 @@ import org.onlab.onos.net.Path; ...@@ -10,6 +12,7 @@ import org.onlab.onos.net.Path;
10 import org.onlab.onos.net.PortNumber; 12 import org.onlab.onos.net.PortNumber;
11 import org.onlab.onos.net.provider.ProviderId; 13 import org.onlab.onos.net.provider.ProviderId;
12 import org.onlab.onos.net.topology.ClusterId; 14 import org.onlab.onos.net.topology.ClusterId;
15 +import org.onlab.onos.net.topology.DefaultGraphDescription;
13 import org.onlab.onos.net.topology.GraphDescription; 16 import org.onlab.onos.net.topology.GraphDescription;
14 import org.onlab.onos.net.topology.LinkWeight; 17 import org.onlab.onos.net.topology.LinkWeight;
15 import org.onlab.onos.net.topology.TopologyCluster; 18 import org.onlab.onos.net.topology.TopologyCluster;
...@@ -21,8 +24,6 @@ import static com.google.common.collect.ImmutableSet.of; ...@@ -21,8 +24,6 @@ import static com.google.common.collect.ImmutableSet.of;
21 import static org.junit.Assert.*; 24 import static org.junit.Assert.*;
22 import static org.onlab.onos.net.DeviceId.deviceId; 25 import static org.onlab.onos.net.DeviceId.deviceId;
23 import static org.onlab.onos.net.PortNumber.portNumber; 26 import static org.onlab.onos.net.PortNumber.portNumber;
24 -import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.device;
25 -import static org.onlab.onos.net.trivial.topology.impl.TopologyManagerTest.link;
26 27
27 /** 28 /**
28 * Test of the default topology implementation. 29 * Test of the default topology implementation.
...@@ -108,4 +109,22 @@ public class DefaultTopologyTest { ...@@ -108,4 +109,22 @@ public class DefaultTopologyTest {
108 assertFalse("cluster should not contain D5", devs.contains(D5)); 109 assertFalse("cluster should not contain D5", devs.contains(D5));
109 } 110 }
110 111
112 + // Short-hand for creating a link.
113 + public static Link link(String src, int sp, String dst, int dp) {
114 + return new DefaultLink(PID, new ConnectPoint(did(src), portNumber(sp)),
115 + new ConnectPoint(did(dst), portNumber(dp)),
116 + Link.Type.DIRECT);
117 + }
118 +
119 + // Crates a new device with the specified id
120 + public static Device device(String id) {
121 + return new DefaultDevice(PID, did(id), Device.Type.SWITCH,
122 + "mfg", "1.0", "1.1", "1234");
123 + }
124 +
125 + // Short-hand for producing a device id from a string
126 + public static DeviceId did(String id) {
127 + return deviceId("of:" + id);
128 + }
129 +
111 } 130 }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
36 <feature name="onos-core" version="1.0.0" 36 <feature name="onos-core" version="1.0.0"
37 description="ONOS core components"> 37 description="ONOS core components">
38 <feature>onos-api</feature> 38 <feature>onos-api</feature>
39 + <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle>
39 <bundle>mvn:org.onlab.onos/onos-core-trivial/1.0.0-SNAPSHOT</bundle> 40 <bundle>mvn:org.onlab.onos/onos-core-trivial/1.0.0-SNAPSHOT</bundle>
40 </feature> 41 </feature>
41 42
......
...@@ -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.DeviceManager}, 31 + {@link org.onlab.onos.net.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.DeviceManager} 42 + On the south-bound side, the core {@link org.onlab.onos.net.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
......