2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
25 package org.onap.aai.sparky.aggregation.sync;
27 import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
28 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
29 import org.onap.aai.sparky.dal.ElasticSearchAdapter;
30 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
31 import org.onap.aai.sparky.sync.IndexIntegrityValidator;
32 import org.onap.aai.sparky.sync.SyncControllerImpl;
33 import org.onap.aai.sparky.sync.SyncControllerRegistrar;
34 import org.onap.aai.sparky.sync.SyncControllerRegistry;
35 import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
36 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
37 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
38 import org.onap.aai.sparky.sync.config.SyncControllerConfig;
40 public class HistoricalEntitySyncController extends SyncControllerImpl
41 implements SyncControllerRegistrar {
43 private SyncControllerRegistry syncControllerRegistry;
45 public HistoricalEntitySyncController(SyncControllerConfig syncControllerConfig,
46 ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
47 ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
48 int syncFrequencyInMinutes, NetworkStatisticsConfig aaiStatConfig,
49 NetworkStatisticsConfig esStatConfig, SearchableEntityLookup searchableEntityLookup,
50 ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
51 super(syncControllerConfig);
53 // final String controllerName = "Historical Entity Count Synchronizer";
55 long taskFrequencyInMs = syncFrequencyInMinutes * 60 * 1000;
57 setDelayInMs(taskFrequencyInMs);
58 setSyncFrequencyInMs(taskFrequencyInMs);
60 IndexIntegrityValidator entityCounterHistoryValidator = new IndexIntegrityValidator(esAdapter,
61 schemaConfig, endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
63 registerIndexValidator(entityCounterHistoryValidator);
65 HistoricalEntitySummarizer historicalSummarizer = new HistoricalEntitySummarizer(schemaConfig,
66 syncControllerConfig.getNumInternalSyncWorkers(),
67 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
68 syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig, esStatConfig,searchableEntityLookup);
70 historicalSummarizer.setAaiAdapter(aaiAdapter);
71 historicalSummarizer.setElasticSearchAdapter(esAdapter);
73 registerEntitySynchronizer(historicalSummarizer);
77 public SyncControllerRegistry getSyncControllerRegistry() {
78 return syncControllerRegistry;
81 public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
82 this.syncControllerRegistry = syncControllerRegistry;
86 public void registerController() {
87 if ( syncControllerRegistry != null ) {
88 if ( syncControllerConfig.isEnabled()) {
89 syncControllerRegistry.registerSyncController(this);