Committed by
Gerrit Code Review
GUI -- Moved of potentially expensive processing off listener dispatch thread.
Change-Id: Iba30f01b99f464b06c7d33fddf2b143ce6aa1fdd
Showing
2 changed files
with
28 additions
and
12 deletions
... | @@ -67,8 +67,11 @@ import java.util.List; | ... | @@ -67,8 +67,11 @@ import java.util.List; |
67 | import java.util.Set; | 67 | import java.util.Set; |
68 | import java.util.Timer; | 68 | import java.util.Timer; |
69 | import java.util.TimerTask; | 69 | import java.util.TimerTask; |
70 | +import java.util.concurrent.ExecutorService; | ||
70 | 71 | ||
71 | import static com.google.common.base.Strings.isNullOrEmpty; | 72 | import static com.google.common.base.Strings.isNullOrEmpty; |
73 | +import static java.util.concurrent.Executors.newSingleThreadExecutor; | ||
74 | +import static org.onlab.util.Tools.groupedThreads; | ||
72 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; | 75 | import static org.onosproject.cluster.ClusterEvent.Type.INSTANCE_ADDED; |
73 | import static org.onosproject.net.DeviceId.deviceId; | 76 | import static org.onosproject.net.DeviceId.deviceId; |
74 | import static org.onosproject.net.HostId.hostId; | 77 | import static org.onosproject.net.HostId.hostId; |
... | @@ -111,7 +114,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -111,7 +114,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
111 | (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()); | 114 | (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()); |
112 | 115 | ||
113 | 116 | ||
114 | - private final Timer timer = new Timer("topology-view"); | 117 | + private final Timer timer = new Timer("onos-topology-view"); |
115 | 118 | ||
116 | private static final int MAX_EVENTS = 1000; | 119 | private static final int MAX_EVENTS = 1000; |
117 | private static final int MAX_BATCH_MS = 5000; | 120 | private static final int MAX_BATCH_MS = 5000; |
... | @@ -128,6 +131,8 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -128,6 +131,8 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
128 | private final FlowRuleListener flowListener = new InternalFlowListener(); | 131 | private final FlowRuleListener flowListener = new InternalFlowListener(); |
129 | 132 | ||
130 | private final Accumulator<Event> eventAccummulator = new InternalEventAccummulator(); | 133 | private final Accumulator<Event> eventAccummulator = new InternalEventAccummulator(); |
134 | + private final ExecutorService msgSender = | ||
135 | + newSingleThreadExecutor(groupedThreads("onos/gui", "msg-sender")); | ||
131 | 136 | ||
132 | private TimerTask trafficTask = null; | 137 | private TimerTask trafficTask = null; |
133 | private TrafficEvent trafficEvent = null; | 138 | private TrafficEvent trafficEvent = null; |
... | @@ -507,6 +512,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -507,6 +512,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
507 | 512 | ||
508 | // Subscribes for summary messages. | 513 | // Subscribes for summary messages. |
509 | private synchronized void requestSummary(long sid) { | 514 | private synchronized void requestSummary(long sid) { |
515 | + | ||
510 | sendMessage(summmaryMessage(sid)); | 516 | sendMessage(summmaryMessage(sid)); |
511 | } | 517 | } |
512 | 518 | ||
... | @@ -748,7 +754,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -748,7 +754,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
748 | private class InternalClusterListener implements ClusterEventListener { | 754 | private class InternalClusterListener implements ClusterEventListener { |
749 | @Override | 755 | @Override |
750 | public void event(ClusterEvent event) { | 756 | public void event(ClusterEvent event) { |
751 | - sendMessage(instanceMessage(event, null)); | 757 | + msgSender.execute(() -> { |
758 | + sendMessage(instanceMessage(event, null)); | ||
759 | + }); | ||
752 | } | 760 | } |
753 | } | 761 | } |
754 | 762 | ||
... | @@ -756,11 +764,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -756,11 +764,13 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
756 | private class InternalMastershipListener implements MastershipListener { | 764 | private class InternalMastershipListener implements MastershipListener { |
757 | @Override | 765 | @Override |
758 | public void event(MastershipEvent event) { | 766 | public void event(MastershipEvent event) { |
759 | - sendAllInstances("updateInstance"); | 767 | + msgSender.execute(() -> { |
760 | - Device device = deviceService.getDevice(event.subject()); | 768 | + sendAllInstances("updateInstance"); |
761 | - if (device != null) { | 769 | + Device device = deviceService.getDevice(event.subject()); |
762 | - sendMessage(deviceMessage(new DeviceEvent(DEVICE_UPDATED, device))); | 770 | + if (device != null) { |
763 | - } | 771 | + sendMessage(deviceMessage(new DeviceEvent(DEVICE_UPDATED, device))); |
772 | + } | ||
773 | + }); | ||
764 | } | 774 | } |
765 | } | 775 | } |
766 | 776 | ||
... | @@ -769,7 +779,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -769,7 +779,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
769 | @Override | 779 | @Override |
770 | public void event(DeviceEvent event) { | 780 | public void event(DeviceEvent event) { |
771 | if (event.type() != PORT_STATS_UPDATED) { | 781 | if (event.type() != PORT_STATS_UPDATED) { |
772 | - sendMessage(deviceMessage(event)); | 782 | + msgSender.execute(() -> { |
783 | + sendMessage(deviceMessage(event)); | ||
784 | + }); | ||
773 | eventAccummulator.add(event); | 785 | eventAccummulator.add(event); |
774 | } | 786 | } |
775 | } | 787 | } |
... | @@ -779,7 +791,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -779,7 +791,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
779 | private class InternalLinkListener implements LinkListener { | 791 | private class InternalLinkListener implements LinkListener { |
780 | @Override | 792 | @Override |
781 | public void event(LinkEvent event) { | 793 | public void event(LinkEvent event) { |
782 | - sendMessage(linkMessage(event)); | 794 | + msgSender.execute(() -> { |
795 | + sendMessage(linkMessage(event)); | ||
796 | + }); | ||
783 | eventAccummulator.add(event); | 797 | eventAccummulator.add(event); |
784 | } | 798 | } |
785 | } | 799 | } |
... | @@ -788,7 +802,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -788,7 +802,9 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
788 | private class InternalHostListener implements HostListener { | 802 | private class InternalHostListener implements HostListener { |
789 | @Override | 803 | @Override |
790 | public void event(HostEvent event) { | 804 | public void event(HostEvent event) { |
791 | - sendMessage(hostMessage(event)); | 805 | + msgSender.execute(() -> { |
806 | + sendMessage(hostMessage(event)); | ||
807 | + }); | ||
792 | eventAccummulator.add(event); | 808 | eventAccummulator.add(event); |
793 | } | 809 | } |
794 | } | 810 | } |
... | @@ -798,7 +814,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { | ... | @@ -798,7 +814,7 @@ public class TopologyViewMessageHandler extends TopologyViewMessageHandlerBase { |
798 | @Override | 814 | @Override |
799 | public void event(IntentEvent event) { | 815 | public void event(IntentEvent event) { |
800 | if (trafficTask != null) { | 816 | if (trafficTask != null) { |
801 | - requestSelectedIntentTraffic(); | 817 | + msgSender.execute(TopologyViewMessageHandler.this::requestSelectedIntentTraffic); |
802 | } | 818 | } |
803 | eventAccummulator.add(event); | 819 | eventAccummulator.add(event); |
804 | } | 820 | } | ... | ... |
... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
22 | 22 | ||
23 | // configuration | 23 | // configuration |
24 | var defaultSettings = { | 24 | var defaultSettings = { |
25 | - zoomMin: 0.25, | 25 | + zoomMin: 0.05, |
26 | zoomMax: 10, | 26 | zoomMax: 10, |
27 | zoomEnabled: function (ev) { return true; }, | 27 | zoomEnabled: function (ev) { return true; }, |
28 | zoomCallback: function () {} | 28 | zoomCallback: function () {} | ... | ... |
-
Please register or login to post a comment