Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / aggregation / sync / HistoricalEntitySyncController.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.aggregation.sync;
26
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;
39
40 public class HistoricalEntitySyncController extends SyncControllerImpl
41     implements SyncControllerRegistrar {
42
43   private SyncControllerRegistry syncControllerRegistry;
44
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);
52
53     // final String controllerName = "Historical Entity Count Synchronizer";
54
55     long taskFrequencyInMs = syncFrequencyInMinutes * 60 * 1000;
56
57     setDelayInMs(taskFrequencyInMs);
58     setSyncFrequencyInMs(taskFrequencyInMs);
59
60     IndexIntegrityValidator entityCounterHistoryValidator = new IndexIntegrityValidator(esAdapter,
61         schemaConfig, endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
62
63     registerIndexValidator(entityCounterHistoryValidator);
64
65     HistoricalEntitySummarizer historicalSummarizer = new HistoricalEntitySummarizer(schemaConfig,
66         syncControllerConfig.getNumInternalSyncWorkers(),
67         syncControllerConfig.getNumSyncActiveInventoryWorkers(),
68         syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig, esStatConfig,searchableEntityLookup);
69
70     historicalSummarizer.setAaiAdapter(aaiAdapter);
71     historicalSummarizer.setElasticSearchAdapter(esAdapter);
72
73     registerEntitySynchronizer(historicalSummarizer);
74
75   }
76
77   public SyncControllerRegistry getSyncControllerRegistry() {
78     return syncControllerRegistry;
79   }
80
81   public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
82     this.syncControllerRegistry = syncControllerRegistry;
83   }
84
85   @Override
86   public void registerController() {
87     if ( syncControllerRegistry != null ) {
88       if ( syncControllerConfig.isEnabled()) { 
89         syncControllerRegistry.registerSyncController(this);
90       }
91     }
92
93   }
94 }