diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpath index 3f4f9477f41..d7980920936 100644 --- a/dev-tools/eclipse/dot.classpath +++ b/dev-tools/eclipse/dot.classpath @@ -103,6 +103,7 @@ + diff --git a/dev-tools/maven/pom.xml.template b/dev-tools/maven/pom.xml.template index aeb4bb457c3..29c62dde1a1 100644 --- a/dev-tools/maven/pom.xml.template +++ b/dev-tools/maven/pom.xml.template @@ -155,6 +155,11 @@ commons-codec 1.6 + + commons-cli + commons-cli + 1.2 + commons-digester commons-digester diff --git a/dev-tools/maven/solr/core/pom.xml.template b/dev-tools/maven/solr/core/pom.xml.template index 04907fa459a..f91c89d8d78 100644 --- a/dev-tools/maven/solr/core/pom.xml.template +++ b/dev-tools/maven/solr/core/pom.xml.template @@ -138,6 +138,10 @@ commons-codec commons-codec + + commons-cli + commons-cli + commons-fileupload commons-fileupload diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 4c511e2959d..5afe8187eea 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -56,6 +56,9 @@ New Features * SOLR-2616: Include a sample java util logging configuration file. (David Smiley, Mark Miller) + +* SOLR-3460: Add cloud-scripts directory and a zkcli.sh|bat tool for easy scripting + and interaction with ZooKeeper. (Mark Miller) Bug Fixes @@ -88,6 +91,8 @@ Other Changes * SOLR-3599: Add zkClientTimeout to solr.xml so that it's obvious how to change it and so that you can change it with a system property. (Mark Miller) +* SOLR-3609: Change Solr's expanded webapp directory to be at a consistent path called + solr-webapp rather than a temporary directory. (Mark Miller) ================== 4.0.0-ALPHA ================== More information about this release, including any errata related to the diff --git a/solr/cloud-dev/cli-test-solrcloud-start.sh b/solr/cloud-dev/cli-test-solrcloud-start.sh new file mode 100644 index 00000000000..3ea3d37d147 --- /dev/null +++ b/solr/cloud-dev/cli-test-solrcloud-start.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +cd .. + +rm -r -f example2 +rm -r -f example3 +rm -r -f example4 +rm -r -f example5 +rm -r -f example6 + +rm -r -f dist +rm -r -f build +rm -r -f example/solr/zoo_data +rm -r -f example/solr/data +rm -f example/example.log + +ant example dist + +cp -r -f example example2 +cp -r -f example example3 +cp -r -f example example4 +cp -r -f example example5 +cp -r -f example example6 + +# first try uploading a conf dir +java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 127.0.0.1:9983 -confdir example/solr/collection1/conf -confname conf1 -solrhome example/solr -runzk 8983 + +# upload a second conf set so we avoid single conf auto linking +java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 127.0.0.1:9983 -confdir example/solr/collection1/conf -confname conf2 -solrhome example/solr -runzk 8983 + +# now try linking a collection to a conf set +java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkCLI -cmd linkconfig -zkhost 127.0.0.1:9983 -collection collection1 -confname conf1 -solrhome example/solr -runzk 8983 + + +cd example +java -DzkRun -DnumShards=2 -DSTOP.PORT=7983 -DSTOP.KEY=key -jar start.jar 1>example.log 2>&1 & + +cd ../example2 +java -Djetty.port=7574 -DzkHost=localhost:9983 -DnumShards=2 -DSTOP.PORT=6574 -DSTOP.KEY=key -jar start.jar 1>example2.log 2>&1 & + +cd ../example3 +java -Djetty.port=7575 -DzkHost=localhost:9983 -DnumShards=2 -DSTOP.PORT=6575 -DSTOP.KEY=key -jar start.jar 1>example3.log 2>&1 & + +cd ../example4 +java -Djetty.port=7576 -DzkHost=localhost:9983 -DnumShards=2 -DSTOP.PORT=6576 -DSTOP.KEY=key -jar start.jar 1>example4.log 2>&1 & + +cd ../example5 +java -Djetty.port=7577 -DzkHost=localhost:9983 -DnumShards=2 -DSTOP.PORT=6577 -DSTOP.KEY=key -jar start.jar 1>example5.log 2>&1 & + +cd ../example6 +java -Djetty.port=7578 -DzkHost=localhost:9983 -DnumShards=2 -DSTOP.PORT=6578 -DSTOP.KEY=key -jar start.jar 1>example6.log 2>&1 & diff --git a/solr/cloud-dev/solrcloud-multi-start.sh b/solr/cloud-dev/solrcloud-multi-start.sh index 4715d6c606a..5e5d7ab0c9e 100644 --- a/solr/cloud-dev/solrcloud-multi-start.sh +++ b/solr/cloud-dev/solrcloud-multi-start.sh @@ -24,7 +24,7 @@ cp -r -f example example4 cp -r -f example example5 cp -r -f example example6 -java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkController 127.0.0.1:9983 example/multicore 8983 +java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkCLI -cmd upconf -zkhost 127.0.0.1:9983 -solrhome example/multicore -runzk 8983 cd example java -DzkRun -DnumShards=2 -DSTOP.PORT=7983 -DSTOP.KEY=key -Dsolr.solr.home=multicore -jar start.jar 1>example.log 2>&1 & diff --git a/solr/cloud-dev/solrcloud-start.sh b/solr/cloud-dev/solrcloud-start.sh index 142d2342d1b..bcb00a22796 100644 --- a/solr/cloud-dev/solrcloud-start.sh +++ b/solr/cloud-dev/solrcloud-start.sh @@ -22,7 +22,7 @@ cp -r -f example example4 cp -r -f example example5 cp -r -f example example6 -java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkController 127.0.0.1:9983 example/solr 8983 +java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkCLI -cmd upconf -zkhost 127.0.0.1:9983 -solrhome example/solr -runzk 8983 cd example java -DzkRun -DnumShards=2 -DSTOP.PORT=7983 -DSTOP.KEY=key -jar start.jar 1>example.log 2>&1 & diff --git a/solr/core/ivy.xml b/solr/core/ivy.xml index afb6c17dd71..d1e424a68ba 100644 --- a/solr/core/ivy.xml +++ b/solr/core/ivy.xml @@ -22,6 +22,7 @@ + diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java new file mode 100644 index 00000000000..ce09f295f36 --- /dev/null +++ b/solr/core/src/java/org/apache/solr/cloud/ZkCLI.java @@ -0,0 +1,244 @@ +package org.apache.solr.cloud; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeoutException; + +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.PosixParser; +import org.apache.solr.common.cloud.OnReconnect; +import org.apache.solr.common.cloud.SolrZkClient; +import org.apache.solr.core.Config; +import org.apache.solr.core.SolrResourceLoader; +import org.apache.zookeeper.KeeperException; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class ZkCLI { + + private static final String MAKEPATH = "makepath"; + private static final String DOWNCONFIG = "downconfig"; + private static final String ZK_CLI_NAME = "ZkCLI"; + private static final String HELP = "help"; + private static final String LINKCONFIG = "linkconfig"; + private static final String CONFDIR = "confdir"; + private static final String CONFNAME = "confname"; + private static final String REVERSE = "reverse"; + private static final String ZKHOST = "zkhost"; + private static final String RUNZK = "runzk"; + private static final String SOLRHOME = "solrhome"; + private static final String BOOTSTRAP = "bootstrap"; + private static final String SOLR_XML = "solr.xml"; + private static final String UPCONFIG = "upconfig"; + private static final String COLLECTION = "collection"; + private static final String CLEAR = "clear"; + private static final String CMD = "cmd"; + + /** + * Allows you to perform a variety of zookeeper related tasks, such as: + * + * Bootstrap the current configs for all collections in solr.xml. + * + * Upload a named config set from a given directory. + * + * Link a named config set explicity to a collection. + * + * Clear ZooKeeper info. + * + * If you also pass a solrPort, it will be used to start an embedded zk useful + * for single machine, multi node tests. + * + * @param args + * @throws IOException + * @throws TimeoutException + * @throws InterruptedException + * @throws SAXException + * @throws ParserConfigurationException + * @throws KeeperException + */ + public static void main(String[] args) throws InterruptedException, + TimeoutException, IOException, ParserConfigurationException, + SAXException, KeeperException { + + CommandLineParser parser = new PosixParser(); + Options options = new Options(); + + options.addOption(OptionBuilder + .hasArg(true) + .withDescription( + "cmd to run: " + BOOTSTRAP + ", " + UPCONFIG + ", " + DOWNCONFIG + + ", " + LINKCONFIG + ", " + MAKEPATH + ", "+ CLEAR).create(CMD)); + + Option zkHostOption = new Option("z", ZKHOST, true, + "ZooKeeper host address"); + options.addOption(zkHostOption); + Option solrHomeOption = new Option("s", SOLRHOME, true, + "for " + BOOTSTRAP + ", " + RUNZK + ": solrhome location"); + options.addOption(zkHostOption); + options.addOption(solrHomeOption); + + options.addOption("d", CONFDIR, true, + "for " + UPCONFIG + ": a directory of configuration files"); + options.addOption("n", CONFNAME, true, + "for " + UPCONFIG + ", " + LINKCONFIG + ": name of the config set"); + + + options.addOption("c", COLLECTION, true, + "for " + LINKCONFIG + ": name of the collection"); + + options + .addOption( + "r", + RUNZK, + true, + "run zk internally by passing the solr run port - only for clusters on one machine (tests, dev)"); + + options.addOption("h", HELP, false, "bring up this help page"); + + try { + // parse the command line arguments + CommandLine line = parser.parse(options, args); + + if (line.hasOption(HELP) || !line.hasOption(ZKHOST) + || !line.hasOption(CMD)) { + // automatically generate the help statement + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp(ZK_CLI_NAME, options); + System.out.println("Examples:"); + System.out.println("zkcli.sh -cmd " + BOOTSTRAP + " -" + SOLRHOME + " /opt/solr"); + System.out.println("zkcli.sh -cmd " + UPCONFIG + " -" + CONFDIR + " /opt/solr/collection1/conf" + " -" + CONFNAME + " myconf"); + System.out.println("zkcli.sh -cmd " + DOWNCONFIG + " -" + CONFDIR + " /opt/solr/collection1/conf" + " -" + CONFNAME + " myconf"); + System.out.println("zkcli.sh -cmd " + LINKCONFIG + " -" + COLLECTION + " collection1" + " -" + CONFNAME + " myconf"); + System.out.println("zkcli.sh -cmd " + MAKEPATH + " /apache/solr"); + System.out.println("zkcli.sh -cmd " + CLEAR + " /solr"); + return; + } + + // start up a tmp zk server first + String zkServerAddress = line.getOptionValue(ZKHOST); + String solrHome = line.getOptionValue(SOLRHOME); + + String solrPort = null; + if (line.hasOption(RUNZK)) { + if (!line.hasOption(SOLRHOME)) { + System.out + .println("-" + SOLRHOME + " is required for " + RUNZK); + System.exit(1); + } + solrPort = line.getOptionValue(RUNZK); + } + + SolrZkServer zkServer = null; + if (solrPort != null) { + zkServer = new SolrZkServer("true", null, solrHome + "/zoo_data", + solrHome, solrPort); + zkServer.parseConfig(); + zkServer.start(); + } + SolrZkClient zkClient = null; + try { + zkClient = new SolrZkClient(zkServerAddress, 15000, 5000, + new OnReconnect() { + @Override + public void command() {} + }); + + if (line.getOptionValue(CMD).equals(BOOTSTRAP)) { + if (!line.hasOption(SOLRHOME)) { + System.out.println("-" + SOLRHOME + + " is required for " + BOOTSTRAP); + System.exit(1); + } + SolrResourceLoader loader = new SolrResourceLoader(solrHome); + solrHome = loader.getInstanceDir(); + + InputSource cfgis = new InputSource(new File(solrHome, SOLR_XML) + .toURI().toASCIIString()); + Config cfg = new Config(loader, null, cfgis, null, false); + ZkController.bootstrapConf(zkClient, cfg, solrHome); + + } else if (line.getOptionValue(CMD).equals(UPCONFIG)) { + if (!line.hasOption(CONFDIR) || !line.hasOption(CONFNAME)) { + System.out.println("-" + CONFDIR + " and -" + CONFNAME + + " are required for " + UPCONFIG); + System.exit(1); + } + String confDir = line.getOptionValue(CONFDIR); + String confName = line.getOptionValue(CONFNAME); + + ZkController.uploadConfigDir(zkClient, new File(confDir), confName); + } else if (line.getOptionValue(CMD).equals(DOWNCONFIG)) { + if (!line.hasOption(CONFDIR) || !line.hasOption(CONFNAME)) { + System.out.println("-" + CONFDIR + " and -" + CONFNAME + + " are required for " + DOWNCONFIG); + System.exit(1); + } + String confDir = line.getOptionValue(CONFDIR); + String confName = line.getOptionValue(CONFNAME); + + ZkController.downloadConfigDir(zkClient, confName, new File(confDir)); + } else if (line.getOptionValue(CMD).equals(LINKCONFIG)) { + if (!line.hasOption(COLLECTION) || !line.hasOption(CONFNAME)) { + System.out.println("-" + CONFDIR + " and -" + CONFNAME + + " are required for " + LINKCONFIG); + System.exit(1); + } + String collection = line.getOptionValue(COLLECTION); + String confName = line.getOptionValue(CONFNAME); + + ZkController.linkConfSet(zkClient, collection, confName); + } else if (line.getOptionValue(CMD).equals(CLEAR)) { + List arglist = line.getArgList(); + if (arglist.size() != 1) { + System.out.println("-" + CLEAR + " requires one arg - the path to clear"); + System.exit(1); + } + zkClient.clean(arglist.get(0).toString()); + } else if (line.getOptionValue(CMD).equals(MAKEPATH)) { + List arglist = line.getArgList(); + if (arglist.size() != 1) { + System.out.println("-" + MAKEPATH + " requires one arg - the path to make"); + System.exit(1); + } + zkClient.makePath(arglist.get(0).toString(), true); + } + } finally { + if (solrPort != null) { + zkServer.stop(); + } + if (zkClient != null) { + zkClient.close(); + } + } + } catch (ParseException exp) { + System.out.println("Unexpected exception:" + exp.getMessage()); + } + + } +} diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index cbc67f4d323..750a44a4a8c 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import javax.xml.xpath.XPathConstants; +import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState; import org.apache.solr.common.SolrException; @@ -50,8 +51,8 @@ import org.apache.solr.core.Config; import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreDescriptor; import org.apache.solr.core.SolrCore; -import org.apache.solr.core.SolrResourceLoader; import org.apache.solr.handler.component.HttpShardHandlerFactory; + import org.apache.solr.handler.component.ShardHandler; import org.apache.solr.update.UpdateLog; import org.apache.solr.util.DOMUtil; @@ -63,7 +64,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; /** * Handle ZooKeeper interactions. @@ -121,53 +121,6 @@ public final class ZkController { // may accept defaults or use mocks rather than pulling things from a CoreContainer private CoreContainer cc; - /** - * Bootstraps the current configs for all collections in solr.xml. - * Takes two params - the zkhost to connect to and the solrhome location - * to find solr.xml. - * - * If you also pass a solrPort, it will be used to start - * an embedded zk useful for single machine, multi node tests. - * - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - // start up a tmp zk server first - String zkServerAddress = args[0]; - - String solrHome = args[1]; - - String solrPort = null; - if (args.length > 2) { - solrPort = args[2]; - } - - - SolrZkServer zkServer = null; - if (solrPort != null) { - zkServer = new SolrZkServer("true", null, solrHome + "/zoo_data", solrHome, solrPort); - zkServer.parseConfig(); - zkServer.start(); - } - - SolrZkClient zkClient = new SolrZkClient(zkServerAddress, 15000, 5000, - new OnReconnect() { - @Override - public void command() { - }}); - - SolrResourceLoader loader = new SolrResourceLoader(solrHome); - solrHome = loader.getInstanceDir(); - - InputSource cfgis = new InputSource(new File(solrHome, "solr.xml").toURI().toASCIIString()); - Config cfg = new Config(loader, null, cfgis , null, false); - bootstrapConf(zkClient, cfg, solrHome); - if (solrPort != null) { - zkServer.stop(); - } - } - /** * @param cc if null, recovery will not be enabled * @param zkServerAddress @@ -898,9 +851,7 @@ public final class ZkController { ZkNodeProps zkProps = new ZkNodeProps(collectionProps); zkClient.makePath(collectionPath, ZkStateReader.toJSON(zkProps), CreateMode.PERSISTENT, null, true); - - // ping that there is a new collection - zkClient.setData(ZkStateReader.COLLECTIONS_ZKNODE, (byte[])null, true); + } catch (KeeperException e) { // its okay if the node already exists if (e.code() != KeeperException.Code.NODEEXISTS) { @@ -1008,6 +959,24 @@ public final class ZkController { } } + public static void downloadFromZK(SolrZkClient zkClient, String zkPath, + File dir) throws IOException, KeeperException, InterruptedException { + List files = zkClient.getChildren(zkPath, null, true); + + for (String file : files) { + List children = zkClient.getChildren(zkPath + "/" + file, null, true); + if (children.size() == 0) { + byte[] data = zkClient.getData(zkPath + "/" + file, null, null, true); + dir.mkdirs(); + log.info("Write file " + new File(dir, file)); + FileUtils.writeStringToFile(new File(dir, file), new String(data, "UTF-8"), "UTF-8"); + } else { + downloadFromZK(zkClient, zkPath + "/" + file, new File(dir, file)); + } + } + } + + private String getCoreNodeName(CoreDescriptor descriptor){ return getNodeName() + "_" + descriptor.getName(); @@ -1016,6 +985,10 @@ public final class ZkController { public static void uploadConfigDir(SolrZkClient zkClient, File dir, String configName) throws IOException, KeeperException, InterruptedException { uploadToZK(zkClient, dir, ZkController.CONFIGS_ZKNODE + "/" + configName); } + + public static void downloadConfigDir(SolrZkClient zkClient, String configName, File dir) throws IOException, KeeperException, InterruptedException { + downloadFromZK(zkClient, ZkController.CONFIGS_ZKNODE + "/" + configName, dir); + } public void preRegister(CoreDescriptor cd) throws KeeperException, InterruptedException { // before becoming available, make sure we are not live and active @@ -1100,6 +1073,50 @@ public final class ZkController { return leaderProps; } + public static void linkConfSet(SolrZkClient zkClient, String collection, String confSetName) throws KeeperException, InterruptedException { + String path = ZkStateReader.COLLECTIONS_ZKNODE + "/" + collection; + if (log.isInfoEnabled()) { + log.info("Load collection config from:" + path); + } + byte[] data; + try { + data = zkClient.getData(path, null, null, true); + } catch (NoNodeException e) { + // if there is no node, we will try and create it + // first try to make in case we are pre configuring + ZkNodeProps props = new ZkNodeProps(CONFIGNAME_PROP, confSetName); + try { + + zkClient.makePath(path, ZkStateReader.toJSON(props), + CreateMode.PERSISTENT, null, true); + } catch (KeeperException e2) { + // its okay if the node already exists + if (e2.code() != KeeperException.Code.NODEEXISTS) { + throw e; + } + // if we fail creating, setdata + // TODO: we should consider using version + zkClient.setData(path, ZkStateReader.toJSON(props), true); + } + return; + } + // we found existing data, let's update it + ZkNodeProps props = null; + if(data != null) { + props = ZkNodeProps.load(data); + Map newProps = new HashMap(); + newProps.putAll(props.getProperties()); + newProps.put(CONFIGNAME_PROP, confSetName); + props = new ZkNodeProps(newProps); + } else { + props = new ZkNodeProps(CONFIGNAME_PROP, confSetName); + } + + // TODO: we should consider using version + zkClient.setData(path, ZkStateReader.toJSON(props), true); + + } + /** * If in SolrCloud mode, upload config sets for each SolrCore in solr.xml. * @@ -1114,18 +1131,20 @@ public final class ZkController { for (int i=0; i zkFiles = zkClient.getChildren(ZkController.CONFIGS_ZKNODE + "/" + confsetname, null, true); + assertEquals(files.length, zkFiles.size()); + + // test reset zk + args = new String[] {"-zkhost", zkServer.getZkAddress(), "-cmd", + "clear", "/"}; + ZkCLI.main(args); + + assertEquals(0, zkClient.getChildren("/", null, true).size()); + } + + @Override + public void tearDown() throws Exception { + if (VERBOSE) { + printLayout(zkServer.getZkHost()); + } + zkClient.close(); + zkServer.shutdown(); + super.tearDown(); + } + + private void printLayout(String zkHost) throws Exception { + SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT); + zkClient.printLayoutToStdOut(); + zkClient.close(); + } +} diff --git a/solr/example/cloud-scripts/zkcli.bat b/solr/example/cloud-scripts/zkcli.bat new file mode 100644 index 00000000000..9036dd9b24b --- /dev/null +++ b/solr/example/cloud-scripts/zkcli.bat @@ -0,0 +1,12 @@ +REM You can override pass the following parameters to this script: +REM + +set JVM=java + +REM Find location of this script + +set SDIR=%~dp0 +if "%SDIR:~-1%"=="\" set SDIR=%SDIR:~0,-1% + + +"%JVM%" -classpath "%SDIR%\..\solr-webapp\webapp\WEB-INF\lib\*" org.apache.solr.cloud.ZkCLI %* diff --git a/solr/example/cloud-scripts/zkcli.sh b/solr/example/cloud-scripts/zkcli.sh new file mode 100644 index 00000000000..26c5bc09b22 --- /dev/null +++ b/solr/example/cloud-scripts/zkcli.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# You can override pass the following parameters to this script: +# + +JVM="java" + +# Find location of this script + +sdir="`dirname \"$0\"`" + + +$JVM -classpath "$sdir/../solr-webapp/webapp/WEB-INF/lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} + diff --git a/solr/example/contexts/solr.xml b/solr/example/contexts/solr.xml new file mode 100644 index 00000000000..aa68b78e705 --- /dev/null +++ b/solr/example/contexts/solr.xml @@ -0,0 +1,8 @@ + + + + /solr + /webapps/solr.war + /etc/webdefault.xml + /solr-webapp + \ No newline at end of file diff --git a/solr/example/etc/jetty.xml b/solr/example/etc/jetty.xml index db89be1fe01..6203004f8db 100644 --- a/solr/example/etc/jetty.xml +++ b/solr/example/etc/jetty.xml @@ -134,17 +134,14 @@ - - - - /webapps - /etc/webdefault.xml - 0 - /contexts - true - - - + + + + /contexts + 0 + + + diff --git a/solr/example/work/.gitignore b/solr/example/work/.gitignore deleted file mode 100644 index 72e8ffc0db8..00000000000 --- a/solr/example/work/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/solr/lib/commons-cli-LICENSE-ASL.txt b/solr/lib/commons-cli-LICENSE-ASL.txt new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/solr/lib/commons-cli-LICENSE-ASL.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/solr/lib/commons-cli-NOTICE.txt b/solr/lib/commons-cli-NOTICE.txt new file mode 100644 index 00000000000..33cb7aba1ea --- /dev/null +++ b/solr/lib/commons-cli-NOTICE.txt @@ -0,0 +1,5 @@ +Apache Commons CLI +Copyright 2001-2009 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java index 91d71575434..16d11cc1d2b 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java @@ -689,10 +689,16 @@ public class SolrZkClient { return; } for (String string : children) { - clean(path + "/" + string); + if (path.equals("/")) { + clean(path + string); + } else { + clean(path + "/" + string); + } } try { - delete(path, -1, true); + if (!path.equals("/")) { + delete(path, -1, true); + } } catch (NoNodeException r) { return; }