diff options
author | 2017-04-21 11:51:01 -0700 | |
---|---|---|
committer | 2017-05-01 15:15:33 +0000 | |
commit | 14365b73fbf5111e62ba91b9d7f80602db383a3c (patch) | |
tree | e8c2bbf3d3197a52e556b11df7410805df9d22c1 /appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp | |
parent | caa1d0171c90f390c60e4e635ee98e49f413d3c2 (diff) |
Remove CommandExecutorInput
CommandExecutorInput.getTtl() was never called. Once that
is removed, CommandExecutorInput only contains a single
RuntimeContext object. This change removes CommandExecutorInput
and replaces its uses with RuntimeContext directly.
Change-Id: Ib8145b7f844d4b9ea294622e7cf4bdfc3aefcd0a
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp')
5 files changed, 44 insertions, 44 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 7832b517a..0948b2b4d 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 @@ -29,11 +29,12 @@ import java.util.Date; import java.util.concurrent.TimeUnit; import org.apache.commons.lang.ObjectUtils; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.exceptions.APPCException; import org.openecomp.appc.executionqueue.ExecutionQueueService; import org.openecomp.appc.executionqueue.impl.ExecutionQueueServiceFactory; import org.openecomp.appc.executor.CommandExecutor; -import org.openecomp.appc.executor.objects.CommandExecutorInput; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -75,7 +76,7 @@ public class CommandExecutorImpl implements CommandExecutor { * @throws APPCException in case of error. */ @Override - public void executeCommand (CommandExecutorInput commandExecutorInput) throws APPCException{ + public void executeCommand (RuntimeContext commandExecutorInput) throws APPCException{ if (logger.isTraceEnabled()) { logger.trace("Entering to executeCommand with CommandExecutorInput = "+ ObjectUtils.toString(commandExecutorInput)); } @@ -86,12 +87,12 @@ public class CommandExecutorImpl implements CommandExecutor { } @SuppressWarnings("unchecked") - private void enqueRequest(CommandExecutorInput request) throws APPCException{ + private void enqueRequest(RuntimeContext request) throws APPCException{ if (logger.isTraceEnabled()) { logger.trace("Entering to enqueRequest with CommandRequest = "+ ObjectUtils.toString(request)); } try { - CommandTask commandTask = getMessageExecutor(request.getRuntimeContext().getRequestContext().getAction().name()); + CommandTask commandTask = getMessageExecutor(request.getRequestContext().getAction().name()); commandTask.setCommandRequest(request); long remainingTTL = getRemainingTTL(request); executionQueueService.putMessage(commandTask,remainingTTL, TimeUnit.MILLISECONDS); @@ -105,9 +106,9 @@ public class CommandExecutorImpl implements CommandExecutor { } } - private long getRemainingTTL(CommandExecutorInput request) { - Date requestTimestamp = request.getRuntimeContext().getRequestContext().getCommonHeader().getTimeStamp(); - int ttl = request.getRuntimeContext().getRequestContext().getCommonHeader().getFlags().getTtl(); + private long getRemainingTTL(RuntimeContext request) { + Date requestTimestamp = request.getRequestContext().getCommonHeader().getTimeStamp(); + int ttl = request.getRequestContext().getCommonHeader().getFlags().getTtl(); return ttl*1000 + requestTimestamp.getTime() - System.currentTimeMillis(); } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java index be899268b..f34746b24 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java @@ -33,7 +33,6 @@ import java.net.InetAddress; import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.domainmodel.lcm.Status; -import org.openecomp.appc.executor.objects.CommandExecutorInput; import org.openecomp.appc.executor.objects.CommandResponse; import org.openecomp.appc.executor.objects.LCMCommandStatus; import org.openecomp.appc.executor.objects.Params; @@ -55,13 +54,13 @@ public abstract class CommandTask implements Runnable { protected RequestHandler requestHandler; protected WorkFlowManager workflowManager; - private CommandExecutorInput commandRequest; + private RuntimeContext commandRequest; - public CommandExecutorInput getCommandRequest() { + public RuntimeContext getCommandRequest() { return commandRequest; } - public void setCommandRequest(CommandExecutorInput commandRequest) { + public void setCommandRequest(RuntimeContext commandRequest) { this.commandRequest = commandRequest; } @@ -78,23 +77,23 @@ public abstract class CommandTask implements Runnable { CommandTask(){ } - public void onRequestCompletion(CommandExecutorInput request, CommandResponse response , boolean isAAIUpdated) { + public void onRequestCompletion(RuntimeContext request, CommandResponse response , boolean isAAIUpdated) { logger.debug("Entry: onRequestCompletion()"); - requestHandler.onRequestExecutionEnd(request.getRuntimeContext(), isAAIUpdated); + requestHandler.onRequestExecutionEnd(request, isAAIUpdated); } - public abstract void onRequestCompletion(CommandExecutorInput request, CommandResponse response); + public abstract void onRequestCompletion(RuntimeContext request, CommandResponse response); - protected CommandResponse buildCommandResponse(CommandExecutorInput request, WorkflowResponse response) { + protected CommandResponse buildCommandResponse(RuntimeContext request, WorkflowResponse response) { CommandResponse commandResponse = new CommandResponse(); - commandResponse.setRuntimeContext(request.getRuntimeContext()); + commandResponse.setRuntimeContext(request); return commandResponse; } public void execute() { - final RuntimeContext runtimeContext = commandRequest.getRuntimeContext(); + final RuntimeContext runtimeContext = commandRequest; MDC.put(MDC_KEY_REQUEST_ID, runtimeContext.getRequestContext().getCommonHeader().getRequestId()); if (runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId() != null) MDC.put(MDC_SERVICE_INSTANCE_ID, runtimeContext.getRequestContext().getActionIdentifiers().getServiceInstanceId()); 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 500f75735..626d3dfce 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 @@ -21,8 +21,8 @@ package org.openecomp.appc.executor.impl; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.executionqueue.MessageExpirationListener; -import org.openecomp.appc.executor.objects.CommandExecutorInput; import org.openecomp.appc.requesthandler.RequestHandler; @@ -39,7 +39,7 @@ public class ExpiredMessageHandler<M> implements MessageExpirationListener<M>{ @Override public void onMessageExpiration(M message) { - CommandExecutorInput commandRequest = (CommandExecutorInput)message; - requestHandler.onRequestTTLEnd(commandRequest.getRuntimeContext(), true); + RuntimeContext commandRequest = (RuntimeContext)message; + requestHandler.onRequestTTLEnd(commandRequest, true); } } 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 935260a10..889bd25da 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 @@ -24,10 +24,10 @@ package org.openecomp.appc.executor.impl; import org.apache.commons.lang3.StringUtils; import org.openecomp.appc.domainmodel.lcm.CommonHeader; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.domainmodel.lcm.Status; import org.openecomp.appc.domainmodel.lcm.VNFOperation; import org.openecomp.appc.executor.UnstableVNFException; -import org.openecomp.appc.executor.objects.CommandExecutorInput; import org.openecomp.appc.executor.objects.CommandResponse; import org.openecomp.appc.executor.objects.LCMCommandStatus; import org.openecomp.appc.executor.objects.Params; @@ -90,12 +90,12 @@ public class LCMCommandTask extends CommandTask { @Override - public void onRequestCompletion(CommandExecutorInput request, CommandResponse response) { + public void onRequestCompletion(RuntimeContext request, CommandResponse response) { boolean isAAIUpdated = false; try { - final int statusCode = request.getRuntimeContext().getResponseContext().getStatus().getCode(); + final int statusCode = request.getResponseContext().getStatus().getCode(); if (logger.isDebugEnabled()) { logger.debug("Workflow Execution Status = "+ statusCode); @@ -103,13 +103,13 @@ public class LCMCommandTask extends CommandTask { boolean isSuccess = statusCode == 100 || statusCode == 400; - if (isSuccess && VNFOperation.Terminate == request.getRuntimeContext().getRequestContext().getAction()) { + if (isSuccess && VNFOperation.Terminate == request.getRequestContext().getAction()) { SvcLogicContext ctx = new SvcLogicContext(); - ctx = getVnfdata(request.getRuntimeContext().getVnfContext().getId(), "vnf", ctx); - isAAIUpdated = aaiService.deleteGenericVnfData(request.getRuntimeContext().getVnfContext().getId(), ctx.getAttribute("vnf.resource-version")); + ctx = getVnfdata(request.getVnfContext().getId(), "vnf", ctx); + isAAIUpdated = aaiService.deleteGenericVnfData(request.getVnfContext().getId(), ctx.getAttribute("vnf.resource-version")); } else{ - isAAIUpdated = updateAAI(request.getRuntimeContext().getVnfContext().getId() , false, isSuccess); + isAAIUpdated = updateAAI(request.getVnfContext().getId() , false, isSuccess); } logger.debug("isAAIUpdated = " + isAAIUpdated); } @@ -124,20 +124,20 @@ public class LCMCommandTask extends CommandTask { @Override public void run() { - CommandExecutorInput request = getCommandRequest(); + RuntimeContext request = getCommandRequest(); boolean isAAIUpdated; - final String vnfId = request.getRuntimeContext().getVnfContext().getId(); - final String vnfType = request.getRuntimeContext().getVnfContext().getType(); + final String vnfId = request.getVnfContext().getId(); + final String vnfType = request.getVnfContext().getType(); try { - final CommonHeader commonHeader = request.getRuntimeContext().getRequestContext().getCommonHeader(); + final CommonHeader commonHeader = request.getRequestContext().getCommonHeader(); final boolean forceFlag = commonHeader.getFlags().isForce(); UniqueRequestIdentifier requestIdentifier = new UniqueRequestIdentifier(commonHeader.getOriginatorId(), commonHeader.getRequestId(), commonHeader.getSubRequestId()); String requestIdentifierString = requestIdentifier.toIdentifierString(); requestHandler.onRequestExecutionStart(vnfId,false, requestIdentifierString, forceFlag); - final String currentStatus = request.getRuntimeContext().getVnfContext().getStatus(); - final VNFOperation action = request.getRuntimeContext().getRequestContext().getAction(); + final String currentStatus = request.getVnfContext().getStatus(); + final VNFOperation action = request.getRequestContext().getAction(); final String nextState = lifecyclemanager.getNextState(vnfType, currentStatus, action.name()); @@ -147,18 +147,18 @@ public class LCMCommandTask extends CommandTask { } catch (NoTransitionDefinedException e) { logger.error("Error getting Next State for AAI Update: " + e.getMessage(), e); Params params = new Params().addParam("actionName",e.event).addParam("currentState",e.currentState); - request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.NO_TRANSITION_DEFINE_FAILURE.toStatus(params)); + request.getResponseContext().setStatus(LCMCommandStatus.NO_TRANSITION_DEFINE_FAILURE.toStatus(params)); isAAIUpdated = false; } catch (UnstableVNFException e) { logger.error(e.getMessage(), e); Params params = new Params().addParam("vnfId",vnfId); - request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params)); + request.getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params)); isAAIUpdated = false; }catch (Exception e) { logger.error("Error before Request Execution starts.", e); String errorMsg = StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage(); Params params = new Params().addParam("errorMsg",errorMsg); - request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params)); + request.getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params)); isAAIUpdated = false; } @@ -168,7 +168,7 @@ public class LCMCommandTask extends CommandTask { String errorMsg = "Error updating A& AI before Workflow execution"; logger.error(errorMsg); WorkflowResponse response = new WorkflowResponse(); - response.setResponseContext(request.getRuntimeContext().getResponseContext()); + response.setResponseContext(request.getResponseContext()); CommandResponse commandResponse = super.buildCommandResponse(request, response); this.onRequestCompletion(request,commandResponse); } diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java index 755f70c31..a351c4d36 100644 --- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java +++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java @@ -24,9 +24,9 @@ package org.openecomp.appc.executor.impl; import org.apache.commons.lang3.StringUtils; import org.openecomp.appc.domainmodel.lcm.CommonHeader; +import org.openecomp.appc.domainmodel.lcm.RuntimeContext; import org.openecomp.appc.domainmodel.lcm.Status; import org.openecomp.appc.executor.UnstableVNFException; -import org.openecomp.appc.executor.objects.CommandExecutorInput; import org.openecomp.appc.executor.objects.CommandResponse; import org.openecomp.appc.executor.objects.LCMCommandStatus; import org.openecomp.appc.executor.objects.Params; @@ -48,30 +48,30 @@ public class LCMReadonlyCommandTask extends CommandTask { @Override - public void onRequestCompletion(CommandExecutorInput request, CommandResponse response) { + public void onRequestCompletion(RuntimeContext request, CommandResponse response) { super.onRequestCompletion(request, response, true); } @Override public void run() { - CommandExecutorInput request = getCommandRequest(); - final CommonHeader commonHeader = request.getRuntimeContext().getRequestContext().getCommonHeader(); + RuntimeContext request = getCommandRequest(); + final CommonHeader commonHeader = request.getRequestContext().getCommonHeader(); final boolean forceFlag = commonHeader.getFlags().isForce(); UniqueRequestIdentifier requestIdentifier = new UniqueRequestIdentifier(commonHeader.getOriginatorId(), commonHeader.getRequestId(), commonHeader.getSubRequestId()); String requestIdentifierString = requestIdentifier.toIdentifierString(); - final String vnfId = request.getRuntimeContext().getVnfContext().getId(); + final String vnfId = request.getVnfContext().getId(); try { requestHandler.onRequestExecutionStart(vnfId,true, requestIdentifierString, forceFlag); super.execute(); } catch (UnstableVNFException e) { logger.error(e.getMessage(), e); Params params = new Params().addParam("vnfId",vnfId); - request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params)); + request.getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params)); }catch (Exception e) { logger.error("Error during runing LCMReadonlyCommandTask.", e); String errorMsg = StringUtils.isEmpty(e.getMessage()) ? e.toString() : e.getMessage(); Params params = new Params().addParam("errorMsg",errorMsg); - request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params)); + request.getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params)); } } } |