<dependency>
<groupId>org.openecomp.ecompsdkos</groupId>
<artifactId>epsdk-fw</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
package org.openecomp.sparky.dal.aai.config;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Properties;
import javax.ws.rs.core.UriBuilder;
+import org.openecomp.cl.api.Logger;
+import org.openecomp.cl.eelf.LoggerFactory;
+import org.openecomp.sparky.logging.AaiUiMsgs;
import org.openecomp.sparky.synchronizer.config.TaskProcessorConfig;
import org.openecomp.sparky.util.ConfigHelper;
import org.openecomp.sparky.util.Encryptor;
import org.openecomp.sparky.viewandinspect.config.TierSupportUiConstants;
-
/**
* The Class ActiveInventoryConfig.
*/
public static final String CONFIG_FILE =
TierSupportUiConstants.DYNAMIC_CONFIG_APP_LOCATION + "aai.properties";
private static ActiveInventoryConfig instance;
-
+ private static final Logger LOG = LoggerFactory.getInstance().getLogger(
+ ActiveInventoryConfig.class);
private static final String HTTP_SCHEME = "http";
private static final String HTTPS_SCHEME = "https";
return builder.build().toString();
}
-
+
+ public static String extractResourcePath(String selflink) {
+ try {
+ return new URI(selflink).getPath();
+ } catch (URISyntaxException uriSyntaxException) {
+ LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK, uriSyntaxException.getMessage());
+ return selflink;
+ }
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
/** Arguments: {0} = Exception */
ERROR_D3_GRAPH_VISUALIZATION,
/** Arguments: {0} = Exception */
- ERROR_AAI_QUERY_WITH_RETRY;
-
+ ERROR_AAI_QUERY_WITH_RETRY,
+ /** Arguments: Error extracting resource path from self-link. Error = {0} */
+ ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK;
/**
* Static initializer to ensure the resource bundles for this class are loaded...
*/
protected final Logger logger;
protected ObjectMapper mapper;
protected OxmModelLoader oxmModelLoader;
-
+ protected long syncDurationInMs;
/**
* The Enum StatFlag.
*/
protected String synchronizerName;
protected abstract boolean isSyncDone();
-
+ protected boolean shouldSkipSync;
+
public String getActiveInventoryStatisticsReport() {
StringBuilder sb = new StringBuilder(128);
String txnID = NodeUtils.getRandomTxnId();
MdcContext.initialize(txnID, "AbstractEntitySynchronizer", "", "Sync", "");
+
+ this.shouldSkipSync = false;
+ this.syncStartedTimeStampInMs = System.currentTimeMillis();
+ this.syncDurationInMs = -1;
+ }
+
+ public boolean shouldSkipSync() {
+ return shouldSkipSync;
+ }
+ public void setShouldSkipSync(boolean shouldSkipSync) {
+ this.shouldSkipSync = shouldSkipSync;
}
/**
import static java.util.concurrent.CompletableFuture.supplyAsync;
-import org.openecomp.cl.mdc.MdcContext;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import org.openecomp.cl.api.Logger;
import org.openecomp.cl.eelf.LoggerFactory;
+import org.openecomp.cl.mdc.MdcContext;
import org.openecomp.sparky.dal.NetworkTransaction;
import org.openecomp.sparky.dal.rest.HttpMethod;
import org.openecomp.sparky.dal.rest.OperationResult;
@Override
public OperationState doSync() {
isSyncInProgress = true;
-
+ this.syncDurationInMs = -1;
+ syncStartedTimeStampInMs = System.currentTimeMillis();
syncEntity();
while (!isSyncDone()) {
@Override
public String getStatReport(boolean shouldDisplayFinalReport) {
- return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs,
- shouldDisplayFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return getStatReport(syncDurationInMs, shouldDisplayFinalReport);
}
@Override
import org.openecomp.cl.eelf.LoggerFactory;
import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
import org.openecomp.sparky.dal.NetworkTransaction;
+import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfig;
import org.openecomp.sparky.dal.elasticsearch.config.ElasticSearchConfig;
import org.openecomp.sparky.dal.rest.HttpMethod;
import org.openecomp.sparky.dal.rest.OperationResult;
if (jsonResult != null && jsonResult.length() > 0) {
AggregationEntity ae = new AggregationEntity(oxmModelLoader);
- ae.setLink( txn.getLink() );
+ ae.setLink(ActiveInventoryConfig.extractResourcePath(txn.getLink()));
populateAggregationEntityDocument(ae, jsonResult, txn.getDescriptor());
ae.deriveFields();
*/
@Override
public OperationState doSync() {
+ this.syncDurationInMs = -1;
+ syncStartedTimeStampInMs = System.currentTimeMillis();
String txnID = NodeUtils.getRandomTxnId();
MdcContext.initialize(txnID, "AggregationSynchronizer", "", "Sync", "");
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return getStatReport(syncDurationInMs, showFinalReport);
}
public String getEntityType() {
import static java.util.concurrent.CompletableFuture.supplyAsync;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import org.openecomp.cl.api.Logger;
import org.openecomp.cl.eelf.LoggerFactory;
+import org.openecomp.cl.mdc.MdcContext;
import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
import org.openecomp.sparky.dal.NetworkTransaction;
+import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfig;
import org.openecomp.sparky.dal.rest.HttpMethod;
import org.openecomp.sparky.dal.rest.OperationResult;
import org.openecomp.sparky.logging.AaiUiMsgs;
import org.openecomp.sparky.util.SuggestionsPermutation;
import org.slf4j.MDC;
-import org.openecomp.cl.mdc.MdcContext;
-
-import org.openecomp.cl.mdc.MdcContext;
-
-import org.openecomp.cl.mdc.MdcContext;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
this.syncInProgress = false;
this.contextMap = MDC.getCopyOfContextMap();
this.esPutExecutor = NodeUtils.createNamedExecutor("SUES-ES-PUT", 5, LOG);
+ this.syncDurationInMs = -1;
}
/**
*/
@Override
public OperationState doSync() {
+ this.syncDurationInMs = -1;
+ syncStartedTimeStampInMs = System.currentTimeMillis();
String txnID = NodeUtils.getRandomTxnId();
MdcContext.initialize(txnID, "AutosuggestionSynchronizer", "", "Sync", "");
sse.setSuggestableAttr(uniqueList);
sse.setPayloadFromResponse(entityNode);
sse.setLink(txn.getLink());
+ sse.setLink(ActiveInventoryConfig.extractResourcePath(txn.getLink()));
populateSuggestionSearchEntityDocument(sse, jsonResult, txn);
// The unique id for the document will be created at derive fields
sse.deriveFields();
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return getStatReport(syncDurationInMs, showFinalReport);
}
/*
private static final Logger LOG =
LoggerFactory.getInstance().getLogger(CrossEntityReferenceSynchronizer.class);
-
+
+ private static final String SERVICE_INSTANCE = "service-instance";
private Deque<SelfLinkDescriptor> selflinks;
private Deque<RetryCrossEntitySyncContainer> retryQueue;
private Map<String, Integer> retryLimitTracker;
this.esEntityStats.initializeCountersFromOxmEntityDescriptors(
oxmModelLoader.getCrossReferenceEntityDescriptors());
this.aaiConfig = aaiConfig;
+ this.syncDurationInMs = -1;
}
/* (non-Javadoc)
*/
@Override
public OperationState doSync() {
+ this.syncDurationInMs = -1;
String txnID = NodeUtils.getRandomTxnId();
MdcContext.initialize(txnID, "CrossEntitySynchronizer", "", "Sync", "");
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return getStatReport(syncDurationInMs, showFinalReport);
}
/* (non-Javadoc)
* Build generic-query to query child instance self-link from AAI
*/
List<String> orderedQueryKeyParams = new ArrayList<String>();
- orderedQueryKeyParams.add(parentEntityQueryString);
- orderedQueryKeyParams.add(childEntityQueryKeyString);
+ if (SERVICE_INSTANCE.equals(childEntityType)) {
+ orderedQueryKeyParams.clear();
+ orderedQueryKeyParams.add(childEntityQueryKeyString);
+ } else {
+ orderedQueryKeyParams.add(parentEntityQueryString);
+ orderedQueryKeyParams.add(childEntityQueryKeyString);
+ }
String genericQueryStr = null;
try {
genericQueryStr = aaiDataProvider.getGenericQueryForSelfLink(childEntityType, orderedQueryKeyParams);
if (genericQueryStr != null) {
-
+ aaiWorkOnHand.incrementAndGet();
OperationResult aaiQueryResult = aaiDataProvider.queryActiveInventoryWithRetries(
genericQueryStr, "application/json",
aaiConfig.getAaiRestConfig().getNumRequestRetries());
-
+ aaiWorkOnHand.decrementAndGet();
if (aaiQueryResult!= null && aaiQueryResult.wasSuccessful()) {
Collection<JsonNode> entityLinks = new ArrayList<JsonNode>();
parentCrossEntityReferenceAttributeValue);
}
- icer.setLink(selfLink);
+ icer.setLink(ActiveInventoryConfig.extractResourcePath(selfLink));
icer.deriveFields();
import static java.util.concurrent.CompletableFuture.supplyAsync;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import org.openecomp.cl.api.Logger;
import org.openecomp.cl.eelf.LoggerFactory;
+import org.openecomp.cl.mdc.MdcContext;
import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
import org.openecomp.sparky.dal.NetworkTransaction;
import org.openecomp.sparky.dal.elasticsearch.config.ElasticSearchConfig;
import org.openecomp.sparky.util.NodeUtils;
import org.slf4j.MDC;
-import org.openecomp.cl.mdc.MdcContext;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
this.geoDescriptorMap = oxmModelLoader.getGeoEntityDescriptors();
this.aaiEntityStats.initializeCountersFromOxmEntityDescriptors(geoDescriptorMap);
this.esEntityStats.initializeCountersFromOxmEntityDescriptors(geoDescriptorMap);
-
+ this.syncDurationInMs = -1;
}
}
if (geoDescriptorMap.isEmpty()) {
+ setShouldSkipSync(true);
LOG.error(AaiUiMsgs.OXM_FAILED_RETRIEVAL, "geo entities");
return OperationState.ERROR;
}
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return this.getStatReport(syncDurationInMs, showFinalReport);
}
/* (non-Javadoc)
import static java.util.concurrent.CompletableFuture.supplyAsync;
import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Collection;
import org.openecomp.cl.api.Logger;
import org.openecomp.cl.eelf.LoggerFactory;
+import org.openecomp.cl.mdc.MdcContext;
import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
import org.openecomp.sparky.dal.rest.HttpMethod;
import org.openecomp.sparky.dal.rest.OperationResult;
import org.openecomp.sparky.util.NodeUtils;
import org.slf4j.MDC;
-import org.openecomp.cl.mdc.MdcContext;
-
-import org.openecomp.cl.mdc.MdcContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
this.enabledStatFlags = EnumSet.of(StatFlag.AAI_REST_STATS, StatFlag.ES_REST_STATS);
this.syncInProgress = false;
this.contextMap = MDC.getCopyOfContextMap();
+ this.syncDurationInMs = -1;
}
/**
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return this.getStatReport(syncDurationInMs, showFinalReport);
}
/* (non-Javadoc)
import org.openecomp.cl.eelf.LoggerFactory;
import org.openecomp.sparky.config.oxm.OxmEntityDescriptor;
import org.openecomp.sparky.dal.NetworkTransaction;
+import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfig;
import org.openecomp.sparky.dal.elasticsearch.config.ElasticSearchConfig;
import org.openecomp.sparky.dal.rest.HttpMethod;
import org.openecomp.sparky.dal.rest.OperationResult;
oxmModelLoader.getSearchableEntityDescriptors());
this.esEntityStats.initializeCountersFromOxmEntityDescriptors(
oxmModelLoader.getSearchableEntityDescriptors());
+ this.syncDurationInMs = -1;
}
/**
*/
@Override
public OperationState doSync() {
+ this.syncDurationInMs = -1;
String txnID = NodeUtils.getRandomTxnId();
MdcContext.initialize(txnID, "SearchableEntitySynchronizer", "", "Sync", "");
if (jsonResult != null && jsonResult.length() > 0) {
SearchableEntity se = new SearchableEntity(oxmModelLoader);
- se.setLink( txn.getLink() );
+ se.setLink(ActiveInventoryConfig.extractResourcePath(txn.getLink()));
populateSearchableEntityDocument(se, jsonResult, txn.getDescriptor());
se.deriveFields();
*/
@Override
public String getStatReport(boolean showFinalReport) {
- return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs,
- showFinalReport);
+ syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
+ return this.getStatReport(syncDurationInMs, showFinalReport);
}
/* (non-Javadoc)
boolean allDone = false;
long nextReportTimeStampInMs = System.currentTimeMillis() + 30000L;
+ boolean dumpPeriodicStatReport = false;
while (!allDone) {
- // allDone = false;
-
int totalFinished = 0;
for (IndexSynchronizer synchronizer : registeredSynchronizers) {
- if (System.currentTimeMillis() > nextReportTimeStampInMs) {
-
- nextReportTimeStampInMs = System.currentTimeMillis() + 30000L;
-
- String statReport = synchronizer.getStatReport(false);
-
- if (statReport != null) {
- LOG.info(AaiUiMsgs.INFO_GENERIC, statReport);
- }
- }
-
- if (synchronizer.getState() == SynchronizerState.IDLE) {
- totalFinished++;
- }
+ if (dumpPeriodicStatReport) {
+ if (synchronizer.getState() != SynchronizerState.IDLE) {
+ String statReport = synchronizer.getStatReport(false);
+ if (statReport != null) {
+ LOG.info(AaiUiMsgs.INFO_GENERIC, statReport);
+ }
+ }
+ if (synchronizer.getState() == SynchronizerState.IDLE) {
+ totalFinished++;
+ }
+ }
}
-
+ if ( System.currentTimeMillis() > nextReportTimeStampInMs) {
+ dumpPeriodicStatReport = true;
+ nextReportTimeStampInMs = System.currentTimeMillis() + 30000L;
+ } else {
+ dumpPeriodicStatReport = false;
+ }
allDone = (totalFinished == registeredSynchronizers.size());
try {
new HistoricalEntitySummarizer(esConfig.getEntityCountHistoryIndex());
historicalSummarizer.setAaiDataProvider(aaiAdapter);
historicalSummarizer.setEsDataProvider(esAdapter);
- //entityCounterHistorySummarizer.registerEntitySynchronizer(historicalSummarizer);
+ entityCounterHistorySummarizer.registerEntitySynchronizer(historicalSummarizer);
} catch (Exception exc) {
String message = "Error: failed to sync with message = " + exc.getMessage();
public void setRequestParameters(String requestParameters) {
this.requestParameters = requestParameters;
}
-
+
+ public String getSelfLink() {
+ if (processingNode == null) {
+ return null;
+ }
+
+ return processingNode.getSelfLink();
+ }
+
public String getSelfLinkWithModifiers() {
-
if (processingNode == null) {
return null;
}
} else {
selfLink = ((JsonNode) entityLinks.toArray()[0]).asText();
+ selfLink = ActiveInventoryConfig.extractResourcePath(selfLink);
newChildNode.setSelfLink(selfLink);
newChildNode.setNodeId(NodeUtils.generateUniqueShaDigest(selfLink));
txn.setRequestParameters(depthModifier);
aaiWorkOnHand.incrementAndGet();
supplyAsync(
- new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider),
+ new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider, aaiConfig),
aaiExecutorService).whenComplete((nodeTxn, error) -> {
aaiWorkOnHand.decrementAndGet();
if (error != null) {
Relationship[] relationshipArray = relationshipList.getRelationshipList();
OxmEntityDescriptor descriptor = null;
- String repairedSelfLink = null;
if (relationshipArray != null) {
ActiveInventoryNode newNode = null;
+ String resourcePath = null;
for (Relationship r : relationshipArray) {
- repairedSelfLink = aaiConfig.repairSelfLink(r.getRelatedLink());
+ resourcePath = ActiveInventoryConfig.extractResourcePath(r.getRelatedLink());
- String nodeId = NodeUtils.generateUniqueShaDigest(repairedSelfLink);
+ String nodeId = NodeUtils.generateUniqueShaDigest(resourcePath);
if (nodeId == null) {
newNode.setNodeId(nodeId);
newNode.setEntityType(entityType);
- newNode.setSelfLink(repairedSelfLink);
+ newNode.setSelfLink(resourcePath);
processingNode.addOutboundNeighbor(nodeId);
private NodeProcessingTransaction txn;
private ActiveInventoryDataProvider aaiProvider;
private Map<String, String> contextMap;
+ private ActiveInventoryConfig aaiConfig;
/**
* Instantiates a new perform node self link processing task.
* @param aaiProvider the aai provider
*/
public PerformNodeSelfLinkProcessingTask(NodeProcessingTransaction txn, String requestParameters,
- ActiveInventoryDataProvider aaiProvider) {
+ ActiveInventoryDataProvider aaiProvider, ActiveInventoryConfig aaiConfig) {
this.aaiProvider = aaiProvider;
this.txn = txn;
this.contextMap = MDC.getCopyOfContextMap();
+ this.aaiConfig = aaiConfig;
}
/* (non-Javadoc)
@Override
public NodeProcessingTransaction get() {
MDC.setContextMap(contextMap);
- String link = txn.getSelfLinkWithModifiers();
-
+ OperationResult opResult = new OperationResult();
+ String link = txn.getSelfLink();
if (link == null) {
- OperationResult opResult = new OperationResult();
opResult.setResult(500, "Aborting self-link processing because self link is null");
txn.setOpResult(opResult);
return txn;
logger.debug(AaiUiMsgs.DEBUG_GENERIC, "Collecting " + link);
}
- OperationResult opResult = null;
try {
opResult = aaiProvider.queryActiveInventoryWithRetries(link, "application/json",
ActiveInventoryConfig.getConfig().getAaiRestConfig().getNumRequestRetries());
QUERY_PARAM_EXTRACTION_ERROR=\
AAIUI9003E|\
Query Parameter Self-Link Extraction Error: {0}
-
\ No newline at end of file
+
+ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK=\
+ AAIUI9004E|\
+ Error extracting resource path from self-link. Error: {0}
\ No newline at end of file