Committed by
Gerrit Code Review
ONOS-1981: Move expensive work off of event loop thread
Change-Id: I200d9b727a7d501d5b055574ddb0907b8f4756a2
Showing
1 changed file
with
15 additions
and
5 deletions
... | @@ -613,11 +613,7 @@ public class DeviceManager | ... | @@ -613,11 +613,7 @@ public class DeviceManager |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | - // Intercepts mastership events | 616 | + private void handleMastershipEvent(MastershipEvent event) { |
617 | - private class InternalMastershipListener implements MastershipListener { | ||
618 | - | ||
619 | - @Override | ||
620 | - public void event(MastershipEvent event) { | ||
621 | if (event.type() != MastershipEvent.Type.MASTER_CHANGED) { | 617 | if (event.type() != MastershipEvent.Type.MASTER_CHANGED) { |
622 | // Don't care if backup list changed. | 618 | // Don't care if backup list changed. |
623 | return; | 619 | return; |
... | @@ -664,6 +660,20 @@ public class DeviceManager | ... | @@ -664,6 +660,20 @@ public class DeviceManager |
664 | log.debug("Device is not yet/no longer in the store: {}", did); | 660 | log.debug("Device is not yet/no longer in the store: {}", did); |
665 | } | 661 | } |
666 | } | 662 | } |
663 | + | ||
664 | + // Intercepts mastership events | ||
665 | + private class InternalMastershipListener implements MastershipListener { | ||
666 | + | ||
667 | + @Override | ||
668 | + public void event(MastershipEvent event) { | ||
669 | + backgroundService.submit(() -> { | ||
670 | + try { | ||
671 | + handleMastershipEvent(event); | ||
672 | + } catch (Exception e) { | ||
673 | + log.warn("Failed to handle {}", event, e); | ||
674 | + } | ||
675 | + }); | ||
676 | + } | ||
667 | } | 677 | } |
668 | 678 | ||
669 | // Store delegate to re-post events emitted from the store. | 679 | // Store delegate to re-post events emitted from the store. | ... | ... |
-
Please register or login to post a comment