properly reallocate thread pools after a restart

Change-Id: I08042acd75ebcb3ca16af189917c1fe6904f3afd
This commit is contained in:
Ray Milkey 2019-04-02 09:12:00 -07:00
parent 4910c4b676
commit d1092d6583

View File

@ -179,11 +179,8 @@ public class ECFlowRuleStore
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 class ECFlowRuleStore
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 @@ public class ECFlowRuleStore
messageHandlingExecutor.shutdownNow();
backupScheduler.shutdownNow();
backupExecutor.shutdownNow();
backupScheduler = null;
backupExecutor = null;
log.info("Stopped");
}