summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-04-07 22:18:59 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-04-19 01:20:26 +0000
commit73ccfd414207018f891eaaa3f36aff95e4b18b5a (patch)
tree2b543292dfd7d825fdc11accae5acd468f731e44 /appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src
parenta8d6915645c780c9e0eef189fb72d45635b581a0 (diff)
Parameterize raw generic type QueueMessage<M>
Change-Id: Ib6de8d2f0c62bf7a5564b4e104c9384b7b6debce Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src')
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceImpl.java5
-rw-r--r--appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/QueueManager.java10
2 files changed, 6 insertions, 9 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceImpl.java b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
index c2be1b4ac..2ac383696 100644
--- a/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
+++ b/appc-dispatcher/appc-dispatcher-common/execution-queue-management-lib/src/main/java/org/openecomp/appc/executionqueue/impl/ExecutionQueueServiceImpl.java
@@ -48,13 +48,10 @@ public class ExecutionQueueServiceImpl<M extends Runnable> implements ExecutionQ
@Override
public void putMessage(M message, long timeout, TimeUnit unit) throws APPCException{
- QueueMessage queueMessage = null;
-
try {
Date expirationTime = calculateExpirationTime(timeout,unit);
- queueMessage = new QueueMessage(message,expirationTime);
QueueManager queueManager = QueueManager.getInstance();
- boolean enqueueTask = queueManager.enqueueTask(queueMessage);
+ boolean enqueueTask = queueManager.enqueueTask(new QueueMessage<M>(message,expirationTime));
if(!enqueueTask){
throw new APPCException("failed to put message in queue");
}
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 2d4907fa1..cf625b4d5 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
@@ -33,7 +33,7 @@ import com.att.eelf.configuration.EELFManager;
public class QueueManager {
- private LinkedBlockingQueue<QueueMessage> queue;
+ private LinkedBlockingQueue<QueueMessage<? extends Runnable>> queue;
private MessageExpirationListener listener;
@@ -59,7 +59,7 @@ public class QueueManager {
}
private void init(){
- queue = new LinkedBlockingQueue(MAX_QUEUE_SIZE);
+ queue = new LinkedBlockingQueue<QueueMessage<? extends Runnable>>(MAX_QUEUE_SIZE);
messageExecutor = Executors.newFixedThreadPool(MAX_THREAD_SIZE,Util.getThreadFactory(true));
for(int i=0;i<MAX_THREAD_SIZE;i++){
@@ -68,7 +68,7 @@ public class QueueManager {
public void run() {
while (true){
try{
- QueueMessage queueMessage = queue.take();
+ QueueMessage<? extends Runnable> queueMessage = queue.take();
if(messageExpired(queueMessage)){
logger.debug("Message expired "+ queueMessage.getMessage());
if(listener != null){
@@ -94,11 +94,11 @@ public class QueueManager {
this.listener = listener;
}
- public boolean enqueueTask(QueueMessage queueMessage) {
+ public boolean enqueueTask(QueueMessage<? extends Runnable> queueMessage) {
return queue.offer(queueMessage);
}
- private boolean messageExpired(QueueMessage queueMessage) {
+ private boolean messageExpired(QueueMessage<? extends Runnable> queueMessage) {
if(queueMessage.getExpirationTime() != null){
return queueMessage.getExpirationTime().getTime() < System.currentTimeMillis();
}