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.viewinspect.sync;
27 import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup;
28 import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
29 import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
30 import org.onap.aai.sparky.crossentityreference.sync.CrossEntityReferenceSynchronizer;
31 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
32 import org.onap.aai.sparky.dal.ElasticSearchAdapter;
33 import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
34 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
35 import org.onap.aai.sparky.sync.IndexCleaner;
36 import org.onap.aai.sparky.sync.IndexIntegrityValidator;
37 import org.onap.aai.sparky.sync.SyncControllerImpl;
38 import org.onap.aai.sparky.sync.SyncControllerRegistrar;
39 import org.onap.aai.sparky.sync.SyncControllerRegistry;
40 import org.onap.aai.sparky.sync.config.ElasticSearchEndpointConfig;
41 import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
42 import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
43 import org.onap.aai.sparky.sync.config.SyncControllerConfig;
45 public class ViewInspectSyncController extends SyncControllerImpl
46 implements SyncControllerRegistrar {
48 private SyncControllerRegistry syncControllerRegistry;
49 private ActiveInventoryAdapter aaiAdapter;
50 private ElasticSearchAdapter esAdapter;
51 private ElasticSearchSchemaConfig schemaConfig;
52 private ElasticSearchEndpointConfig endpointConfig;
54 public ViewInspectSyncController(SyncControllerConfig syncControllerConfig,
55 ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
56 ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
57 NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig,
58 CrossEntityReferenceLookup crossEntityReferenceLookup, OxmEntityLookup oxmEntityLookup,
59 SearchableEntityLookup searchableEntityLookup,
60 ElasticSearchSchemaFactory elasticSearchSchemaFactory) throws Exception {
61 super(syncControllerConfig);
64 // final String controllerName = "View and Inspect Entity Synchronizer";
66 this.aaiAdapter = aaiAdapter;
67 this.esAdapter = esAdapter;
68 this.schemaConfig = schemaConfig;
69 this.endpointConfig = endpointConfig;
70 IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
71 endpointConfig, elasticSearchSchemaFactory.getIndexSchema(schemaConfig));
73 registerIndexValidator(indexValidator);
76 ViewInspectEntitySynchronizer ses = new ViewInspectEntitySynchronizer(schemaConfig,
77 syncControllerConfig.getNumInternalSyncWorkers(),
78 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
79 syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
80 oxmEntityLookup, searchableEntityLookup);
82 ses.setAaiAdapter(aaiAdapter);
83 ses.setElasticSearchAdapter(esAdapter);
85 registerEntitySynchronizer(ses);
87 CrossEntityReferenceSynchronizer cers = new CrossEntityReferenceSynchronizer(schemaConfig,
88 syncControllerConfig.getNumInternalSyncWorkers(),
89 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
90 syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig,esStatConfig,
91 crossEntityReferenceLookup, oxmEntityLookup, searchableEntityLookup);
93 cers.setAaiAdapter(aaiAdapter);
94 cers.setElasticSearchAdapter(esAdapter);
96 registerEntitySynchronizer(cers);
98 IndexCleaner indexCleaner =
99 new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
101 registerIndexCleaner(indexCleaner);
105 public SyncControllerRegistry getSyncControllerRegistry() {
106 return syncControllerRegistry;
109 public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
110 this.syncControllerRegistry = syncControllerRegistry;
114 public void registerController() {
115 if ( syncControllerRegistry != null ) {
116 if ( syncControllerConfig.isEnabled()) {
117 syncControllerRegistry.registerSyncController(this);