remove dependency on Devices for handling MastershipEvents
Change-Id: Ie1670e77d3eee5dbd597f574ebe16d687e7b551e
diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
index 68db55a..325128c 100644
--- a/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
+++ b/apps/optical/src/main/java/org/onlab/onos/optical/cfg/OpticalConfigProvider.java
@@ -358,7 +358,7 @@
}
@Override
- public void triggerProbe(Device device) {
+ public void triggerProbe(DeviceId deviceId) {
// TODO We may want to consider re-reading config files and publishing them based on this event.
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java b/core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
index 8dd405a..7280faf 100644
--- a/core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
+++ b/core/api/src/main/java/org/onlab/onos/net/device/DeviceProvider.java
@@ -15,7 +15,6 @@
*/
package org.onlab.onos.net.device;
-import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.net.provider.Provider;
@@ -35,9 +34,9 @@
* {@link org.onlab.onos.net.device.DeviceProviderService#deviceDisconnected}
* at some later point in time.
*
- * @param device device to be probed
+ * @param deviceId ID of device to be probed
*/
- void triggerProbe(Device device);
+ void triggerProbe(DeviceId deviceId);
/**
* Notifies the provider of a mastership role change for the specified
diff --git a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
index 546b497..597f15f 100644
--- a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
@@ -182,6 +182,9 @@
// Check a device for control channel connectivity.
private boolean isReachable(DeviceId deviceId) {
+ if (deviceId == null) {
+ return false;
+ }
DeviceProvider provider = getProvider(deviceId);
if (provider != null) {
return provider.isReachable(deviceId);
@@ -370,7 +373,6 @@
checkNotNull(portDescriptions,
"Port descriptions list cannot be null");
checkValidity();
-
if (!deviceClockProviderService.isTimestampAvailable(deviceId)) {
// Never been a master for this device
// any update will be ignored.
@@ -475,15 +477,7 @@
return true;
}
- Device device = store.getDevice(deviceId);
- // FIXME: Device might not be there yet. (eventual consistent)
- // FIXME relinquish role
- if (device == null) {
- log.warn("{} was not there. Cannot apply role {}", deviceId, newRole);
- return false;
- }
-
- DeviceProvider provider = getProvider(device.providerId());
+ DeviceProvider provider = getProvider(deviceId);
if (provider == null) {
log.warn("Provider for {} was not found. Cannot apply role {}", deviceId, newRole);
return false;
@@ -492,10 +486,7 @@
if (newRole.equals(MastershipRole.MASTER)) {
// only trigger event when request was sent to provider
- // TODO: consider removing this from Device event type?
- post(new DeviceEvent(DEVICE_MASTERSHIP_CHANGED, device));
-
- provider.triggerProbe(device);
+ provider.triggerProbe(deviceId);
}
return true;
}
diff --git a/core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java b/core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
index d278c24..58af77a 100644
--- a/core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/device/impl/DeviceManagerTest.java
@@ -259,7 +259,7 @@
}
@Override
- public void triggerProbe(Device device) {
+ public void triggerProbe(DeviceId deviceId) {
}
@Override
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
index 0c7fb0c..df6ed3c 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
@@ -235,7 +235,10 @@
DeviceId deviceId,
List<PortDescription> portDescriptions) {
Device device = devices.get(deviceId);
- checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
+ if (device == null) {
+ log.debug("Device {} doesn't exist or hasn't been initialized yet", deviceId);
+ return Collections.emptyList();
+ }
Map<ProviderId, DeviceDescriptions> descsMap = deviceDescs.get(deviceId);
checkArgument(descsMap != null, DEVICE_NOT_FOUND, deviceId);
diff --git a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
index 51e90e5..030b9c1 100644
--- a/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
+++ b/openflow/ctl/src/main/java/org/onlab/onos/openflow/controller/impl/RoleManager.java
@@ -57,7 +57,7 @@
private static Logger log = LoggerFactory.getLogger(RoleManager.class);
- // The time until cached XID is evicted. Arbitray for now.
+ // The time until cached XID is evicted. Arbitrary for now.
private final int pendingXidTimeoutSeconds = 60;
// The cache for pending expected RoleReplies keyed on expected XID
diff --git a/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
index 3b74807..efb76ab 100644
--- a/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -127,17 +127,16 @@
}
@Override
- public void triggerProbe(Device device) {
- final DeviceId deviceId = device.id();
+ public void triggerProbe(DeviceId deviceId) {
LOG.info("Triggering probe on device {}", deviceId);
final Dpid dpid = dpid(deviceId.uri());
OpenFlowSwitch sw = controller.getSwitch(dpid);
if (sw == null || !sw.isConnected()) {
- LOG.error("Failed to probe device {} on sw={}", device, sw);
+ LOG.error("Failed to probe device {} on sw={}", deviceId, sw);
providerService.deviceDisconnected(deviceId);
} else {
- LOG.trace("Confirmed device {} connection", device);
+ LOG.trace("Confirmed device {} connection", deviceId);
// FIXME require something like below to match javadoc description
// but this starts infinite loop with current DeviceManager
// final ChassisId cId = new ChassisId(dpid.value());
diff --git a/web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java b/web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
index e4a0763..5a0d909 100644
--- a/web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
+++ b/web/api/src/main/java/org/onlab/onos/rest/ConfigProvider.java
@@ -240,7 +240,7 @@
}
@Override
- public void triggerProbe(Device device) {
+ public void triggerProbe(DeviceId deviceId) {
}
@Override