alshabib
Committed by Gerrit Code Review

fix for reactive forwarding failing in a

distributed setting.

Change-Id: I992d62bbbd3d873bc8715419592951704903c49d

making the ECHostStore respect sequentiality of events.

Change-Id: I14fa65fc78742c3ea7d417cddefef9f171472246
...@@ -27,10 +27,10 @@ import org.apache.felix.scr.annotations.Reference; ...@@ -27,10 +27,10 @@ import org.apache.felix.scr.annotations.Reference;
27 import org.apache.felix.scr.annotations.ReferenceCardinality; 27 import org.apache.felix.scr.annotations.ReferenceCardinality;
28 import org.apache.felix.scr.annotations.Service; 28 import org.apache.felix.scr.annotations.Service;
29 import org.onosproject.event.AbstractListenerManager; 29 import org.onosproject.event.AbstractListenerManager;
30 -import org.onosproject.event.Event;
31 import org.onosproject.net.ConnectPoint; 30 import org.onosproject.net.ConnectPoint;
32 import org.onosproject.net.DeviceId; 31 import org.onosproject.net.DeviceId;
33 import org.onosproject.net.device.DeviceEvent; 32 import org.onosproject.net.device.DeviceEvent;
33 +import org.onosproject.net.device.DeviceListener;
34 import org.onosproject.net.device.DeviceService; 34 import org.onosproject.net.device.DeviceService;
35 import org.onosproject.net.edge.EdgePortEvent; 35 import org.onosproject.net.edge.EdgePortEvent;
36 import org.onosproject.net.edge.EdgePortListener; 36 import org.onosproject.net.edge.EdgePortListener;
...@@ -38,17 +38,16 @@ import org.onosproject.net.edge.EdgePortService; ...@@ -38,17 +38,16 @@ import org.onosproject.net.edge.EdgePortService;
38 import org.onosproject.net.flow.DefaultTrafficTreatment; 38 import org.onosproject.net.flow.DefaultTrafficTreatment;
39 import org.onosproject.net.flow.TrafficTreatment; 39 import org.onosproject.net.flow.TrafficTreatment;
40 import org.onosproject.net.link.LinkEvent; 40 import org.onosproject.net.link.LinkEvent;
41 +import org.onosproject.net.link.LinkListener;
42 +import org.onosproject.net.link.LinkService;
41 import org.onosproject.net.packet.DefaultOutboundPacket; 43 import org.onosproject.net.packet.DefaultOutboundPacket;
42 import org.onosproject.net.packet.OutboundPacket; 44 import org.onosproject.net.packet.OutboundPacket;
43 import org.onosproject.net.packet.PacketService; 45 import org.onosproject.net.packet.PacketService;
44 import org.onosproject.net.topology.Topology; 46 import org.onosproject.net.topology.Topology;
45 -import org.onosproject.net.topology.TopologyEvent;
46 -import org.onosproject.net.topology.TopologyListener;
47 import org.onosproject.net.topology.TopologyService; 47 import org.onosproject.net.topology.TopologyService;
48 import org.slf4j.Logger; 48 import org.slf4j.Logger;
49 49
50 import java.nio.ByteBuffer; 50 import java.nio.ByteBuffer;
51 -import java.util.List;
52 import java.util.Map; 51 import java.util.Map;
53 import java.util.Optional; 52 import java.util.Optional;
54 import java.util.Set; 53 import java.util.Set;
...@@ -73,7 +72,9 @@ public class EdgeManager ...@@ -73,7 +72,9 @@ public class EdgeManager
73 72
74 private final Map<DeviceId, Set<ConnectPoint>> connectionPoints = Maps.newConcurrentMap(); 73 private final Map<DeviceId, Set<ConnectPoint>> connectionPoints = Maps.newConcurrentMap();
75 74
76 - private final TopologyListener topologyListener = new InnerTopologyListener(); 75 + private final LinkListener linkListener = new InnerLinkListener();
76 +
77 + private final DeviceListener deviceListener = new InnerDeviceListener();
77 78
78 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 79 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
79 protected PacketService packetService; 80 protected PacketService packetService;
...@@ -84,17 +85,23 @@ public class EdgeManager ...@@ -84,17 +85,23 @@ public class EdgeManager
84 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 85 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
85 protected TopologyService topologyService; 86 protected TopologyService topologyService;
86 87
88 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
89 + protected LinkService linkService;
90 +
87 @Activate 91 @Activate
88 public void activate() { 92 public void activate() {
89 eventDispatcher.addSink(EdgePortEvent.class, listenerRegistry); 93 eventDispatcher.addSink(EdgePortEvent.class, listenerRegistry);
90 - topologyService.addListener(topologyListener); 94 + deviceService.addListener(deviceListener);
95 + linkService.addListener(linkListener);
96 + loadAllEdgePorts();
91 log.info("Started"); 97 log.info("Started");
92 } 98 }
93 99
94 @Deactivate 100 @Deactivate
95 public void deactivate() { 101 public void deactivate() {
96 eventDispatcher.removeSink(EdgePortEvent.class); 102 eventDispatcher.removeSink(EdgePortEvent.class);
97 - topologyService.removeListener(topologyListener); 103 + deviceService.removeListener(deviceListener);
104 + linkService.removeListener(linkListener);
98 log.info("Stopped"); 105 log.info("Stopped");
99 } 106 }
100 107
...@@ -142,31 +149,27 @@ public class EdgeManager ...@@ -142,31 +149,27 @@ public class EdgeManager
142 return new DefaultOutboundPacket(point.deviceId(), builder.build(), data); 149 return new DefaultOutboundPacket(point.deviceId(), builder.build(), data);
143 } 150 }
144 151
145 - // Internal listener for topo events used to keep our edge-port cache 152 + private class InnerLinkListener implements LinkListener {
146 - // up to date. 153 +
147 - private class InnerTopologyListener implements TopologyListener {
148 @Override 154 @Override
149 - public void event(TopologyEvent event) { 155 + public void event(LinkEvent event) {
150 - topology = event.subject(); 156 + topology = topologyService.currentTopology();
151 - List<Event> triggers = event.reasons(); 157 + processLinkEvent(event);
152 - if (triggers != null) { 158 + }
153 - triggers.forEach(reason -> { 159 + }
154 - if (reason instanceof DeviceEvent) { 160 +
155 - processDeviceEvent((DeviceEvent) reason); 161 + private class InnerDeviceListener implements DeviceListener {
156 - } else if (reason instanceof LinkEvent) { 162 +
157 - processLinkEvent((LinkEvent) reason); 163 + @Override
158 - } 164 + public void event(DeviceEvent event) {
159 - }); 165 + topology = topologyService.currentTopology();
160 - } else { 166 + processDeviceEvent(event);
161 - //FIXME special case of preexisting edgeport & no triggerless events could cause this to never hit and
162 - //never discover an edgeport that should have been discovered.
163 - loadAllEdgePorts();
164 - }
165 } 167 }
166 } 168 }
167 169
168 // Initial loading of the edge port cache. 170 // Initial loading of the edge port cache.
169 private void loadAllEdgePorts() { 171 private void loadAllEdgePorts() {
172 + topology = topologyService.currentTopology();
170 deviceService.getAvailableDevices().forEach(d -> deviceService.getPorts(d.id()) 173 deviceService.getAvailableDevices().forEach(d -> deviceService.getPorts(d.id())
171 .forEach(p -> addEdgePort(new ConnectPoint(d.id(), p.number())))); 174 .forEach(p -> addEdgePort(new ConnectPoint(d.id(), p.number()))));
172 } 175 }
......
...@@ -22,7 +22,6 @@ import org.junit.After; ...@@ -22,7 +22,6 @@ import org.junit.After;
22 import org.junit.Before; 22 import org.junit.Before;
23 import org.junit.Test; 23 import org.junit.Test;
24 import org.onosproject.common.event.impl.TestEventDispatcher; 24 import org.onosproject.common.event.impl.TestEventDispatcher;
25 -import org.onosproject.event.Event;
26 import org.onosproject.net.ConnectPoint; 25 import org.onosproject.net.ConnectPoint;
27 import org.onosproject.net.DefaultPort; 26 import org.onosproject.net.DefaultPort;
28 import org.onosproject.net.Device; 27 import org.onosproject.net.Device;
...@@ -31,15 +30,17 @@ import org.onosproject.net.NetTestTools; ...@@ -31,15 +30,17 @@ import org.onosproject.net.NetTestTools;
31 import org.onosproject.net.Port; 30 import org.onosproject.net.Port;
32 import org.onosproject.net.PortNumber; 31 import org.onosproject.net.PortNumber;
33 import org.onosproject.net.device.DeviceEvent; 32 import org.onosproject.net.device.DeviceEvent;
33 +import org.onosproject.net.device.DeviceListener;
34 import org.onosproject.net.device.DeviceServiceAdapter; 34 import org.onosproject.net.device.DeviceServiceAdapter;
35 import org.onosproject.net.edge.EdgePortEvent; 35 import org.onosproject.net.edge.EdgePortEvent;
36 import org.onosproject.net.edge.EdgePortListener; 36 import org.onosproject.net.edge.EdgePortListener;
37 import org.onosproject.net.flow.TrafficTreatment; 37 import org.onosproject.net.flow.TrafficTreatment;
38 import org.onosproject.net.link.LinkEvent; 38 import org.onosproject.net.link.LinkEvent;
39 +import org.onosproject.net.link.LinkListener;
40 +import org.onosproject.net.link.LinkServiceAdapter;
39 import org.onosproject.net.packet.OutboundPacket; 41 import org.onosproject.net.packet.OutboundPacket;
40 import org.onosproject.net.packet.PacketServiceAdapter; 42 import org.onosproject.net.packet.PacketServiceAdapter;
41 import org.onosproject.net.topology.Topology; 43 import org.onosproject.net.topology.Topology;
42 -import org.onosproject.net.topology.TopologyEvent;
43 import org.onosproject.net.topology.TopologyListener; 44 import org.onosproject.net.topology.TopologyListener;
44 import org.onosproject.net.topology.TopologyServiceAdapter; 45 import org.onosproject.net.topology.TopologyServiceAdapter;
45 46
...@@ -58,7 +59,6 @@ import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_ADDED; ...@@ -58,7 +59,6 @@ import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_ADDED;
58 import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED; 59 import static org.onosproject.net.edge.EdgePortEvent.Type.EDGE_PORT_REMOVED;
59 import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED; 60 import static org.onosproject.net.link.LinkEvent.Type.LINK_ADDED;
60 import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED; 61 import static org.onosproject.net.link.LinkEvent.Type.LINK_REMOVED;
61 -import static org.onosproject.net.topology.TopologyEvent.Type.TOPOLOGY_CHANGED;
62 62
63 /** 63 /**
64 * Test of the edge port manager. Each device has ports '0' through 'numPorts - 1' 64 * Test of the edge port manager. Each device has ports '0' through 'numPorts - 1'
...@@ -74,6 +74,8 @@ public class EdgeManagerTest { ...@@ -74,6 +74,8 @@ public class EdgeManagerTest {
74 private final Map<DeviceId, Device> devices = Maps.newConcurrentMap(); 74 private final Map<DeviceId, Device> devices = Maps.newConcurrentMap();
75 private Set<OutboundPacket> packets = Sets.newConcurrentHashSet(); 75 private Set<OutboundPacket> packets = Sets.newConcurrentHashSet();
76 private final EdgePortListener testListener = new TestListener(events); 76 private final EdgePortListener testListener = new TestListener(events);
77 + private TestLinkManager testLinkManager;
78 + private TestDeviceManager testDeviceManager;
77 private TestTopologyManager testTopologyManager; 79 private TestTopologyManager testTopologyManager;
78 80
79 @Before 81 @Before
...@@ -82,8 +84,11 @@ public class EdgeManagerTest { ...@@ -82,8 +84,11 @@ public class EdgeManagerTest {
82 injectEventDispatcher(mgr, new TestEventDispatcher()); 84 injectEventDispatcher(mgr, new TestEventDispatcher());
83 testTopologyManager = new TestTopologyManager(infrastructurePorts); 85 testTopologyManager = new TestTopologyManager(infrastructurePorts);
84 mgr.topologyService = testTopologyManager; 86 mgr.topologyService = testTopologyManager;
85 - mgr.deviceService = new TestDeviceManager(devices); 87 + testDeviceManager = new TestDeviceManager(devices);
88 + mgr.deviceService = testDeviceManager;
86 mgr.packetService = new TestPacketManager(); 89 mgr.packetService = new TestPacketManager();
90 + testLinkManager = new TestLinkManager();
91 + mgr.linkService = testLinkManager;
87 mgr.activate(); 92 mgr.activate();
88 mgr.addListener(testListener); 93 mgr.addListener(testListener);
89 94
...@@ -108,11 +113,11 @@ public class EdgeManagerTest { ...@@ -108,11 +113,11 @@ public class EdgeManagerTest {
108 assertFalse("no ports expected", mgr.getEdgePoints().iterator().hasNext()); 113 assertFalse("no ports expected", mgr.getEdgePoints().iterator().hasNext());
109 114
110 assertFalse("Expected isEdge to return false", 115 assertFalse("Expected isEdge to return false",
111 - mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); 116 + mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1)));
112 117
113 removeInfraPort(NetTestTools.connectPoint(Integer.toString(1), 1)); 118 removeInfraPort(NetTestTools.connectPoint(Integer.toString(1), 1));
114 assertTrue("Expected isEdge to return false", 119 assertTrue("Expected isEdge to return false",
115 - mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1))); 120 + mgr.isEdgePoint(NetTestTools.connectPoint(Integer.toString(1), 1)));
116 } 121 }
117 122
118 @Test 123 @Test
...@@ -121,69 +126,57 @@ public class EdgeManagerTest { ...@@ -121,69 +126,57 @@ public class EdgeManagerTest {
121 ConnectPoint testPoint, referencePoint; 126 ConnectPoint testPoint, referencePoint;
122 127
123 //Testing link removal 128 //Testing link removal
124 - List<Event> eventsToAdd = Lists.newArrayList(); 129 + testLinkManager.listener.event(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2)));
125 - eventsToAdd.add(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2)));
126 - TopologyEvent event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
127 - testTopologyManager.listener.event(event);
128 130
129 assertTrue("The list contained an unexpected number of events", events.size() == 2); 131 assertTrue("The list contained an unexpected number of events", events.size() == 2);
130 assertTrue("The first element is of the wrong type.", 132 assertTrue("The first element is of the wrong type.",
131 - events.get(0).type() == EDGE_PORT_ADDED); 133 + events.get(0).type() == EDGE_PORT_ADDED);
132 - assertTrue("The second element is of the wrong type.",
133 - events.get(1).type() == EDGE_PORT_ADDED);
134 134
135 testPoint = events.get(0).subject(); 135 testPoint = events.get(0).subject();
136 referencePoint = NetTestTools.connectPoint("a", 1); 136 referencePoint = NetTestTools.connectPoint("a", 1);
137 assertTrue("The port numbers of the first element are incorrect", 137 assertTrue("The port numbers of the first element are incorrect",
138 - testPoint.port().toLong() == referencePoint.port().toLong()); 138 + testPoint.port().toLong() == referencePoint.port().toLong());
139 assertTrue("The device id of the first element is incorrect.", 139 assertTrue("The device id of the first element is incorrect.",
140 - testPoint.deviceId().equals(referencePoint.deviceId())); 140 + testPoint.deviceId().equals(referencePoint.deviceId()));
141 141
142 testPoint = events.get(1).subject(); 142 testPoint = events.get(1).subject();
143 referencePoint = NetTestTools.connectPoint("b", 2); 143 referencePoint = NetTestTools.connectPoint("b", 2);
144 assertTrue("The port numbers of the second element are incorrect", 144 assertTrue("The port numbers of the second element are incorrect",
145 - testPoint.port().toLong() == referencePoint.port().toLong()); 145 + testPoint.port().toLong() == referencePoint.port().toLong());
146 assertTrue("The device id of the second element is incorrect.", 146 assertTrue("The device id of the second element is incorrect.",
147 - testPoint.deviceId().equals(referencePoint.deviceId())); 147 + testPoint.deviceId().equals(referencePoint.deviceId()));
148 148
149 //Rebroadcast event to ensure it results in no additional events 149 //Rebroadcast event to ensure it results in no additional events
150 - testTopologyManager.listener.event(event); 150 + testLinkManager.listener.event(new LinkEvent(LINK_REMOVED, NetTestTools.link("a", 1, "b", 2)));
151 assertTrue("The list contained an unexpected number of events", events.size() == 2); 151 assertTrue("The list contained an unexpected number of events", events.size() == 2);
152 152
153 //Testing link adding when links to remove exist 153 //Testing link adding when links to remove exist
154 - eventsToAdd.clear();
155 events.clear(); 154 events.clear();
156 - eventsToAdd.add(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); 155 + testLinkManager.listener.event(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2)));
157 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
158 - testTopologyManager.listener.event(event);
159 156
160 assertTrue("The list contained an unexpected number of events", events.size() == 2); 157 assertTrue("The list contained an unexpected number of events", events.size() == 2);
161 assertTrue("The first element is of the wrong type.", 158 assertTrue("The first element is of the wrong type.",
162 - events.get(0).type() == EDGE_PORT_REMOVED); 159 + events.get(0).type() == EDGE_PORT_REMOVED);
163 assertTrue("The second element is of the wrong type.", 160 assertTrue("The second element is of the wrong type.",
164 - events.get(1).type() == EDGE_PORT_REMOVED); 161 + events.get(1).type() == EDGE_PORT_REMOVED);
165 162
166 testPoint = events.get(0).subject(); 163 testPoint = events.get(0).subject();
167 referencePoint = NetTestTools.connectPoint("a", 1); 164 referencePoint = NetTestTools.connectPoint("a", 1);
168 assertTrue("The port numbers of the first element are incorrect", 165 assertTrue("The port numbers of the first element are incorrect",
169 - testPoint.port().toLong() == referencePoint.port().toLong()); 166 + testPoint.port().toLong() == referencePoint.port().toLong());
170 assertTrue("The device id of the first element is incorrect.", 167 assertTrue("The device id of the first element is incorrect.",
171 - testPoint.deviceId().equals(referencePoint.deviceId())); 168 + testPoint.deviceId().equals(referencePoint.deviceId()));
172 169
173 testPoint = events.get(1).subject(); 170 testPoint = events.get(1).subject();
174 referencePoint = NetTestTools.connectPoint("b", 2); 171 referencePoint = NetTestTools.connectPoint("b", 2);
175 assertTrue("The port numbers of the second element are incorrect", 172 assertTrue("The port numbers of the second element are incorrect",
176 - testPoint.port().toLong() == referencePoint.port().toLong()); 173 + testPoint.port().toLong() == referencePoint.port().toLong());
177 assertTrue("The device id of the second element is incorrect.", 174 assertTrue("The device id of the second element is incorrect.",
178 - testPoint.deviceId().equals(referencePoint.deviceId())); 175 + testPoint.deviceId().equals(referencePoint.deviceId()));
179 176
180 //Apparent duplicate of previous method tests removal when the elements have already been removed 177 //Apparent duplicate of previous method tests removal when the elements have already been removed
181 - eventsToAdd.clear();
182 events.clear(); 178 events.clear();
183 - eventsToAdd.add(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2))); 179 + testLinkManager.listener.event(new LinkEvent(LINK_ADDED, NetTestTools.link("a", 1, "b", 2)));
184 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
185 - testTopologyManager.listener.event(event);
186 -
187 assertTrue("The list should contain no events, the removed elements don't exist.", events.size() == 0); 180 assertTrue("The list should contain no events, the removed elements don't exist.", events.size() == 0);
188 } 181 }
189 182
...@@ -192,8 +185,7 @@ public class EdgeManagerTest { ...@@ -192,8 +185,7 @@ public class EdgeManagerTest {
192 //Setup 185 //Setup
193 186
194 Device referenceDevice; 187 Device referenceDevice;
195 - TopologyEvent event; 188 + DeviceEvent event;
196 - List<Event> eventsToAdd = Lists.newArrayList();
197 int numDevices = 10; 189 int numDevices = 10;
198 int numInfraPorts = 5; 190 int numInfraPorts = 5;
199 totalPorts = 10; 191 totalPorts = 10;
...@@ -201,14 +193,13 @@ public class EdgeManagerTest { ...@@ -201,14 +193,13 @@ public class EdgeManagerTest {
201 193
202 //Test response to device added events 194 //Test response to device added events
203 referenceDevice = NetTestTools.device("1"); 195 referenceDevice = NetTestTools.device("1");
204 - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, referenceDevice, 196 + event = new DeviceEvent(DEVICE_ADDED, referenceDevice,
205 - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); 197 + new DefaultPort(referenceDevice, PortNumber.portNumber(1), true));
206 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); 198 + testDeviceManager.listener.event(event);
207 - testTopologyManager.listener.event(event);
208 199
209 //Check that ports were populated correctly 200 //Check that ports were populated correctly
210 assertTrue("Unexpected number of new ports added", 201 assertTrue("Unexpected number of new ports added",
211 - mgr.deviceService.getPorts(NetTestTools.did("1")).size() == 10); 202 + mgr.deviceService.getPorts(NetTestTools.did("1")).size() == 10);
212 203
213 //Check that of the ten ports the half that are infrastructure ports aren't added 204 //Check that of the ten ports the half that are infrastructure ports aren't added
214 assertEquals("Unexpected number of new edge ports added", (totalPorts - numInfraPorts), events.size()); 205 assertEquals("Unexpected number of new edge ports added", (totalPorts - numInfraPorts), events.size());
...@@ -219,15 +210,15 @@ public class EdgeManagerTest { ...@@ -219,15 +210,15 @@ public class EdgeManagerTest {
219 //Names here are irrelevant, the first 5 ports are populated as infrastructure, 6-10 are edge 210 //Names here are irrelevant, the first 5 ports are populated as infrastructure, 6-10 are edge
220 for (int index = 0; index < events.size(); index++) { 211 for (int index = 0; index < events.size(); index++) {
221 assertEquals("Port added had unexpected port number.", 212 assertEquals("Port added had unexpected port number.",
222 - events.get(index).subject().port(), 213 + events.get(index).subject().port(),
223 - NetTestTools.connectPoint("a", index + numInfraPorts + 1).port()); 214 + NetTestTools.connectPoint("a", index + numInfraPorts + 1).port());
224 } 215 }
225 events.clear(); 216 events.clear();
226 217
227 //Repost the event to test repeated posts 218 //Repost the event to test repeated posts
228 - testTopologyManager.listener.event(event); 219 + testDeviceManager.listener.event(event);
229 assertEquals("The redundant notification should not have created additional notifications.", 220 assertEquals("The redundant notification should not have created additional notifications.",
230 - 0, events.size()); 221 + 0, events.size());
231 //Calculate the size of the returned iterable of edge points. 222 //Calculate the size of the returned iterable of edge points.
232 Iterable<ConnectPoint> pts = mgr.getEdgePoints(); 223 Iterable<ConnectPoint> pts = mgr.getEdgePoints();
233 Iterator pointIterator = pts.iterator(); 224 Iterator pointIterator = pts.iterator();
...@@ -238,45 +229,41 @@ public class EdgeManagerTest { ...@@ -238,45 +229,41 @@ public class EdgeManagerTest {
238 assertEquals("Unexpected number of edge points", totalPorts - numInfraPorts, count); 229 assertEquals("Unexpected number of edge points", totalPorts - numInfraPorts, count);
239 //Testing device removal 230 //Testing device removal
240 events.clear(); 231 events.clear();
241 - eventsToAdd.clear(); 232 + event = (new DeviceEvent(DEVICE_REMOVED, referenceDevice,
242 - eventsToAdd.add(new DeviceEvent(DEVICE_REMOVED, referenceDevice, 233 + new DefaultPort(referenceDevice, PortNumber.portNumber(1), true)));
243 - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); 234 + testDeviceManager.listener.event(event);
244 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
245 - testTopologyManager.listener.event(event);
246 235
247 assertEquals("There should be five new events from removal of edge points", 236 assertEquals("There should be five new events from removal of edge points",
248 - totalPorts - numInfraPorts, events.size()); 237 + totalPorts - numInfraPorts, events.size());
249 for (int index = 0; index < events.size(); index++) { 238 for (int index = 0; index < events.size(); index++) {
250 //Assert that the correct port numbers were removed in the correct order 239 //Assert that the correct port numbers were removed in the correct order
251 assertEquals("Port removed had unexpected port number.", 240 assertEquals("Port removed had unexpected port number.",
252 - events.get(index).subject().port(), 241 + events.get(index).subject().port(),
253 - (NetTestTools.connectPoint("a", index + numInfraPorts + 1).port())); 242 + (NetTestTools.connectPoint("a", index + numInfraPorts + 1).port()));
254 //Assert that the events are of the correct type 243 //Assert that the events are of the correct type
255 assertEquals("Unexpected type of event", events.get(index).type(), EDGE_PORT_REMOVED); 244 assertEquals("Unexpected type of event", events.get(index).type(), EDGE_PORT_REMOVED);
256 } 245 }
257 events.clear(); 246 events.clear();
258 //Rebroadcast event to check that it triggers no new behavior 247 //Rebroadcast event to check that it triggers no new behavior
259 - testTopologyManager.listener.event(event); 248 + testDeviceManager.listener.event(event);
260 assertEquals("Rebroadcast of removal event should not produce additional events", 249 assertEquals("Rebroadcast of removal event should not produce additional events",
261 - 0, events.size()); 250 + 0, events.size());
262 251
263 //Testing device status change, changed from unavailable to available 252 //Testing device status change, changed from unavailable to available
264 events.clear(); 253 events.clear();
265 - eventsToAdd.clear();
266 //Make sure that the devicemanager shows the device as available. 254 //Make sure that the devicemanager shows the device as available.
267 addDevice(referenceDevice, "1", 5); 255 addDevice(referenceDevice, "1", 5);
268 devices.put(referenceDevice.id(), referenceDevice); 256 devices.put(referenceDevice.id(), referenceDevice);
269 257
270 - eventsToAdd.add(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, referenceDevice)); 258 + event = new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, referenceDevice);
271 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd); 259 + testDeviceManager.listener.event(event);
272 - testTopologyManager.listener.event(event);
273 //An earlier setup set half of the reference device ports to infrastructure 260 //An earlier setup set half of the reference device ports to infrastructure
274 assertEquals("An unexpected number of events were generated.", totalPorts - numInfraPorts, events.size()); 261 assertEquals("An unexpected number of events were generated.", totalPorts - numInfraPorts, events.size());
275 for (int i = 0; i < 5; i++) { 262 for (int i = 0; i < 5; i++) {
276 assertEquals("The event was not of the right type", events.get(i).type(), EDGE_PORT_ADDED); 263 assertEquals("The event was not of the right type", events.get(i).type(), EDGE_PORT_ADDED);
277 } 264 }
278 events.clear(); 265 events.clear();
279 - testTopologyManager.listener.event(event); 266 + testDeviceManager.listener.event(event);
280 assertEquals("No events should have been generated for a set of existing ports.", 0, events.size()); 267 assertEquals("No events should have been generated for a set of existing ports.", 0, events.size());
281 268
282 //Test removal when state changes when the device becomes unavailable 269 //Test removal when state changes when the device becomes unavailable
...@@ -288,21 +275,20 @@ public class EdgeManagerTest { ...@@ -288,21 +275,20 @@ public class EdgeManagerTest {
288 no events will be generated since no ports will be provided in getPorts() to EdgeManager. 275 no events will be generated since no ports will be provided in getPorts() to EdgeManager.
289 */ 276 */
290 alwaysReturnPorts = true; 277 alwaysReturnPorts = true;
291 - testTopologyManager.listener.event(event); 278 + testDeviceManager.listener.event(event);
292 alwaysReturnPorts = false; 279 alwaysReturnPorts = false;
293 assertEquals("An unexpected number of events were created.", totalPorts - numInfraPorts, events.size()); 280 assertEquals("An unexpected number of events were created.", totalPorts - numInfraPorts, events.size());
294 for (int i = 0; i < 5; i++) { 281 for (int i = 0; i < 5; i++) {
295 EdgePortEvent edgeEvent = events.get(i); 282 EdgePortEvent edgeEvent = events.get(i);
296 assertEquals("The event is of an unexpected type.", 283 assertEquals("The event is of an unexpected type.",
297 - EdgePortEvent.Type.EDGE_PORT_REMOVED, edgeEvent.type()); 284 + EdgePortEvent.Type.EDGE_PORT_REMOVED, edgeEvent.type());
298 assertEquals("The event pertains to an unexpected port", PortNumber.portNumber(i + numInfraPorts + 1), 285 assertEquals("The event pertains to an unexpected port", PortNumber.portNumber(i + numInfraPorts + 1),
299 - edgeEvent.subject().port()); 286 + edgeEvent.subject().port());
300 } 287 }
301 } 288 }
302 289
303 @Test 290 @Test
304 public void testInternalCache() { 291 public void testInternalCache() {
305 - List<Event> eventsToAdd = Lists.newArrayList();
306 int numDevices = 10; 292 int numDevices = 10;
307 //Number of infrastructure ports per device 293 //Number of infrastructure ports per device
308 int numPorts = 5; 294 int numPorts = 5;
...@@ -312,11 +298,8 @@ public class EdgeManagerTest { ...@@ -312,11 +298,8 @@ public class EdgeManagerTest {
312 for (int i = 0; i < numDevices; i++) { 298 for (int i = 0; i < numDevices; i++) {
313 Device newDevice = NetTestTools.device(Integer.toString(i)); 299 Device newDevice = NetTestTools.device(Integer.toString(i));
314 devices.put(newDevice.id(), newDevice); 300 devices.put(newDevice.id(), newDevice);
315 - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, newDevice)); 301 + testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, newDevice));
316 } 302 }
317 - TopologyEvent event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
318 - testTopologyManager.listener.event(event);
319 -
320 //Check all ports have correct designations 303 //Check all ports have correct designations
321 ConnectPoint testPoint; 304 ConnectPoint testPoint;
322 for (int deviceNum = 0; deviceNum < numDevices; deviceNum++) { 305 for (int deviceNum = 0; deviceNum < numDevices; deviceNum++) {
...@@ -334,7 +317,7 @@ public class EdgeManagerTest { ...@@ -334,7 +317,7 @@ public class EdgeManagerTest {
334 count++; 317 count++;
335 } 318 }
336 assertEquals("There are an unexpeceted number of edge points returned.", 319 assertEquals("There are an unexpeceted number of edge points returned.",
337 - (totalPorts - numPorts) * numDevices, count); 320 + (totalPorts - numPorts) * numDevices, count);
338 for (int deviceNumber = 0; deviceNumber < numDevices; deviceNumber++) { 321 for (int deviceNumber = 0; deviceNumber < numDevices; deviceNumber++) {
339 count = 0; 322 count = 0;
340 for (ConnectPoint ignored : mgr.getEdgePoints(NetTestTools.did("1"))) { 323 for (ConnectPoint ignored : mgr.getEdgePoints(NetTestTools.did("1"))) {
...@@ -349,8 +332,7 @@ public class EdgeManagerTest { ...@@ -349,8 +332,7 @@ public class EdgeManagerTest {
349 public void testEmit() { 332 public void testEmit() {
350 byte[] arr = new byte[10]; 333 byte[] arr = new byte[10];
351 Device referenceDevice; 334 Device referenceDevice;
352 - TopologyEvent event; 335 + DeviceEvent event;
353 - List<Event> eventsToAdd = Lists.newArrayList();
354 int numDevices = 10; 336 int numDevices = 10;
355 int numInfraPorts = 5; 337 int numInfraPorts = 5;
356 totalPorts = 10; 338 totalPorts = 10;
...@@ -360,16 +342,16 @@ public class EdgeManagerTest { ...@@ -360,16 +342,16 @@ public class EdgeManagerTest {
360 } 342 }
361 for (int i = 0; i < numDevices; i++) { 343 for (int i = 0; i < numDevices; i++) {
362 referenceDevice = NetTestTools.device(Integer.toString(i)); 344 referenceDevice = NetTestTools.device(Integer.toString(i));
363 - eventsToAdd.add(new DeviceEvent(DEVICE_ADDED, referenceDevice, 345 + testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, referenceDevice,
364 - new DefaultPort(referenceDevice, PortNumber.portNumber(1), true))); 346 + new DefaultPort(referenceDevice,
347 + PortNumber.portNumber(1),
348 + true)));
365 } 349 }
366 - event = new TopologyEvent(TOPOLOGY_CHANGED, null, eventsToAdd);
367 - testTopologyManager.listener.event(event);
368 350
369 mgr.emitPacket(ByteBuffer.wrap(arr), Optional.<TrafficTreatment>empty()); 351 mgr.emitPacket(ByteBuffer.wrap(arr), Optional.<TrafficTreatment>empty());
370 352
371 assertEquals("There were an unexpected number of emitted packets", 353 assertEquals("There were an unexpected number of emitted packets",
372 - (totalPorts - numInfraPorts) * numDevices, packets.size()); 354 + (totalPorts - numInfraPorts) * numDevices, packets.size());
373 Iterator<OutboundPacket> packetIter = packets.iterator(); 355 Iterator<OutboundPacket> packetIter = packets.iterator();
374 OutboundPacket packet; 356 OutboundPacket packet;
375 while (packetIter.hasNext()) { 357 while (packetIter.hasNext()) {
...@@ -381,7 +363,7 @@ public class EdgeManagerTest { ...@@ -381,7 +363,7 @@ public class EdgeManagerTest {
381 mgr.emitPacket(NetTestTools.did(Integer.toString(1)), ByteBuffer.wrap(arr), Optional.<TrafficTreatment>empty()); 363 mgr.emitPacket(NetTestTools.did(Integer.toString(1)), ByteBuffer.wrap(arr), Optional.<TrafficTreatment>empty());
382 364
383 assertEquals("Unexpected number of outbound packets were emitted.", 365 assertEquals("Unexpected number of outbound packets were emitted.",
384 - totalPorts - numInfraPorts, packets.size()); 366 + totalPorts - numInfraPorts, packets.size());
385 packetIter = packets.iterator(); 367 packetIter = packets.iterator();
386 while (packetIter.hasNext()) { 368 while (packetIter.hasNext()) {
387 packet = packetIter.next(); 369 packet = packetIter.next();
...@@ -455,6 +437,7 @@ public class EdgeManagerTest { ...@@ -455,6 +437,7 @@ public class EdgeManagerTest {
455 } 437 }
456 438
457 private class TestDeviceManager extends DeviceServiceAdapter { 439 private class TestDeviceManager extends DeviceServiceAdapter {
440 + private DeviceListener listener;
458 441
459 private Map<DeviceId, Device> devices; 442 private Map<DeviceId, Device> devices;
460 443
...@@ -490,6 +473,17 @@ public class EdgeManagerTest { ...@@ -490,6 +473,17 @@ public class EdgeManagerTest {
490 public Iterable<Device> getAvailableDevices() { 473 public Iterable<Device> getAvailableDevices() {
491 return devices.values(); 474 return devices.values();
492 } 475 }
476 +
477 +
478 + @Override
479 + public void addListener(DeviceListener listener) {
480 + this.listener = listener;
481 + }
482 +
483 + @Override
484 + public void removeListener(DeviceListener listener) {
485 + this.listener = null;
486 + }
493 } 487 }
494 488
495 private class TestPacketManager extends PacketServiceAdapter { 489 private class TestPacketManager extends PacketServiceAdapter {
...@@ -499,6 +493,15 @@ public class EdgeManagerTest { ...@@ -499,6 +493,15 @@ public class EdgeManagerTest {
499 } 493 }
500 } 494 }
501 495
496 + private class TestLinkManager extends LinkServiceAdapter {
497 + private LinkListener listener;
498 +
499 + @Override
500 + public void addListener(LinkListener listener) {
501 + this.listener = listener;
502 + }
503 + }
504 +
502 private class TestListener implements EdgePortListener { 505 private class TestListener implements EdgePortListener {
503 private List<EdgePortEvent> events; 506 private List<EdgePortEvent> events;
504 507
......
...@@ -15,26 +15,8 @@ ...@@ -15,26 +15,8 @@
15 */ 15 */
16 package org.onosproject.store.host.impl; 16 package org.onosproject.store.host.impl;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import com.google.common.collect.ImmutableSet;
19 -import static com.google.common.base.Preconditions.checkState; 19 +import com.google.common.collect.Sets;
20 -import static org.onosproject.net.DefaultAnnotations.merge;
21 -import static org.onosproject.net.host.HostEvent.Type.HOST_ADDED;
22 -import static org.onosproject.net.host.HostEvent.Type.HOST_MOVED;
23 -import static org.onosproject.net.host.HostEvent.Type.HOST_REMOVED;
24 -import static org.onosproject.net.host.HostEvent.Type.HOST_UPDATED;
25 -import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
26 -import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.REMOVE;
27 -import static org.slf4j.LoggerFactory.getLogger;
28 -
29 -import java.util.Collection;
30 -import java.util.HashSet;
31 -import java.util.Map;
32 -import java.util.Objects;
33 -import java.util.Set;
34 -import java.util.concurrent.ConcurrentHashMap;
35 -import java.util.function.Predicate;
36 -import java.util.stream.Collectors;
37 -
38 import org.apache.felix.scr.annotations.Activate; 20 import org.apache.felix.scr.annotations.Activate;
39 import org.apache.felix.scr.annotations.Component; 21 import org.apache.felix.scr.annotations.Component;
40 import org.apache.felix.scr.annotations.Deactivate; 22 import org.apache.felix.scr.annotations.Deactivate;
...@@ -60,22 +42,34 @@ import org.onosproject.net.host.HostStoreDelegate; ...@@ -60,22 +42,34 @@ import org.onosproject.net.host.HostStoreDelegate;
60 import org.onosproject.net.provider.ProviderId; 42 import org.onosproject.net.provider.ProviderId;
61 import org.onosproject.store.AbstractStore; 43 import org.onosproject.store.AbstractStore;
62 import org.onosproject.store.serializers.KryoNamespaces; 44 import org.onosproject.store.serializers.KryoNamespaces;
63 -import org.onosproject.store.service.EventuallyConsistentMap; 45 +import org.onosproject.store.service.ConsistentMap;
64 -import org.onosproject.store.service.EventuallyConsistentMapEvent; 46 +import org.onosproject.store.service.MapEvent;
65 -import org.onosproject.store.service.EventuallyConsistentMapListener; 47 +import org.onosproject.store.service.MapEventListener;
66 -import org.onosproject.store.service.LogicalClockService; 48 +import org.onosproject.store.service.Serializer;
67 import org.onosproject.store.service.StorageService; 49 import org.onosproject.store.service.StorageService;
68 import org.slf4j.Logger; 50 import org.slf4j.Logger;
69 51
70 -import com.google.common.collect.ImmutableSet; 52 +import java.util.Collection;
71 -import com.google.common.collect.Sets; 53 +import java.util.HashSet;
54 +import java.util.Map;
55 +import java.util.Objects;
56 +import java.util.Set;
57 +import java.util.concurrent.ConcurrentHashMap;
58 +import java.util.function.Predicate;
59 +import java.util.stream.Collectors;
60 +
61 +import static com.google.common.base.Preconditions.checkNotNull;
62 +import static com.google.common.base.Preconditions.checkState;
63 +import static org.onosproject.net.DefaultAnnotations.merge;
64 +import static org.onosproject.net.host.HostEvent.Type.*;
65 +import static org.slf4j.LoggerFactory.getLogger;
72 66
73 /** 67 /**
74 * Manages the inventory of hosts using a {@code EventuallyConsistentMap}. 68 * Manages the inventory of hosts using a {@code EventuallyConsistentMap}.
75 */ 69 */
76 @Component(immediate = true) 70 @Component(immediate = true)
77 @Service 71 @Service
78 -public class ECHostStore 72 +public class DistributedHostStore
79 extends AbstractStore<HostEvent, HostStoreDelegate> 73 extends AbstractStore<HostEvent, HostStoreDelegate>
80 implements HostStore { 74 implements HostStore {
81 75
...@@ -84,15 +78,13 @@ public class ECHostStore ...@@ -84,15 +78,13 @@ public class ECHostStore
84 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 78 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
85 protected StorageService storageService; 79 protected StorageService storageService;
86 80
87 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 81 + private ConsistentMap<HostId, DefaultHost> host;
88 - protected LogicalClockService clockService; 82 + private Map<HostId, DefaultHost> hosts;
89 -
90 - private EventuallyConsistentMap<HostId, DefaultHost> hosts;
91 83
92 private final ConcurrentHashMap<HostId, DefaultHost> prevHosts = 84 private final ConcurrentHashMap<HostId, DefaultHost> prevHosts =
93 new ConcurrentHashMap<>(); 85 new ConcurrentHashMap<>();
94 86
95 - private EventuallyConsistentMapListener<HostId, DefaultHost> hostLocationTracker = 87 + private MapEventListener<HostId, DefaultHost> hostLocationTracker =
96 new HostLocationTracker(); 88 new HostLocationTracker();
97 89
98 @Activate 90 @Activate
...@@ -100,21 +92,22 @@ public class ECHostStore ...@@ -100,21 +92,22 @@ public class ECHostStore
100 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder() 92 KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
101 .register(KryoNamespaces.API); 93 .register(KryoNamespaces.API);
102 94
103 - hosts = storageService.<HostId, DefaultHost>eventuallyConsistentMapBuilder() 95 + host = storageService.<HostId, DefaultHost>consistentMapBuilder()
104 .withName("onos-hosts") 96 .withName("onos-hosts")
105 - .withSerializer(hostSerializer) 97 + .withRelaxedReadConsistency()
106 - .withTimestampProvider((k, v) -> clockService.getTimestamp()) 98 + .withSerializer(Serializer.using(hostSerializer.build()))
107 .build(); 99 .build();
108 100
109 - hosts.addListener(hostLocationTracker); 101 + hosts = host.asJavaMap();
102 +
103 + host.addListener(hostLocationTracker);
110 104
111 log.info("Started"); 105 log.info("Started");
112 } 106 }
113 107
114 @Deactivate 108 @Deactivate
115 public void deactivate() { 109 public void deactivate() {
116 - hosts.removeListener(hostLocationTracker); 110 + host.removeListener(hostLocationTracker);
117 - hosts.destroy();
118 prevHosts.clear(); 111 prevHosts.clear();
119 112
120 log.info("Stopped"); 113 log.info("Stopped");
...@@ -249,11 +242,11 @@ public class ECHostStore ...@@ -249,11 +242,11 @@ public class ECHostStore
249 return collection.stream().filter(predicate).collect(Collectors.toSet()); 242 return collection.stream().filter(predicate).collect(Collectors.toSet());
250 } 243 }
251 244
252 - private class HostLocationTracker implements EventuallyConsistentMapListener<HostId, DefaultHost> { 245 + private class HostLocationTracker implements MapEventListener<HostId, DefaultHost> {
253 @Override 246 @Override
254 - public void event(EventuallyConsistentMapEvent<HostId, DefaultHost> event) { 247 + public void event(MapEvent<HostId, DefaultHost> event) {
255 - DefaultHost host = checkNotNull(event.value()); 248 + DefaultHost host = checkNotNull(event.value().value());
256 - if (event.type() == PUT) { 249 + if (event.type() == MapEvent.Type.INSERT) {
257 Host prevHost = prevHosts.put(host.id(), host); 250 Host prevHost = prevHosts.put(host.id(), host);
258 if (prevHost == null) { 251 if (prevHost == null) {
259 notifyDelegate(new HostEvent(HOST_ADDED, host)); 252 notifyDelegate(new HostEvent(HOST_ADDED, host));
...@@ -262,7 +255,7 @@ public class ECHostStore ...@@ -262,7 +255,7 @@ public class ECHostStore
262 } else if (!Objects.equals(prevHost, host)) { 255 } else if (!Objects.equals(prevHost, host)) {
263 notifyDelegate(new HostEvent(HOST_UPDATED, host, prevHost)); 256 notifyDelegate(new HostEvent(HOST_UPDATED, host, prevHost));
264 } 257 }
265 - } else if (event.type() == REMOVE) { 258 + } else if (event.type() == MapEvent.Type.REMOVE) {
266 if (prevHosts.remove(host.id()) != null) { 259 if (prevHosts.remove(host.id()) != null) {
267 notifyDelegate(new HostEvent(HOST_REMOVED, host)); 260 notifyDelegate(new HostEvent(HOST_REMOVED, host));
268 } 261 }
......
...@@ -113,7 +113,7 @@ public class DistributedProxyArpStore implements ProxyArpStore { ...@@ -113,7 +113,7 @@ public class DistributedProxyArpStore implements ProxyArpStore {
113 113
114 @Override 114 @Override
115 public void forward(ConnectPoint outPort, Host subject, ByteBuffer packet) { 115 public void forward(ConnectPoint outPort, Host subject, ByteBuffer packet) {
116 - NodeId nodeId = mastershipService.getMasterFor(outPort.deviceId()); 116 + /*NodeId nodeId = mastershipService.getMasterFor(outPort.deviceId());
117 if (nodeId.equals(localNodeId)) { 117 if (nodeId.equals(localNodeId)) {
118 if (delegate != null) { 118 if (delegate != null) {
119 delegate.emitResponse(outPort, packet); 119 delegate.emitResponse(outPort, packet);
...@@ -122,7 +122,10 @@ public class DistributedProxyArpStore implements ProxyArpStore { ...@@ -122,7 +122,10 @@ public class DistributedProxyArpStore implements ProxyArpStore {
122 log.info("Forwarding ARP response from {} to {}", subject.id(), outPort); 122 log.info("Forwarding ARP response from {} to {}", subject.id(), outPort);
123 commService.unicast(new ArpResponseMessage(outPort, subject, packet.array()), 123 commService.unicast(new ArpResponseMessage(outPort, subject, packet.array()),
124 ARP_RESPONSE_MESSAGE, serializer::encode, nodeId); 124 ARP_RESPONSE_MESSAGE, serializer::encode, nodeId);
125 - } 125 + }*/
126 + //FIXME: Code above may be unnecessary and therefore cluster messaging
127 + // and pendingMessages could be pruned as well.
128 + delegate.emitResponse(outPort, packet);
126 } 129 }
127 130
128 @Override 131 @Override
......
...@@ -27,8 +27,6 @@ import org.onosproject.net.HostLocation; ...@@ -27,8 +27,6 @@ import org.onosproject.net.HostLocation;
27 import org.onosproject.net.host.DefaultHostDescription; 27 import org.onosproject.net.host.DefaultHostDescription;
28 import org.onosproject.net.host.HostDescription; 28 import org.onosproject.net.host.HostDescription;
29 import org.onosproject.net.provider.ProviderId; 29 import org.onosproject.net.provider.ProviderId;
30 -import org.onosproject.store.Timestamp;
31 -import org.onosproject.store.service.LogicalClockService;
32 import org.onosproject.store.service.TestStorageService; 30 import org.onosproject.store.service.TestStorageService;
33 31
34 import java.util.HashSet; 32 import java.util.HashSet;
...@@ -37,9 +35,9 @@ import java.util.Set; ...@@ -37,9 +35,9 @@ import java.util.Set;
37 /** 35 /**
38 * Tests for the ECHostStore. 36 * Tests for the ECHostStore.
39 */ 37 */
40 -public class ECHostStoreTest extends TestCase { 38 +public class DistributedHostStoreTest extends TestCase {
41 39
42 - private ECHostStore ecXHostStore; 40 + private DistributedHostStore ecXHostStore;
43 41
44 private static final HostId HOSTID = HostId.hostId(MacAddress.valueOf("1a:1a:1a:1a:1a:1a")); 42 private static final HostId HOSTID = HostId.hostId(MacAddress.valueOf("1a:1a:1a:1a:1a:1a"));
45 43
...@@ -50,10 +48,9 @@ public class ECHostStoreTest extends TestCase { ...@@ -50,10 +48,9 @@ public class ECHostStoreTest extends TestCase {
50 48
51 @Before 49 @Before
52 public void setUp() { 50 public void setUp() {
53 - ecXHostStore = new ECHostStore(); 51 + ecXHostStore = new DistributedHostStore();
54 52
55 ecXHostStore.storageService = new TestStorageService(); 53 ecXHostStore.storageService = new TestStorageService();
56 - ecXHostStore.clockService = new TestLogicalClockService();
57 ecXHostStore.activate(); 54 ecXHostStore.activate();
58 } 55 }
59 56
...@@ -83,13 +80,4 @@ public class ECHostStoreTest extends TestCase { ...@@ -83,13 +80,4 @@ public class ECHostStoreTest extends TestCase {
83 assertTrue(host.ipAddresses().contains(IP2)); 80 assertTrue(host.ipAddresses().contains(IP2));
84 } 81 }
85 82
86 - /**
87 - * Mocks the LogicalClockService class.
88 - */
89 - class TestLogicalClockService implements LogicalClockService {
90 - @Override
91 - public Timestamp getTimestamp() {
92 - return null;
93 - }
94 - }
95 } 83 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,19 +15,23 @@ from mininet.util import dumpNodeConnections ...@@ -15,19 +15,23 @@ from mininet.util import dumpNodeConnections
15 class AttMplsTopo( Topo ): 15 class AttMplsTopo( Topo ):
16 "Internet Topology Zoo Specimen." 16 "Internet Topology Zoo Specimen."
17 17
18 - def build( self ): 18 + def __init__( self ):
19 "Create a topology." 19 "Create a topology."
20 20
21 + # Initialize Topology
22 + Topo.__init__( self )
23 +
21 # add nodes, switches first... 24 # add nodes, switches first...
25 + NY54 = self.addSwitch( 's25' ) # 40.728270, -73.994483
22 CMBR = self.addSwitch( 's1' ) # 42.373730, -71.109734 26 CMBR = self.addSwitch( 's1' ) # 42.373730, -71.109734
23 - CHCG = self.addSwitch( 's2' ) # 41.877461, -87.642892 27 + CHCG = self.addSwitch( 's2', protocols='OpenFlow13' ) # 41.877461, -87.642892
24 CLEV = self.addSwitch( 's3' ) # 41.498928, -81.695217 28 CLEV = self.addSwitch( 's3' ) # 41.498928, -81.695217
25 RLGH = self.addSwitch( 's4' ) # 35.780150, -78.644026 29 RLGH = self.addSwitch( 's4' ) # 35.780150, -78.644026
26 ATLN = self.addSwitch( 's5' ) # 33.749017, -84.394168 30 ATLN = self.addSwitch( 's5' ) # 33.749017, -84.394168
27 PHLA = self.addSwitch( 's6' ) # 39.952906, -75.172278 31 PHLA = self.addSwitch( 's6' ) # 39.952906, -75.172278
28 WASH = self.addSwitch( 's7' ) # 38.906696, -77.035509 32 WASH = self.addSwitch( 's7' ) # 38.906696, -77.035509
29 NSVL = self.addSwitch( 's8' ) # 36.166410, -86.787305 33 NSVL = self.addSwitch( 's8' ) # 36.166410, -86.787305
30 - STLS = self.addSwitch( 's9' ) # 38.626418, -90.198143 34 + STLS = self.addSwitch( 's9', protocols='OpenFlow13' ) # 38.626418, -90.198143
31 NWOR = self.addSwitch( 's10' ) # 29.951475, -90.078434 35 NWOR = self.addSwitch( 's10' ) # 29.951475, -90.078434
32 HSTN = self.addSwitch( 's11' ) # 29.763249, -95.368332 36 HSTN = self.addSwitch( 's11' ) # 29.763249, -95.368332
33 SNAN = self.addSwitch( 's12' ) # 29.424331, -98.491745 37 SNAN = self.addSwitch( 's12' ) # 29.424331, -98.491745
...@@ -40,12 +44,12 @@ class AttMplsTopo( Topo ): ...@@ -40,12 +44,12 @@ class AttMplsTopo( Topo ):
40 PTLD = self.addSwitch( 's19' ) # 45.523317, -122.677768 44 PTLD = self.addSwitch( 's19' ) # 45.523317, -122.677768
41 STTL = self.addSwitch( 's20' ) # 47.607326, -122.331786 45 STTL = self.addSwitch( 's20' ) # 47.607326, -122.331786
42 SLKC = self.addSwitch( 's21' ) # 40.759577, -111.895079 46 SLKC = self.addSwitch( 's21' ) # 40.759577, -111.895079
43 - LA03 = self.addSwitch( 's22' ) # 34.056346, -118.235951 47 + LA03 = self.addSwitch( 's22', protocols='OpenFlow13' ) # 34.056346, -118.235951
44 SNDG = self.addSwitch( 's23' ) # 32.714564, -117.153528 48 SNDG = self.addSwitch( 's23' ) # 32.714564, -117.153528
45 PHNX = self.addSwitch( 's24' ) # 33.448289, -112.076299 49 PHNX = self.addSwitch( 's24' ) # 33.448289, -112.076299
46 - NY54 = self.addSwitch( 's25' ) # 40.728270, -73.994483
47 50
48 # ... and now hosts 51 # ... and now hosts
52 + NY54_host = self.addHost( 'h25' )
49 CMBR_host = self.addHost( 'h1' ) 53 CMBR_host = self.addHost( 'h1' )
50 CHCG_host = self.addHost( 'h2' ) 54 CHCG_host = self.addHost( 'h2' )
51 CLEV_host = self.addHost( 'h3' ) 55 CLEV_host = self.addHost( 'h3' )
...@@ -70,7 +74,6 @@ class AttMplsTopo( Topo ): ...@@ -70,7 +74,6 @@ class AttMplsTopo( Topo ):
70 LA03_host = self.addHost( 'h22' ) 74 LA03_host = self.addHost( 'h22' )
71 SNDG_host = self.addHost( 'h23' ) 75 SNDG_host = self.addHost( 'h23' )
72 PHNX_host = self.addHost( 'h24' ) 76 PHNX_host = self.addHost( 'h24' )
73 - NY54_host = self.addHost( 'h25' )
74 77
75 # add edges between switch and corresponding host 78 # add edges between switch and corresponding host
76 self.addLink( NY54 , NY54_host ) 79 self.addLink( NY54 , NY54_host )
......