List of usage examples for org.apache.solr.common.cloud SolrZkClient makePath
public void makePath(String zkPath, CreateMode createMode, Watcher watcher, boolean retryOnConnLoss) throws KeeperException, InterruptedException
From source file:com.cloudera.cdk.morphline.solr.AbstractSolrMorphlineZkTest.java
License:Apache License
private static void putConfig(SolrZkClient zkClient, File solrhome, String srcName, String destName) throws Exception { File file = new File(solrhome, "conf" + File.separator + srcName); if (!file.exists()) { // LOG.info("skipping " + file.getAbsolutePath() + // " because it doesn't exist"); return;//from w ww . j av a 2 s . c o m } String destPath = "/configs/conf1/" + destName; // LOG.info("put " + file.getAbsolutePath() + " to " + destPath); zkClient.makePath(destPath, file, false, true); }
From source file:org.apache.camel.component.solr.SolrCloudFixture.java
License:Apache License
public static void putConfig(String confName, SolrZkClient zkClient, File solrhome, final String srcName, String destName) throws Exception { File file = new File(solrhome, "collection1" + File.separator + "conf" + File.separator + srcName); if (!file.exists()) { log.info("zk skipping " + file.getAbsolutePath() + " because it doesn't exist"); return;/* www . j av a 2 s. c om*/ } String destPath = "/configs/" + confName + "/" + destName; log.info("zk put " + file.getAbsolutePath() + " to " + destPath); zkClient.makePath(destPath, file, false, true); }
From source file:org.opencommercesearch.CloudSearchServer.java
License:Apache License
/** * Exports the given synonym list into a configuration file in ZooKeeper * /*ww w . ja v a 2s .c o m*/ * @param synonymList * the synonym list's repository item * @throws SearchServerException * if a problem occurs while writing the file in ZooKeeper */ protected void exportSynonymList(RepositoryItem synonymList, Locale locale) throws RepositoryException, SearchServerException { SolrZkClient client = getZkClient(locale); if (client != null) { if (isLoggingInfo()) { logInfo("Exporting synoymym list '" + synonymList.getItemDisplayName() + "' to ZooKeeper"); } ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(byteStream); out.println("# This file has been auto-generated. Do not modify"); RepositoryView view = getSearchRepository().getView(SearchRepositoryItemDescriptor.SYNONYM); Object params[] = { new String(synonymList.getRepositoryId()) }; RepositoryItem[] synonymMappings = getSynonymRql().executeQuery(view, params); if (synonymMappings != null) { for (RepositoryItem synonym : synonymMappings) { out.println((String) synonym.getPropertyValue(SynonymProperty.MAPPING)); } } out.close(); String environment = "preview"; if (getCatalogCollection().endsWith("Public")) { environment = "public"; } for (String config : Arrays.asList(getCatalogConfig(), getRulesConfig())) { byte[] data = byteStream.toByteArray(); String path = new StringBuffer("/configs/").append(config).append("/synonyms-").append(environment) .append("/").append(formatSynonymListFileName( (String) synonymList.getPropertyValue(SynonymListProperty.FILENAME))) .toString(); try { if (!client.exists(path, true)) { client.makePath(path, data, CreateMode.PERSISTENT, true); } else { client.setData(path, data, true); } } catch (KeeperException ex) { throw create(EXPORT_SYNONYM_EXCEPTION, ex); } catch (InterruptedException ex) { throw create(EXPORT_SYNONYM_EXCEPTION, ex); } } } }