Example usage for org.apache.solr.common.cloud ZkConfigManager uploadConfigDir

List of usage examples for org.apache.solr.common.cloud ZkConfigManager uploadConfigDir

Introduction

In this page you can find the example usage for org.apache.solr.common.cloud ZkConfigManager uploadConfigDir.

Prototype

public void uploadConfigDir(Path dir, String configName) throws IOException 

Source Link

Document

Upload files from a given path to a config in Zookeeper

Usage

From source file:fr.jetoile.hadoopunit.component.SolrCloudBootstrap.java

License:Apache License

private void populateZkWithCollectionInfo() {
    System.setProperty("zkHost", zkHostString);

    try {// ww  w  .  j a va2s.  c  o  m

        URI solrDirectoryFile = solrServer.getClass().getClassLoader()
                .getResource(solrDirectory + "/collection1/conf").toURI();

        try (SolrZkClient zkClient = new SolrZkClient(zkHostString, TIMEOUT, 45000, null)) {
            ZkConfigManager manager = new ZkConfigManager(zkClient);
            manager.uploadConfigDir(Paths.get(solrDirectoryFile), solrCollectionName);
        }

        //            CuratorFramework client = CuratorFrameworkFactory.newClient(zkHostString, new RetryOneTime(300));
        //            client.start();
        //            File schema = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/schema.xml").toURI());
        //            File solrConfig = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/solrconfig.xml").toURI());
        //            File stopwords = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/stopwords.txt").toURI());
        //            File synonyms = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/synonyms.txt").toURI());
        //            File stopwords_en = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/lang/stopwords_en.txt").toURI());
        //            File protwords = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/protwords.txt").toURI());
        //            File currency = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/currency.xml").toURI());
        //
        //            byte[] schemaContent = Files.readAllBytes(schema.toPath());
        //            byte[] solrConfigContent = Files.readAllBytes(solrConfig.toPath());
        //            byte[] stopwordsContent = Files.readAllBytes(stopwords.toPath());
        //            byte[] synonymsContent = Files.readAllBytes(synonyms.toPath());
        //            byte[] stopwordsEnContent = Files.readAllBytes(stopwords_en.toPath());
        //            byte[] protwordsContent = Files.readAllBytes(protwords.toPath());
        //            byte[] currencyContent = Files.readAllBytes(currency.toPath());
        //
        //            client.create().forPath("/configs");
        //            client.create().forPath("/configs/collection1");
        //            client.create().forPath("/configs/collection1/lang");
        //            client.create().forPath("/configs/collection1/solrconfig.xml", solrConfigContent);
        //            client.create().forPath("/configs/collection1/schema.xml", schemaContent);
        //            client.create().forPath("/configs/collection1/stopwords.txt", stopwordsContent);
        //            client.create().forPath("/configs/collection1/synonyms.txt", synonymsContent);
        //            client.create().forPath("/configs/collection1/lang/stopwords_en.txt", stopwordsEnContent);
        //            client.create().forPath("/configs/collection1/protwords.txt", protwordsContent);
        //            client.create().forPath("/configs/collection1/currency.xml", currencyContent);
        //
        //            client.close();

    } catch (URISyntaxException | IOException e) {
        LOGGER.error("unable to populate zookeeper", e);
    }
}