diff options
author | Hao Kuang <Hao.Kuang@amdocs.com> | 2017-08-25 16:15:26 +0000 |
---|---|---|
committer | Skip Wonnell <skip@att.com> | 2017-08-28 20:29:58 +0000 |
commit | d0bcf2eca3ff91fa69b20aabc8b6c57b789fb0ff (patch) | |
tree | 103fbe43b3e3fc3929dac16e49d986f09ebade5c /appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib | |
parent | 8c5324203efa73fdd6e00e52e92cf1f1bc3910f4 (diff) |
Fix that APP-C LCM Command Running After OAM Stop
The fix code does that waiting for threads in the queue completely
interrupted than let bundle:stop() method return.
Issue-Id: APPC-162
Change-Id: I8b34fc48fd2ae5ae1ad67d11ee3ad5f349171b47
Signed-off-by: Hao Kuang <Hao.Kuang@amdocs.com>
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib')
-rw-r--r-- | appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java index b78f399e0..9e1efb644 100644 --- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java +++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java @@ -30,6 +30,7 @@ import org.openecomp.appc.executionqueue.MessageExpirationListener; import org.openecomp.appc.executionqueue.helper.Util; import org.openecomp.appc.executionqueue.impl.object.QueueMessage; +import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; @@ -70,7 +71,23 @@ public class QueueManager { * Destory method used by blueprint */ public void stop() { - messageExecutor.shutdownNow(); + // Disable new tasks from being submitted + messageExecutor.shutdown(); + List<Runnable> rejectedRunnables = messageExecutor.shutdownNow(); + logger.info(String.format("Rejected %d waiting tasks include ", rejectedRunnables.size())); + + try { + messageExecutor.shutdownNow(); // Cancel currently executing tasks + // Wait a while for tasks to respond to being cancelled + while (!messageExecutor.awaitTermination(100, TimeUnit.MILLISECONDS)) { + logger.debug("QueueManager is being shut down because it still has threads not interrupted"); + } + } catch (InterruptedException ie) { + // (Re-)Cancel if current thread also interrupted + messageExecutor.shutdownNow(); + // Preserve interrupt status + Thread.currentThread().interrupt(); + } } public void setListener(MessageExpirationListener listener) { |