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.List;
12 import java.util.concurrent.ConcurrentHashMap;
13 import java.util.concurrent.ConcurrentMap;
14 import java.util.concurrent.ExecutionException;
15 import java.util.concurrent.Future;
17 import org.opendaylight.controller.md.statistics.manager.MultipartMessageManager.StatsRequestType;
18 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
19 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
20 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
21 import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
22 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
23 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
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.getTargetNodeKey());
243 private void sendStatisticsRequestsToNode(NodeKey targetNode){
245 spLogger.debug("Send requests for statistics collection to node : {})",targetNode.getId());
247 InstanceIdentifier<Node> targetInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class,targetNode).toInstance();
249 NodeRef targetNodeRef = new NodeRef(targetInstanceId);
252 if(flowStatsService != null){
253 sendAggregateFlowsStatsFromAllTablesRequest(targetNode);
254 sendAllFlowsStatsFromAllTablesRequest(targetNodeRef);
256 if(flowTableStatsService != null){
257 sendAllFlowTablesStatisticsRequest(targetNodeRef);
259 if(portStatsService != null){
260 sendAllNodeConnectorsStatisticsRequest(targetNodeRef);
262 if(groupStatsService != null){
263 sendAllGroupStatisticsRequest(targetNodeRef);
264 sendGroupDescriptionRequest(targetNodeRef);
266 if(meterStatsService != null){
267 sendAllMeterStatisticsRequest(targetNodeRef);
268 sendMeterConfigStatisticsRequest(targetNodeRef);
270 if(queueStatsService != null){
271 sendAllQueueStatsFromAllNodeConnector (targetNodeRef);
274 spLogger.error("Exception occured while sending statistics requests : {}", e);
279 private void sendAllFlowTablesStatisticsRequest(NodeRef targetNodeRef) throws InterruptedException, ExecutionException {
280 final GetFlowTablesStatisticsInputBuilder input =
281 new GetFlowTablesStatisticsInputBuilder();
283 input.setNode(targetNodeRef);
285 Future<RpcResult<GetFlowTablesStatisticsOutput>> response =
286 flowTableStatsService.getFlowTablesStatistics(input.build());
288 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNodeRef),response.get().getResult().getTransactionId()
289 , StatsRequestType.ALL_FLOW_TABLE);
293 private void sendAllFlowsStatsFromAllTablesRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
294 final GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
295 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
297 input.setNode(targetNode);
299 Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> response =
300 flowStatsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
302 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
303 , StatsRequestType.ALL_FLOW);
307 public void sendFlowStatsFromTableRequest(NodeRef targetNode,Flow flow) throws InterruptedException, ExecutionException{
308 final GetFlowStatisticsFromFlowTableInputBuilder input =
309 new GetFlowStatisticsFromFlowTableInputBuilder();
311 input.setNode(targetNode);
312 input.fieldsFrom(flow);
314 Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> response =
315 flowStatsService.getFlowStatisticsFromFlowTable(input.build());
317 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
318 , StatsRequestType.ALL_FLOW);
322 private void sendAggregateFlowsStatsFromAllTablesRequest(final NodeKey nodeKey) throws InterruptedException, ExecutionException{
323 FlowCapableNode node = (FlowCapableNode)dps.readOperationalData(
324 InstanceIdentifier.builder(Nodes.class).child(Node.class,nodeKey).augmentation(FlowCapableNode.class).build());
326 final List<Table> tables = node.getTable();
327 if (tables != null) {
328 spLogger.debug("Node {} supports {} table(s)", nodeKey, tables.size());
329 for(Table table : tables) {
330 sendAggregateFlowsStatsFromTableRequest(nodeKey, table.getId());
333 spLogger.debug("Node {} has no associated tables", nodeKey);
336 spLogger.debug("Node {} not found", nodeKey);
340 private void sendAggregateFlowsStatsFromTableRequest(NodeKey targetNodeKey,Short tableId) throws InterruptedException, ExecutionException{
342 spLogger.debug("Send aggregate stats request for flow table {} to node {}",tableId,targetNodeKey);
343 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
344 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
346 input.setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, targetNodeKey).toInstance()));
347 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId(tableId));
348 Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> response =
349 flowStatsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
351 multipartMessageManager.setTxIdAndTableIdMapEntry(targetNodeKey.getId(), response.get().getResult().getTransactionId(), tableId);
352 this.multipartMessageManager.addTxIdToRequestTypeEntry(targetNodeKey.getId(), response.get().getResult().getTransactionId()
353 , StatsRequestType.AGGR_FLOW);
356 private void sendAllNodeConnectorsStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
358 final GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
360 input.setNode(targetNode);
362 Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> response =
363 portStatsService.getAllNodeConnectorsStatistics(input.build());
364 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
365 , StatsRequestType.ALL_PORT);
369 private void sendAllGroupStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
371 final GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
373 input.setNode(targetNode);
375 Future<RpcResult<GetAllGroupStatisticsOutput>> response =
376 groupStatsService.getAllGroupStatistics(input.build());
378 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
379 , StatsRequestType.ALL_GROUP);
383 public void sendGroupDescriptionRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
384 final GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
386 input.setNode(targetNode);
388 Future<RpcResult<GetGroupDescriptionOutput>> response =
389 groupStatsService.getGroupDescription(input.build());
391 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
392 , StatsRequestType.GROUP_DESC);
396 private void sendAllMeterStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
398 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
400 input.setNode(targetNode);
402 Future<RpcResult<GetAllMeterStatisticsOutput>> response =
403 meterStatsService.getAllMeterStatistics(input.build());
405 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
406 , StatsRequestType.ALL_METER);;
410 public void sendMeterConfigStatisticsRequest(NodeRef targetNode) throws InterruptedException, ExecutionException{
412 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
414 input.setNode(targetNode);
416 Future<RpcResult<GetAllMeterConfigStatisticsOutput>> response =
417 meterStatsService.getAllMeterConfigStatistics(input.build());
419 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
420 , StatsRequestType.METER_CONFIG);;
424 private void sendAllQueueStatsFromAllNodeConnector(NodeRef targetNode) throws InterruptedException, ExecutionException {
425 GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder();
427 input.setNode(targetNode);
429 Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> response =
430 queueStatsService.getAllQueuesStatisticsFromAllPorts(input.build());
432 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
433 , StatsRequestType.ALL_QUEUE_STATS);;
437 public void sendQueueStatsFromGivenNodeConnector(NodeRef targetNode,NodeConnectorId nodeConnectorId, QueueId queueId) throws InterruptedException, ExecutionException {
438 GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder();
440 input.setNode(targetNode);
441 input.setNodeConnectorId(nodeConnectorId);
442 input.setQueueId(queueId);
443 Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> response =
444 queueStatsService.getQueueStatisticsFromGivenPort(input.build());
446 this.multipartMessageManager.addTxIdToRequestTypeEntry(getNodeId(targetNode), response.get().getResult().getTransactionId()
447 , StatsRequestType.ALL_QUEUE_STATS);;
452 * Get the handler for a particular node.
454 * @param nodeId source node
455 * @return Node statistics handler for that node. Null if the statistics should
458 public final NodeStatisticsHandler getStatisticsHandler(final NodeId nodeId) {
459 Preconditions.checkNotNull(nodeId);
460 NodeStatisticsHandler handler = handlers.get(nodeId);
461 if (handler == null) {
462 spLogger.info("Attempted to get non-existing handler for {}", nodeId);
467 @SuppressWarnings("unchecked")
468 private NodeId getNodeId(NodeRef nodeRef){
469 InstanceIdentifier<Node> nodeII = (InstanceIdentifier<Node>) nodeRef.getValue();
470 NodeKey nodeKey = InstanceIdentifier.keyOf(nodeII);
471 return nodeKey.getId();
475 public void close() {
477 if (this.listenerRegistration != null) {
478 this.listenerRegistration.close();
479 this.statisticsRequesterThread.destroy();
480 this.statisticsAgerThread.destroy();
482 if (this.flowCapableTrackerRegistration != null) {
483 this.flowCapableTrackerRegistration.close();
484 this.flowCapableTrackerRegistration = null;
486 } catch (Exception e) {
487 spLogger.warn("Failed to stop Statistics Provider completely", e);
489 spLogger.info("Statistics Provider stopped.");
493 synchronized void startNodeHandlers(final Collection<NodeKey> addedNodes) {
494 for (NodeKey key : addedNodes) {
495 if (handlers.containsKey(key.getId())) {
496 spLogger.warn("Attempted to start already-existing handler for {}, very strange", key.getId());
500 final NodeStatisticsHandler h = new NodeStatisticsHandler(this, key);
501 handlers.put(key.getId(), h);
502 spLogger.debug("Started node handler for {}", key.getId());
504 // FIXME: this should be in the NodeStatisticsHandler itself
505 sendStatisticsRequestsToNode(key);
509 synchronized void stopNodeHandlers(final Collection<NodeKey> removedNodes) {
510 for (NodeKey key : removedNodes) {
511 final NodeStatisticsHandler s = handlers.remove(key.getId());
513 spLogger.debug("Stopping node handler for {}", key.getId());
516 spLogger.warn("Attempted to remove non-existing handler for {}, very strange", key.getId());