2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.onap.aai.sparky.viewinspect.sync;
25 import org.onap.aai.sparky.crossentityreference.sync.CrossEntityReferenceSynchronizer;
26 import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
27 import org.onap.aai.sparky.dal.ElasticSearchAdapter;
28 import org.onap.aai.sparky.sync.ElasticSearchIndexCleaner;
29 import org.onap.aai.sparky.sync.ElasticSearchSchemaFactory;
30 import org.onap.aai.sparky.sync.IndexCleaner;
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 ViewInspectSyncController extends SyncControllerImpl
41 implements SyncControllerRegistrar {
43 private SyncControllerRegistry syncControllerRegistry;
44 private ActiveInventoryAdapter aaiAdapter;
45 private ElasticSearchAdapter esAdapter;
46 private ElasticSearchSchemaConfig schemaConfig;
47 private ElasticSearchEndpointConfig endpointConfig;
49 public ViewInspectSyncController(SyncControllerConfig syncControllerConfig,
50 ActiveInventoryAdapter aaiAdapter, ElasticSearchAdapter esAdapter,
51 ElasticSearchSchemaConfig schemaConfig, ElasticSearchEndpointConfig endpointConfig,
52 NetworkStatisticsConfig aaiStatConfig, NetworkStatisticsConfig esStatConfig)
54 super(syncControllerConfig);
57 // final String controllerName = "View and Inspect Entity Synchronizer";
59 this.aaiAdapter = aaiAdapter;
60 this.esAdapter = esAdapter;
61 this.schemaConfig = schemaConfig;
62 this.endpointConfig = endpointConfig;
63 IndexIntegrityValidator indexValidator = new IndexIntegrityValidator(esAdapter, schemaConfig,
64 endpointConfig, ElasticSearchSchemaFactory.getIndexSchema(schemaConfig));
66 registerIndexValidator(indexValidator);
69 ViewInspectEntitySynchronizer ses = new ViewInspectEntitySynchronizer(schemaConfig,
70 syncControllerConfig.getNumInternalSyncWorkers(),
71 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
72 syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig);
73 ses.setAaiAdapter(aaiAdapter);
74 ses.setElasticSearchAdapter(esAdapter);
76 registerEntitySynchronizer(ses);
78 CrossEntityReferenceSynchronizer cers = new CrossEntityReferenceSynchronizer(schemaConfig,
79 syncControllerConfig.getNumInternalSyncWorkers(),
80 syncControllerConfig.getNumSyncActiveInventoryWorkers(),
81 syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig);
83 cers.setAaiAdapter(aaiAdapter);
84 cers.setElasticSearchAdapter(esAdapter);
86 registerEntitySynchronizer(cers);
88 IndexCleaner indexCleaner =
89 new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
91 registerIndexCleaner(indexCleaner);
95 public SyncControllerRegistry getSyncControllerRegistry() {
96 return syncControllerRegistry;
99 public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
100 this.syncControllerRegistry = syncControllerRegistry;
103 public ActiveInventoryAdapter getAaiAdapter() {
104 return this.aaiAdapter;
107 public ElasticSearchAdapter getElasticSearchAdapter() {
108 return this.esAdapter;
111 public ElasticSearchEndpointConfig getendpointConfig() {
112 return this.endpointConfig;
115 public ElasticSearchSchemaConfig getschemaConfig() {
116 return this.schemaConfig;
121 public void registerController() {
122 if (syncControllerRegistry != null) {
123 if (syncControllerConfig.isEnabled()) {
124 syncControllerRegistry.registerSyncController(this);