List of usage examples for org.apache.solr.common.cloud SolrZkClient SolrZkClient
public SolrZkClient(String zkServerAddress, int zkClientTimeout, ZkClientConnectionStrategy strat, final OnReconnect onReconnect)
From source file:com.doculibre.constellio.solr.context.SolrCoreContext.java
License:Open Source License
public static synchronized void init() { if (mainSolrServer == null) { try {//from ww w . j a v a2 s . c om mainSolrServer = new CloudSolrServer(ConstellioSpringUtils.getZooKeeperAddress()); mainSolrServer.setZkClientTimeout(ConstellioSpringUtils.getZooKeeperClientTimeout()); mainSolrServer.setZkConnectTimeout(ConstellioSpringUtils.getZooKeeperConTimeout()); } catch (MalformedURLException e) { e.printStackTrace(); } } initCores(); if (zkClient == null) { zkClient = new SolrZkClient(ConstellioSpringUtils.getZooKeeperAddress(), ConstellioSpringUtils.getZooKeeperClientTimeout(), ConstellioSpringUtils.getZooKeeperConTimeout(), new OnReconnect() { @Override public void command() { } }); } }
From source file:com.ngdata.hbaseindexer.util.solr.SolrTestingUtility.java
License:Apache License
/** * Utility method to upload a Solr config into ZooKeeper. If you don't have the config in the form of * a filesystem directory, you might want to use {@link #uploadConfig(String, byte[], byte[])}. */// w w w . j a v a 2 s . c om public void uploadConfig(String confName, File confDir) throws InterruptedException, IOException, KeeperException { SolrZkClient zkClient = new SolrZkClient(zkConnectString, 30000, 30000, new OnReconnect() { @Override public void command() { } }); ZkController.uploadConfigDir(zkClient, confDir, confName); zkClient.close(); }
From source file:fr.jetoile.hadoopunit.component.SolrCloudBootstrap.java
License:Apache License
private void populateZkWithCollectionInfo() { System.setProperty("zkHost", zkHostString); try {/*from w w w .j a va 2 s .com*/ 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); } }