Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.topology.impl; |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 17 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 18 | import com.google.common.collect.ImmutableList; |
Thomas Vachuska | ecb63c5 | 2015-02-19 10:03:48 -0800 | [diff] [blame] | 19 | import org.onlab.util.AbstractAccumulator; |
| 20 | import org.onlab.util.Accumulator; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 21 | import org.onosproject.cfg.ComponentConfigService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.event.Event; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 23 | import org.onosproject.net.device.DeviceEvent; |
| 24 | import org.onosproject.net.device.DeviceListener; |
| 25 | import org.onosproject.net.device.DeviceService; |
| 26 | import org.onosproject.net.link.LinkEvent; |
| 27 | import org.onosproject.net.link.LinkListener; |
| 28 | import org.onosproject.net.link.LinkService; |
| 29 | import org.onosproject.net.provider.AbstractProvider; |
| 30 | import org.onosproject.net.topology.DefaultGraphDescription; |
| 31 | import org.onosproject.net.topology.GraphDescription; |
| 32 | import org.onosproject.net.topology.TopologyProvider; |
| 33 | import org.onosproject.net.topology.TopologyProviderRegistry; |
| 34 | import org.onosproject.net.topology.TopologyProviderService; |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 35 | import org.osgi.service.component.ComponentContext; |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 36 | import org.osgi.service.component.annotations.Activate; |
| 37 | import org.osgi.service.component.annotations.Component; |
| 38 | import org.osgi.service.component.annotations.Deactivate; |
| 39 | import org.osgi.service.component.annotations.Modified; |
| 40 | import org.osgi.service.component.annotations.Reference; |
| 41 | import org.osgi.service.component.annotations.ReferenceCardinality; |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 42 | import org.slf4j.Logger; |
| 43 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 44 | import java.util.Collections; |
| 45 | import java.util.Dictionary; |
| 46 | import java.util.List; |
| 47 | import java.util.Timer; |
| 48 | import java.util.concurrent.ExecutorService; |
| 49 | |
| 50 | import static com.google.common.base.Strings.isNullOrEmpty; |
| 51 | import static java.util.concurrent.Executors.newFixedThreadPool; |
| 52 | import static org.onlab.util.Tools.get; |
| 53 | import static org.onlab.util.Tools.groupedThreads; |
| 54 | import static org.onosproject.core.CoreService.CORE_PROVIDER_ID; |
| 55 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_ADDED; |
| 56 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED; |
| 57 | import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED; |
| 58 | import static org.slf4j.LoggerFactory.getLogger; |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 61 | * Default implementation of a network topology provider that feeds off |
| 62 | * device and link subsystem events to trigger assembly and computation of |
| 63 | * new topology snapshots. |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 64 | */ |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 65 | @Component(immediate = true, service = TopologyProvider.class) |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 66 | public class DefaultTopologyProvider extends AbstractProvider |
| 67 | implements TopologyProvider { |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 68 | |
Thomas Vachuska | a132e3a | 2015-02-21 01:53:14 -0800 | [diff] [blame] | 69 | private static final int MAX_THREADS = 8; |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 70 | private static final int DEFAULT_MAX_EVENTS = 1000; |
| 71 | private static final int DEFAULT_MAX_IDLE_MS = 10; |
| 72 | private static final int DEFAULT_MAX_BATCH_MS = 50; |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 73 | |
tom | 025e09f | 2014-09-15 15:29:24 -0700 | [diff] [blame] | 74 | // FIXME: Replace with a system-wide timer instance; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 75 | // TODO: Convert to use HashedWheelTimer or produce a variant of that; then decide which we want to adopt |
Thomas Vachuska | a132e3a | 2015-02-21 01:53:14 -0800 | [diff] [blame] | 76 | private static final Timer TIMER = new Timer("onos-topo-event-batching"); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 77 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 78 | //@Property(name = "maxEvents", intValue = DEFAULT_MAX_EVENTS, |
| 79 | // label = "Maximum number of events to accumulate") |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 80 | private int maxEvents = DEFAULT_MAX_EVENTS; |
| 81 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 82 | //@Property(name = "maxIdleMs", intValue = DEFAULT_MAX_IDLE_MS, |
| 83 | // label = "Maximum number of millis between events") |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 84 | private int maxIdleMs = DEFAULT_MAX_IDLE_MS; |
| 85 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 86 | //@Property(name = "maxBatchMs", intValue = DEFAULT_MAX_BATCH_MS, |
| 87 | // label = "Maximum number of millis for whole batch") |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 88 | private int maxBatchMs = DEFAULT_MAX_BATCH_MS; |
| 89 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 90 | private final Logger log = getLogger(getClass()); |
| 91 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 92 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 93 | protected TopologyProviderRegistry providerRegistry; |
| 94 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 95 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 96 | protected DeviceService deviceService; |
| 97 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 99 | protected LinkService linkService; |
| 100 | |
Ray Milkey | d84f89b | 2018-08-17 14:54:17 -0700 | [diff] [blame^] | 101 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 102 | protected ComponentConfigService cfgService; |
| 103 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 104 | private volatile boolean isStarted = false; |
| 105 | |
| 106 | private TopologyProviderService providerService; |
Abhishek Dwaraki | 1e5873e | 2015-03-08 00:01:17 -0500 | [diff] [blame] | 107 | private final DeviceListener deviceListener = new InternalDeviceListener(); |
| 108 | private final LinkListener linkListener = new InternalLinkListener(); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 109 | |
Thomas Vachuska | ecb63c5 | 2015-02-19 10:03:48 -0800 | [diff] [blame] | 110 | private Accumulator<Event> accumulator; |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 111 | private ExecutorService executor; |
| 112 | |
| 113 | /** |
| 114 | * Creates a provider with the supplier identifier. |
| 115 | */ |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 116 | public DefaultTopologyProvider() { |
Thomas Vachuska | 6acd3bb | 2014-11-09 23:44:22 -0800 | [diff] [blame] | 117 | super(CORE_PROVIDER_ID); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | @Activate |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 121 | public synchronized void activate(ComponentContext context) { |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 122 | cfgService.registerProperties(DefaultTopologyProvider.class); |
HIGUCHI Yuta | d9e0105 | 2016-04-14 09:31:42 -0700 | [diff] [blame] | 123 | executor = newFixedThreadPool(MAX_THREADS, groupedThreads("onos/topo", "build-%d", log)); |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 124 | accumulator = new TopologyChangeAccumulator(); |
| 125 | logConfig("Configured"); |
| 126 | |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 127 | modified(context); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 128 | |
| 129 | providerService = providerRegistry.register(this); |
| 130 | deviceService.addListener(deviceListener); |
| 131 | linkService.addListener(linkListener); |
| 132 | |
| 133 | isStarted = true; |
Thomas Vachuska | 0e752bd | 2014-10-22 22:33:41 -0700 | [diff] [blame] | 134 | triggerRecompute(); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 135 | log.info("Started"); |
| 136 | } |
| 137 | |
| 138 | @Deactivate |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 139 | public synchronized void deactivate(ComponentContext context) { |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 140 | cfgService.unregisterProperties(DefaultTopologyProvider.class, false); |
tom | e52ce70 | 2014-09-11 00:12:54 -0700 | [diff] [blame] | 141 | isStarted = false; |
| 142 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 143 | deviceService.removeListener(deviceListener); |
| 144 | linkService.removeListener(linkListener); |
| 145 | providerRegistry.unregister(this); |
| 146 | providerService = null; |
| 147 | |
| 148 | executor.shutdownNow(); |
| 149 | executor = null; |
| 150 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 151 | log.info("Stopped"); |
| 152 | } |
| 153 | |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 154 | @Modified |
| 155 | public void modified(ComponentContext context) { |
| 156 | if (context == null) { |
| 157 | accumulator = new TopologyChangeAccumulator(); |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 158 | logConfig("Reconfigured"); |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 159 | return; |
| 160 | } |
| 161 | |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 162 | Dictionary<?, ?> properties = context.getProperties(); |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 163 | int newMaxEvents, newMaxBatchMs, newMaxIdleMs; |
| 164 | try { |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 165 | String s = get(properties, "maxEvents"); |
Ayaka Koshibe | 8851ed9 | 2015-01-22 12:07:24 -0800 | [diff] [blame] | 166 | newMaxEvents = isNullOrEmpty(s) ? maxEvents : Integer.parseInt(s.trim()); |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 167 | |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 168 | s = get(properties, "maxBatchMs"); |
Ayaka Koshibe | 8851ed9 | 2015-01-22 12:07:24 -0800 | [diff] [blame] | 169 | newMaxBatchMs = isNullOrEmpty(s) ? maxBatchMs : Integer.parseInt(s.trim()); |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 170 | |
Thomas Vachuska | 6519e6f | 2015-03-11 02:29:31 -0700 | [diff] [blame] | 171 | s = get(properties, "maxIdleMs"); |
Ayaka Koshibe | 8851ed9 | 2015-01-22 12:07:24 -0800 | [diff] [blame] | 172 | newMaxIdleMs = isNullOrEmpty(s) ? maxIdleMs : Integer.parseInt(s.trim()); |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 173 | |
Pavlin Radoslavov | b9e50df | 2015-02-20 20:01:26 -0800 | [diff] [blame] | 174 | } catch (NumberFormatException | ClassCastException e) { |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 175 | newMaxEvents = DEFAULT_MAX_EVENTS; |
| 176 | newMaxBatchMs = DEFAULT_MAX_BATCH_MS; |
| 177 | newMaxIdleMs = DEFAULT_MAX_IDLE_MS; |
| 178 | } |
| 179 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 180 | if (newMaxEvents != maxEvents || newMaxBatchMs != maxBatchMs || newMaxIdleMs != maxIdleMs) { |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 181 | maxEvents = newMaxEvents; |
| 182 | maxBatchMs = newMaxBatchMs; |
| 183 | maxIdleMs = newMaxIdleMs; |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 184 | accumulator = maxEvents > 1 ? new TopologyChangeAccumulator() : null; |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 185 | logConfig("Reconfigured"); |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 189 | private void logConfig(String prefix) { |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 190 | log.info("{} with maxEvents = {}; maxBatchMs = {}; maxIdleMs = {}; accumulator={}", |
| 191 | prefix, maxEvents, maxBatchMs, maxIdleMs, accumulator != null); |
Thomas Vachuska | 6b7920d | 2014-11-25 19:48:39 -0800 | [diff] [blame] | 192 | } |
| 193 | |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 194 | |
Thomas Vachuska | 0e752bd | 2014-10-22 22:33:41 -0700 | [diff] [blame] | 195 | @Override |
| 196 | public void triggerRecompute() { |
Sho SHIMIZU | 21d0069 | 2016-08-15 11:15:28 -0700 | [diff] [blame] | 197 | triggerTopologyBuild(Collections.emptyList()); |
Thomas Vachuska | 0e752bd | 2014-10-22 22:33:41 -0700 | [diff] [blame] | 198 | } |
| 199 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 200 | /** |
| 201 | * Triggers assembly of topology data citing the specified events as the |
| 202 | * reason. |
| 203 | * |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 204 | * @param reasons events which triggered the topology change |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 205 | */ |
tom | e52ce70 | 2014-09-11 00:12:54 -0700 | [diff] [blame] | 206 | private synchronized void triggerTopologyBuild(List<Event> reasons) { |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 207 | if (executor != null) { |
| 208 | executor.execute(new TopologyBuilderTask(reasons)); |
| 209 | } |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | // Builds the topology using the latest device and link information |
| 213 | // and citing the specified events as reasons for the change. |
| 214 | private void buildTopology(List<Event> reasons) { |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 215 | if (isStarted) { |
tom | 9793755 | 2014-09-11 10:48:42 -0700 | [diff] [blame] | 216 | GraphDescription desc = |
| 217 | new DefaultGraphDescription(System.nanoTime(), |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 218 | System.currentTimeMillis(), |
| 219 | deviceService.getAvailableDevices(), |
| 220 | linkService.getActiveLinks()); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 221 | providerService.topologyChanged(desc, reasons); |
| 222 | } |
| 223 | } |
| 224 | |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 225 | private void processEvent(Event event) { |
| 226 | if (accumulator != null) { |
| 227 | accumulator.add(event); |
| 228 | } else { |
| 229 | triggerTopologyBuild(ImmutableList.of(event)); |
| 230 | } |
| 231 | } |
| 232 | |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 233 | // Callback for device events |
Ayaka Koshibe | 3de43ca | 2014-09-26 16:40:23 -0700 | [diff] [blame] | 234 | private class InternalDeviceListener implements DeviceListener { |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 235 | @Override |
| 236 | public void event(DeviceEvent event) { |
| 237 | DeviceEvent.Type type = event.type(); |
Thomas Vachuska | 6d697f1 | 2015-03-08 20:59:50 -0700 | [diff] [blame] | 238 | if (type == DEVICE_ADDED || type == DEVICE_REMOVED || |
| 239 | type == DEVICE_AVAILABILITY_CHANGED) { |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 240 | processEvent(event); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 241 | } |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | // Callback for link events |
Ayaka Koshibe | 3de43ca | 2014-09-26 16:40:23 -0700 | [diff] [blame] | 246 | private class InternalLinkListener implements LinkListener { |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 247 | @Override |
| 248 | public void event(LinkEvent event) { |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 249 | processEvent(event); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | |
| 253 | // Event accumulator for paced triggering of topology assembly. |
Thomas Vachuska | ecb63c5 | 2015-02-19 10:03:48 -0800 | [diff] [blame] | 254 | private class TopologyChangeAccumulator extends AbstractAccumulator<Event> { |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 255 | TopologyChangeAccumulator() { |
Thomas Vachuska | 912bdd5 | 2014-11-17 11:39:01 -0800 | [diff] [blame] | 256 | super(TIMER, maxEvents, maxBatchMs, maxIdleMs); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | @Override |
Thomas Vachuska | ecb63c5 | 2015-02-19 10:03:48 -0800 | [diff] [blame] | 260 | public void processItems(List<Event> items) { |
| 261 | triggerTopologyBuild(items); |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 262 | } |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | // Task for building topology data in a separate thread. |
| 266 | private class TopologyBuilderTask implements Runnable { |
| 267 | private final List<Event> reasons; |
| 268 | |
| 269 | public TopologyBuilderTask(List<Event> reasons) { |
| 270 | this.reasons = reasons; |
| 271 | } |
| 272 | |
| 273 | @Override |
| 274 | public void run() { |
Thomas Vachuska | 0e752bd | 2014-10-22 22:33:41 -0700 | [diff] [blame] | 275 | try { |
| 276 | buildTopology(reasons); |
| 277 | } catch (Exception e) { |
Thomas Vachuska | 320c58f | 2015-08-05 10:42:32 -0700 | [diff] [blame] | 278 | log.warn("Unable to compute topology", e); |
Thomas Vachuska | 0e752bd | 2014-10-22 22:33:41 -0700 | [diff] [blame] | 279 | } |
tom | cbff939 | 2014-09-10 00:45:23 -0700 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
| 283 | } |