changed the header license to new license
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / sync / AbstractEntitySynchronizer.java
index bf1a7ee..52de8e4 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.onap.aai.sparky.sync;
 
@@ -35,7 +33,6 @@ import org.onap.aai.sparky.dal.NetworkTransaction;
 import org.onap.aai.sparky.dal.aai.ActiveInventoryEntityStatistics;
 import org.onap.aai.sparky.dal.aai.ActiveInventoryProcessingExceptionStatistics;
 import org.onap.aai.sparky.dal.elasticsearch.ElasticSearchEntityStatistics;
-import org.onap.aai.sparky.dal.elasticsearch.config.ElasticSearchConfig;
 import org.onap.aai.sparky.dal.rest.HttpMethod;
 import org.onap.aai.sparky.dal.rest.RestOperationalStatistics;
 import org.onap.aai.sparky.logging.AaiUiMsgs;
@@ -62,7 +59,8 @@ public abstract class AbstractEntitySynchronizer {
    * The Enum StatFlag.
    */
   protected enum StatFlag {
-    AAI_REST_STATS, AAI_ENTITY_STATS, AAI_PROCESSING_EXCEPTION_STATS, AAI_TASK_PROCESSING_STATS, ES_REST_STATS, ES_ENTITY_STATS, ES_TASK_PROCESSING_STATS
+    AAI_REST_STATS, AAI_ENTITY_STATS, AAI_PROCESSING_EXCEPTION_STATS,
+    AAI_TASK_PROCESSING_STATS, ES_REST_STATS, ES_ENTITY_STATS, ES_TASK_PROCESSING_STATS
   }
 
   protected EnumSet<StatFlag> enabledStatFlags;
@@ -92,7 +90,6 @@ public abstract class AbstractEntitySynchronizer {
   protected String synchronizerName;
 
   protected abstract boolean isSyncDone();
-
   protected boolean shouldSkipSync;
 
   public String getActiveInventoryStatisticsReport() {
@@ -254,7 +251,7 @@ public abstract class AbstractEntitySynchronizer {
   protected AbstractEntitySynchronizer(Logger logger, String syncName, int numSyncWorkers,
       int numActiveInventoryWorkers, int numElasticsearchWorkers, String indexName,
       NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig)
-      throws Exception {
+          throws Exception {
     this.logger = logger;
     this.synchronizerExecutor =
         NodeUtils.createNamedExecutor(syncName + "-INTERNAL", numSyncWorkers, logger);
@@ -263,14 +260,16 @@ public abstract class AbstractEntitySynchronizer {
     this.esExecutor =
         NodeUtils.createNamedExecutor(syncName + "-ES", numElasticsearchWorkers, logger);
     this.mapper = new ObjectMapper();
-    this.indexName = indexName;
+    this.indexName = indexName; 
     this.esRestStats = new RestOperationalStatistics();
     this.esEntityStats = new ElasticSearchEntityStatistics();
     this.aaiRestStats = new RestOperationalStatistics();
     this.aaiEntityStats = new ActiveInventoryEntityStatistics();
     this.aaiProcessingExceptionStats = new ActiveInventoryProcessingExceptionStatistics();
-    this.aaiTaskProcessingStats = new TaskProcessingStats(aaiStatConfig);
-    this.esTaskProcessingStats = new TaskProcessingStats(esStatConfig);
+    this.aaiTaskProcessingStats =
+        new TaskProcessingStats(aaiStatConfig);
+    this.esTaskProcessingStats =
+        new TaskProcessingStats(esStatConfig);
 
     this.aaiTransactionRateController =
         new TransactionRateMonitor(numActiveInventoryWorkers, aaiStatConfig);
@@ -283,9 +282,9 @@ public abstract class AbstractEntitySynchronizer {
     enabledStatFlags = EnumSet.allOf(StatFlag.class);
 
     this.synchronizerName = "Abstact Entity Synchronizer";
-
+    
     String txnID = NodeUtils.getRandomTxnId();
-    MdcContext.initialize(txnID, "AbstractEntitySynchronizer", "", "Sync", "");
+       MdcContext.initialize(txnID, "AbstractEntitySynchronizer", "", "Sync", "");
 
     this.shouldSkipSync = false;
     this.syncStartedTimeStampInMs = System.currentTimeMillis();
@@ -345,9 +344,9 @@ public abstract class AbstractEntitySynchronizer {
       if (esExecutor != null) {
         esExecutor.shutdown();
       }
-
+    
     } catch (Exception exc) {
-      logger.error(AaiUiMsgs.ERROR_SHUTDOWN_EXECUTORS, exc);
+      logger.error(AaiUiMsgs.ERROR_SHUTDOWN_EXECUTORS, exc );
     }
   }
 
@@ -355,7 +354,7 @@ public abstract class AbstractEntitySynchronizer {
    * Clear cache.
    */
   public void clearCache() {}
-
+  
   public ElasticSearchAdapter getElasticSearchAdapter() {
     return elasticSearchAdapter;
   }
@@ -372,32 +371,6 @@ public abstract class AbstractEntitySynchronizer {
     this.aaiAdapter = aaiAdapter;
   }
 
-  /**
-   * Gets the elastic full url.
-   *
-   * @param resourceUrl the resource url
-   * @param indexName the index name
-   * @param indexType the index type
-   * @return the elastic full url
-   * @throws Exception the exception
-   */
-  protected String getElasticFullUrl(String resourceUrl, String indexName, String indexType)
-      throws Exception {
-    return ElasticSearchConfig.getConfig().getElasticFullUrl(resourceUrl, indexName, indexType);
-  }
-
-  /**
-   * Gets the elastic full url.
-   *
-   * @param resourceUrl the resource url
-   * @param indexName the index name
-   * @return the elastic full url
-   * @throws Exception the exception
-   */
-  protected String getElasticFullUrl(String resourceUrl, String indexName) throws Exception {
-    return ElasticSearchConfig.getConfig().getElasticFullUrl(resourceUrl, indexName);
-  }
-
   public String getIndexName() {
     return indexName;
   }
@@ -432,16 +405,6 @@ public abstract class AbstractEntitySynchronizer {
     return -1;
   }
 
-  /**
-   * Update elastic search counters.
-   *
-   * @param method the method
-   * @param or the or
-   */
-  protected void updateElasticSearchCounters(HttpMethod method, OperationResult or) {
-    updateElasticSearchCounters(new NetworkTransaction(method, null, or));
-  }
-
   /**
    * Update elastic search counters.
    *
@@ -473,7 +436,8 @@ public abstract class AbstractEntitySynchronizer {
 
       esTransactionRateController.trackResponseTime(txn.getOpTimeInMs());
 
-      esTaskProcessingStats.updateTaskResponseStatsHistogram(txn.getOpTimeInMs());
+      esTaskProcessingStats
+          .updateTaskResponseStatsHistogram(txn.getOpTimeInMs());
       esTaskProcessingStats.updateTaskAgeStatsHistogram(txn.getTaskAgeInMs());
 
       // don't know the cost of the lengh calc, we'll see if it causes a
@@ -489,16 +453,6 @@ public abstract class AbstractEntitySynchronizer {
     }
   }
 
-  /**
-   * Update active inventory counters.
-   *
-   * @param method the method
-   * @param or the or
-   */
-  protected void updateActiveInventoryCounters(HttpMethod method, OperationResult or) {
-    updateActiveInventoryCounters(new NetworkTransaction(method, null, or));
-  }
-
   /**
    * Update active inventory counters.
    *
@@ -531,9 +485,11 @@ public abstract class AbstractEntitySynchronizer {
     }
 
     if (enabledStatFlags.contains(StatFlag.AAI_TASK_PROCESSING_STATS)) {
-      aaiTransactionRateController.trackResponseTime(txn.getOpTimeInMs());
+      aaiTransactionRateController
+          .trackResponseTime(txn.getOpTimeInMs());
 
-      aaiTaskProcessingStats.updateTaskResponseStatsHistogram(txn.getOpTimeInMs());
+      aaiTaskProcessingStats
+          .updateTaskResponseStatsHistogram(txn.getOpTimeInMs());
       aaiTaskProcessingStats.updateTaskAgeStatsHistogram(txn.getTaskAgeInMs());
 
       // don't know the cost of the lengh calc, we'll see if it causes a