Added a simple device manager to have a working provider broker.
diff --git a/net/api/src/main/java/org/onlab/onos/net/Link.java b/net/api/src/main/java/org/onlab/onos/net/Link.java
index 62fc9f8..200f682 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Link.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Link.java
@@ -18,8 +18,9 @@
/**
* Signifies that this link is potentially comprised from multiple
- * underlying segments or hops, e.g. optical links, tunnel links,
- * multi-hop links spanning 'dark' switches
+ * underlying segments or hops, and as such should be used to tag
+ * links traversing optical paths, tunnels or intervening 'dark'
+ * switches.
*/
INDIRECT
}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
index f55675c..9d8eb6a 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceProviderService.java
@@ -1,5 +1,6 @@
package org.onlab.onos.net.device;
+import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.provider.ProviderService;
@@ -19,28 +20,31 @@
* @param deviceDescription information about network device
* @return mastership role chosen by the provider service
*/
- MastershipRole deviceConnected(DeviceDescription deviceDescription);
+ MastershipRole deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription);
/**
* Signals the core that a device has disconnected or is no longer reachable.
*
- * @param deviceDescription device to be removed
+ * @param deviceId identity of the device to be removed
*/
- void deviceDisconnected(DeviceDescription deviceDescription);
+ void deviceDisconnected(DeviceId deviceId);
/**
* Sends information about all ports of a device. It is up to the core to
* determine what has changed.
+ * <p/>
*
+ * @param deviceId identity of the device
* @param ports list of device ports
*/
- void updatePorts(List<PortDescription> ports);
+ void updatePorts(DeviceId deviceId, List<PortDescription> ports);
/**
* Used to notify the core about port status change of a single port.
*
+ * @param deviceId identity of the device
* @param port description of the port that changed
*/
- void portStatusChanged(PortDescription port);
+ void portStatusChanged(DeviceId deviceId, PortDescription port);
}
diff --git a/net/core/src/main/java/org/onlab/onos/net/impl/SimpleDeviceManager.java b/net/core/src/main/java/org/onlab/onos/net/impl/SimpleDeviceManager.java
new file mode 100644
index 0000000..767169a
--- /dev/null
+++ b/net/core/src/main/java/org/onlab/onos/net/impl/SimpleDeviceManager.java
@@ -0,0 +1,94 @@
+package org.onlab.onos.net.impl;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.MastershipRole;
+import org.onlab.onos.net.device.DeviceDescription;
+import org.onlab.onos.net.device.DeviceProvider;
+import org.onlab.onos.net.device.DeviceProviderBroker;
+import org.onlab.onos.net.device.DeviceProviderService;
+import org.onlab.onos.net.device.PortDescription;
+import org.onlab.onos.net.provider.AbstractProviderBroker;
+import org.onlab.onos.net.provider.AbstractProviderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Provides basic implementation of the device SB & NB APIs.
+ */
+@Component(immediate = true)
+@Service
+public class SimpleDeviceManager implements DeviceProviderBroker {
+
+ private Logger log = LoggerFactory.getLogger(SimpleDeviceManager.class);
+
+ private final DeviceProviderBroker broker = new InternalBroker();
+
+ @Activate
+ public void activate() {
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public DeviceProviderService register(DeviceProvider provider) {
+ return broker.register(provider);
+ }
+
+ @Override
+ public void unregister(DeviceProvider provider) {
+ broker.unregister(provider);
+ }
+
+ // Internal delegate for tracking various providers and issuing them a
+ // personalized provider service.
+ private class InternalBroker extends AbstractProviderBroker<DeviceProvider, DeviceProviderService>
+ implements DeviceProviderBroker {
+ @Override
+ protected DeviceProviderService createProviderService(DeviceProvider provider) {
+ return new InternalDeviceProviderService(provider);
+ }
+ }
+
+ // Personalized device provider service issued to the supplied provider.
+ private class InternalDeviceProviderService extends AbstractProviderService<DeviceProvider>
+ implements DeviceProviderService {
+
+ public InternalDeviceProviderService(DeviceProvider provider) {
+ super(provider);
+ }
+
+ @Override
+ public MastershipRole deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) {
+ log.info("Device {} connected: {}", deviceId, deviceDescription);
+ return MastershipRole.MASTER;
+ }
+
+ @Override
+ public void deviceDisconnected(DeviceId deviceId) {
+ log.info("Device {} disconnected", deviceId);
+
+ }
+
+ @Override
+ public void updatePorts(DeviceId deviceId, List<PortDescription> ports) {
+ // FIXME: fix the interface to accept DeviceId separately
+ log.info("Device {} ports updated: {}", ports);
+
+ }
+
+ @Override
+ public void portStatusChanged(DeviceId deviceId, PortDescription port) {
+ log.info("Device {} port status changed: {}", deviceId, port);
+ }
+ }
+}