diff options
author | ARUL NAMBI <arul.nambi@amdocs.com> | 2017-07-25 14:46:08 -0400 |
---|---|---|
committer | ARUL NAMBI <arul.nambi@amdocs.com> | 2017-07-25 14:46:59 -0400 |
commit | d4241a5c945d04e44716851cfd2b7ef427accb48 (patch) | |
tree | 805b432231bca7732ea30af365d2b53f534c0ddd /src | |
parent | f8de1f25e7c71380a61b96d5251f224e3a4c821f (diff) |
Fixing the sync issues with AAI
Issue-ID: AAI-73
Change-Id: I5c7df7c24c59c347b112cdb003eea726e239a1ca
Signed-off-by: ARUL NAMBI <arul.nambi@amdocs.com>
Diffstat (limited to 'src')
16 files changed, 126 insertions, 81 deletions
diff --git a/src/main/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfig.java b/src/main/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfig.java index c0f5db8..1a2e59e 100644 --- a/src/main/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfig.java +++ b/src/main/java/org/openecomp/sparky/dal/aai/config/ActiveInventoryConfig.java @@ -26,15 +26,18 @@ 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. */ @@ -45,7 +48,8 @@ public 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"; @@ -141,7 +145,16 @@ public class ActiveInventoryConfig { 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() */ diff --git a/src/main/java/org/openecomp/sparky/logging/AaiUiMsgs.java b/src/main/java/org/openecomp/sparky/logging/AaiUiMsgs.java index a06559c..cdd2a77 100644 --- a/src/main/java/org/openecomp/sparky/logging/AaiUiMsgs.java +++ b/src/main/java/org/openecomp/sparky/logging/AaiUiMsgs.java @@ -411,8 +411,9 @@ public enum AaiUiMsgs implements LogMessageEnum { /** 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... */ diff --git a/src/main/java/org/openecomp/sparky/synchronizer/AbstractEntitySynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/AbstractEntitySynchronizer.java index 14ea149..024e8f7 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/AbstractEntitySynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/AbstractEntitySynchronizer.java @@ -63,7 +63,7 @@ public abstract class AbstractEntitySynchronizer { protected final Logger logger; protected ObjectMapper mapper; protected OxmModelLoader oxmModelLoader; - + protected long syncDurationInMs; /** * The Enum StatFlag. */ @@ -99,7 +99,8 @@ public abstract class AbstractEntitySynchronizer { protected String synchronizerName; protected abstract boolean isSyncDone(); - + protected boolean shouldSkipSync; + public String getActiveInventoryStatisticsReport() { StringBuilder sb = new StringBuilder(128); @@ -293,7 +294,18 @@ public abstract class AbstractEntitySynchronizer { 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; } /** diff --git a/src/main/java/org/openecomp/sparky/synchronizer/AggregationSuggestionSynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/AggregationSuggestionSynchronizer.java index 0337f6a..75200be 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/AggregationSuggestionSynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/AggregationSuggestionSynchronizer.java @@ -27,15 +27,12 @@ package org.openecomp.sparky.synchronizer; 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; @@ -87,7 +84,8 @@ public class AggregationSuggestionSynchronizer extends AbstractEntitySynchronize @Override public OperationState doSync() { isSyncInProgress = true; - + this.syncDurationInMs = -1; + syncStartedTimeStampInMs = System.currentTimeMillis(); syncEntity(); while (!isSyncDone()) { @@ -176,8 +174,8 @@ public class AggregationSuggestionSynchronizer extends AbstractEntitySynchronize @Override public String getStatReport(boolean shouldDisplayFinalReport) { - return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs, - shouldDisplayFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return getStatReport(syncDurationInMs, shouldDisplayFinalReport); } @Override diff --git a/src/main/java/org/openecomp/sparky/synchronizer/AggregationSynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/AggregationSynchronizer.java index ba1fb24..1f8be1d 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/AggregationSynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/AggregationSynchronizer.java @@ -54,6 +54,7 @@ import org.openecomp.cl.api.Logger; 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; @@ -554,7 +555,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer 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(); @@ -680,6 +681,8 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer */ @Override public OperationState doSync() { + this.syncDurationInMs = -1; + syncStartedTimeStampInMs = System.currentTimeMillis(); String txnID = NodeUtils.getRandomTxnId(); MdcContext.initialize(txnID, "AggregationSynchronizer", "", "Sync", ""); @@ -704,8 +707,8 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer */ @Override public String getStatReport(boolean showFinalReport) { - return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return getStatReport(syncDurationInMs, showFinalReport); } public String getEntityType() { diff --git a/src/main/java/org/openecomp/sparky/synchronizer/AutosuggestionSynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/AutosuggestionSynchronizer.java index 05a9698..2966c1f 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/AutosuggestionSynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/AutosuggestionSynchronizer.java @@ -28,8 +28,6 @@ package org.openecomp.sparky.synchronizer; 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; @@ -47,8 +45,10 @@ import java.util.function.Supplier; 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; @@ -64,11 +64,6 @@ import org.openecomp.sparky.util.NodeUtils; 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; @@ -135,6 +130,7 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer this.syncInProgress = false; this.contextMap = MDC.getCopyOfContextMap(); this.esPutExecutor = NodeUtils.createNamedExecutor("SUES-ES-PUT", 5, LOG); + this.syncDurationInMs = -1; } /** @@ -232,6 +228,8 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer */ @Override public OperationState doSync() { + this.syncDurationInMs = -1; + syncStartedTimeStampInMs = System.currentTimeMillis(); String txnID = NodeUtils.getRandomTxnId(); MdcContext.initialize(txnID, "AutosuggestionSynchronizer", "", "Sync", ""); @@ -400,6 +398,7 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer 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(); @@ -676,8 +675,8 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer */ @Override public String getStatReport(boolean showFinalReport) { - return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return getStatReport(syncDurationInMs, showFinalReport); } /* diff --git a/src/main/java/org/openecomp/sparky/synchronizer/CrossEntityReferenceSynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/CrossEntityReferenceSynchronizer.java index 2ba2500..c1da401 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/CrossEntityReferenceSynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/CrossEntityReferenceSynchronizer.java @@ -106,7 +106,8 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer 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; @@ -133,6 +134,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer this.esEntityStats.initializeCountersFromOxmEntityDescriptors( oxmModelLoader.getCrossReferenceEntityDescriptors()); this.aaiConfig = aaiConfig; + this.syncDurationInMs = -1; } /* (non-Javadoc) @@ -140,6 +142,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer */ @Override public OperationState doSync() { + this.syncDurationInMs = -1; String txnID = NodeUtils.getRandomTxnId(); MdcContext.initialize(txnID, "CrossEntitySynchronizer", "", "Sync", ""); @@ -163,8 +166,8 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer */ @Override public String getStatReport(boolean showFinalReport) { - return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return getStatReport(syncDurationInMs, showFinalReport); } /* (non-Javadoc) @@ -483,18 +486,23 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer * 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>(); @@ -527,7 +535,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer parentCrossEntityReferenceAttributeValue); } - icer.setLink(selfLink); + icer.setLink(ActiveInventoryConfig.extractResourcePath(selfLink)); icer.deriveFields(); diff --git a/src/main/java/org/openecomp/sparky/synchronizer/GeoSynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/GeoSynchronizer.java index e53c5a7..2715b61 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/GeoSynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/GeoSynchronizer.java @@ -28,8 +28,6 @@ package org.openecomp.sparky.synchronizer; 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; @@ -41,6 +39,7 @@ import java.util.function.Supplier; 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; @@ -56,7 +55,6 @@ import org.openecomp.sparky.synchronizer.task.StoreDocumentTask; 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; @@ -90,7 +88,7 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index this.geoDescriptorMap = oxmModelLoader.getGeoEntityDescriptors(); this.aaiEntityStats.initializeCountersFromOxmEntityDescriptors(geoDescriptorMap); this.esEntityStats.initializeCountersFromOxmEntityDescriptors(geoDescriptorMap); - + this.syncDurationInMs = -1; } @@ -126,6 +124,7 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index } if (geoDescriptorMap.isEmpty()) { + setShouldSkipSync(true); LOG.error(AaiUiMsgs.OXM_FAILED_RETRIEVAL, "geo entities"); return OperationState.ERROR; } @@ -401,8 +400,8 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index */ @Override public String getStatReport(boolean showFinalReport) { - return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return this.getStatReport(syncDurationInMs, showFinalReport); } /* (non-Javadoc) diff --git a/src/main/java/org/openecomp/sparky/synchronizer/HistoricalEntitySummarizer.java b/src/main/java/org/openecomp/sparky/synchronizer/HistoricalEntitySummarizer.java index 81201d2..0fc79c6 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/HistoricalEntitySummarizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/HistoricalEntitySummarizer.java @@ -28,8 +28,6 @@ package org.openecomp.sparky.synchronizer; 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; @@ -45,6 +43,7 @@ import javax.json.Json; 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; @@ -54,9 +53,6 @@ import org.openecomp.sparky.synchronizer.enumeration.SynchronizerState; 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; @@ -89,6 +85,7 @@ public class HistoricalEntitySummarizer extends AbstractEntitySynchronizer this.enabledStatFlags = EnumSet.of(StatFlag.AAI_REST_STATS, StatFlag.ES_REST_STATS); this.syncInProgress = false; this.contextMap = MDC.getCopyOfContextMap(); + this.syncDurationInMs = -1; } /** @@ -319,8 +316,8 @@ public class HistoricalEntitySummarizer extends AbstractEntitySynchronizer */ @Override public String getStatReport(boolean showFinalReport) { - return getStatReport(System.currentTimeMillis() - this.syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return this.getStatReport(syncDurationInMs, showFinalReport); } /* (non-Javadoc) diff --git a/src/main/java/org/openecomp/sparky/synchronizer/SearchableEntitySynchronizer.java b/src/main/java/org/openecomp/sparky/synchronizer/SearchableEntitySynchronizer.java index 3ebf203..76b625c 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/SearchableEntitySynchronizer.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/SearchableEntitySynchronizer.java @@ -54,6 +54,7 @@ import org.openecomp.cl.api.Logger; 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; @@ -131,6 +132,7 @@ public class SearchableEntitySynchronizer extends AbstractEntitySynchronizer oxmModelLoader.getSearchableEntityDescriptors()); this.esEntityStats.initializeCountersFromOxmEntityDescriptors( oxmModelLoader.getSearchableEntityDescriptors()); + this.syncDurationInMs = -1; } /** @@ -228,6 +230,7 @@ public class SearchableEntitySynchronizer extends AbstractEntitySynchronizer */ @Override public OperationState doSync() { + this.syncDurationInMs = -1; String txnID = NodeUtils.getRandomTxnId(); MdcContext.initialize(txnID, "SearchableEntitySynchronizer", "", "Sync", ""); @@ -562,7 +565,7 @@ public class SearchableEntitySynchronizer extends AbstractEntitySynchronizer 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(); @@ -734,8 +737,8 @@ public class SearchableEntitySynchronizer extends AbstractEntitySynchronizer */ @Override public String getStatReport(boolean showFinalReport) { - return this.getStatReport(System.currentTimeMillis() - syncStartedTimeStampInMs, - showFinalReport); + syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs; + return this.getStatReport(syncDurationInMs, showFinalReport); } /* (non-Javadoc) diff --git a/src/main/java/org/openecomp/sparky/synchronizer/SyncController.java b/src/main/java/org/openecomp/sparky/synchronizer/SyncController.java index 85cbeb5..5d5ef61 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/SyncController.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/SyncController.java @@ -422,30 +422,31 @@ public class SyncController { 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 { diff --git a/src/main/java/org/openecomp/sparky/synchronizer/SyncHelper.java b/src/main/java/org/openecomp/sparky/synchronizer/SyncHelper.java index 7c37859..2c1188b 100644 --- a/src/main/java/org/openecomp/sparky/synchronizer/SyncHelper.java +++ b/src/main/java/org/openecomp/sparky/synchronizer/SyncHelper.java @@ -438,7 +438,7 @@ public class SyncHelper { 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(); diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java b/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java index f881f06..178dc46 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java @@ -49,9 +49,16 @@ public class NodeProcessingTransaction { 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; } diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java b/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java index c5adfd4..7c8714f 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java @@ -405,6 +405,7 @@ public class VisualizationContext { } else { selfLink = ((JsonNode) entityLinks.toArray()[0]).asText(); + selfLink = ActiveInventoryConfig.extractResourcePath(selfLink); newChildNode.setSelfLink(selfLink); newChildNode.setNodeId(NodeUtils.generateUniqueShaDigest(selfLink)); @@ -677,7 +678,7 @@ public class VisualizationContext { 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) { @@ -1184,17 +1185,17 @@ public class VisualizationContext { 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) { @@ -1218,7 +1219,7 @@ public class VisualizationContext { newNode.setNodeId(nodeId); newNode.setEntityType(entityType); - newNode.setSelfLink(repairedSelfLink); + newNode.setSelfLink(resourcePath); processingNode.addOutboundNeighbor(nodeId); diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java index b7fe3a5..1918e60 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java @@ -48,6 +48,7 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin private NodeProcessingTransaction txn; private ActiveInventoryDataProvider aaiProvider; private Map<String, String> contextMap; + private ActiveInventoryConfig aaiConfig; /** * Instantiates a new perform node self link processing task. @@ -57,10 +58,11 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin * @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) @@ -69,10 +71,9 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin @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; @@ -82,7 +83,6 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin logger.debug(AaiUiMsgs.DEBUG_GENERIC, "Collecting " + link); } - OperationResult opResult = null; try { opResult = aaiProvider.queryActiveInventoryWithRetries(link, "application/json", ActiveInventoryConfig.getConfig().getAaiRestConfig().getNumRequestRetries()); diff --git a/src/main/resources/logging/AAIUIMsgs.properties b/src/main/resources/logging/AAIUIMsgs.properties index 99e40c8..a70d9df 100644 --- a/src/main/resources/logging/AAIUIMsgs.properties +++ b/src/main/resources/logging/AAIUIMsgs.properties @@ -794,4 +794,7 @@ SEARCH_ADAPTER_ERROR=\ 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 |