1 package org.opendaylight.mwtn.index.impl;
3 import org.opendaylight.mwtn.base.database.HtDatabaseClientAbstract;
4 import org.opendaylight.mwtn.base.database.HtDatabaseNode;
5 import org.opendaylight.mwtn.base.database.IndexClientBuilder;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
10 * Setup index mwtn in the database
14 public class IndexMwtnService implements AutoCloseable {
16 private static final Logger LOG = LoggerFactory.getLogger(IndexMwtnService.class);
18 /** Index name to be used */
19 private static final String INDEX = "mwtn";
20 /** Location of mapping data **/
21 private static final String MAPPING = "/elasticsearch/index/mwtn/mwtnMapping.json";
22 /** Location of configuration data **/
23 private static final String MODELDATA = "/elasticsearch/index/mwtn/modelDescription";
25 private HtDatabaseClientAbstract client;
27 // --- Construct and initialize
29 public IndexMwtnService(HtDatabaseNode database) {
30 LOG.info("Create {} start", this.getClass().getSimpleName());
32 IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX)
33 .setMappingSettingJsonFileName(MAPPING)
34 .setModelDataDirectory(MODELDATA);
35 client = clientBuilder.create(database);
36 LOG.info("Create {} finished. DB Service {} started.", this.getClass().getSimpleName(), client != null ? "sucessfully" : "not" );
40 public void close() throws Exception {