From be752d30c939d6d9ea266b5cdeb2fb4d110d1b31 Mon Sep 17 00:00:00 2001 From: Jakub Dudycz Date: Thu, 25 Jan 2018 18:22:46 +0100 Subject: [PATCH] TaskQueueManager fixes Change-Id: I246683edabbd851125fc47772be203c2c7482a9c Issue-ID: APPC-528 Signed-off-by: Jakub Dudycz --- .../appc/client/impl/core/TaskQueueManager.java | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/core/TaskQueueManager.java b/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/core/TaskQueueManager.java index b87349411..d0314c81d 100644 --- a/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/core/TaskQueueManager.java +++ b/appc-client/client-lib/src/main/java/org/onap/appc/client/impl/core/TaskQueueManager.java @@ -26,34 +26,35 @@ package org.onap.appc.client.impl.core; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - import java.util.List; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -/** Creates a task queue pool that reuses a fixed number of threads. - * Assigns one thread for each queue. +/** + * Creates a task queue pool that reuses a fixed number of threads. Assigns one thread for each queue. */ class TaskQueueManager { - private final EELFLogger LOG = EELFManager.getInstance().getLogger(TaskQueueManager.class); + + private static final EELFLogger LOG = EELFManager.getInstance().getLogger(TaskQueueManager.class); + private static final String DEFAULT_POOL_SIZE = "10"; + private static final String CLIENT_POOL_SIZE = "client.pool.size"; + private ExecutorService executorService; - private final static String DEFAULT_POOL_SIZE = "10"; - private final static String CLIENT_POOL_SIZE = "client.pool.size"; private TaskQueue[] queues; private int poolInt; - TaskQueueManager(Properties properties){ + TaskQueueManager(Properties properties) { String size = properties.getProperty(CLIENT_POOL_SIZE, DEFAULT_POOL_SIZE); poolInt = Integer.parseInt(size); this.executorService = Executors.newFixedThreadPool(poolInt); initTaskQueues(); } - private void initTaskQueues(){ + private void initTaskQueues() { queues = new TaskQueue[poolInt]; - for(int i=0; i { + // wake up the queue for stopping thread }); } List listTask = executorService.shutdownNow(); - if (!executorService.awaitTermination(6, TimeUnit.SECONDS)) - System.err.println("Pool did not terminate"); + if (!executorService.awaitTermination(6, TimeUnit.SECONDS)) { + LOG.error("Pool did not terminate"); + } LOG.info("the amount of tasks that never commenced execution " + listTask.size()); } } -- 2.16.6