tom

Sketching more topology related stuff.

......@@ -105,7 +105,7 @@ public class DeviceEvent extends AbstractEvent<DeviceEvent.Type, Device> {
*
* @return port subject or null if the event is not port specific.
*/
Port port() {
public Port port() {
return port;
}
......
......@@ -143,8 +143,11 @@ public class SimpleDeviceManager
public void removeDevice(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_ID_NULL);
DeviceEvent event = store.removeDevice(deviceId);
if (event != null) {
log.info("Device {} administratively removed", deviceId);
post(event);
}
}
// Personalized device provider service issued to the supplied provider.
private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider>
......@@ -159,12 +162,12 @@ public class SimpleDeviceManager
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL);
checkValidity();
log.info("Device {} connected", deviceId);
DeviceEvent event = store.createOrUpdateDevice(provider().id(),
deviceId, deviceDescription);
// If there was a change of any kind, trigger role selection process.
if (event != null) {
log.info("Device {} connected", deviceId);
Device device = event.subject();
provider().roleChanged(device, store.getRole(device.id()));
post(event);
......@@ -175,17 +178,18 @@ public class SimpleDeviceManager
public void deviceDisconnected(DeviceId deviceId) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkValidity();
log.info("Device {} disconnected", deviceId);
DeviceEvent event = store.markOffline(deviceId);
if (event != null) {
log.info("Device {} disconnected", deviceId);
post(event);
}
}
@Override
public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) {
checkNotNull(deviceId, DEVICE_ID_NULL);
checkNotNull(portDescriptions, "Port descriptions list cannot be null");
checkValidity();
log.info("Device {} ports updated", deviceId);
List<DeviceEvent> events = store.updatePorts(deviceId, portDescriptions);
for (DeviceEvent event : events) {
post(event);
......@@ -199,11 +203,12 @@ public class SimpleDeviceManager
checkValidity();
DeviceEvent event = store.updatePortStatus(deviceId, portDescription);
if (event != null) {
log.info("Device {} port status changed", deviceId);
}
log.info("Device {} port {} status changed", deviceId,
event.port().number());
post(event);
}
}
}
// Posts the specified event to the local event dispatcher.
private void post(DeviceEvent event) {
......
......@@ -53,6 +53,8 @@ public class SimpleTopologyManager
private final AbstractListenerRegistry<TopologyEvent, TopologyListener>
listenerRegistry = new AbstractListenerRegistry<>();
private final SimpleTopologyStore store = new SimpleTopologyStore();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private EventDeliveryService eventDispatcher;
......
package org.onlab.onos.net.trivial.impl;
/**
* Manages inventory of topology snapshots using trivial in-memory
* implementation.
*/
public class SimpleTopologyStore {
}