* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* 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=========================================================
*/
import com.att.eelf.i18n.EELFResourceManager;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import jline.internal.Log;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
-import org.json.JSONObject;
import org.onap.appc.domainmodel.lcm.Flags;
import org.onap.appc.domainmodel.lcm.RequestContext;
import org.onap.appc.domainmodel.lcm.RuntimeContext;
logger.info("Initializing RequestValidatorImpl.");
String endpoint = null;
String user = null;
- String pass =null;
+ String pass = null;
String transactionWindow = null;
-
Properties properties = configuration.getProperties();
if (properties != null) {
endpoint = properties.getProperty(SCOPE_OVERLAP_ENDPOINT);
}
List<TransactionRecord> inProgressTransactionsAll = transactionRecorder
- .getInProgressRequests(runtimeContext.getTransactionRecord(),0);
+ .getInProgressRequests(runtimeContext.getTransactionRecord(), 0);
List<TransactionRecord> inProgressTransactions = transactionRecorder
- .getInProgressRequests(runtimeContext.getTransactionRecord(),transactionWindowInterval);
-
- long inProgressTransactionsAllCount = inProgressTransactionsAll.size();
- long inProgressTransactionsRelevant = inProgressTransactions.size();
+ .getInProgressRequests(runtimeContext.getTransactionRecord(), transactionWindowInterval);
+ long inProgressTransactionsAllCount = inProgressTransactionsAll == null ? 0 : inProgressTransactionsAll.size();
+ long inProgressTransactionsRelevant = inProgressTransactions == null ? 0 : inProgressTransactions.size();
logger.debug("In progress requests " + inProgressTransactions.toString());
- if ( inProgressTransactions.isEmpty()){ //No need to check for scope overlap
+ if (inProgressTransactionsRelevant == 0) { //No need for further checks
return;
}
- logInProgressTransactions(inProgressTransactions,inProgressTransactionsAllCount,
- inProgressTransactionsRelevant );
+ if (logger.isInfoEnabled()) {
+ logger.info(logInProgressTransactions(inProgressTransactions, inProgressTransactionsAllCount,
+ inProgressTransactionsRelevant));
+ }
Long exclusiveRequestCount = inProgressTransactions.stream()
.filter(record -> record.getMode().equals(Flags.Mode.EXCLUSIVE.name())).count();
return vnfContext;
}
- private SvcLogicContext getVnfdata(String vnf_id, String prefix, SvcLogicContext ctx) throws VNFNotFoundException {
+ private SvcLogicContext getVnfdata(String vnfId, String prefix, SvcLogicContext ctx) throws VNFNotFoundException {
if (logger.isTraceEnabled()) {
- logger.trace("Entering to getVnfdata with vnfid = " + ObjectUtils.toString(vnf_id) + ", prefix = "
+ logger.trace("Entering to getVnfdata with vnfid = " + ObjectUtils.toString(vnfId) + ", prefix = "
+ ObjectUtils.toString(prefix) + ", SvcLogicContext" + ObjectUtils.toString(ctx));
}
- String key = "vnf-id = '" + vnf_id + "'";
+ String key = "vnf-id = '" + vnfId + "'";
logger.debug("inside getVnfdata=== " + key);
try {
Date beginTimestamp = new Date();
LoggingConstants.TargetNames.AAI, LoggingConstants.TargetServiceNames.AAIServiceNames.QUERY, status,
"", response.name(), this.getClass().getCanonicalName());
if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) {
- throw new VNFNotFoundException("VNF not found for vnf_id = " + vnf_id, vnf_id);
+ throw new VNFNotFoundException("VNF not found for vnf_id = " + vnfId, vnfId);
} else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- throw new RuntimeException("Error Querying AAI with vnfID = " + vnf_id);
+ throw new RuntimeException("Error Querying AAI with vnfID = " + vnfId);
}
logger.info("AAIResponse: " + response.toString());
} catch (SvcLogicException e) {
this.getClass().getCanonicalName());
throw new WorkflowNotFoundException(
"Workflow mapping not found for vnfType = " + vnfContext.getType() + ", command = "
- + requestContext.getAction().name(),
+ + requestContext.getAction().name(),
vnfContext.getType(), requestContext.getAction().name());
}
if (!workflowExistsOutput.isDgExist()) {
this.getClass().getCanonicalName());
throw new DGWorkflowNotFoundException(
"Workflow not found for vnfType = " + vnfContext.getType() + ", command = "
- + requestContext.getAction().name(),
+ + requestContext.getAction().name(),
workflowExistsOutput.getWorkflowModule(), workflowExistsOutput.getWorkflowName(),
workflowExistsOutput.getWorkflowVersion(), vnfContext.getType(), requestContext.getAction().name());
}
public String logInProgressTransactions(List<TransactionRecord> inProgressTransactions,
long inProgressTransactionsAllCount, long inProgressTransactionsRelevant) {
- if (inProgressTransactionsAllCount > inProgressTransactionsRelevant) {
- logger.info("Found Stale Transactions! Ignoring Stale Transactions for target, only considering "
+ if (inProgressTransactionsAllCount > inProgressTransactionsRelevant) {
+ logger.info("Found Stale Transactions! Ignoring Stale Transactions for target, only considering "
+ "transactions within the last " + transactionWindowInterval + " hours as transactions in-progress");
- }
- String logMsg="";
- for (TransactionRecord tr: inProgressTransactions) {
- logMsg = ("In Progress transaction for Target ID - "+ tr.getTargetId()
- + " in state " + tr.getRequestState()
- + " with Start time " + tr.getStartTime().toString()
- + " for more than configurable time period " + transactionWindowInterval
- + " hours [transaction details - Request ID - " + tr.getTransactionId()
- + ", Service Instance Id -" + tr.getServiceInstanceId()
- + ", Vserver_id - " + tr.getVserverId()
- + ", VNFC_name - "+ tr.getVnfcName()
- + ", VF module Id - " + tr.getVfModuleId()
- + " Start time " + tr.getStartTime().toString()
- + "]" );
- }
- return logMsg;
-
+ }
+ String logMsg = "";
+ for (TransactionRecord tr: inProgressTransactions) {
+ logMsg = ("In Progress transaction for Target ID - " + tr.getTargetId()
+ + " in state " + tr.getRequestState()
+ + " with Start time " + tr.getStartTime().toString()
+ + " for more than configurable time period " + transactionWindowInterval
+ + " hours [transaction details - Request ID - " + tr.getTransactionId()
+ + ", Service Instance Id - " + tr.getServiceInstanceId()
+ + ", Vserver_id - " + tr.getVserverId()
+ + ", VNFC_name - " + tr.getVnfcName()
+ + ", VF module Id - " + tr.getVfModuleId()
+ + " Start time " + tr.getStartTime().toString()
+ + "]");
+ }
+ return logMsg;
}
}