MastershipService.relinquishRole returns CompletableFuture + Block deviceDiconnected until role relinquish is complete
Change-Id: I081df48fc05fdca2e452a937a093d5caa16091ed
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 37c431e..73bbe2f 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
@@ -16,7 +16,6 @@
package org.onosproject.net.device.impl;
import com.google.common.collect.Lists;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -411,8 +410,15 @@
}
});
} finally {
- //relinquish master role and ability to be backup.
- mastershipService.relinquishMastership(deviceId);
+ try {
+ //relinquish master role and ability to be backup.
+ mastershipService.relinquishMastership(deviceId).get();
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while reliquishing role for {}", deviceId);
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ log.error("Exception thrown while relinquishing role for {}", deviceId, e);
+ }
}
}