2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sparky.viewinspect.sync;
23 import static java.util.concurrent.CompletableFuture.supplyAsync;
25 import java.io.IOException;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.Deque;
29 import java.util.Iterator;
30 import java.util.List;
32 import java.util.concurrent.ConcurrentHashMap;
33 import java.util.concurrent.ConcurrentLinkedDeque;
34 import java.util.concurrent.ExecutorService;
35 import java.util.function.Supplier;
37 import org.onap.aai.cl.api.Logger;
38 import org.onap.aai.cl.eelf.LoggerFactory;
39 import org.onap.aai.cl.mdc.MdcContext;
40 import org.onap.aai.restclient.client.OperationResult;
41 import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
42 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
43 import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
44 import org.onap.aai.sparky.config.oxm.SearchableOxmEntityDescriptor;
45 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
46 import org.onap.aai.sparky.dal.NetworkTransaction;
47 import org.onap.aai.sparky.dal.rest.HttpMethod;
48 import org.onap.aai.sparky.logging.AaiUiMsgs;
49 import org.onap.aai.sparky.sync.AbstractEntitySynchronizer;
50 import org.onap.aai.sparky.sync.IndexSynchronizer;
51 import org.onap.aai.sparky.sync.SynchronizerConstants;
52 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
53 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
54 import org.onap.aai.sparky.sync.entity.MergableEntity;
55 import org.onap.aai.sparky.sync.entity.SearchableEntity;
56 import org.onap.aai.sparky.sync.entity.SelfLinkDescriptor;
57 import org.onap.aai.sparky.sync.enumeration.OperationState;
58 import org.onap.aai.sparky.sync.enumeration.SynchronizerState;
59 import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
60 import org.onap.aai.sparky.sync.task.PerformElasticSearchPut;
61 import org.onap.aai.sparky.sync.task.PerformElasticSearchRetrieval;
62 import org.onap.aai.sparky.sync.task.PerformElasticSearchUpdate;
63 import org.onap.aai.sparky.util.NodeUtils;
66 import com.fasterxml.jackson.core.JsonProcessingException;
67 import com.fasterxml.jackson.databind.JsonNode;
68 import com.fasterxml.jackson.databind.ObjectReader;
69 import com.fasterxml.jackson.databind.node.ArrayNode;
72 * The Class SearchableEntitySynchronizer.
74 public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
75 implements IndexSynchronizer {
78 * The Class RetrySearchableEntitySyncContainer.
80 private class RetrySearchableEntitySyncContainer {
81 NetworkTransaction txn;
85 * Instantiates a new retry searchable entity sync container.
90 public RetrySearchableEntitySyncContainer(NetworkTransaction txn, SearchableEntity se) {
95 public NetworkTransaction getNetworkTransaction() {
99 public SearchableEntity getSearchableEntity() {
104 private static final Logger LOG =
105 LoggerFactory.getInstance().getLogger(ViewInspectEntitySynchronizer.class);
107 private boolean allWorkEnumerated;
108 private Deque<SelfLinkDescriptor> selflinks;
109 private Deque<RetrySearchableEntitySyncContainer> retryQueue;
110 private Map<String, Integer> retryLimitTracker;
111 protected ExecutorService esPutExecutor;
112 private OxmEntityLookup oxmEntityLookup;
113 private SearchableEntityLookup searchableEntityLookup;
116 * Instantiates a new searchable entity synchronizer.
118 * @param indexName the index name
119 * @throws Exception the exception
121 public ViewInspectEntitySynchronizer(ElasticSearchSchemaConfig schemaConfig,
122 int internalSyncWorkers, int aaiWorkers, int esWorkers, NetworkStatisticsConfig aaiStatConfig,
123 NetworkStatisticsConfig esStatConfig, OxmEntityLookup oxmEntityLookup,
124 SearchableEntityLookup searchableEntityLookup) throws Exception {
125 super(LOG, "SES", internalSyncWorkers, aaiWorkers, esWorkers, schemaConfig.getIndexName(),
126 aaiStatConfig, esStatConfig);
128 this.oxmEntityLookup = oxmEntityLookup;
129 this.searchableEntityLookup = searchableEntityLookup;
130 this.allWorkEnumerated = false;
131 this.selflinks = new ConcurrentLinkedDeque<SelfLinkDescriptor>();
132 this.retryQueue = new ConcurrentLinkedDeque<RetrySearchableEntitySyncContainer>();
133 this.retryLimitTracker = new ConcurrentHashMap<String, Integer>();
134 this.synchronizerName = "Searchable Entity Synchronizer";
135 this.esPutExecutor = NodeUtils.createNamedExecutor("SES-ES-PUT", 5, LOG);
136 this.aaiEntityStats.intializeEntityCounters(
137 searchableEntityLookup.getSearchableEntityDescriptors().keySet());
138 this.esEntityStats.intializeEntityCounters(
139 searchableEntityLookup.getSearchableEntityDescriptors().keySet());
140 this.syncDurationInMs = -1;
144 * Collect all the work.
146 * @return the operation state
148 private OperationState collectAllTheWork() {
149 final Map<String, String> contextMap = MDC.getCopyOfContextMap();
150 Map<String, SearchableOxmEntityDescriptor> descriptorMap =
151 searchableEntityLookup.getSearchableEntityDescriptors();
153 if (descriptorMap.isEmpty()) {
154 LOG.error(AaiUiMsgs.ERROR_LOADING_OXM_SEARCHABLE_ENTITIES);
155 LOG.info(AaiUiMsgs.ERROR_LOADING_OXM_SEARCHABLE_ENTITIES);
156 return OperationState.ERROR;
159 Collection<String> syncTypes = descriptorMap.keySet();
161 /*Collection<String> syncTypes = new ArrayList<String>();
162 syncTypes.add("service-instance");*/
167 * launch a parallel async thread to process the documents for each entity-type (to max the
168 * of the configured executor anyway)
171 aaiWorkOnHand.set(syncTypes.size());
173 for (String key : syncTypes) {
175 supplyAsync(new Supplier<Void>() {
179 MDC.setContextMap(contextMap);
180 OperationResult typeLinksResult = null;
182 typeLinksResult = aaiAdapter.getSelfLinksByEntityType(key);
183 System.out.println(typeLinksResult);
184 aaiWorkOnHand.decrementAndGet();
185 processEntityTypeSelfLinks(typeLinksResult);
186 } catch (Exception exc) {
187 // TODO -> LOG, what should be logged here?
193 }, aaiExecutor).whenComplete((result, error) -> {
196 LOG.error(AaiUiMsgs.ERROR_GENERIC,
197 "An error occurred getting data from AAI. Error = " + error.getMessage());
203 while (aaiWorkOnHand.get() != 0) {
205 if (LOG.isDebugEnabled()) {
206 LOG.debug(AaiUiMsgs.WAIT_FOR_ALL_SELFLINKS_TO_BE_COLLECTED);
212 aaiWorkOnHand.set(selflinks.size());
213 allWorkEnumerated = true;
216 while (!isSyncDone()) {
222 * Make sure we don't hang on to retries that failed which could cause issues during future
225 retryLimitTracker.clear();
227 } catch (Exception exc) {
228 // TODO -> LOG, waht should be logged here?
231 return OperationState.OK;
235 * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#doSync()
238 public OperationState doSync() {
239 this.syncDurationInMs = -1;
240 String txnID = NodeUtils.getRandomTxnId();
241 MdcContext.initialize(txnID, "SearchableEntitySynchronizer", "", "Sync", "");
244 this.allWorkEnumerated = false;
245 syncStartedTimeStampInMs = System.currentTimeMillis();
248 return OperationState.OK;
252 * Process entity type self links.
254 * @param operationResult the operation result
256 private void processEntityTypeSelfLinks(OperationResult operationResult) {
258 JsonNode rootNode = null;
260 final String jsonResult = operationResult.getResult();
262 if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
265 rootNode = mapper.readTree(jsonResult);
266 } catch (IOException exc) {
268 "Could not deserialize JSON (representing operation result) as node tree. " +
269 "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
270 LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
273 JsonNode resultData = rootNode.get("result-data");
274 ArrayNode resultDataArrayNode = null;
276 if (resultData.isArray()) {
277 resultDataArrayNode = (ArrayNode) resultData;
279 Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
280 JsonNode element = null;
282 while (elementIterator.hasNext()) {
283 element = elementIterator.next();
285 final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
286 final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
288 SearchableOxmEntityDescriptor descriptor = null;
290 if (resourceType != null && resourceLink != null) {
292 descriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resourceType);
294 if (descriptor == null) {
295 LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
296 // go to next element in iterator
300 if (descriptor.hasSearchableAttributes()) {
301 selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
314 private void syncEntityTypes() {
316 while (selflinks.peek() != null) {
318 SelfLinkDescriptor linkDescriptor = selflinks.poll();
319 aaiWorkOnHand.decrementAndGet();
321 OxmEntityDescriptor descriptor = null;
323 if (linkDescriptor.getSelfLink() != null && linkDescriptor.getEntityType() != null) {
325 descriptor = oxmEntityLookup.getEntityDescriptors().get(linkDescriptor.getEntityType());
327 if (descriptor == null) {
328 LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, linkDescriptor.getEntityType());
329 // go to next element in iterator
333 NetworkTransaction txn = new NetworkTransaction();
334 txn.setDescriptor(descriptor);
335 txn.setLink(linkDescriptor.getSelfLink());
336 txn.setOperationType(HttpMethod.GET);
337 txn.setEntityType(linkDescriptor.getEntityType());
339 aaiWorkOnHand.incrementAndGet();
341 supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor)
342 .whenComplete((result, error) -> {
344 aaiWorkOnHand.decrementAndGet();
347 LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_GENERIC, error.getLocalizedMessage());
349 if (result == null) {
350 LOG.error(AaiUiMsgs.AAI_RETRIEVAL_FAILED_FOR_SELF_LINK,
351 linkDescriptor.getSelfLink());
353 updateActiveInventoryCounters(result);
354 fetchDocumentForUpsert(result);
365 * Perform document upsert.
367 * @param esGetTxn the es get txn
370 protected void performDocumentUpsert(NetworkTransaction esGetTxn, SearchableEntity se) {
374 * As part of the response processing we need to do the following:
375 * <li>1. Extract the version (if present), it will be the ETAG when we use the
376 * Search-Abstraction-Service
377 * <li>2. Spawn next task which is to do the PUT operation into elastic with or with the version
379 * <li>a) if version is null or RC=404, then standard put, no _update with version tag
380 * <li>b) if version != null, do PUT with _update?version= versionNumber in the URI to elastic
386 link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
387 } catch (Exception exc) {
388 LOG.error(AaiUiMsgs.ES_LINK_UPSERT, exc.getLocalizedMessage());
392 String versionNumber = null;
393 boolean wasEntryDiscovered = false;
394 if (esGetTxn.getOperationResult().getResultCode() == 404) {
395 LOG.info(AaiUiMsgs.ES_SIMPLE_PUT, se.getEntityPrimaryKeyValue());
396 } else if (esGetTxn.getOperationResult().getResultCode() == 200) {
397 wasEntryDiscovered = true;
399 versionNumber = NodeUtils.extractFieldValueFromObject(
400 NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
402 } catch (IOException exc) {
404 "Error extracting version number from response, aborting searchable entity sync of "
405 + se.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
406 LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
411 * Not being a 200 does not mean a failure. eg 201 is returned for created. TODO -> Should we
414 LOG.error(AaiUiMsgs.ES_OPERATION_RETURN_CODE,
415 String.valueOf(esGetTxn.getOperationResult().getResultCode()));
420 String jsonPayload = null;
421 if (wasEntryDiscovered) {
423 ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
424 NodeUtils.extractObjectsByKey(
425 NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
426 "_source", sourceObject);
428 if (!sourceObject.isEmpty()) {
429 String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
430 MergableEntity me = mapper.readValue(responseSource, MergableEntity.class);
431 ObjectReader updater = mapper.readerForUpdating(me);
432 MergableEntity merged = updater.readValue(NodeUtils.convertObjectToJson(se,false));
433 jsonPayload = mapper.writeValueAsString(merged);
435 } catch (IOException exc) {
437 "Error extracting source value from response, aborting searchable entity sync of "
438 + se.getEntityPrimaryKeyValue() + ". Error - " + exc.getLocalizedMessage();
439 LOG.error(AaiUiMsgs.ERROR_EXTRACTING_FROM_RESPONSE, message);
443 jsonPayload = se.getAsJson();
446 if (wasEntryDiscovered) {
447 if (versionNumber != null && jsonPayload != null) {
449 String requestPayload = elasticSearchAdapter.buildBulkImportOperationRequest(getIndexName(),
450 "default", se.getId(), versionNumber, jsonPayload);
452 NetworkTransaction transactionTracker = new NetworkTransaction();
453 transactionTracker.setEntityType(esGetTxn.getEntityType());
454 transactionTracker.setDescriptor(esGetTxn.getDescriptor());
455 transactionTracker.setOperationType(HttpMethod.PUT);
457 esWorkOnHand.incrementAndGet();
458 supplyAsync(new PerformElasticSearchUpdate(elasticSearchAdapter.getBulkUrl(),
459 requestPayload, elasticSearchAdapter, transactionTracker), esPutExecutor)
460 .whenComplete((result, error) -> {
462 esWorkOnHand.decrementAndGet();
465 String message = "Searchable entity sync UPDATE PUT error - "
466 + error.getLocalizedMessage();
467 LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
469 updateElasticSearchCounters(result);
470 processStoreDocumentResult(result, esGetTxn, se);
477 if (link != null && jsonPayload != null) {
479 NetworkTransaction updateElasticTxn = new NetworkTransaction();
480 updateElasticTxn.setLink(link);
481 updateElasticTxn.setEntityType(esGetTxn.getEntityType());
482 updateElasticTxn.setDescriptor(esGetTxn.getDescriptor());
483 updateElasticTxn.setOperationType(HttpMethod.PUT);
485 esWorkOnHand.incrementAndGet();
486 supplyAsync(new PerformElasticSearchPut(jsonPayload, updateElasticTxn, elasticSearchAdapter),
487 esPutExecutor).whenComplete((result, error) -> {
489 esWorkOnHand.decrementAndGet();
493 "Searchable entity sync UPDATE PUT error - " + error.getLocalizedMessage();
494 LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
496 updateElasticSearchCounters(result);
497 processStoreDocumentResult(result, esGetTxn, se);
502 } catch (Exception exc) {
503 String message = "Exception caught during searchable entity sync PUT operation. Message - "
504 + exc.getLocalizedMessage();
505 LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
510 * Populate searchable entity document.
513 * @param result the result
514 * @param resultDescriptor the result descriptor
515 * @throws JsonProcessingException the json processing exception
516 * @throws IOException Signals that an I/O exception has occurred.
518 protected void populateSearchableEntityDocument(SearchableEntity doc, String result,
519 OxmEntityDescriptor resultDescriptor) throws JsonProcessingException, IOException {
521 doc.setEntityType(resultDescriptor.getEntityName());
523 JsonNode entityNode = mapper.readTree(result);
525 List<String> primaryKeyValues = new ArrayList<String>();
526 String pkeyValue = null;
528 SearchableOxmEntityDescriptor searchableDescriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resultDescriptor.getEntityName());
530 for (String keyName : searchableDescriptor.getPrimaryKeyAttributeNames()) {
531 pkeyValue = NodeUtils.getNodeFieldAsText(entityNode, keyName);
532 if (pkeyValue != null) {
533 primaryKeyValues.add(pkeyValue);
535 String message = "populateSearchableEntityDocument(), pKeyValue is null for entityType = "
536 + resultDescriptor.getEntityName();
537 LOG.warn(AaiUiMsgs.WARN_GENERIC, message);
541 final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
542 doc.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
544 final List<String> searchTagFields = searchableDescriptor.getSearchableAttributes();
547 * Based on configuration, use the configured field names for this entity-Type to build a
548 * multi-value collection of search tags for elastic search entity search criteria.
550 for (String searchTagField : searchTagFields) {
551 String searchTagValue = NodeUtils.getNodeFieldAsText(entityNode, searchTagField);
552 if (searchTagValue != null && !searchTagValue.isEmpty()) {
553 doc.addSearchTagWithKey(searchTagValue, searchTagField);
559 * Fetch document for upsert.
563 private void fetchDocumentForUpsert(NetworkTransaction txn) {
564 if (!txn.getOperationResult().wasSuccessful()) {
565 String message = "Self link failure. Result - " + txn.getOperationResult().getResult();
566 LOG.error(AaiUiMsgs.ERROR_GENERIC, message);
570 SearchableOxmEntityDescriptor searchableDescriptor = searchableEntityLookup
571 .getSearchableEntityDescriptors().get(txn.getDescriptor().getEntityName());
574 if (searchableDescriptor.hasSearchableAttributes()) {
576 final String jsonResult = txn.getOperationResult().getResult();
577 if (jsonResult != null && jsonResult.length() > 0) {
579 SearchableEntity se = new SearchableEntity();
580 se.setLink(ActiveInventoryAdapter.extractResourcePath(txn.getLink()));
581 populateSearchableEntityDocument(se, jsonResult, txn.getDescriptor());
586 link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
587 } catch (Exception exc) {
588 LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_QUERY, exc.getLocalizedMessage());
592 NetworkTransaction n2 = new NetworkTransaction();
594 n2.setEntityType(txn.getEntityType());
595 n2.setDescriptor(txn.getDescriptor());
596 n2.setOperationType(HttpMethod.GET);
598 esWorkOnHand.incrementAndGet();
600 supplyAsync(new PerformElasticSearchRetrieval(n2, elasticSearchAdapter), esExecutor)
601 .whenComplete((result, error) -> {
603 esWorkOnHand.decrementAndGet();
606 LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED, error.getLocalizedMessage());
608 updateElasticSearchCounters(result);
609 performDocumentUpsert(result, se);
616 } catch (JsonProcessingException exc) {
617 // TODO -> LOG, waht should be logged here?
618 } catch (IOException exc) {
619 // TODO -> LOG, waht should be logged here?
624 * Process store document result.
626 * @param esPutResult the es put result
627 * @param esGetResult the es get result
630 private void processStoreDocumentResult(NetworkTransaction esPutResult,
631 NetworkTransaction esGetResult, SearchableEntity se) {
633 OperationResult or = esPutResult.getOperationResult();
635 if (!or.wasSuccessful()) {
636 if (or.getResultCode() == VERSION_CONFLICT_EXCEPTION_CODE) {
638 if (shouldAllowRetry(se.getId())) {
639 esWorkOnHand.incrementAndGet();
641 RetrySearchableEntitySyncContainer rsc =
642 new RetrySearchableEntitySyncContainer(esGetResult, se);
643 retryQueue.push(rsc);
645 String message = "Store document failed during searchable entity synchronization"
646 + " due to version conflict. Entity will be re-synced.";
647 LOG.warn(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
651 "Store document failed during searchable entity synchronization with result code "
652 + or.getResultCode() + " and result message " + or.getResult();
653 LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
659 * Perform retry sync.
661 private void performRetrySync() {
662 while (retryQueue.peek() != null) {
664 RetrySearchableEntitySyncContainer rsc = retryQueue.poll();
667 SearchableEntity se = rsc.getSearchableEntity();
668 NetworkTransaction txn = rsc.getNetworkTransaction();
673 * In this retry flow the se object has already derived its fields
675 link = elasticSearchAdapter.buildElasticSearchGetDocUrl(getIndexName(), se.getId());
676 } catch (Exception exc) {
677 LOG.error(AaiUiMsgs.ES_FAILED_TO_CONSTRUCT_URI, exc.getLocalizedMessage());
681 NetworkTransaction retryTransaction = new NetworkTransaction();
682 retryTransaction.setLink(link);
683 retryTransaction.setEntityType(txn.getEntityType());
684 retryTransaction.setDescriptor(txn.getDescriptor());
685 retryTransaction.setOperationType(HttpMethod.GET);
688 * IMPORTANT - DO NOT incrementAndGet the esWorkOnHand as this is a retry flow! We already
689 * called incrementAndGet when queuing the failed PUT!
692 supplyAsync(new PerformElasticSearchRetrieval(retryTransaction, elasticSearchAdapter),
693 esExecutor).whenComplete((result, error) -> {
695 esWorkOnHand.decrementAndGet();
698 LOG.error(AaiUiMsgs.ES_RETRIEVAL_FAILED_RESYNC, error.getLocalizedMessage());
700 updateElasticSearchCounters(result);
701 performDocumentUpsert(result, se);
711 * Should allow retry.
714 * @return true, if successful
716 private boolean shouldAllowRetry(String id) {
717 boolean isRetryAllowed = true;
718 if (retryLimitTracker.get(id) != null) {
719 Integer currentCount = retryLimitTracker.get(id);
720 if (currentCount.intValue() >= RETRY_COUNT_PER_ENTITY_LIMIT.intValue()) {
721 isRetryAllowed = false;
722 String message = "Searchable entity re-sync limit reached for " + id
723 + ", re-sync will no longer be attempted for this entity";
724 LOG.error(AaiUiMsgs.ES_SEARCHABLE_ENTITY_SYNC_ERROR, message);
726 Integer newCount = new Integer(currentCount.intValue() + 1);
727 retryLimitTracker.put(id, newCount);
730 Integer firstRetryCount = new Integer(1);
731 retryLimitTracker.put(id, firstRetryCount);
734 return isRetryAllowed;
738 public SynchronizerState getState() {
740 return SynchronizerState.PERFORMING_SYNCHRONIZATION;
743 return SynchronizerState.IDLE;
748 * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#getStatReport(boolean)
751 public String getStatReport(boolean showFinalReport) {
752 syncDurationInMs = System.currentTimeMillis() - syncStartedTimeStampInMs;
753 return this.getStatReport(syncDurationInMs, showFinalReport);
757 * @see org.openecomp.sparky.synchronizer.IndexSynchronizer#shutdown()
760 public void shutdown() {
761 this.shutdownExecutors();
765 protected boolean isSyncDone() {
766 int totalWorkOnHand = aaiWorkOnHand.get() + esWorkOnHand.get();
768 if (totalWorkOnHand > 0 || !allWorkEnumerated) {