93b6eb40cd0bb1dbdfda07a9dc54b60b6bc86b5a
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / topology / sync / GeoSyncController.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.topology.sync;
26
27 import org.onap.aai.sparky.config.oxm.GeoEntityLookup;
28 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
29 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
30 import org.onap.aai.sparky.dal.ElasticSearchAdapter;
31 import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
32 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
33 import org.onap.aai.sparky.sync.IndexCleaner;
34 import org.onap.aai.sparky.sync.IndexIntegrityValidator;
35 import org.onap.aai.sparky.sync.SyncControllerImpl;
36 import org.onap.aai.sparky.sync.SyncControllerRegistrar;
37 import org.onap.aai.sparky.sync.SyncControllerRegistry;
38 import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
39 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
40 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
41 import org.onap.aai.sparky.sync.config.SyncControllerConfig;
42
43 public class GeoSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
44
45   private SyncControllerRegistry syncControllerRegistry;
46
47   public GeoSyncController(SyncControllerConfig syncControllerConfig,
48       ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
49       ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
50       NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
51       GeoEntityLookup geoEntityLookup, OxmEntityLookup oxmEntityLookup,
52       ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
53     super(syncControllerConfig);
54
55     // final String controllerName = "Inventory Geo Synchronizer";
56     
57     IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
58         endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
59
60     registerIndexValidator(indexValidator);
61
62     GeoSynchronizer synchronizer =
63         new GeoSynchronizer(schemaConfig, syncControllerConfig.getNumInternalSyncWorkers(),
64             syncControllerConfig.getNumSyncActiveInventoryWorkers(),
65             syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
66             geoEntityLookup, oxmEntityLookup);
67
68     synchronizer.setAaiAdapter(aaiAdapter);
69     synchronizer.setElasticSearchAdapter(esAdapter);
70
71     registerEntitySynchronizer(synchronizer);
72
73
74     IndexCleaner indexCleaner =
75         new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
76
77     registerIndexCleaner(indexCleaner);
78
79   }
80
81   public SyncControllerRegistry getSyncControllerRegistry() {
82     return syncControllerRegistry;
83   }
84
85   public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
86     this.syncControllerRegistry = syncControllerRegistry;
87   }
88
89   @Override
90   public void registerController() {
91
92     if ( syncControllerRegistry != null ) {
93       if ( syncControllerConfig.isEnabled()) { 
94         syncControllerRegistry.registerSyncController(this);
95       }
96     }
97   }
98
99
100
101 }