import org.opendaylight.openflowplugin.applications.statistics.manager.StatNodeRegistration;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatNotifyCommiter;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatRpcMsgManager;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation.StatsManagerOperationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
*/
public class StatisticsManagerImpl implements StatisticsManager, Runnable {
- private final static Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(StatisticsManagerImpl.class);
private static final int QUEUE_DEPTH = 5000;
private static final int MAX_BATCH = 100;
LOG.info("Statistics Manager started successfully!");
}
+ private <T extends AutoCloseable> T close(final T closeable) throws Exception {
+ if (closeable != null) {
+ closeable.close();
+ }
+ return null;
+ }
+
@Override
public void close() throws Exception {
LOG.info("StatisticsManager close called");
finishing = true;
- if (nodeRegistrator != null) {
- nodeRegistrator.close();
- nodeRegistrator = null;
- }
- if (flowListeningCommiter != null) {
- flowListeningCommiter.close();
- flowListeningCommiter = null;
- }
- if (meterListeningCommiter != null) {
- meterListeningCommiter.close();
- meterListeningCommiter = null;
- }
- if (groupListeningCommiter != null) {
- groupListeningCommiter.close();
- groupListeningCommiter = null;
- }
- if (tableNotifCommiter != null) {
- tableNotifCommiter.close();
- tableNotifCommiter = null;
- }
- if (portNotifyCommiter != null) {
- portNotifyCommiter.close();
- portNotifyCommiter = null;
- }
- if (queueNotifyCommiter != null) {
- queueNotifyCommiter.close();
- queueNotifyCommiter = null;
- }
+ nodeRegistrator = close(nodeRegistrator);
+ flowListeningCommiter = close(flowListeningCommiter);
+ meterListeningCommiter = close(meterListeningCommiter);
+ groupListeningCommiter = close(groupListeningCommiter);
+ tableNotifCommiter = close(tableNotifCommiter);
+ portNotifyCommiter = close(portNotifyCommiter);
+ queueNotifyCommiter = close(queueNotifyCommiter);
if (statCollectors != null) {
for (StatPermCollector collector : statCollectors) {
- collector.close();
- collector = null;
+ collector = close(collector);
}
statCollectors = null;
}
- if (rpcMsgManager != null) {
- rpcMsgManager.close();
- rpcMsgManager = null;
- }
+ rpcMsgManager = close(rpcMsgManager);
statRpcMsgManagerExecutor.shutdown();
statDataStoreOperationServ.shutdown();
- if (txChain != null) {
- txChain.close();
- txChain = null;
- }
+ txChain = close(txChain);
}
@Override
try {
LOG.debug("Node {} disconnected. Cleaning internal data.",op.getNodeId());
op.applyOperation(null);
- } catch (final Exception ex) {
- LOG.warn("Unhandled exception while cleaning up internal data of node [{}]",op.getNodeId());
+ } catch (final Exception e) {
+ LOG.warn("Unhandled exception while cleaning up internal data of node [{}]. "
+ + "Exception {}",op.getNodeId(), e);
}
}
}