Hi Artem, This question (or one very like it) has been asked on this list before so there's some prior art you could modify to suit your needs.
Taken from Timothy Potter <thelabd...@gmail.com>: ** public static void updateClusterstateJsonInZk(CloudSolrServer cloudSolrServer, CommandLine cli) throws Exception { String updateClusterstateJson = cli.getOptionValue("updateClusterstateJson"); ZkStateReader zkStateReader = cloudSolrServer.getZkStateReader(); SolrZkClient zkClient = zkStateReader.getZkClient(); File jsonFile = new File(updateClusterstateJson); if (!jsonFile.isFile()) { System.err.println(jsonFile.getAbsolutePath()+" not found."); return; } byte[] clusterstateJson = readFile(jsonFile); // validate the user is passing is valid JSON InputStreamReader bytesReader = new InputStreamReader(new ByteArrayInputStream(clusterstateJson), "UTF-8"); JSONParser parser = new JSONParser(bytesReader); parser.toString(); zkClient.setData("/clusterstate.json", clusterstateJson, true); System.out.println("Updated /clusterstate.json with data from "+jsonFile.getAbsolutePath()); } ** You should be able to modify that or use it as a basis for uploading the changed files in your config. Thanks, Greg On Dec 4, 2013, at 8:36 AM, Artem Karpenko <gooy...@gmail.com> wrote: > What is the best way to upload Solr configuration files into ZooKeeper > programmatically, i.e. - from within Java code? > I know that there are cloud-scripts for this, but in the end they should use > some Java client library, don't they? > > This question raised because we use special configuration system (Java-based) > to store all configuration files (not only Solr) and it'd be cool if we could > export modified files into ZooKeeper when applying changes. We would then > reload collections remotely via REST API. > > I've digged a little into ZkCli class and it seems that SolrZkClient can do > something along the lines above. Is it the right tool for the job? > > Any hints would be appreciated. > > Regards, > Artem.