Madan Jampani
Committed by Gerrit Code Review

ONOS-1981: Move expensive work off of event loop thread

Change-Id: I200d9b727a7d501d5b055574ddb0907b8f4756a2
......@@ -613,11 +613,7 @@ public class DeviceManager
}
}
// Intercepts mastership events
private class InternalMastershipListener implements MastershipListener {
@Override
public void event(MastershipEvent event) {
private void handleMastershipEvent(MastershipEvent event) {
if (event.type() != MastershipEvent.Type.MASTER_CHANGED) {
// Don't care if backup list changed.
return;
......@@ -664,6 +660,20 @@ public class DeviceManager
log.debug("Device is not yet/no longer in the store: {}", did);
}
}
// Intercepts mastership events
private class InternalMastershipListener implements MastershipListener {
@Override
public void event(MastershipEvent event) {
backgroundService.submit(() -> {
try {
handleMastershipEvent(event);
} catch (Exception e) {
log.warn("Failed to handle {}", event, e);
}
});
}
}
// Store delegate to re-post events emitted from the store.
......