[SDFAB-935] Optimize and improve the p. mastership
This patch is the part 1 and contains the following:
- Make the GDP greedy by reasserting immediately the role
Change-Id: I7259d4ace4a3e58ae2d97b6e53a393c41d5c0df9
(cherry picked from commit d510b7db8aeafbb52b00982dacb1f1079b0cc4b2)
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index cd8ab96..a85ee8f 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -513,6 +513,7 @@
final DeviceId deviceId = device.id();
MastershipRole myRole = mastershipService.getLocalRole(deviceId);
log.trace("Checking device {}. Current role is {}", deviceId, myRole);
+ log.info("Device local status is {}", localStatus(deviceId));
if (!isReachable(deviceId)) {
if (myRole != NONE) {
// Verify if the device is fully disconnected from the cluster
@@ -1079,6 +1080,7 @@
}
final boolean isReachable = isReachable(did);
+ log.info("Device local status is {}", localStatus(did));
if (!isReachable) {
// device is not connected to this node, nevertheless we should get a role
if (mastershipService.getLocalRole(did) == NONE) {
diff --git a/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
index 6ce3269..4c3018a 100644
--- a/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
+++ b/providers/general/device/src/main/java/org/onosproject/provider/general/device/impl/GeneralDeviceProvider.java
@@ -797,14 +797,24 @@
}
final MastershipRole deviceRole = handshaker.getRole();
+ // FIXME: we should be checking the mastership term as well.
if (expectedRole != deviceRole) {
- // FIXME: we should be checking the mastership term as well.
- log.debug("Detected role mismatch for {}, core expects {}, " +
- "but device reports {}, waiting for mastership " +
- "service to fix this...",
- deviceId, expectedRole, deviceRole);
- // Gentle nudge to fix things...
- providerService.receivedRoleReply(deviceId, deviceRole);
+ // Let's be greedy, if the role is NONE likely is due to the lazy channel
+ if (deviceRole == MastershipRole.NONE) {
+ log.warn("Detected role mismatch for {}, core expects {}, " +
+ "but device reports {}, reassert the role... ",
+ deviceId, expectedRole, deviceRole);
+ /* If we are experience a severe issue, eventually
+ the DeviceManager will move the mastership */
+ roleChanged(deviceId, expectedRole);
+ } else {
+ log.debug("Detected role mismatch for {}, core expects {}, " +
+ "but device reports {}, waiting for mastership " +
+ "service to fix this...",
+ deviceId, expectedRole, deviceRole);
+ // Gentle nudge to fix things...
+ providerService.receivedRoleReply(deviceId, deviceRole);
+ }
return;
}