public static void upConfig(SolrZkClient zkClient, Path confPath, String confName) throws IOException { ZkConfigManager manager = new ZkConfigManager(zkClient); // Try to download the configset manager.uploadConfigDir(confPath, confName); }
/** * Upload a set of config files to Zookeeper and give it a name * * NOTE: You should only allow trusted users to upload configs. If you * are allowing client access to zookeeper, you should protect the * /configs node against unauthorised write access. * * @param configPath {@link java.nio.file.Path} to the config files * @param configName the name of the config * @throws IOException if an IO error occurs */ public void uploadConfig(Path configPath, String configName) throws IOException { connect(); zkStateReader.getConfigManager().uploadConfigDir(configPath, configName); }
/** * Upload a set of config files to Zookeeper and give it a name * * NOTE: You should only allow trusted users to upload configs. If you * are allowing client access to zookeeper, you should protect the * /configs node against unauthorised write access. * * @param configPath {@link java.nio.file.Path} to the config files * @param configName the name of the config * @throws IOException if an IO error occurs */ public void uploadConfig(Path configPath, String configName) throws IOException { connect(); zkStateReader.getConfigManager().uploadConfigDir(configPath, configName); }
private void populateZkWithCollectionInfo() { System.setProperty("zkHost", zkHostString); try { URL url = ConfigurationUtils.locate(FileSystem.getDefaultFileSystem(), "", solrDirectory + "/collection1/conf"); if (url == null) { try { url = new URL(solrDirectory + "/collection1/conf"); } catch (MalformedURLException e) { LOGGER.error("unable to load solr config", e); } } URI solrDirectoryFile = url.toURI(); try (SolrZkClient zkClient = new SolrZkClient(zkHostString, TIMEOUT, 45000, null)) { ZkConfigManager manager = new ZkConfigManager(zkClient); manager.uploadConfigDir(Paths.get(solrDirectoryFile), solrCollectionName); } } catch (URISyntaxException | IOException e) { LOGGER.error("unable to populate zookeeper", e); } }
/** * 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[])}. */ public void uploadConfig(String confName, File confDir) throws IOException { SolrZkClient zkClient = new SolrZkClient(zkConnectString, 30000, 30000, new OnReconnect() { @Override public void command() { } }); new ZkConfigManager(zkClient).uploadConfigDir(confDir.toPath(), confName); zkClient.close(); }
/** * 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[])}. */ public void uploadConfig(String confName, File confDir) throws IOException { SolrZkClient zkClient = new SolrZkClient(zkConnectString, 30000, 30000, new OnReconnect() { @Override public void command() { } }); new ZkConfigManager(zkClient).uploadConfigDir(confDir.toPath(), confName); zkClient.close(); }
/** * Upload a config set * @param configDir a path to the config set to upload * @param configName the name to give the configset */ public void uploadConfigSet(Path configDir, String configName) throws IOException, KeeperException, InterruptedException { try(SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null)) { ZkConfigManager manager = new ZkConfigManager(zkClient); manager.uploadConfigDir(configDir, configName); } }