summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl')
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java33
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java62
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java47
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java38
4 files changed, 164 insertions, 16 deletions
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
index 4546726e9..c2455a3b4 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
@@ -36,6 +36,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonIgnoreProperties(ignoreUnknown = true)
public class DmaapOutgoingMessage {
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("correlation-id")
+ private String correlationID;
+
private final static String defaultCambriaPartition = "MSO";
@JsonProperty("cambria.partition")
private String cambriaPartition = defaultCambriaPartition;
@@ -49,6 +58,30 @@ public class DmaapOutgoingMessage {
public DmaapOutgoingMessage() {
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCorrelationID() {
+ return correlationID;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
public String getCambriaPartition() {
return cambriaPartition;
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
new file mode 100644
index 000000000..0c97ebcbe
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.requesthandler.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.openecomp.appc.requesthandler.LCMStateManager;
+
+public class LCMStateManagerImpl implements LCMStateManager {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LCMStateManagerImpl.class);
+ private static AtomicBoolean isLCMEnabled = new AtomicBoolean(true);
+
+ /**
+ * This method checks if the LCM operations are enabled or not
+ * * @return true if enabled else false
+ */
+ public boolean isLCMOperationEnabled() {
+ return isLCMEnabled.get();
+ }
+
+ /**
+ * This method disables the LCM operations
+ */
+ public void disableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to disableLCMOperations");
+ }
+ isLCMEnabled.set(false);
+ }
+
+ /**
+ * This method enables the LCM operations
+ */
+ public void enableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to enableLCMOperations");
+ }
+ isLCMEnabled.set(true);
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
index d63cb8bb8..e6f7452c9 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
@@ -40,7 +40,7 @@ import org.openecomp.appc.lockmanager.api.LockManager;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
import org.openecomp.appc.messageadapter.MessageAdapter;
-import org.openecomp.appc.messageadapter.impl.MessageAdapterDmaapImpl;
+import org.openecomp.appc.messageadapter.impl.MessageAdapterImpl;
import org.openecomp.appc.metricservice.MetricRegistry;
import org.openecomp.appc.metricservice.MetricService;
import org.openecomp.appc.metricservice.metric.DispatchingFuntionMetric;
@@ -133,7 +133,7 @@ public class RequestHandlerImpl implements RequestHandler {
public RequestHandlerImpl() {
requestRegistry = new RequestRegistry();
- messageAdapter = new MessageAdapterDmaapImpl();
+ messageAdapter = new MessageAdapterImpl();
messageAdapter.init();
Properties properties = configuration.getProperties();
if (properties != null && properties.getProperty("metric.enabled") != null) {
@@ -215,7 +215,7 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (LifecycleException e) {
errorMessage = e.getMessage();
params = new Params().addParam("actionName", input.getRequestContext().getAction()).addParam("currentState", e.currentState);
- output = buildRequestHandlerOutput(LCMCommandStatus.ACTION_NOT_SUPPORTED, params);
+ output = buildRequestHandlerOutput(LCMCommandStatus.INVALID_VNF_STATE, params);
} catch (UnstableVNFException e) {
errorMessage = e.getMessage();
params = new Params().addParam("vnfId", vnfId);
@@ -246,6 +246,15 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (DuplicateRequestException e) {
errorMessage = e.getMessage();
output = buildRequestHandlerOutput(LCMCommandStatus.DUPLICATE_REQUEST, null);
+ } catch (MissingVNFDataInAAIException e) {
+ params = new Params().addParam("attributeName",e.getMissingAttributeName())
+ .addParam("vnfId",vnfId);
+ output = buildRequestHandlerOutput(LCMCommandStatus.MISSING_VNF_DATA_IN_AAI,params);
+ errorMessage = output.getResponseContext().getStatus().getMessage();
+ } catch (LCMOperationsDisabledException e) {
+ errorMessage = e.getMessage();
+ params = new Params().addParam("errorMsg", errorMessage);
+ output = buildRequestHandlerOutput(LCMCommandStatus.REJECTED, params);
} catch (Exception e) {
storeErrorMessageToLog(runtimeContext, "", "", "Exception = " + e.getMessage());
errorMessage = e.getMessage() != null ? e.getMessage() : e.toString();
@@ -261,7 +270,11 @@ public class RequestHandlerImpl implements RequestHandler {
runtimeContext.setResponseContext(output.getResponseContext());
if ((null == output) || !(output.getResponseContext().getStatus().getCode() == LCMCommandStatus.ACCEPTED.getResponseCode())) {
if (isMetricEnabled) {
- ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ if((output.getResponseContext().getStatus().getCode() == LCMCommandStatus.SUCCESS.getResponseCode())) {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementAcceptedRequest();
+ }else {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ }
}
removeRequestFromRegistry(input.getRequestContext().getCommonHeader());
}
@@ -580,14 +593,18 @@ public class RequestHandlerImpl implements RequestHandler {
if (logger.isTraceEnabled()) {
logger.trace("Entering to onRequestExecutionStart with vnfId = " + vnfId + "and requestIdentifierString = " + requestIdentifierString);
}
- try {
- boolean updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+
+ if(!readOnlyActivity || !forceFlag || workingStateManager.isVNFStable(vnfId)) {
+ boolean updated = false;
+ try {
+ updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+ } catch (Exception e) {
+ logger.error("Error updating working state for vnf " + vnfId + e);
+ throw new RuntimeException(e);
+ }
if (!updated) {
throw new UnstableVNFException("VNF is not stable for vnfID = " + vnfId);
}
- } catch (Exception e) {
- logger.error("Error updating working state for vnf " + vnfId + e);
- throw new RuntimeException(e);
}
if (logger.isTraceEnabled())
@@ -805,4 +822,16 @@ public class RequestHandlerImpl implements RequestHandler {
return null;
}
}
+
+ /**
+ * This method returns the count of in progress requests
+ * * @return in progress requests count
+ */
+ @Override
+ public int getInprogressRequestCount() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getInprogressRequestCount");
+ }
+ return requestRegistry.getRegisteredRequestCount();
+ }
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
index 509c351ea..8499937c7 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
@@ -24,6 +24,7 @@ package org.openecomp.appc.requesthandler.impl;
import java.time.Instant;
import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
import org.openecomp.appc.common.constant.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
@@ -40,6 +41,8 @@ import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
+import org.openecomp.appc.requesthandler.LCMStateManager;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
@@ -74,6 +77,7 @@ public class RequestValidatorImpl implements RequestValidator {
private WorkFlowManager workflowManager;
private WorkingStateManager workingStateManager;
+ private LCMStateManager lcmStateManager;
private final RequestRegistry requestRegistry = new RequestRegistry();
@@ -93,14 +97,26 @@ public class RequestValidatorImpl implements RequestValidator {
this.workingStateManager = workingStateManager;
}
+ public void setLcmStateManager(LCMStateManager lcmStateManager) {
+ this.lcmStateManager = lcmStateManager;
+ }
+
public RequestValidatorImpl() {
}
@Override
- public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
if (logger.isTraceEnabled()){
logger.trace("Entering to validateRequest with RequestHandlerInput = "+ ObjectUtils.toString(runtimeContext));
}
+ if(!lcmStateManager.isLCMOperationEnabled()) {
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.REQUEST_VALIDATOR,
+ EELFResourceManager.format(Msg.LCM_OPERATIONS_DISABLED),
+ this.getClass().getCanonicalName());
+ throw new LCMOperationsDisabledException("APPC LCM operations have been administratively disabled");
+ }
+
getAAIservice();
validateInput(runtimeContext.getRequestContext());
checkVNFWorkingState(runtimeContext);
@@ -114,9 +130,9 @@ public class RequestValidatorImpl implements RequestValidator {
// for built-in operations skip WF presence check
queryWFM(vnfContext, runtimeContext.getRequestContext());
}
- }
+ }
- private boolean isValidTTL(String ttl) {
+ private boolean isValidTTL(String ttl) {
if (logger.isTraceEnabled()){
logger.trace("Entering to isValidTTL where ttl = "+ ObjectUtils.toString(ttl));
}
@@ -206,7 +222,7 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private VNFContext queryAAI(String vnfId) throws VNFNotFoundException {
+ private VNFContext queryAAI(String vnfId) throws VNFNotFoundException, MissingVNFDataInAAIException {
SvcLogicContext ctx = new SvcLogicContext();
ctx = getVnfdata(vnfId, "vnf", ctx);
@@ -267,9 +283,17 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) {
- vnfContext.setType(ctx.getAttribute("vnf.vnf-type"));
- vnfContext.setStatus(ctx.getAttribute("vnf.orchestration-status"));
+ private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) throws MissingVNFDataInAAIException {
+ String vnfType = ctx.getAttribute("vnf.vnf-type");
+ String orchestrationStatus = ctx.getAttribute("vnf.orchestration-status");
+ if(StringUtils.isEmpty(vnfType)){
+ throw new MissingVNFDataInAAIException("vnf-type");
+ }
+ else if(StringUtils.isEmpty(orchestrationStatus)){
+ throw new MissingVNFDataInAAIException("orchestration-status");
+ }
+ vnfContext.setType(vnfType);
+ vnfContext.setStatus(orchestrationStatus);
vnfContext.setId(ctx.getAttribute("vnf.vnf-id"));
// TODO: Uncomment once A&AI supports VNF version
//vnfContext.setVersion(ctx.getAttribute("vnf.vnf-version"));