1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl;
20 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
21 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Setup index mwtn in the database
31 public class IndexMwtnService implements AutoCloseable {
33 private static final Logger LOG = LoggerFactory.getLogger(IndexMwtnService.class);
35 /** Index name to be used */
36 public static final String INDEX = "mwtn";
37 /** Location of mapping data **/
38 private static final String MAPPING = "/elasticsearch/index/mwtn/mwtnMapping.json";
39 /** Location of configuration data **/
40 private static final String MODELDATA = "/elasticsearch/index/mwtn/modelDescription";
42 private final HtDatabaseClientAbstract client;
44 // --- Construct and initialize
46 public IndexMwtnService(HtDatabaseNode database) throws Exception {
47 LOG.info("Create {} start", this.getClass().getSimpleName());
49 IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX)
50 .setMappingSettingJsonFileName(MAPPING)
51 .setModelDataDirectory(MODELDATA);
52 client = clientBuilder.create(database);
53 clientBuilder.close();
54 LOG.info("Create {} finished. DB Service sucessfully started.", this.getClass().getSimpleName());
58 * Get client to be used in other services
61 public HtDatabaseClientAbstract getClient() {
68 public void close() throws Exception {