Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / viewinspect / sync / ViewInspectSyncController.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.viewinspect.sync;
26
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;
44
45 public class ViewInspectSyncController extends SyncControllerImpl
46     implements SyncControllerRegistrar {
47
48   private SyncControllerRegistry syncControllerRegistry;
49   private ActiveInventoryAdapter aaiAdapter;
50   private ElasticSearchAdapter esAdapter;
51   private ElasticSearchSchemaConfig schemaConfig;
52   private ElasticSearchEndpointConfig endpointConfig;
53
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);
62
63
64     // final String controllerName = "View and Inspect Entity Synchronizer";
65
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));
72
73     registerIndexValidator(indexValidator);
74
75
76     ViewInspectEntitySynchronizer ses = new ViewInspectEntitySynchronizer(schemaConfig,
77         syncControllerConfig.getNumInternalSyncWorkers(),
78         syncControllerConfig.getNumSyncActiveInventoryWorkers(),
79         syncControllerConfig.getNumSyncElasticWorkers(), aaiStatConfig, esStatConfig,
80         oxmEntityLookup, searchableEntityLookup);
81     
82     ses.setAaiAdapter(aaiAdapter);
83     ses.setElasticSearchAdapter(esAdapter);
84
85     registerEntitySynchronizer(ses);
86
87     CrossEntityReferenceSynchronizer cers = new CrossEntityReferenceSynchronizer(schemaConfig,
88         syncControllerConfig.getNumInternalSyncWorkers(),
89         syncControllerConfig.getNumSyncActiveInventoryWorkers(),
90         syncControllerConfig.getNumSyncElasticWorkers(),aaiStatConfig,esStatConfig,
91         crossEntityReferenceLookup, oxmEntityLookup, searchableEntityLookup);
92
93     cers.setAaiAdapter(aaiAdapter);
94     cers.setElasticSearchAdapter(esAdapter);
95
96     registerEntitySynchronizer(cers);
97
98     IndexCleaner indexCleaner =
99         new ElasticSearchIndexCleaner(esAdapter, endpointConfig, schemaConfig);
100
101     registerIndexCleaner(indexCleaner);
102
103   }
104
105   public SyncControllerRegistry getSyncControllerRegistry() {
106     return syncControllerRegistry;
107   }
108
109   public void setSyncControllerRegistry(SyncControllerRegistry syncControllerRegistry) {
110     this.syncControllerRegistry = syncControllerRegistry;
111   }
112   
113   @Override
114   public void registerController() {
115     if ( syncControllerRegistry != null ) {
116       if ( syncControllerConfig.isEnabled()) { 
117         syncControllerRegistry.registerSyncController(this);
118       }
119     }
120
121   }
122 }