2 * Copyright IBM Corporation, 2013. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.statistics.manager;
10 import java.util.Collection;
11 import java.util.concurrent.ConcurrentHashMap;
12 import java.util.concurrent.ConcurrentMap;
13 import java.util.concurrent.ExecutionException;
14 import java.util.concurrent.Future;
16 import org.opendaylight.controller.md.statistics.manager.MultipartMessageManager.StatsRequestType;
17 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
18 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
19 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
20 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
21 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
22 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
67 import org.opendaylight.yangtools.concepts.ListenerRegistration;
68 import org.opendaylight.yangtools.concepts.Registration;
69 import org.opendaylight.yangtools.yang.binding.DataObject;
70 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
71 import org.opendaylight.yangtools.yang.binding.NotificationListener;
72 import org.opendaylight.yangtools.yang.common.RpcResult;
73 import org.slf4j.Logger;
74 import org.slf4j.LoggerFactory;
76 import com.google.common.base.Preconditions;
79 * Following are main responsibilities of the class:
80 * 1) Invoke statistics request thread to send periodic statistics request to all the
81 * flow capable switch connected to the controller. It sends statistics request for
82 * Group,Meter,Table,Flow,Queue,Aggregate stats.
84 * 2) Invoke statistics ager thread, to clean up all the stale statistics data from
85 * operational data store.
87 * @author avishnoi@in.ibm.com
90 public class StatisticsProvider implements AutoCloseable {
91 public static final int STATS_THREAD_EXECUTION_TIME= 15000;
93 private static final Logger spLogger = LoggerFactory.getLogger(StatisticsProvider.class);
95 private final MultipartMessageManager multipartMessageManager = new MultipartMessageManager();
96 private final DataProviderService dps;
98 //Local caching of stats
99 private final ConcurrentMap<NodeId, NodeStatisticsHandler> handlers = new ConcurrentHashMap<>();
101 private OpendaylightGroupStatisticsService groupStatsService;
103 private OpendaylightMeterStatisticsService meterStatsService;
105 private OpendaylightFlowStatisticsService flowStatsService;
107 private OpendaylightPortStatisticsService portStatsService;
109 private OpendaylightFlowTableStatisticsService flowTableStatsService;
111 private OpendaylightQueueStatisticsService queueStatsService;
113 private StatisticsUpdateHandler statsUpdateHandler;
115 private Thread statisticsRequesterThread;
117 private Thread statisticsAgerThread;
120 public StatisticsProvider(final DataProviderService dataService) {
121 this.dps = Preconditions.checkNotNull(dataService);
124 public MultipartMessageManager getMultipartMessageManager() {
125 return multipartMessageManager;
128 private final StatisticsListener updateCommiter = new StatisticsListener(StatisticsProvider.this);
130 private Registration<NotificationListener> listenerRegistration;
132 private ListenerRegistration<DataChangeListener> flowCapableTrackerRegistration;
134 public void start(final DataBrokerService dbs, final NotificationProviderService nps, final RpcConsumerRegistry rpcRegistry) {
136 // Get Group/Meter statistics service instances
137 groupStatsService = rpcRegistry.getRpcService(OpendaylightGroupStatisticsService.class);
138 meterStatsService = rpcRegistry.getRpcService(OpendaylightMeterStatisticsService.class);
139 flowStatsService = rpcRegistry.getRpcService(OpendaylightFlowStatisticsService.class);
140 portStatsService = rpcRegistry.getRpcService(OpendaylightPortStatisticsService.class);
141 flowTableStatsService = rpcRegistry.getRpcService(OpendaylightFlowTableStatisticsService.class);
142 queueStatsService = rpcRegistry.getRpcService(OpendaylightQueueStatisticsService.class);
144 // Start receiving notifications
145 this.listenerRegistration = nps.registerNotificationListener(this.updateCommiter);
147 // Register for switch connect/disconnect notifications
148 final InstanceIdentifier<FlowCapableNode> fcnId = InstanceIdentifier.builder(Nodes.class)
149 .child(Node.class).augmentation(FlowCapableNode.class).build();
150 this.flowCapableTrackerRegistration = dbs.registerDataChangeListener(fcnId,
151 new FlowCapableTracker(this, fcnId));
153 statsUpdateHandler = new StatisticsUpdateHandler(StatisticsProvider.this);
154 registerDataStoreUpdateListener(dbs);
156 statisticsRequesterThread = new Thread( new Runnable(){
162 statsRequestSender();
164 Thread.sleep(STATS_THREAD_EXECUTION_TIME);
165 }catch (Exception e){
166 spLogger.error("Exception occurred while sending stats request : {}",e);
172 spLogger.debug("Statistics requester thread started with timer interval : {}",STATS_THREAD_EXECUTION_TIME);
174 statisticsRequesterThread.start();
176 statisticsAgerThread = new Thread( new Runnable(){
182 for(NodeStatisticsHandler nodeStatisticsAger : handlers.values()){
183 nodeStatisticsAger.cleanStaleStatistics();
185 multipartMessageManager.cleanStaleTransactionIds();
187 Thread.sleep(STATS_THREAD_EXECUTION_TIME);
188 }catch (Exception e){
189 spLogger.error("Exception occurred while sending stats request : {}",e);
195 spLogger.debug("Statistics ager thread started with timer interval : {}",STATS_THREAD_EXECUTION_TIME);
197 statisticsAgerThread.start();
199 spLogger.info("Statistics Provider started.");
202 private void registerDataStoreUpdateListener(DataBrokerService dbs) {
203 // FIXME: the below should be broken out into StatisticsUpdateHandler
205 //Register for flow updates
206 InstanceIdentifier<? extends DataObject> pathFlow = InstanceIdentifier.builder(Nodes.class).child(Node.class)
207 .augmentation(FlowCapableNode.class)
209 .child(Flow.class).toInstance();
210 dbs.registerDataChangeListener(pathFlow, statsUpdateHandler);
212 //Register for meter updates
213 InstanceIdentifier<? extends DataObject> pathMeter = InstanceIdentifier.builder(Nodes.class).child(Node.class)
214 .augmentation(FlowCapableNode.class)
215 .child(Meter.class).toInstance();
217 dbs.registerDataChangeListener(pathMeter, statsUpdateHandler);
219 //Register for group updates
220 InstanceIdentifier<? extends DataObject> pathGroup = InstanceIdentifier.builder(Nodes.class).child(Node.class)
221 .augmentation(FlowCapableNode.class)
222 .child(Group.class).toInstance();
223 dbs.registerDataChangeListener(pathGroup, statsUpdateHandler);
225 //Register for queue updates
226 InstanceIdentifier<? extends DataObject> pathQueue = InstanceIdentifier.builder(Nodes.class).child(Node.class)
227 .child(NodeConnector.class)
228 .augmentation(FlowCapableNodeConnector.class)
229 .child(Queue.class).toInstance();
230 dbs.registerDataChangeListener(pathQueue, statsUpdateHandler);
233 protected DataModificationTransaction startChange() {
234 return dps.beginTransaction();
237 private void statsRequestSender() {
238 for (NodeStatisticsHandler h : handlers.values()) {
239 sendStatisticsRequestsToNode(h);
243 private void sendStatisticsRequestsToNode(NodeStatisticsHandler h) {
244 NodeKey targetNode = h.getTargetNodeKey();
245 spLogger.debug("Send requests for statistics collection to node : {}", targetNode.getId());
247 InstanceIdentifier<Node> targetInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNode).build();
249 NodeRef targetNodeRef = new NodeRef(targetInstanceId);
252 if(flowTableStatsService != null){
253 sendAllFlowTablesStatisticsRequest(targetNodeRef);
255 if(flowStatsService != null){
256 // FIXME: it does not make sense to trigger this before sendAllFlowTablesStatisticsRequest()
257 // comes back -- we do not have any tables anyway.
258 sendAggregateFlowsStatsFromAllTablesRequest(h);
260 sendAllFlowsStatsFromAllTablesRequest(targetNodeRef);
262 if(portStatsService != null){
263 sendAllNodeConnectorsStatisticsRequest(targetNodeRef);
265 if(groupStatsService != null){
266 sendAllGroupStatisticsRequest(targetNodeRef);
267 sendGroupDescriptionRequest(targetNodeRef);
269 if(meterStatsService != null){
270 sendAllMeterStatisticsRequest(targetNodeRef);
271 sendMeterConfigStatisticsRequest(targetNodeRef);
273 if(queueStatsService != null){
274 sendAllQueueStatsFromAllNodeConnector(targetNodeRef);
277 spLogger.error("Exception occured while sending statistics requests : {}", e);
282 private void sendAllFlowTablesStatisticsRequest(NodeRef targetNodeRef) throws InterruptedException, ExecutionException {
283 final GetFlowTablesStatisticsInputBuilder input =
284 new GetFlowTablesStatisticsInputBuilder();
286 input.setNode(targetNodeRef);
288 Future<RpcResult<GetFlowTablesStatisticsOutput>> response =
289 flowTableStatsService.getFlowTablesStatistics(input.build());
291 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNodeRef),response.get().getResult().getTransactionId()
292 , StatsRequestType.ALL_FLOW_TABLE);
296 private void sendAllFlowsStatsFromAllTablesRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
297 final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
298 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
300 input.setNode(targetNode);
302 Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> response =
303 flowStatsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
305 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
306 , StatsRequestType.ALL_FLOW);
310 public void sendFlowStatsFromTableRequest(NodeRef targetNode,Flow flow) throws InterruptedException, ExecutionException{
311 final GetFlowStatisticsFromFlowTableInputBuilder input =
312 new GetFlowStatisticsFromFlowTableInputBuilder();
314 input.setNode(targetNode);
315 input.fieldsFrom(flow);
317 Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> response =
318 flowStatsService.getFlowStatisticsFromFlowTable(input.build());
320 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
321 , StatsRequestType.ALL_FLOW);
325 private void sendAggregateFlowsStatsFromAllTablesRequest(final NodeStatisticsHandler h) throws InterruptedException, ExecutionException{
326 final Collection<TableKey> tables = h.getKnownTables();
327 spLogger.debug("Node {} supports {} table(s)", h, tables.size());
329 for (TableKey key : h.getKnownTables()) {
330 sendAggregateFlowsStatsFromTableRequest(h.getTargetNodeKey(), key.getId().shortValue());
334 private void sendAggregateFlowsStatsFromTableRequest(NodeKey targetNodeKey,Short tableId) throws InterruptedException, ExecutionException{
336 spLogger.debug("Send aggregate stats request for flow table {} to node {}",tableId,targetNodeKey);
337 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
338 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
340 input.setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey).toInstance()));
341 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(tableId));
342 Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> response =
343 flowStatsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
345 multipartMessageManager.setTxIdAndTableIdMapEntry(targetNodeKey.getId(), response.get().getResult().getTransactionId(), tableId);
346 this.multipartMessageManager.addTxIdToRequestTypeEntry(targetNodeKey.getId(), response.get().getResult().getTransactionId()
347 , StatsRequestType.AGGR_FLOW);
350 private void sendAllNodeConnectorsStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
352 final GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
354 input.setNode(targetNode);
356 Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> response =
357 portStatsService.getAllNodeConnectorsStatistics(input.build());
358 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
359 , StatsRequestType.ALL_PORT);
363 private void sendAllGroupStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
365 final GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
367 input.setNode(targetNode);
369 Future<RpcResult<GetAllGroupStatisticsOutput>> response =
370 groupStatsService.getAllGroupStatistics(input.build());
372 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
373 , StatsRequestType.ALL_GROUP);
377 public void sendGroupDescriptionRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
378 final GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
380 input.setNode(targetNode);
382 Future<RpcResult<GetGroupDescriptionOutput>> response =
383 groupStatsService.getGroupDescription(input.build());
385 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
386 , StatsRequestType.GROUP_DESC);
390 private void sendAllMeterStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
392 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
394 input.setNode(targetNode);
396 Future<RpcResult<GetAllMeterStatisticsOutput>> response =
397 meterStatsService.getAllMeterStatistics(input.build());
399 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
400 , StatsRequestType.ALL_METER);;
404 public void sendMeterConfigStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
406 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
408 input.setNode(targetNode);
410 Future<RpcResult<GetAllMeterConfigStatisticsOutput>> response =
411 meterStatsService.getAllMeterConfigStatistics(input.build());
413 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
414 , StatsRequestType.METER_CONFIG);;
418 private void sendAllQueueStatsFromAllNodeConnector(NodeRef targetNode) throws InterruptedException, ExecutionException {
419 GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder();
421 input.setNode(targetNode);
423 Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> response =
424 queueStatsService.getAllQueuesStatisticsFromAllPorts(input.build());
426 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
427 , StatsRequestType.ALL_QUEUE_STATS);;
431 public void sendQueueStatsFromGivenNodeConnector(NodeRef targetNode,NodeConnectorId nodeConnectorId, QueueId queueId) throws InterruptedException, ExecutionException {
432 GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder();
434 input.setNode(targetNode);
435 input.setNodeConnectorId(nodeConnectorId);
436 input.setQueueId(queueId);
437 Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> response =
438 queueStatsService.getQueueStatisticsFromGivenPort(input.build());
440 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
441 , StatsRequestType.ALL_QUEUE_STATS);;
446 * Get the handler for a particular node.
448 * @param nodeId source node
449 * @return Node statistics handler for that node. Null if the statistics should
452 public final NodeStatisticsHandler getStatisticsHandler(final NodeId nodeId) {
453 Preconditions.checkNotNull(nodeId);
454 NodeStatisticsHandler handler = handlers.get(nodeId);
455 if (handler == null) {
456 spLogger.info("Attempted to get non-existing handler for {}", nodeId);
461 @SuppressWarnings("unchecked")
462 private NodeId getNodeId(NodeRef nodeRef){
463 InstanceIdentifier<Node> nodeII = (InstanceIdentifier<Node>) nodeRef.getValue();
464 NodeKey nodeKey = InstanceIdentifier.keyOf(nodeII);
465 return nodeKey.getId();
469 public void close() {
471 if (this.listenerRegistration != null) {
472 this.listenerRegistration.close();
473 this.statisticsRequesterThread.destroy();
474 this.statisticsAgerThread.destroy();
476 if (this.flowCapableTrackerRegistration != null) {
477 this.flowCapableTrackerRegistration.close();
478 this.flowCapableTrackerRegistration = null;
480 } catch (Exception e) {
481 spLogger.warn("Failed to stop Statistics Provider completely", e);
483 spLogger.info("Statistics Provider stopped.");
487 synchronized void startNodeHandlers(final Collection<NodeKey> addedNodes) {
488 for (NodeKey key : addedNodes) {
489 if (handlers.containsKey(key.getId())) {
490 spLogger.warn("Attempted to start already-existing handler for {}, very strange", key.getId());
494 final NodeStatisticsHandler h = new NodeStatisticsHandler(this, key);
495 handlers.put(key.getId(), h);
496 spLogger.debug("Started node handler for {}", key.getId());
498 // FIXME: this should be in the NodeStatisticsHandler itself
499 sendStatisticsRequestsToNode(h);
503 synchronized void stopNodeHandlers(final Collection<NodeKey> removedNodes) {
504 for (NodeKey key : removedNodes) {
505 final NodeStatisticsHandler s = handlers.remove(key.getId());
507 spLogger.debug("Stopping node handler for {}", key.getId());
510 spLogger.warn("Attempted to remove non-existing handler for {}, very strange", key.getId());