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.topology.sync;
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;
43 public class GeoSyncController extends SyncControllerImpl implements SyncControllerRegistrar {
45 private SyncControllerRegistry syncControllerRegistry;
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);
55 // final String controllerName = "Inventory Geo Synchronizer";
57 IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
58 endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
60 registerIndexValidator(indexValidator);
62 GeoSynchronizer synchronizer =
63 new GeoSynchronizer(schemaConfig, syncControllerConfig.getNumInternalSyncWorkers(),
64 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
65 syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
66 geoEntityLookup, oxmEntityLookup);
68 synchronizer.setAaiAdapter(aaiAdapter);
69 synchronizer.setElasticSearchAdapter(esAdapter);
71 registerEntitySynchronizer(synchronizer);
74 IndexCleaner indexCleaner =
75 new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
77 registerIndexCleaner(indexCleaner);
81 public SyncControllerRegistry getSyncControllerRegistry() {
82 return syncControllerRegistry;
85 public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
86 this.syncControllerRegistry = syncControllerRegistry;
90 public void registerController() {
92 if ( syncControllerRegistry != null ) {
93 if ( syncControllerConfig.isEnabled()) {
94 syncControllerRegistry.registerSyncController(this);