diff options
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp')
4 files changed, 66 insertions, 29 deletions
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java index 55499d75d..5054d34c7 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java @@ -34,6 +34,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang.ObjectUtils; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; +import org.openecomp.appc.domainmodel.lcm.ActionLevel; import org.openecomp.appc.exceptions.APPCException; import org.openecomp.appc.executionqueue.ExecutionQueueService; import org.openecomp.appc.executionqueue.impl.ExecutionQueueServiceFactory; @@ -96,22 +97,6 @@ public class CommandExecutorImpl implements CommandExecutor { } RuntimeContext commandRequest; commandRequest = commandExecutorInput; - /* - CommandRequest commandRequest; - - switch(commandExecutorInput.getRequestContext().getAction()){ - case Sync: - case Audit: - case ConfigBackup: - case ConfigBackupDelete: - case ConfigExport: - commandRequest = new LCMReadOnlyCommandRequest(commandExecutorInput); - break; - default: - commandRequest = new LCMCommandRequest(commandExecutorInput); - break; - } - */ if (logger.isTraceEnabled()) { logger.trace("Exiting from getCommandRequest with (CommandRequest = "+ ObjectUtils.toString(commandRequest)+")"); } @@ -125,7 +110,7 @@ public class CommandExecutorImpl implements CommandExecutor { } try { String action = request.getRequestContext().getAction().name(); - CommandTask commandTask = executionTaskFactory.getExecutionTask(action, request); + CommandTask commandTask = executionTaskFactory.getExecutionTask(request); long remainingTTL = getRemainingTTL(request); executionQueueService.putMessage(commandTask,remainingTTL, TimeUnit.MILLISECONDS); } catch (Exception e) { @@ -144,5 +129,16 @@ public class CommandExecutorImpl implements CommandExecutor { return ChronoUnit.MILLIS.between(Instant.now(), requestTimestamp.plusSeconds(ttl)); } + private CommandTask getMessageExecutor(RuntimeContext request){ + if (logger.isTraceEnabled()) { + logger.trace("Entering to getMessageExecutor with command = "+ request); + } + CommandTask executionTask = executionTaskFactory.getExecutionTask(request); + if (logger.isTraceEnabled()) { + logger.trace("Exiting from getMessageExecutor"); + } + return executionTask; + } + } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java index 571f51ed9..c5590f961 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java @@ -25,6 +25,7 @@ package org.openecomp.appc.executor.impl; +import org.openecomp.appc.domainmodel.lcm.ActionLevel; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.domainmodel.lcm.VNFOperation; import org.openecomp.appc.lifecyclemanager.LifecycleManager; @@ -35,7 +36,12 @@ import org.openecomp.appc.workflow.WorkFlowManager; public class CommandTaskFactory { - private RequestHandler requestHandler; + +// private LCMCommandTask lcmCommandTask; +// private LCMReadonlyCommandTask LCMReadonlyCommandTask; + + private RequestHandler vnfRequestHandler; + private RequestHandler vmRequestHandler; private WorkFlowManager workflowManager; private LifecycleManager lifecyclemanager; @@ -44,8 +50,12 @@ public class CommandTaskFactory { this.workflowManager = workflowManager; } - public void setRequestHandler(RequestHandler requestHandler) { - this.requestHandler = requestHandler; + public void setVnfRequestHandler(RequestHandler vnfRequestHandler) { + this.vnfRequestHandler = vnfRequestHandler; + } + + public void setVmRequestHandler(RequestHandler vmRequestHandler) { + this.vmRequestHandler = vmRequestHandler; } public void setLifecyclemanager(LifecycleManager lifecyclemanager) { @@ -53,14 +63,30 @@ public class CommandTaskFactory { } - public synchronized CommandTask getExecutionTask(String action, RuntimeContext commandRequest){ - if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action) || VNFOperation.ConfigBackup.toString().equals(action) || - VNFOperation.ConfigBackupDelete.toString().equals(action) || VNFOperation.ConfigExport.toString().equals(action)){ - return new LCMReadonlyCommandTask(commandRequest, requestHandler,workflowManager); + public synchronized CommandTask getExecutionTask(RuntimeContext runtimeContext){ + String action = runtimeContext.getRequestContext().getAction().name(); + ActionLevel actionLevel = runtimeContext.getRequestContext().getActionLevel(); + RequestHandler requestHandler = readRequestHandler(actionLevel); + if(ActionLevel.VM.equals(actionLevel)){ + return new LCMReadonlyCommandTask(runtimeContext,requestHandler,workflowManager); + } + if (VNFOperation.Sync.toString().equals(action) || + VNFOperation.Audit.toString().equals(action) || + VNFOperation.ConfigBackup.toString().equals(action) || + VNFOperation.ConfigBackupDelete.toString().equals(action) || + VNFOperation.ConfigExport.toString().equals(action)){ + return new LCMReadonlyCommandTask(runtimeContext,requestHandler,workflowManager); }else { - return new LCMCommandTask(commandRequest, requestHandler,workflowManager, + return new LCMCommandTask(runtimeContext,requestHandler,workflowManager, lifecyclemanager); } } + private RequestHandler readRequestHandler(ActionLevel actionLevel) { + if (ActionLevel.VM.equals(actionLevel)) { + return vmRequestHandler; + } + return vnfRequestHandler; + } + } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/ExpiredMessageHandler.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/ExpiredMessageHandler.java index 46a15f1da..7aa4cd167 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/ExpiredMessageHandler.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/ExpiredMessageHandler.java @@ -25,24 +25,39 @@ package org.openecomp.appc.executor.impl; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; +import org.openecomp.appc.domainmodel.lcm.ActionLevel; import org.openecomp.appc.executionqueue.MessageExpirationListener; import org.openecomp.appc.requesthandler.RequestHandler; public class ExpiredMessageHandler<M> implements MessageExpirationListener<M>{ - private RequestHandler requestHandler; + private RequestHandler vnfRequestHandler; + + private RequestHandler vmRequestHandler; public ExpiredMessageHandler(){ } - public void setRequestHandler(RequestHandler requestHandler) { - this.requestHandler = requestHandler; + public void setVnfRequestHandler(RequestHandler vnfRequestHandler) { + this.vnfRequestHandler = vnfRequestHandler; + } + + public void setVmRequestHandler(RequestHandler vmRequestHandler) { + this.vmRequestHandler = vmRequestHandler; } @Override public void onMessageExpiration(M message) { RuntimeContext commandRequest = (RuntimeContext)message; + RequestHandler requestHandler = readRequestHandler(commandRequest); requestHandler.onRequestTTLEnd(commandRequest, true); } + + private RequestHandler readRequestHandler(RuntimeContext runtimeContext) { + if(ActionLevel.VM.equals(runtimeContext.getRequestContext().getActionLevel())){ + return vmRequestHandler; + } + return vnfRequestHandler; + } } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java index bba735a19..aadfd3a9c 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java @@ -55,10 +55,10 @@ import org.osgi.framework.FrameworkUtil; import org.osgi.framework.ServiceReference; import org.slf4j.MDC; -import java.net.InetAddress; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import java.net.InetAddress; import static com.att.eelf.configuration.Configuration.*; import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID; import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; |