tom

Sketching more topology related stuff.

...@@ -105,7 +105,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> { ...@@ -105,7 +105,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
105 * 105 *
106 * @return port subject or null if the event is not port specific. 106 * @return port subject or null if the event is not port specific.
107 */ 107 */
108 - Port port() { 108 + public Port port() {
109 return port; 109 return port;
110 } 110 }
111 111
......
...@@ -143,8 +143,11 @@ public class SimpleDeviceManager ...@@ -143,8 +143,11 @@ public class SimpleDeviceManager
143 public void removeDevice(DeviceId deviceId) { 143 public void removeDevice(DeviceId deviceId) {
144 checkNotNull(deviceId, DEVICE_ID_NULL); 144 checkNotNull(deviceId, DEVICE_ID_NULL);
145 DeviceEvent event = store.removeDevice(deviceId); 145 DeviceEvent event = store.removeDevice(deviceId);
146 + if (event != null) {
147 + log.info("Device {} administratively removed", deviceId);
146 post(event); 148 post(event);
147 } 149 }
150 + }
148 151
149 // Personalized device provider service issued to the supplied provider. 152 // Personalized device provider service issued to the supplied provider.
150 private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider> 153 private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider>
...@@ -159,12 +162,12 @@ public class SimpleDeviceManager ...@@ -159,12 +162,12 @@ public class SimpleDeviceManager
159 checkNotNull(deviceId, DEVICE_ID_NULL); 162 checkNotNull(deviceId, DEVICE_ID_NULL);
160 checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); 163 checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
161 checkValidity(); 164 checkValidity();
162 - log.info("Device {} connected", deviceId);
163 DeviceEvent event = store.createOrUpdateDevice(provider().id(), 165 DeviceEvent event = store.createOrUpdateDevice(provider().id(),
164 deviceId, deviceDescription); 166 deviceId, deviceDescription);
165 167
166 // If there was a change of any kind, trigger role selection process. 168 // If there was a change of any kind, trigger role selection process.
167 if (event != null) { 169 if (event != null) {
170 + log.info("Device {} connected", deviceId);
168 Device device = event.subject(); 171 Device device = event.subject();
169 provider().roleChanged(device, store.getRole(device.id())); 172 provider().roleChanged(device, store.getRole(device.id()));
170 post(event); 173 post(event);
...@@ -175,17 +178,18 @@ public class SimpleDeviceManager ...@@ -175,17 +178,18 @@ public class SimpleDeviceManager
175 public void deviceDisconnected(DeviceId deviceId) { 178 public void deviceDisconnected(DeviceId deviceId) {
176 checkNotNull(deviceId, DEVICE_ID_NULL); 179 checkNotNull(deviceId, DEVICE_ID_NULL);
177 checkValidity(); 180 checkValidity();
178 - log.info("Device {} disconnected", deviceId);
179 DeviceEvent event = store.markOffline(deviceId); 181 DeviceEvent event = store.markOffline(deviceId);
182 + if (event != null) {
183 + log.info("Device {} disconnected", deviceId);
180 post(event); 184 post(event);
181 } 185 }
186 + }
182 187
183 @Override 188 @Override
184 public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { 189 public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
185 checkNotNull(deviceId, DEVICE_ID_NULL); 190 checkNotNull(deviceId, DEVICE_ID_NULL);
186 checkNotNull(portDescriptions, "Port descriptions list cannot be null"); 191 checkNotNull(portDescriptions, "Port descriptions list cannot be null");
187 checkValidity(); 192 checkValidity();
188 - log.info("Device {} ports updated", deviceId);
189 List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions); 193 List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions);
190 for (DeviceEvent event : events) { 194 for (DeviceEvent event : events) {
191 post(event); 195 post(event);
...@@ -199,11 +203,12 @@ public class SimpleDeviceManager ...@@ -199,11 +203,12 @@ public class SimpleDeviceManager
199 checkValidity(); 203 checkValidity();
200 DeviceEvent event = store.updatePortStatus(deviceId, portDescription); 204 DeviceEvent event = store.updatePortStatus(deviceId, portDescription);
201 if (event != null) { 205 if (event != null) {
202 - log.info("Device {} port status changed", deviceId); 206 + log.info("Device {} port {} status changed", deviceId,
203 - } 207 + event.port().number());
204 post(event); 208 post(event);
205 } 209 }
206 } 210 }
211 + }
207 212
208 // Posts the specified event to the local event dispatcher. 213 // Posts the specified event to the local event dispatcher.
209 private void post(DeviceEvent event) { 214 private void post(DeviceEvent event) {
......
...@@ -53,6 +53,8 @@ public class SimpleTopologyManager ...@@ -53,6 +53,8 @@ public class SimpleTopologyManager
53 private final AbstractListenerRegistry<TopologyEvent, TopologyListener> 53 private final AbstractListenerRegistry<TopologyEvent, TopologyListener>
54 listenerRegistry = new AbstractListenerRegistry<>(); 54 listenerRegistry = new AbstractListenerRegistry<>();
55 55
56 + private final SimpleTopologyStore store = new SimpleTopologyStore();
57 +
56 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
57 private EventDeliveryService eventDispatcher; 59 private EventDeliveryService eventDispatcher;
58 60
......
1 +package org.onlab.onos.net.trivial.impl;
2 +
3 +/**
4 + * Manages inventory of topology snapshots using trivial in-memory
5 + * implementation.
6 + */
7 +public class SimpleTopologyStore {
8 +}