aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-04-21 10:22:36 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-04-21 11:08:06 -0700
commit8b8b54c7ace5d58e4d12b47a7b6fad67c56507a1 (patch)
tree06ae3646263d98c6835b32254a00c5e6e898d898
parent1c01a49fd2ea437587661feb70003c1025163328 (diff)
Remove CommandRequest and subclasses
From the last refactoring, CommandRequest ended up containing only a single CommandExecutorInput value. This change removes CommandRequest and subclasses and replaces their use with CommandExecutorInput directly The type parameter on CommandTask is also removed accordingly. Change-Id: I867df65f344fa58698a44c4b20815dbce382ad55 Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandExecutorImpl.java43
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTask.java22
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java3
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/ExpiredMessageHandler.java6
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMCommandTask.java37
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/LCMReadonlyCommandTask.java18
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/CommandRequest.java44
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMCommandRequest.java32
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMReadOnlyCommandRequest.java33
-rw-r--r--appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java28
10 files changed, 58 insertions, 208 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 e351cfe12..7832b517a 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
@@ -33,9 +33,6 @@ 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.impl.objects.CommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMCommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMReadOnlyCommandRequest;
import org.openecomp.appc.executor.objects.CommandExecutorInput;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -82,43 +79,19 @@ public class CommandExecutorImpl implements CommandExecutor {
if (logger.isTraceEnabled()) {
logger.trace("Entering to executeCommand with CommandExecutorInput = "+ ObjectUtils.toString(commandExecutorInput));
}
- CommandRequest request = getCommandRequest(commandExecutorInput);
- enqueRequest(request);
+ enqueRequest(commandExecutorInput);
if (logger.isTraceEnabled()) {
logger.trace("Exiting from executeCommand");
}
}
- private CommandRequest getCommandRequest(CommandExecutorInput commandExecutorInput){
- if (logger.isTraceEnabled()) {
- logger.trace("Entering to getCommandRequest with CommandExecutorInput = "+ ObjectUtils.toString(commandExecutorInput));
- }
- CommandRequest commandRequest;
-
- switch(commandExecutorInput.getRuntimeContext().getRequestContext().getAction()){
- case Sync:
- commandRequest = new LCMReadOnlyCommandRequest(commandExecutorInput);
- break;
- case Audit:
- commandRequest = new LCMReadOnlyCommandRequest(commandExecutorInput);
- break;
- default:
- commandRequest = new LCMCommandRequest(commandExecutorInput);
- break;
- }
- if (logger.isTraceEnabled()) {
- logger.trace("Exiting from getCommandRequest with (CommandRequest = "+ ObjectUtils.toString(commandRequest)+")");
- }
- return commandRequest;
- }
-
@SuppressWarnings("unchecked")
- private void enqueRequest(CommandRequest request) throws APPCException{
+ private void enqueRequest(CommandExecutorInput request) throws APPCException{
if (logger.isTraceEnabled()) {
logger.trace("Entering to enqueRequest with CommandRequest = "+ ObjectUtils.toString(request));
}
try {
- CommandTask<? extends CommandRequest> commandTask = getMessageExecutor(request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getAction().name());
+ CommandTask commandTask = getMessageExecutor(request.getRuntimeContext().getRequestContext().getAction().name());
commandTask.setCommandRequest(request);
long remainingTTL = getRemainingTTL(request);
executionQueueService.putMessage(commandTask,remainingTTL, TimeUnit.MILLISECONDS);
@@ -132,17 +105,17 @@ public class CommandExecutorImpl implements CommandExecutor {
}
}
- private long getRemainingTTL(CommandRequest request) {
- Date requestTimestamp = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getTimeStamp();
- int ttl = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader().getFlags().getTtl();
+ private long getRemainingTTL(CommandExecutorInput request) {
+ Date requestTimestamp = request.getRuntimeContext().getRequestContext().getCommonHeader().getTimeStamp();
+ int ttl = request.getRuntimeContext().getRequestContext().getCommonHeader().getFlags().getTtl();
return ttl*1000 + requestTimestamp.getTime() - System.currentTimeMillis();
}
- private CommandTask<? extends CommandRequest> getMessageExecutor(String action){
+ private CommandTask getMessageExecutor(String action){
if (logger.isTraceEnabled()) {
logger.trace("Entering to getMessageExecutor with command = "+ action);
}
- CommandTask<? extends CommandRequest> executionTask = executionTaskFactory.getExecutionTask(action);
+ CommandTask executionTask = executionTaskFactory.getExecutionTask(action);
if (logger.isTraceEnabled()) {
logger.trace("Exiting from getMessageExecutor");
}
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 0037434ff..be899268b 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,7 @@ import java.net.InetAddress;
import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
import org.openecomp.appc.domainmodel.lcm.Status;
-import org.openecomp.appc.executor.impl.objects.CommandRequest;
+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;
@@ -50,18 +50,18 @@ import org.slf4j.MDC;
* This abstract class is base class for all Command tasks. All command task must inherit this class.
*/
-public abstract class CommandTask<M> implements Runnable {
+public abstract class CommandTask implements Runnable {
protected RequestHandler requestHandler;
protected WorkFlowManager workflowManager;
- private CommandRequest commandRequest;
+ private CommandExecutorInput commandRequest;
- public CommandRequest getCommandRequest() {
+ public CommandExecutorInput getCommandRequest() {
return commandRequest;
}
- public void setCommandRequest(CommandRequest commandRequest) {
+ public void setCommandRequest(CommandExecutorInput commandRequest) {
this.commandRequest = commandRequest;
}
@@ -78,23 +78,23 @@ public abstract class CommandTask<M> implements Runnable {
CommandTask(){
}
- public void onRequestCompletion(CommandRequest request, CommandResponse response , boolean isAAIUpdated) {
+ public void onRequestCompletion(CommandExecutorInput request, CommandResponse response , boolean isAAIUpdated) {
logger.debug("Entry: onRequestCompletion()");
- requestHandler.onRequestExecutionEnd(request.getCommandExecutorInput().getRuntimeContext(), isAAIUpdated);
+ requestHandler.onRequestExecutionEnd(request.getRuntimeContext(), isAAIUpdated);
}
- public abstract void onRequestCompletion(CommandRequest request, CommandResponse response);
+ public abstract void onRequestCompletion(CommandExecutorInput request, CommandResponse response);
- protected CommandResponse buildCommandResponse(CommandRequest request, WorkflowResponse response) {
+ protected CommandResponse buildCommandResponse(CommandExecutorInput request, WorkflowResponse response) {
CommandResponse commandResponse = new CommandResponse();
- commandResponse.setRuntimeContext(request.getCommandExecutorInput().getRuntimeContext());
+ commandResponse.setRuntimeContext(request.getRuntimeContext());
return commandResponse;
}
public void execute() {
- final RuntimeContext runtimeContext = commandRequest.getCommandExecutorInput().getRuntimeContext();
+ final RuntimeContext runtimeContext = commandRequest.getRuntimeContext();
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/CommandTaskFactory.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/CommandTaskFactory.java
index d01722062..610f0bca3 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
@@ -23,7 +23,6 @@ package org.openecomp.appc.executor.impl;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
-import org.openecomp.appc.executor.impl.objects.CommandRequest;
import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.requesthandler.RequestHandler;
import org.openecomp.appc.workflow.WorkFlowManager;
@@ -54,7 +53,7 @@ public class CommandTaskFactory {
}
- public synchronized CommandTask<? extends CommandRequest> getExecutionTask(String action){
+ public synchronized CommandTask getExecutionTask(String action){
if (VNFOperation.Sync.toString().equals(action) || VNFOperation.Audit.toString().equals(action)){
return new LCMReadonlyCommandTask(requestHandler,workflowManager);
}else {
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 fc79c461f..500f75735 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
@@ -22,7 +22,7 @@
package org.openecomp.appc.executor.impl;
import org.openecomp.appc.executionqueue.MessageExpirationListener;
-import org.openecomp.appc.executor.impl.objects.CommandRequest;
+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) {
- CommandRequest commandRequest = (CommandRequest)message;
- requestHandler.onRequestTTLEnd(commandRequest.getCommandExecutorInput().getRuntimeContext(), true);
+ CommandExecutorInput commandRequest = (CommandExecutorInput)message;
+ requestHandler.onRequestTTLEnd(commandRequest.getRuntimeContext(), 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 9f7c13513..935260a10 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
@@ -27,8 +27,7 @@ import org.openecomp.appc.domainmodel.lcm.CommonHeader;
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.impl.objects.CommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMCommandRequest;
+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;
@@ -54,7 +53,7 @@ import java.util.HashMap;
import java.util.Map;
-public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
+public class LCMCommandTask extends CommandTask {
private AAIService aaiService;
private LifecycleManager lifecyclemanager;
@@ -91,12 +90,12 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
@Override
- public void onRequestCompletion(CommandRequest request, CommandResponse response) {
+ public void onRequestCompletion(CommandExecutorInput request, CommandResponse response) {
boolean isAAIUpdated = false;
try {
- final int statusCode = request.getCommandExecutorInput().getRuntimeContext().getResponseContext().getStatus().getCode();
+ final int statusCode = request.getRuntimeContext().getResponseContext().getStatus().getCode();
if (logger.isDebugEnabled()) {
logger.debug("Workflow Execution Status = "+ statusCode);
@@ -104,13 +103,13 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
boolean isSuccess = statusCode == 100 || statusCode == 400;
- if (isSuccess && VNFOperation.Terminate == request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getAction()) {
+ if (isSuccess && VNFOperation.Terminate == request.getRuntimeContext().getRequestContext().getAction()) {
SvcLogicContext ctx = new SvcLogicContext();
- ctx = getVnfdata(request.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId(), "vnf", ctx);
- isAAIUpdated = aaiService.deleteGenericVnfData(request.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId(), ctx.getAttribute("vnf.resource-version"));
+ ctx = getVnfdata(request.getRuntimeContext().getVnfContext().getId(), "vnf", ctx);
+ isAAIUpdated = aaiService.deleteGenericVnfData(request.getRuntimeContext().getVnfContext().getId(), ctx.getAttribute("vnf.resource-version"));
}
else{
- isAAIUpdated = updateAAI(request.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId() , false, isSuccess);
+ isAAIUpdated = updateAAI(request.getRuntimeContext().getVnfContext().getId() , false, isSuccess);
}
logger.debug("isAAIUpdated = " + isAAIUpdated);
}
@@ -125,20 +124,20 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
@Override
public void run() {
- LCMCommandRequest request = (LCMCommandRequest)getCommandRequest();
+ CommandExecutorInput request = getCommandRequest();
boolean isAAIUpdated;
- final String vnfId = request.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId();
- final String vnfType = request.getCommandExecutorInput().getRuntimeContext().getVnfContext().getType();
+ final String vnfId = request.getRuntimeContext().getVnfContext().getId();
+ final String vnfType = request.getRuntimeContext().getVnfContext().getType();
try {
- final CommonHeader commonHeader = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader();
+ final CommonHeader commonHeader = request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getVnfContext().getStatus();
- final VNFOperation action = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getAction();
+ final String currentStatus = request.getRuntimeContext().getVnfContext().getStatus();
+ final VNFOperation action = request.getRuntimeContext().getRequestContext().getAction();
final String nextState = lifecyclemanager.getNextState(vnfType, currentStatus, action.name());
@@ -148,18 +147,18 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
} 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.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.NO_TRANSITION_DEFINE_FAILURE.toStatus(params));
+ request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params));
+ request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
+ request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
isAAIUpdated = false;
}
@@ -169,7 +168,7 @@ public class LCMCommandTask extends CommandTask<LCMCommandRequest> {
String errorMsg = "Error updating A& AI before Workflow execution";
logger.error(errorMsg);
WorkflowResponse response = new WorkflowResponse();
- response.setResponseContext(request.getCommandExecutorInput().getRuntimeContext().getResponseContext());
+ response.setResponseContext(request.getRuntimeContext().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 201662a6c..755f70c31 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
@@ -26,9 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openecomp.appc.domainmodel.lcm.CommonHeader;
import org.openecomp.appc.domainmodel.lcm.Status;
import org.openecomp.appc.executor.UnstableVNFException;
-import org.openecomp.appc.executor.impl.objects.CommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMCommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMReadOnlyCommandRequest;
+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;
@@ -38,7 +36,7 @@ import org.openecomp.appc.workflow.WorkFlowManager;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-public class LCMReadonlyCommandTask extends CommandTask<LCMReadOnlyCommandRequest> {
+public class LCMReadonlyCommandTask extends CommandTask {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(LCMReadonlyCommandTask.class);
@@ -50,30 +48,30 @@ public class LCMReadonlyCommandTask extends CommandTask<LCMReadOnlyCommandReques
@Override
- public void onRequestCompletion(CommandRequest request, CommandResponse response) {
+ public void onRequestCompletion(CommandExecutorInput request, CommandResponse response) {
super.onRequestCompletion(request, response, true);
}
@Override
public void run() {
- LCMReadOnlyCommandRequest request = (LCMReadOnlyCommandRequest)getCommandRequest();
- final CommonHeader commonHeader = request.getCommandExecutorInput().getRuntimeContext().getRequestContext().getCommonHeader();
+ CommandExecutorInput request = getCommandRequest();
+ final CommonHeader commonHeader = request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getVnfContext().getId();
+ final String vnfId = request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNSTABLE_VNF_FAILURE.toStatus(params));
+ request.getRuntimeContext().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.getCommandExecutorInput().getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
+ request.getRuntimeContext().getResponseContext().setStatus(LCMCommandStatus.UNEXPECTED_FAILURE.toStatus(params));
}
}
}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/CommandRequest.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/CommandRequest.java
deleted file mode 100644
index afd7c70a0..000000000
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/CommandRequest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.appc.executor.impl.objects;
-
-import org.openecomp.appc.executor.objects.CommandExecutorInput;
-
-public class CommandRequest {
-
- private final CommandExecutorInput commandExecutorInput;
-
- public CommandRequest(CommandExecutorInput commandExecutorInput) {
- this.commandExecutorInput = commandExecutorInput;
- }
-
- public CommandExecutorInput getCommandExecutorInput() {
- return commandExecutorInput;
- }
-
- @Override
- public String toString() {
- return "CommandRequest{" +
- "commandExecutorInput=" + commandExecutorInput +
- '}';
- }
-}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMCommandRequest.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMCommandRequest.java
deleted file mode 100644
index 45111d6c1..000000000
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMCommandRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.appc.executor.impl.objects;
-
-import org.openecomp.appc.executor.objects.CommandExecutorInput;
-
-
-public class LCMCommandRequest extends CommandRequest {
-
- public LCMCommandRequest(CommandExecutorInput commandExecutorInput) {
- super(commandExecutorInput);
- }
-}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMReadOnlyCommandRequest.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMReadOnlyCommandRequest.java
deleted file mode 100644
index 4d76973e2..000000000
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/main/java/org/openecomp/appc/executor/impl/objects/LCMReadOnlyCommandRequest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.appc.executor.impl.objects;
-
-import org.openecomp.appc.executor.objects.CommandExecutorInput;
-
-
-
-public class LCMReadOnlyCommandRequest extends CommandRequest {
-
- public LCMReadOnlyCommandRequest(CommandExecutorInput commandExecutorInput) {
- super(commandExecutorInput);
- }
-}
diff --git a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
index 1e46393d3..ca6694064 100644
--- a/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
+++ b/appc-dispatcher/appc-command-executor/appc-command-executor-core/src/test/java/org/openecomp/appc/executor/TestCommandExecutionTask.java
@@ -35,9 +35,6 @@ import org.openecomp.appc.executor.impl.CommandTask;
import org.openecomp.appc.executor.impl.CommandTaskFactory;
import org.openecomp.appc.executor.impl.LCMCommandTask;
import org.openecomp.appc.executor.impl.LCMReadonlyCommandTask;
-import org.openecomp.appc.executor.impl.objects.CommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMCommandRequest;
-import org.openecomp.appc.executor.impl.objects.LCMReadOnlyCommandRequest;
import org.openecomp.appc.executor.objects.*;
import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.requesthandler.RequestHandler;
@@ -132,7 +129,7 @@ public class TestCommandExecutionTask {
@Test
public void testFactory(){
- CommandTask<? extends CommandRequest> task = factory.getExecutionTask("Configure");
+ CommandTask task = factory.getExecutionTask("Configure");
assertEquals(LCMCommandTask.class,task.getClass() );
task = factory.getExecutionTask("Sync");
assertEquals(LCMReadonlyCommandTask.class,task.getClass() );
@@ -144,28 +141,28 @@ public class TestCommandExecutionTask {
@Test
public void testOnRequestCompletion(){
Mockito.doNothing().when(requestHandler).onRequestTTLEnd((RuntimeContext) anyObject(),anyBoolean());
- LCMCommandRequest request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"), VNFOperation.Configure, "1", "1.0");
+ CommandExecutorInput request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"), VNFOperation.Configure, "1", "1.0");
CommandResponse response = getCommandResponse(VNFOperation.Configure, true, "11", "","1");
executionTask.onRequestCompletion(request, response);
}
@Test
public void testRunGetConfig(){
- LCMReadOnlyCommandRequest request = getConfigCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
+ CommandExecutorInput request = getConfigCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
LCMReadonlyCommandTask.setCommandRequest(request);
LCMReadonlyCommandTask.run();
}
@Test
public void testRun(){
- LCMCommandRequest request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
+ CommandExecutorInput request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
executionTask.setCommandRequest(request);
executionTask.run();
}
@Test
public void testRunNegative(){
- LCMCommandRequest request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
+ CommandExecutorInput request = getLCMCommandRequest("FIREWALL",30,new Date(), "11" ,setTTLInFlags("30"),VNFOperation.Sync, "1", "1.0");
executionTask.setCommandRequest(request);
executionTask.run();
}
@@ -208,7 +205,6 @@ public class TestCommandExecutionTask {
String requestId = "1";
CommandExecutorInput commandExecutorInput = pouplateCommandExecutorInput("FIREWALL",30, "1.0", timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", VNFOperation.Configure, "33", "");
- CommandRequest request = new CommandRequest(commandExecutorInput);
}
@@ -221,22 +217,16 @@ public class TestCommandExecutionTask {
}
- private LCMReadOnlyCommandRequest getConfigCommandRequest(String vnfType , Integer ttl , Date timeStamp, String requestId,
+ private CommandExecutorInput getConfigCommandRequest(String vnfType , Integer ttl , Date timeStamp, String requestId,
Map<String,Object> flags, VNFOperation command , String vnfId, String vnfVersion ){
- CommandExecutorInput commandExecutorInput = pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
- LCMReadOnlyCommandRequest request = new LCMReadOnlyCommandRequest(commandExecutorInput);
-
- return request;
+ return pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
}
- private LCMCommandRequest getLCMCommandRequest(String vnfType , Integer ttl ,Date timeStamp, String requestId,
+ private CommandExecutorInput getLCMCommandRequest(String vnfType , Integer ttl ,Date timeStamp, String requestId,
Map<String,Object> flags, VNFOperation command , String vnfId, String vnfVersion ){
- CommandExecutorInput commandExecutorInput = pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
- LCMCommandRequest request = new LCMCommandRequest(commandExecutorInput);
-
- return request;
+ return pouplateCommandExecutorInput(vnfType, ttl, vnfVersion, timeStamp, API_VERSION, requestId, ORIGINATOR_ID, "", command, vnfId, "");
}
public WorkflowResponse getWorkflowResponse (){