properly reallocate thread pools after a restart
Change-Id: I08042acd75ebcb3ca16af189917c1fe6904f3afd
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java
index 4294f6e..04c6ecf 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/ECFlowRuleStore.java
@@ -179,11 +179,8 @@
private ExecutorService messageHandlingExecutor;
private ExecutorService eventHandler;
- private final ScheduledExecutorService backupScheduler = Executors.newSingleThreadScheduledExecutor(
- groupedThreads("onos/flow", "backup-scheduler", log));
- private final ExecutorService backupExecutor = Executors.newFixedThreadPool(
- max(min(Runtime.getRuntime().availableProcessors() * 2, 16), 4),
- groupedThreads("onos/flow", "backup-%d", log));
+ private ScheduledExecutorService backupScheduler;
+ private ExecutorService backupExecutor;
private EventuallyConsistentMap<DeviceId, List<TableStatisticsEntry>> deviceTableStats;
private final EventuallyConsistentMapListener<DeviceId, List<TableStatisticsEntry>> tableStatsListener =
@@ -213,6 +210,12 @@
public void activate(ComponentContext context) {
configService.registerProperties(getClass());
+ backupScheduler = Executors.newSingleThreadScheduledExecutor(
+ groupedThreads("onos/flow", "backup-scheduler", log));
+ backupExecutor = Executors.newFixedThreadPool(
+ max(min(Runtime.getRuntime().availableProcessors() * 2, 16), 4),
+ groupedThreads("onos/flow", "backup-%d", log));
+
idGenerator = coreService.getIdGenerator(FlowRuleService.FLOW_OP_TOPIC);
local = clusterService.getLocalNode().id();
@@ -255,6 +258,8 @@
messageHandlingExecutor.shutdownNow();
backupScheduler.shutdownNow();
backupExecutor.shutdownNow();
+ backupScheduler = null;
+ backupExecutor = null;
log.info("Stopped");
}