You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/02/09 00:53:25 UTC
svn commit: r1658277 [24/38] - in /lucene/dev/branches/lucene6005: ./
dev-tools/ dev-tools/idea/solr/contrib/dataimporthandler/
dev-tools/idea/solr/contrib/velocity/ dev-tools/maven/lucene/replicator/
dev-tools/maven/solr/ dev-tools/maven/solr/contrib/...
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/StatelessScriptUpdateProcessorFactory.java Sun Feb 8 23:53:14 2015
@@ -429,13 +429,7 @@ public class StatelessScriptUpdateProces
}
}
- } catch (ScriptException e) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
- "Unable to invoke function " + name +
- " in script: " +
- engine.getScriptFile().getFileName() +
- ": " + e.getMessage(), e);
- } catch (NoSuchMethodException e) {
+ } catch (ScriptException | NoSuchMethodException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Unable to invoke function " + name +
" in script: " +
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/update/processor/URLClassifyProcessor.java Sun Feb 8 23:53:14 2015
@@ -125,9 +125,7 @@ public class URLClassifyProcessor extend
document.setField(canonicalUrlFieldname, getCanonicalUrl(normalizedURL));
}
log.debug(document.toString());
- } catch (MalformedURLException e) {
- log.warn("cannot get the normalized url for \"" + url + "\" due to " + e.getMessage());
- } catch (URISyntaxException e) {
+ } catch (MalformedURLException | URISyntaxException e) {
log.warn("cannot get the normalized url for \"" + url + "\" due to " + e.getMessage());
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SimplePostTool.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SimplePostTool.java Sun Feb 8 23:53:14 2015
@@ -76,7 +76,7 @@ import java.util.zip.InflaterInputStream
public class SimplePostTool {
private static final String DEFAULT_POST_HOST = "localhost";
private static final String DEFAULT_POST_PORT = "8983";
- private static final String VERSION_OF_THIS_TOOL = "1.5";
+ private static final String VERSION_OF_THIS_TOOL = "5.0.0"; // TODO: hardcoded for now, but eventually to sync with actual Solr version
private static final String DEFAULT_COMMIT = "yes";
private static final String DEFAULT_OPTIMIZE = "no";
@@ -130,7 +130,7 @@ public class SimplePostTool {
DATA_MODES.add(DATA_MODE_WEB);
mimeMap = new HashMap<>();
- mimeMap.put("xml", "text/xml");
+ mimeMap.put("xml", "application/xml");
mimeMap.put("csv", "text/csv");
mimeMap.put("json", "application/json");
mimeMap.put("pdf", "application/pdf");
@@ -303,7 +303,7 @@ public class SimplePostTool {
currentDepth = 0;
// Skip posting files if special param "-" given
if (!args[0].equals("-")) {
- info("Posting files to base url " + solrUrl + (!auto?" using content-type "+(type==null?DEFAULT_CONTENT_TYPE:type):"")+"..");
+ info("Posting files to [base] url " + solrUrl + (!auto?" using content-type "+(type==null?DEFAULT_CONTENT_TYPE:type):"")+"...");
if(auto)
info("Entering auto mode. File endings considered are "+fileTypes);
if(recursive > 0)
@@ -314,7 +314,7 @@ public class SimplePostTool {
}
private void doArgsMode() {
- info("POSTing args to " + solrUrl + "..");
+ info("POSTing args to " + solrUrl + "...");
for (String a : args) {
postData(stringToStream(a), null, out, type, solrUrl);
}
@@ -355,7 +355,7 @@ public class SimplePostTool {
}
private void doStdinMode() {
- info("POSTing stdin to " + solrUrl + "..");
+ info("POSTing stdin to " + solrUrl + "...");
postData(System.in, null, out, type, solrUrl);
}
@@ -380,7 +380,7 @@ public class SimplePostTool {
(USAGE_STRING_SHORT+"\n\n" +
"Supported System Properties and their defaults:\n"+
" -Dc=<core/collection>\n"+
- " -Durl=<solr-update-url> \n"+
+ " -Durl=<base Solr update URL> (overrides -Dc option if specified)\n"+
" -Ddata=files|web|args|stdin (default=" + DEFAULT_DATA_MODE + ")\n"+
" -Dtype=<content-type> (default=" + DEFAULT_CONTENT_TYPE + ")\n"+
" -Dhost=<host> (default: " + DEFAULT_POST_HOST+ ")\n"+
@@ -398,13 +398,13 @@ public class SimplePostTool {
"Data can be read from files specified as commandline args,\n"+
"URLs specified as args, as raw commandline arg strings or via STDIN.\n"+
"Examples:\n"+
- " java -jar post.jar *.xml\n"+
+ " java -Dc=gettingstarted -jar post.jar *.xml\n"+
" java -Ddata=args -Dc=gettingstarted -jar post.jar '<delete><id>42</id></delete>'\n"+
" java -Ddata=stdin -Dc=gettingstarted -jar post.jar < hd.xml\n"+
" java -Ddata=web -Dc=gettingstarted -jar post.jar http://example.com/\n"+
" java -Dtype=text/csv -Dc=gettingstarted -jar post.jar *.csv\n"+
" java -Dtype=application/json -Dc=gettingstarted -jar post.jar *.json\n"+
- " java -Durl=http://localhost:8983/solr/update/extract -Dparams=literal.id=a -Dtype=application/pdf -jar post.jar a.pdf\n"+
+ " java -Durl=http://localhost:8983/solr/techproducts/update/extract -Dparams=literal.id=pdf1 -jar post.jar solr-word.pdf\n"+
" java -Dauto -Dc=gettingstarted -jar post.jar *\n"+
" java -Dauto -Dc=gettingstarted -Drecursive -jar post.jar afolder\n"+
" java -Dauto -Dc=gettingstarted -Dfiletypes=ppt,html -jar post.jar afolder\n"+
@@ -729,7 +729,7 @@ public class SimplePostTool {
* Does a simple commit operation
*/
public void commit() {
- info("COMMITting Solr index changes to " + solrUrl + "..");
+ info("COMMITting Solr index changes to " + solrUrl + "...");
doGet(appendParam(solrUrl.toString(), "commit=true"));
}
@@ -737,7 +737,7 @@ public class SimplePostTool {
* Does a simple optimize operation
*/
public void optimize() {
- info("Performing an OPTIMIZE to " + solrUrl + "..");
+ info("Performing an OPTIMIZE to " + solrUrl + "...");
doGet(appendParam(solrUrl.toString(), "optimize=true"));
}
@@ -769,16 +769,18 @@ public class SimplePostTool {
InputStream is = null;
try {
URL url = solrUrl;
+ String suffix = "";
if(auto) {
if(type == null) {
type = guessType(file);
}
if(type != null) {
- if(type.equals("text/xml") || type.equals("text/csv") || type.equals("application/json")) {
+ if(type.equals("application/xml") || type.equals("text/csv") || type.equals("application/json")) {
// Default handler
} else {
// SolrCell
- String urlStr = appendUrlPath(solrUrl, "/extract").toString();
+ suffix = "/extract";
+ String urlStr = appendUrlPath(solrUrl, suffix).toString();
if(urlStr.indexOf("resource.name")==-1)
urlStr = appendParam(urlStr, "resource.name=" + URLEncoder.encode(file.getAbsolutePath(), "UTF-8"));
if(urlStr.indexOf("literal.id")==-1)
@@ -792,7 +794,7 @@ public class SimplePostTool {
} else {
if(type == null) type = DEFAULT_CONTENT_TYPE;
}
- info("POSTing file " + file.getName() + (auto?" ("+type+")":""));
+ info("POSTing file " + file.getName() + (auto?" ("+type+")":"") + " to [base]" + suffix);
is = new FileInputStream(file);
postData(is, (int)file.length(), output, type, url);
} catch (IOException e) {
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrCLI.java Sun Feb 8 23:53:14 2015
@@ -36,6 +36,7 @@ import org.apache.http.client.ResponseHa
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
@@ -112,10 +113,8 @@ public class SolrCLI {
log.debug("Connecting to Solr cluster: " + zkHost);
int exitStatus = 0;
- CloudSolrClient cloudSolrClient = null;
- try {
- cloudSolrClient = new CloudSolrClient(zkHost);
-
+ try (CloudSolrClient cloudSolrClient = new CloudSolrClient(zkHost)) {
+
String collection = cli.getOptionValue("collection");
if (collection != null)
cloudSolrClient.setDefaultCollection(collection);
@@ -126,17 +125,11 @@ public class SolrCLI {
// since this is a CLI, spare the user the stacktrace
String excMsg = exc.getMessage();
if (excMsg != null) {
- System.err.println("\nERROR:"+excMsg+"\n");
+ System.err.println("\nERROR: "+excMsg+"\n");
exitStatus = 1;
} else {
throw exc;
}
- } finally {
- if (cloudSolrClient != null) {
- try {
- cloudSolrClient.shutdown();
- } catch (Exception ignore) {}
- }
}
return exitStatus;
@@ -191,9 +184,36 @@ public class SolrCLI {
CommandLine cli =
processCommandLineArgs(joinCommonAndToolOptions(tool.getOptions()), toolArgs);
+ // for SSL support, try to accommodate relative paths set for SSL store props
+ String solrInstallDir = System.getProperty("solr.install.dir");
+ if (solrInstallDir != null) {
+ checkSslStoreSysProp(solrInstallDir, "keyStore");
+ checkSslStoreSysProp(solrInstallDir, "trustStore");
+ }
+
// run the tool
System.exit(tool.runTool(cli));
}
+
+ protected static void checkSslStoreSysProp(String solrInstallDir, String key) {
+ String sysProp = "javax.net.ssl."+key;
+ String keyStore = System.getProperty(sysProp);
+ if (keyStore == null)
+ return;
+
+ File keyStoreFile = new File(keyStore);
+ if (keyStoreFile.isFile())
+ return; // configured setting is OK
+
+ keyStoreFile = new File(solrInstallDir, "server/"+keyStore);
+ if (keyStoreFile.isFile()) {
+ System.setProperty(sysProp, keyStoreFile.getAbsolutePath());
+ } else {
+ System.err.println("WARNING: "+sysProp+" file "+keyStore+
+ " not found! https requests to Solr will likely fail; please update your "+
+ sysProp+" setting to use an absolute path.");
+ }
+ }
/**
* Support options common to all tools.
@@ -214,6 +234,10 @@ public class SolrCLI {
return new CreateCollectionTool();
else if ("create_core".equals(toolType))
return new CreateCoreTool();
+ else if ("create".equals(toolType))
+ return new CreateTool();
+ else if ("delete".equals(toolType))
+ return new DeleteTool();
// If you add a built-in tool to this class, add it here to avoid
// classpath scanning
@@ -234,6 +258,8 @@ public class SolrCLI {
formatter.printHelp("api", getToolOptions(new ApiTool()));
formatter.printHelp("create_collection", getToolOptions(new CreateCollectionTool()));
formatter.printHelp("create_core", getToolOptions(new CreateCoreTool()));
+ formatter.printHelp("create", getToolOptions(new CreateTool()));
+ formatter.printHelp("delete", getToolOptions(new DeleteTool()));
List<Class<Tool>> toolClasses = findToolClassesInPackage("org.apache.solr.util");
for (Class<Tool> next : toolClasses) {
@@ -379,7 +405,7 @@ public class SolrCLI {
return wasCommError;
}
- public static HttpClient getHttpClient() {
+ public static CloseableHttpClient getHttpClient() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 128);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32);
@@ -388,10 +414,10 @@ public class SolrCLI {
}
@SuppressWarnings("deprecation")
- public static void closeHttpClient(HttpClient httpClient) {
+ public static void closeHttpClient(CloseableHttpClient httpClient) {
if (httpClient != null) {
try {
- httpClient.getConnectionManager().shutdown();
+ HttpClientUtil.close(httpClient);
} catch (Exception exc) {
// safe to ignore, we're just shutting things down
}
@@ -403,7 +429,7 @@ public class SolrCLI {
*/
public static Map<String,Object> getJson(String getUrl) throws Exception {
Map<String,Object> json = null;
- HttpClient httpClient = getHttpClient();
+ CloseableHttpClient httpClient = getHttpClient();
try {
json = getJson(httpClient, getUrl, 2);
} finally {
@@ -444,7 +470,16 @@ public class SolrCLI {
public Map<String,Object> handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
HttpEntity entity = response.getEntity();
if (entity != null) {
- Object resp = ObjectBuilder.getVal(new JSONParser(EntityUtils.toString(entity)));
+
+ String respBody = EntityUtils.toString(entity);
+ Object resp = null;
+ try {
+ resp = ObjectBuilder.getVal(new JSONParser(respBody));
+ } catch (JSONParser.ParseException pe) {
+ throw new ClientProtocolException("Expected JSON response from server but received: "+respBody+
+ "\nTypically, this indicates a problem with the Solr server; check the Solr server logs for more information.");
+ }
+
if (resp != null && resp instanceof Map) {
return (Map<String,Object>)resp;
} else {
@@ -595,7 +630,7 @@ public class SolrCLI {
int exitCode = 0;
String systemInfoUrl = solrUrl+"admin/info/system";
- HttpClient httpClient = getHttpClient();
+ CloseableHttpClient httpClient = getHttpClient();
try {
// hit Solr to get system info
Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
@@ -878,7 +913,7 @@ public class SolrCLI {
if (collection == null)
throw new IllegalArgumentException("Must provide a collection to run a healthcheck against!");
- log.info("Running healthcheck for "+collection);
+ log.debug("Running healthcheck for "+collection);
ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
@@ -930,12 +965,13 @@ public class SolrCLI {
replicaStatus = ZkStateReader.DOWN;
} else {
// query this replica directly to get doc count and assess health
- HttpSolrClient solr = new HttpSolrClient(coreUrl);
- String solrUrl = solr.getBaseURL();
q = new SolrQuery("*:*");
q.setRows(0);
q.set("distrib", "false");
- try {
+ try (HttpSolrClient solr = new HttpSolrClient(coreUrl)) {
+
+ String solrUrl = solr.getBaseURL();
+
qr = solr.query(q);
numDocs = qr.getResults().getNumFound();
@@ -950,15 +986,13 @@ public class SolrCLI {
// if we get here, we can trust the state
replicaStatus = replicaCoreProps.getState();
} catch (Exception exc) {
- log.error("ERROR: " + exc + " when trying to reach: " + solrUrl);
+ log.error("ERROR: " + exc + " when trying to reach: " + coreUrl);
if (checkCommunicationError(exc)) {
replicaStatus = "down";
} else {
replicaStatus = "error: "+exc;
}
- } finally {
- solr.shutdown();
}
}
@@ -992,6 +1026,101 @@ public class SolrCLI {
}
} // end HealthcheckTool
+ private static final Option[] CREATE_COLLECTION_OPTIONS = new Option[] {
+ OptionBuilder
+ .withArgName("HOST")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
+ .create("zkHost"),
+ OptionBuilder
+ .withArgName("HOST")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
+ .create("solrUrl"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(true)
+ .withDescription("Name of collection to create.")
+ .create("name"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Number of shards; default is 1")
+ .create("shards"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Number of copies of each document across the collection (replicas per shard); default is 1")
+ .create("replicationFactor"),
+ OptionBuilder
+ .withArgName("#")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Maximum number of shards per Solr node; default is determined based on the number of shards, replication factor, and live nodes.")
+ .create("maxShardsPerNode"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Configuration directory to copy when creating the new collection; default is "+DEFAULT_CONFIG_SET)
+ .create("confdir"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Configuration name; default is the collection name")
+ .create("confname"),
+ OptionBuilder
+ .withArgName("DIR")
+ .hasArg()
+ .isRequired(true)
+ .withDescription("Path to configsets directory on the local system.")
+ .create("configsetsDir")
+ };
+
+ public static String getZkHost(CommandLine cli) throws Exception {
+ String zkHost = cli.getOptionValue("zkHost");
+ if (zkHost != null)
+ return zkHost;
+
+ // find it using the localPort
+ String solrUrl = cli.getOptionValue("solrUrl");
+ if (solrUrl == null)
+ throw new IllegalStateException(
+ "Must provide either the -zkHost or -solrUrl parameters to use the create_collection command!");
+
+ if (!solrUrl.endsWith("/"))
+ solrUrl += "/";
+
+ String systemInfoUrl = solrUrl+"admin/info/system";
+ CloseableHttpClient httpClient = getHttpClient();
+ try {
+ // hit Solr to get system info
+ Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
+
+ // convert raw JSON into user-friendly output
+ StatusTool statusTool = new StatusTool();
+ Map<String,Object> status = statusTool.reportStatus(solrUrl, systemInfo, httpClient);
+ Map<String,Object> cloud = (Map<String, Object>)status.get("cloud");
+ if (cloud != null) {
+ String zookeeper = (String) cloud.get("ZooKeeper");
+ if (zookeeper.endsWith("(embedded)")) {
+ zookeeper = zookeeper.substring(0, zookeeper.length() - "(embedded)".length());
+ }
+ zkHost = zookeeper;
+ }
+ } finally {
+ HttpClientUtil.close(httpClient);
+ }
+
+ return zkHost;
+ }
+
/**
* Supports create_collection command in the bin/solr script.
*/
@@ -1005,56 +1134,7 @@ public class SolrCLI {
@SuppressWarnings("static-access")
@Override
public Option[] getOptions() {
- return new Option[] {
- OptionBuilder
- .withArgName("HOST")
- .hasArg()
- .isRequired(false)
- .withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
- .create("zkHost"),
- OptionBuilder
- .withArgName("HOST")
- .hasArg()
- .isRequired(false)
- .withDescription("Base Solr URL, which can be used to determine the zkHost if that's not known")
- .create("solrUrl"),
- OptionBuilder
- .withArgName("NAME")
- .hasArg()
- .isRequired(true)
- .withDescription("Name of collection to create.")
- .create("name"),
- OptionBuilder
- .withArgName("#")
- .hasArg()
- .isRequired(false)
- .withDescription("Number of shards; default is 1")
- .create("shards"),
- OptionBuilder
- .withArgName("#")
- .hasArg()
- .isRequired(false)
- .withDescription("Number of copies of each document across the collection (replicas per shard); default is 1")
- .create("replicationFactor"),
- OptionBuilder
- .withArgName("#")
- .hasArg()
- .isRequired(false)
- .withDescription("Maximum number of shards per Solr node; default is determined based on the number of shards, replication factor, and live nodes.")
- .create("maxShardsPerNode"),
- OptionBuilder
- .withArgName("NAME")
- .hasArg()
- .isRequired(false)
- .withDescription("Name of the configuration for this collection; default is "+DEFAULT_CONFIG_SET)
- .create("config"),
- OptionBuilder
- .withArgName("DIR")
- .hasArg()
- .isRequired(true)
- .withDescription("Path to configsets directory on the local system.")
- .create("configsetsDir")
- };
+ return CREATE_COLLECTION_OPTIONS;
}
public int runTool(CommandLine cli) throws Exception {
@@ -1063,49 +1143,17 @@ public class SolrCLI {
LogManager.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
LogManager.getLogger("org.apache.solr.common.cloud").setLevel(Level.WARN);
- String zkHost = cli.getOptionValue("zkHost");
+ String zkHost = getZkHost(cli);
if (zkHost == null) {
- // find it using the localPort
- String solrUrl = cli.getOptionValue("solrUrl");
- if (solrUrl == null)
- throw new IllegalStateException(
- "Must provide either the -zkHost or -solrUrl parameters to use the create_collection command!");
-
- if (!solrUrl.endsWith("/"))
- solrUrl += "/";
-
- String systemInfoUrl = solrUrl+"admin/info/system";
- HttpClient httpClient = getHttpClient();
- try {
- // hit Solr to get system info
- Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
-
- // convert raw JSON into user-friendly output
- StatusTool statusTool = new StatusTool();
- Map<String,Object> status = statusTool.reportStatus(solrUrl, systemInfo, httpClient);
-
- Map<String,Object> cloud = (Map<String, Object>)status.get("cloud");
- if (cloud == null) {
- System.err.println("\nERROR: Solr at "+solrUrl+
- " is running in standalone server mode, please use the create_core command instead;\n" +
- "create_collection can only be used when running in SolrCloud mode.\n");
- return 1;
- }
-
- String zookeeper = (String) cloud.get("ZooKeeper");
- if (zookeeper.endsWith("(embedded)")) {
- zookeeper = zookeeper.substring(0,zookeeper.length()-"(embedded)".length());
- }
- zkHost = zookeeper;
- } finally {
- closeHttpClient(httpClient);
- }
+ System.err.println("\nERROR: Solr at "+cli.getOptionValue("solrUrl")+
+ " is running in standalone server mode, please use the create_core command instead;\n" +
+ "create_collection can only be used when running in SolrCloud mode.\n");
+ return 1;
}
int toolExitStatus = 0;
- CloudSolrClient cloudSolrServer = null;
- try {
- cloudSolrServer = new CloudSolrClient(zkHost);
+
+ try (CloudSolrClient cloudSolrServer = new CloudSolrClient(zkHost)) {
System.out.println("Connecting to ZooKeeper at " + zkHost);
cloudSolrServer.connect();
toolExitStatus = runCloudTool(cloudSolrServer, cli);
@@ -1118,12 +1166,6 @@ public class SolrCLI {
} else {
throw exc;
}
- } finally {
- if (cloudSolrServer != null) {
- try {
- cloudSolrServer.shutdown();
- } catch (Exception ignore) {}
- }
}
return toolExitStatus;
@@ -1136,6 +1178,8 @@ public class SolrCLI {
"there is at least 1 live node in the cluster.");
String firstLiveNode = liveNodes.iterator().next();
+ String collectionName = cli.getOptionValue("name");
+
// build a URL to create the collection
int numShards = optionAsInt(cli, "shards", 1);
int replicationFactor = optionAsInt(cli, "replicationFactor", 1);
@@ -1149,48 +1193,51 @@ public class SolrCLI {
maxShardsPerNode = ((numShards*replicationFactor)+numNodes-1)/numNodes;
}
- String configSet = cli.getOptionValue("config", DEFAULT_CONFIG_SET);
- String configSetNameInZk = configSet;
- File configSetDir = null;
- // we try to be flexible and allow the user to specify a configuration directory instead of a configset name
- File possibleConfigDir = new File(configSet);
- if (possibleConfigDir.isDirectory()) {
- configSetDir = possibleConfigDir;
- configSetNameInZk = possibleConfigDir.getName();
+ String confname = cli.getOptionValue("confname", collectionName);
+ boolean configExistsInZk =
+ cloudSolrClient.getZkStateReader().getZkClient().exists("/configs/"+confname, true);
+
+ if (configExistsInZk) {
+ System.out.println("Re-using existing configuration directory "+confname);
} else {
- File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
- if (!configsetsDir.isDirectory())
- throw new FileNotFoundException(configsetsDir.getAbsolutePath()+" not found!");
-
- // upload the configset if it exists
- configSetDir = new File(configsetsDir, configSet);
- if (!configSetDir.isDirectory()) {
- throw new FileNotFoundException("Specified config " + configSet +
- " not found in " + configsetsDir.getAbsolutePath());
+ String configSet = cli.getOptionValue("confdir", DEFAULT_CONFIG_SET);
+ File configSetDir = null;
+ // we try to be flexible and allow the user to specify a configuration directory instead of a configset name
+ File possibleConfigDir = new File(configSet);
+ if (possibleConfigDir.isDirectory()) {
+ configSetDir = possibleConfigDir;
+ } else {
+ File configsetsDir = new File(cli.getOptionValue("configsetsDir"));
+ if (!configsetsDir.isDirectory())
+ throw new FileNotFoundException(configsetsDir.getAbsolutePath()+" not found!");
+
+ // upload the configset if it exists
+ configSetDir = new File(configsetsDir, configSet);
+ if (!configSetDir.isDirectory()) {
+ throw new FileNotFoundException("Specified config " + configSet +
+ " not found in " + configsetsDir.getAbsolutePath());
+ }
}
- }
- File confDir = new File(configSetDir, "conf");
- if (!confDir.isDirectory()) {
- // config dir should contain a conf sub-directory but if not and there's a solrconfig.xml, then use it
- if ((new File(configSetDir, "solrconfig.xml")).isFile()) {
- confDir = configSetDir;
- } else {
- System.err.println("Specified configuration directory "+configSetDir.getAbsolutePath()+
- " is invalid;\nit should contain either conf sub-directory or solrconfig.xml");
- return 1;
+ File confDir = new File(configSetDir, "conf");
+ if (!confDir.isDirectory()) {
+ // config dir should contain a conf sub-directory but if not and there's a solrconfig.xml, then use it
+ if ((new File(configSetDir, "solrconfig.xml")).isFile()) {
+ confDir = configSetDir;
+ } else {
+ System.err.println("Specified configuration directory "+configSetDir.getAbsolutePath()+
+ " is invalid;\nit should contain either conf sub-directory or solrconfig.xml");
+ return 1;
+ }
}
- }
- // test to see if that config exists in ZK
- if (!cloudSolrClient.getZkStateReader().getZkClient().exists("/configs/"+configSetNameInZk, true)) {
+ // test to see if that config exists in ZK
System.out.println("Uploading "+confDir.getAbsolutePath()+
- " for config "+configSetNameInZk+" to ZooKeeper at "+cloudSolrClient.getZkHost());
- ZkController.uploadConfigDir(cloudSolrClient.getZkStateReader().getZkClient(), confDir, configSetNameInZk);
+ " for config "+confname+" to ZooKeeper at "+cloudSolrClient.getZkHost());
+ ZkController.uploadConfigDir(cloudSolrClient.getZkStateReader().getZkClient(), confDir, confname);
}
String baseUrl = cloudSolrClient.getZkStateReader().getBaseUrlForNodeName(firstLiveNode);
- String collectionName = cli.getOptionValue("name");
// since creating a collection is a heavy-weight operation, check for existence first
String collectionListUrl = baseUrl+"/admin/collections?action=list";
@@ -1210,7 +1257,7 @@ public class SolrCLI {
numShards,
replicationFactor,
maxShardsPerNode,
- configSetNameInZk);
+ confname);
System.out.println("\nCreating new collection '"+collectionName+"' using command:\n"+createCollectionUrl+"\n");
@@ -1281,8 +1328,8 @@ public class SolrCLI {
.withArgName("CONFIG")
.hasArg()
.isRequired(false)
- .withDescription("Name of the configuration for this core; default is "+DEFAULT_CONFIG_SET)
- .create("config"),
+ .withDescription("Configuration directory to copy when creating the new core; default is "+DEFAULT_CONFIG_SET)
+ .create("confdir"),
OptionBuilder
.withArgName("DIR")
.hasArg()
@@ -1303,7 +1350,7 @@ public class SolrCLI {
if (!configsetsDir.isDirectory())
throw new FileNotFoundException(configsetsDir.getAbsolutePath() + " not found!");
- String configSet = cli.getOptionValue("config", DEFAULT_CONFIG_SET);
+ String configSet = cli.getOptionValue("confdir", DEFAULT_CONFIG_SET);
File configSetDir = new File(configsetsDir, configSet);
if (!configSetDir.isDirectory()) {
// we allow them to pass a directory instead of a configset name
@@ -1311,7 +1358,7 @@ public class SolrCLI {
if (possibleConfigDir.isDirectory()) {
configSetDir = possibleConfigDir;
} else {
- throw new FileNotFoundException("Specified config " + configSet +
+ throw new FileNotFoundException("Specified config directory " + configSet +
" not found in " + configsetsDir.getAbsolutePath());
}
}
@@ -1319,7 +1366,7 @@ public class SolrCLI {
String coreName = cli.getOptionValue("name");
String systemInfoUrl = solrUrl+"admin/info/system";
- HttpClient httpClient = getHttpClient();
+ CloseableHttpClient httpClient = getHttpClient();
String solrHome = null;
try {
Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
@@ -1414,4 +1461,259 @@ public class SolrCLI {
return exists;
}
} // end CreateCoreTool class
+
+ public static class CreateTool implements Tool {
+
+ @Override
+ public String getName() {
+ return "create";
+ }
+
+ @SuppressWarnings("static-access")
+ @Override
+ public Option[] getOptions() {
+ return CREATE_COLLECTION_OPTIONS;
+ }
+
+ @Override
+ public int runTool(CommandLine cli) throws Exception {
+
+ String solrUrl = cli.getOptionValue("solrUrl", "http://localhost:8983/solr");
+ if (!solrUrl.endsWith("/"))
+ solrUrl += "/";
+
+ String systemInfoUrl = solrUrl+"admin/info/system";
+ CloseableHttpClient httpClient = getHttpClient();
+
+ int result = -1;
+ Tool tool = null;
+ try {
+ Map<String, Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
+ if ("solrcloud".equals(systemInfo.get("mode"))) {
+ tool = new CreateCollectionTool();
+ } else {
+ tool = new CreateCoreTool();
+ }
+ result = tool.runTool(cli);
+ } catch (Exception exc) {
+ System.err.println("ERROR: create failed due to: "+exc.getMessage());
+ System.err.println();
+ result = 1;
+ } finally {
+ closeHttpClient(httpClient);
+ }
+
+ return result;
+ }
+
+ } // end CreateTool class
+
+ public static class DeleteTool implements Tool {
+
+ @Override
+ public String getName() {
+ return "delete";
+ }
+
+ @SuppressWarnings("static-access")
+ @Override
+ public Option[] getOptions() {
+ return new Option[]{
+ OptionBuilder
+ .withArgName("URL")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Base Solr URL, default is http://localhost:8983/solr")
+ .create("solrUrl"),
+ OptionBuilder
+ .withArgName("NAME")
+ .hasArg()
+ .isRequired(true)
+ .withDescription("Name of the core / collection to delete.")
+ .create("name"),
+ OptionBuilder
+ .withArgName("true|false")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Flag to indicate if the underlying configuration directory for a collection should also be deleted; default is true")
+ .create("deleteConfig"),
+ OptionBuilder
+ .isRequired(false)
+ .withDescription("Skip safety checks when deleting the configuration directory used by a collection")
+ .create("forceDeleteConfig"),
+ OptionBuilder
+ .withArgName("HOST")
+ .hasArg()
+ .isRequired(false)
+ .withDescription("Address of the Zookeeper ensemble; defaults to: "+ZK_HOST)
+ .create("zkHost")
+ };
+ }
+
+ @Override
+ public int runTool(CommandLine cli) throws Exception {
+
+ // quiet down the ZK logging for cli tools
+ LogManager.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);
+ LogManager.getLogger("org.apache.solr.common.cloud").setLevel(Level.WARN);
+
+ String solrUrl = cli.getOptionValue("solrUrl", "http://localhost:8983/solr");
+ if (!solrUrl.endsWith("/"))
+ solrUrl += "/";
+
+ String systemInfoUrl = solrUrl+"admin/info/system";
+ CloseableHttpClient httpClient = getHttpClient();
+
+ int result = 0;
+ try {
+ Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);
+ if ("solrcloud".equals(systemInfo.get("mode"))) {
+ result = deleteCollection(cli);
+ } else {
+ result = deleteCore(cli, httpClient, solrUrl);
+ }
+ } finally {
+ closeHttpClient(httpClient);
+ }
+
+ return result;
+ }
+
+ protected int deleteCollection(CommandLine cli) throws Exception {
+
+ String zkHost = getZkHost(cli);
+
+ int toolExitStatus = 0;
+ try (CloudSolrClient cloudSolrClient = new CloudSolrClient(zkHost)) {
+ System.out.println("Connecting to ZooKeeper at " + zkHost);
+ cloudSolrClient.connect();
+ toolExitStatus = deleteCollection(cloudSolrClient, cli);
+ } catch (Exception exc) {
+ // since this is a CLI, spare the user the stacktrace
+ String excMsg = exc.getMessage();
+ if (excMsg != null) {
+ System.err.println("\nERROR: "+excMsg+"\n");
+ toolExitStatus = 1;
+ } else {
+ throw exc;
+ }
+ }
+
+ return toolExitStatus;
+ }
+
+ protected int deleteCollection(CloudSolrClient cloudSolrClient, CommandLine cli) throws Exception {
+ Set<String> liveNodes = cloudSolrClient.getZkStateReader().getClusterState().getLiveNodes();
+ if (liveNodes.isEmpty())
+ throw new IllegalStateException("No live nodes found! Cannot delete a collection until " +
+ "there is at least 1 live node in the cluster.");
+ String firstLiveNode = liveNodes.iterator().next();
+ ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
+ String baseUrl = zkStateReader.getBaseUrlForNodeName(firstLiveNode);
+
+ String collectionName = cli.getOptionValue("name");
+
+ if (!zkStateReader.getClusterState().hasCollection(collectionName)) {
+ System.err.println("\nERROR: Collection "+collectionName+" not found!");
+ System.err.println();
+ return 1;
+ }
+
+ String configName = zkStateReader.readConfigName(collectionName);
+ boolean deleteConfig = "true".equals(cli.getOptionValue("deleteConfig", "true"));
+ if (deleteConfig && configName != null) {
+ if (cli.hasOption("forceDeleteConfig")) {
+ log.warn("Skipping safety checks, configuration directory "+configName+" will be deleted with impunity.");
+ } else {
+ // need to scan all Collections to see if any are using the config
+ Set<String> collections = zkStateReader.getClusterState().getCollections();
+
+ // give a little note to the user if there are many collections in case it takes a while
+ if (collections.size() > 50)
+ log.info("Scanning " + collections.size() +
+ " to ensure no other collections are using config " + configName);
+
+ for (String next : collections) {
+ if (collectionName.equals(next))
+ continue; // don't check the collection we're deleting
+
+ if (configName.equals(zkStateReader.readConfigName(next))) {
+ deleteConfig = false;
+ log.warn("Configuration directory "+configName+" is also being used by "+next+
+ "; configuration will not be deleted from ZooKeeper. You can pass the -forceDeleteConfig flag to force delete.");
+ break;
+ }
+ }
+ }
+ }
+
+ String deleteCollectionUrl =
+ String.format(Locale.ROOT,
+ "%s/admin/collections?action=DELETE&name=%s",
+ baseUrl,
+ collectionName);
+
+ System.out.println("\nDeleting collection '"+collectionName+"' using command:\n"+deleteCollectionUrl+"\n");
+
+ Map<String,Object> json = null;
+ try {
+ json = getJson(deleteCollectionUrl);
+ } catch (SolrServerException sse) {
+ System.err.println("Failed to delete collection '"+collectionName+"' due to: "+sse.getMessage());
+ System.err.println();
+ return 1;
+ }
+
+ if (deleteConfig) {
+ String configZnode = "/configs/" + configName;
+ try {
+ zkStateReader.getZkClient().clean(configZnode);
+ } catch (Exception exc) {
+ System.err.println("\nERROR: Failed to delete configuration directory "+configZnode+" in ZooKeeper due to: "+
+ exc.getMessage()+"\nYou'll need to manually delete this znode using the zkcli script.");
+ }
+ }
+
+ if (json != null) {
+ CharArr arr = new CharArr();
+ new JSONWriter(arr, 2).write(json);
+ System.out.println(arr.toString());
+ System.out.println();
+ }
+
+ return 0;
+ }
+
+ protected int deleteCore(CommandLine cli, CloseableHttpClient httpClient, String solrUrl) throws Exception {
+
+ int status = 0;
+ String coreName = cli.getOptionValue("name");
+ String deleteCoreUrl =
+ String.format(Locale.ROOT,
+ "%sadmin/cores?action=UNLOAD&core=%s&deleteIndex=true&deleteDataDir=true&deleteInstanceDir=true",
+ solrUrl,
+ coreName);
+
+ System.out.println("\nDeleting core '"+coreName+"' using command:\n"+deleteCoreUrl+"\n");
+
+ Map<String,Object> json = null;
+ try {
+ json = getJson(deleteCoreUrl);
+ } catch (SolrServerException sse) {
+ System.err.println("Failed to delete core '"+coreName+"' due to: "+sse.getMessage());
+ System.err.println();
+ status = 1;
+ }
+
+ if (json != null) {
+ CharArr arr = new CharArr();
+ new JSONWriter(arr, 2).write(json);
+ System.out.println(arr.toString());
+ System.out.println();
+ }
+
+ return status;
+ }
+
+ } // end DeleteTool class
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java Sun Feb 8 23:53:14 2015
@@ -31,6 +31,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Pattern;
+import com.google.common.collect.ImmutableMap;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.BooleanClause;
@@ -49,7 +50,6 @@ import org.apache.solr.common.params.Sol
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.common.util.StrUtils;
-import org.apache.solr.core.InitParams;
import org.apache.solr.core.RequestParams;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.component.HighlightComponent;
@@ -115,6 +115,10 @@ public class SolrPluginUtils {
purposes = Collections.unmodifiableMap(map);
}
+ private static final MapSolrParams maskUseParams = new MapSolrParams(ImmutableMap.<String, String>builder()
+ .put(RequestParams.USEPARAM, "")
+ .build());
+
/**
* Set default-ish params on a SolrQueryRequest.
*
@@ -131,8 +135,18 @@ public class SolrPluginUtils {
List<String> paramNames =null;
String useParams = req.getParams().get(RequestParams.USEPARAM);
+ if(useParams!=null && !useParams.isEmpty()){
+ // now that we have expanded the request macro useParams with the actual values
+ // it makes no sense to keep it visible now on.
+ // distrib request sends all params to the nodes down the line and
+ // if it sends the useParams to other nodes , they will expand them as well.
+ // which is not desirable. At the same time, because we send the useParams
+ // value as an empty string to other nodes we get the desired benefit of
+ // overriding the useParams specified in the requestHandler directly
+ req.setParams(SolrParams.wrapDefaults(maskUseParams,req.getParams()));
+ }
if(useParams == null) useParams = (String) req.getContext().get(RequestParams.USEPARAM);
- if(useParams !=null) paramNames = StrUtils.splitSmart(useParams, ',');
+ if(useParams !=null && !useParams.isEmpty()) paramNames = StrUtils.splitSmart(useParams, ',');
if(paramNames != null){
for (String name : paramNames) {
SolrParams requestParams = req.getCore().getSolrConfig().getRequestParams().getParams(name);
@@ -978,9 +992,7 @@ public class SolrPluginUtils {
Class pClazz = method.getParameterTypes()[0];
Object val = entry.getValue();
method.invoke(bean, val);
- } catch (InvocationTargetException e1) {
- throw new RuntimeException("Error invoking setter " + setterName + " on class : " + clazz.getName(), e1);
- } catch (IllegalAccessException e1) {
+ } catch (InvocationTargetException | IllegalAccessException e1) {
throw new RuntimeException("Error invoking setter " + setterName + " on class : " + clazz.getName(), e1);
}
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/log4j.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/log4j.properties?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/log4j.properties (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/log4j.properties Sun Feb 8 23:53:14 2015
@@ -8,6 +8,7 @@ log4j.appender.CONSOLE.layout.Conversion
log4j.logger.org.apache.zookeeper=WARN
log4j.logger.org.apache.hadoop=WARN
+log4j.logger.org.apache.directory=WARN
log4j.logger.org.apache.solr.hadoop=INFO
#log4j.logger.org.apache.solr.update.processor.LogUpdateProcessor=DEBUG
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml Sun Feb 8 23:53:14 2015
@@ -30,28 +30,25 @@
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
<fieldType name="srpt_geohash" class="solr.SpatialRecursivePrefixTreeFieldType"
- prefixTree="geohash" units="degrees"
+ prefixTree="geohash" distanceUnits="degrees"
/>
<fieldType name="srpt_quad" class="solr.SpatialRecursivePrefixTreeFieldType"
- prefixTree="quad" units="degrees"
+ prefixTree="quad" distanceUnits="degrees"
/>
<fieldType name="srpt_100km" class="solr.SpatialRecursivePrefixTreeFieldType"
- maxDistErr="0.9" units="degrees"
+ maxDistErr="100" distanceUnits="kilometers"
/>
<fieldType name="stqpt_geohash" class="solr.SpatialTermQueryPrefixTreeFieldType"
- prefixTree="geohash" units="degrees" />
+ prefixTree="geohash" distanceUnits="degrees" />
<fieldType name="stqpt_u" class="solr.SpatialTermQueryPrefixTreeFieldType"
- geo="false" distCalculator="cartesian^2" worldBounds="ENVELOPE(0, 1000, 1000, 0)" units="degrees"/>
+ geo="false" distCalculator="cartesian^2" worldBounds="ENVELOPE(0, 1000, 1000, 0)" distanceUnits="degrees"/>
<fieldType name="pointvector" class="solr.SpatialPointVectorFieldType"
- numberType="tdouble" units="degrees"/>
-
- <fieldType name="stqpt_u_oldworldbounds" class="solr.SpatialTermQueryPrefixTreeFieldType"
- geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000" units="degrees"/>
+ numberType="tdouble" distanceUnits="degrees"/>
<fieldType name="bbox" class="solr.BBoxField"
- numberType="tdoubleDV" units="degrees"/>
+ numberType="tdoubleDV" distanceUnits="degrees"/>
</types>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema.xml Sun Feb 8 23:53:14 2015
@@ -401,6 +401,16 @@
</analyzer>
</fieldType>
+ <fieldType name="payloadDelimited" class="solr.TextField">
+ <analyzer type="index">
+ <tokenizer class="solr.WhitespaceTokenizerFactory" />
+ <filter class="solr.DelimitedPayloadTokenFilterFactory" encoder="integer" />
+ </analyzer>
+ <analyzer type="query">
+ <tokenizer class="solr.WhitespaceTokenizerFactory" />
+ </analyzer>
+ </fieldType>
+
</types>
@@ -536,6 +546,8 @@
<field name="lower" type="lowertok" indexed="false" stored="true" multiValued="true" />
<field name="_route_" type="string" indexed="true" stored="true" multiValued="false" />
+ <field name="payloadDelimited" type="payloadDelimited" />
+
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema12.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema12.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema12.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/schema12.xml Sun Feb 8 23:53:14 2015
@@ -392,7 +392,7 @@
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
<!-- sub-centimeter accuracy for RPT; distance calcs -->
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
- geo="true" distErrPct="0.025" maxDistErr="0.00000009" units="degrees" />
+ geo="true" distErrPct="0.025" maxDistErr="0.00001" distanceUnits="kilometers" />
<fieldType name="currency" class="solr.CurrencyField" currencyConfig="currency.xml" multiValued="false" />
</types>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-slave.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-slave.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-slave.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-slave.xml Sun Feb 8 23:53:14 2015
@@ -42,7 +42,7 @@
<requestHandler name="/replication" class="solr.ReplicationHandler">
<lst name="slave">
- <str name="masterUrl">http://127.0.0.1:TEST_PORT/solr</str>
+ <str name="masterUrl">http://127.0.0.1:TEST_PORT/solr/collection1</str>
<str name="pollInterval">00:00:01</str>
<str name="compression">COMPRESSION</str>
</lst>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-suggestercomponent.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-suggestercomponent.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-suggestercomponent.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-suggestercomponent.xml Sun Feb 8 23:53:14 2015
@@ -23,7 +23,7 @@
solr.StandardDirectoryFactory, the default, is filesystem based.
solr.RAMDirectoryFactory is memory based and not persistent. -->
<dataDir>${solr.data.dir:}</dataDir>
- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
+ <directoryFactory name="DirectoryFactory" class="solr.NRTCachingDirectoryFactory"/>
<updateHandler class="solr.DirectUpdateHandler2"/>
@@ -40,7 +40,6 @@
<str name="suggestAnalyzerFieldType">text</str>
<str name="buildOnCommit">true</str>
- <!-- Suggester properties -->
<float name="threshold">0.0</float>
</lst>
@@ -61,9 +60,9 @@
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">cat</str>
<str name="weightField">price</str>
- <str name="storeDir">suggest_fuzzy_doc_dict_payload</str>
<str name="suggestAnalyzerFieldType">text</str>
<str name="buildOnCommit">true</str>
+ <str name="buildOnStartup">false</str>
</lst>
<!-- Suggest component (Document Expression Dictionary) -->
@@ -79,6 +78,57 @@
<str name="suggestAnalyzerFieldType">text</str>
<str name="buildOnCommit">true</str>
</lst>
+
+ <!-- Suggest component (Document Dictionary) that is built on startup-->
+ <lst name="suggester">
+ <str name="name">suggest_fuzzy_doc_dict_build_startup</str>
+ <str name="lookupImpl">FuzzyLookupFactory</str>
+ <str name="dictionaryImpl">DocumentDictionaryFactory</str>
+ <str name="field">cat</str>
+ <str name="weightField">price</str>
+ <str name="suggestAnalyzerFieldType">text</str>
+ <str name="buildOnCommit">false</str>
+ <str name="buildOnStartup">true</str>
+ </lst>
+
+ <!-- Suggest component (Document Dictionary) only builds manually-->
+ <lst name="suggester">
+ <str name="name">suggest_fuzzy_doc_manal_build</str>
+ <str name="lookupImpl">FuzzyLookupFactory</str>
+ <str name="dictionaryImpl">DocumentDictionaryFactory</str>
+ <str name="field">cat</str>
+ <str name="weightField">price</str>
+ <str name="suggestAnalyzerFieldType">text</str>
+ <str name="buildOnCommit">false</str>
+ <str name="buildOnStartup">false</str>
+ <str name="storeDir">suggest_fuzzy_doc_manal_build</str>
+ </lst>
+
+ <!-- Suggest component (Document Dictionary) only builds manually and
+ has the default buildOnStartup behavior -->
+ <lst name="suggester">
+ <str name="name">suggest_doc_default_startup</str>
+ <str name="lookupImpl">AnalyzingLookupFactory</str>
+ <str name="dictionaryImpl">DocumentDictionaryFactory</str>
+ <str name="field">cat</str>
+ <str name="weightField">price</str>
+ <str name="suggestAnalyzerFieldType">text</str>
+ <str name="buildOnCommit">false</str>
+ <str name="storeDir">suggest_doc_default_startup</str>
+ </lst>
+
+ <!-- Suggest component (Document Dictionary) only builds manually and
+ has the default buildOnStartup behavior with no storeDir -->
+ <lst name="suggester">
+ <str name="name">suggest_doc_default_startup_no_store</str>
+ <str name="lookupImpl">AnalyzingLookupFactory</str>
+ <str name="dictionaryImpl">DocumentDictionaryFactory</str>
+ <str name="field">cat</str>
+ <str name="weightField">price</str>
+ <str name="suggestAnalyzerFieldType">text</str>
+ <str name="buildOnCommit">false</str>
+ </lst>
+
</searchComponent>
<requestHandler name="/suggest" class="org.apache.solr.handler.component.SearchHandler">
@@ -91,5 +141,7 @@
</requestHandler>
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
+
+ <query><useColdSearcher>false</useColdSearcher></query>
</config>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-with-delayingcomponent.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-with-delayingcomponent.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-with-delayingcomponent.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog-with-delayingcomponent.xml Sun Feb 8 23:53:14 2015
@@ -81,12 +81,6 @@
</lst>
</requestHandler>
- <requestHandler name="/admin/fileedit" class="solr.admin.EditFileRequestHandler" >
- <lst name="invariants">
- <str name="hidden">bogus.txt</str>
- </lst>
- </requestHandler>
-
<updateRequestProcessorChain name="distrib-dup-test-chain-explicit">
<!-- explicit test using processors before and after distrib -->
<processor class="solr.RegexReplaceProcessorFactory">
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml Sun Feb 8 23:53:14 2015
@@ -82,12 +82,6 @@
</lst>
</requestHandler>
- <requestHandler name="/admin/fileedit" class="solr.admin.EditFileRequestHandler" >
- <lst name="invariants">
- <str name="hidden">bogus.txt</str>
- </lst>
- </requestHandler>
-
<updateRequestProcessorChain name="distrib-dup-test-chain-explicit">
<!-- explicit test using processors before and after distrib -->
<processor class="solr.RegexReplaceProcessorFactory">
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.snippet.randomindexconfig.xml Sun Feb 8 23:53:14 2015
@@ -35,7 +35,6 @@ A solrconfig.xml snippet containing inde
<ramBufferSizeMB>${solr.tests.ramBufferSizeMB}</ramBufferSizeMB>
<mergeScheduler class="${solr.tests.mergeScheduler}" />
- <nrtMode>${solr.tests.nrtMode:true}</nrtMode>
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/collection1/conf/solrconfig.xml Sun Feb 8 23:53:14 2015
@@ -235,12 +235,6 @@
</lst>
</requestHandler>
- <requestHandler name="/admin/fileedit" class="solr.admin.EditFileRequestHandler" >
- <lst name="invariants">
- <str name="hidden">bogus.txt</str>
- </lst>
- </requestHandler>
-
<!-- test query parameter defaults -->
<requestHandler name="defaults" class="solr.StandardRequestHandler">
<lst name="defaults">
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr-no-core.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr-no-core.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr-no-core.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr-no-core.xml Sun Feb 8 23:53:14 2015
@@ -19,6 +19,8 @@
<solr>
<str name="shareSchema">${shareSchema:false}</str>
+ <str name="configSetBaseDir">${configSetBaseDir:configsets}</str>
+ <str name="coreRootDirectory">${coreRootDirectory:.}</str>
<solrcloud>
<str name="host">127.0.0.1</str>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr.xml?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr.xml (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test-files/solr/solr.xml Sun Feb 8 23:53:14 2015
@@ -18,27 +18,28 @@
<!--
All (relative) paths are relative to the installation path
-
- persistent: Save changes made via the API to this file
- sharedLib: path to a lib directory that will be shared across all cores
-->
-<solr persistent="${solr.xml.persist:false}">
+<solr>
+
+ <str name="shareSchema">${shareSchema:false}</str>
+ <str name="configSetBaseDir">${configSetBaseDir:configsets}</str>
+ <str name="coreRootDirectory">${coreRootDirectory:.}</str>
+
+ <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
+ <str name="urlScheme">${urlScheme:}</str>
+ <int name="socketTimeout">${socketTimeout:90000}</int>
+ <int name="connTimeout">${connTimeout:15000}</int>
+ </shardHandlerFactory>
- <!--
- adminPath: RequestHandler path to manage cores.
- If 'null' (or absent), cores will not be manageable via request handler
- -->
- <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}"
- hostContext="${hostContext:solr}" zkClientTimeout="${solr.zkclienttimeout:30000}" shareSchema="${shareSchema:false}"
- genericCoreNodeNames="${genericCoreNodeNames:true}" leaderVoteWait="0"
- distribUpdateConnTimeout="${distribUpdateConnTimeout:45000}" distribUpdateSoTimeout="${distribUpdateSoTimeout:340000}">
- <core name="collection1" instanceDir="collection1" shard="${shard:}" collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"
- coreNodeName="${coreNodeName:}"/>
- <shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory">
- <str name="urlScheme">${urlScheme:}</str>
- <int name="socketTimeout">${socketTimeout:90000}</int>
- <int name="connTimeout">${connTimeout:15000}</int>
- </shardHandlerFactory>
- </cores>
+ <solrcloud>
+ <str name="host">127.0.0.1</str>
+ <int name="hostPort">${hostPort:8983}</int>
+ <str name="hostContext">${hostContext:solr}</str>
+ <int name="zkClientTimeout">${solr.zkclienttimeout:30000}</int>
+ <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
+ <int name="leaderVoteWait">0</int>
+ <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:45000}</int>
+ <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:340000}</int>
+ </solrcloud>
</solr>
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/BasicFunctionalityTest.java Sun Feb 8 23:53:14 2015
@@ -37,7 +37,6 @@ import org.apache.lucene.index.StoredDoc
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext.Context;
import org.apache.lucene.store.MockDirectoryWrapper;
-import org.apache.lucene.store.RateLimitedDirectoryWrapper;
import org.apache.lucene.util.English;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/DistributedIntervalFacetingTest.java Sun Feb 8 23:53:14 2015
@@ -10,6 +10,7 @@ import org.apache.solr.client.solrj.resp
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.junit.BeforeClass;
+import org.junit.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -37,8 +38,8 @@ public class DistributedIntervalFaceting
configString = "solrconfig-basic.xml";
}
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
del("*:*");
commit();
testRandom();
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java Sun Feb 8 23:53:14 2015
@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.resp
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.junit.Test;
/**
* TODO? perhaps use:
@@ -43,8 +44,8 @@ public class TestDistributedGrouping ext
String tdate_b = "b_n_tdt";
String oddField="oddField_s";
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
del("*:*");
commit();
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedMissingSort.java Sun Feb 8 23:53:14 2015
@@ -19,6 +19,7 @@ package org.apache.solr;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.client.solrj.response.QueryResponse;
+import org.junit.Test;
/**
* Tests sortMissingFirst and sortMissingLast in distributed sort
@@ -37,8 +38,8 @@ public class TestDistributedMissingSort
String string1_ml = "five_s1_ml"; // StringField, sortMissingLast=true, multiValued=false
String string1_mf = "six_s1_mf"; // StringField, sortMissingFirst=true, multiValued=false
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
index();
testSortMissingLast();
testSortMissingFirst();
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedSearch.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedSearch.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestDistributedSearch.java Sun Feb 8 23:53:14 2015
@@ -37,6 +37,7 @@ import org.apache.solr.common.params.Com
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
+import org.junit.Test;
/**
* TODO? perhaps use:
@@ -61,8 +62,8 @@ public class TestDistributedSearch exten
String missingField="ignore_exception__missing_but_valid_field_t";
String invalidField="ignore_exception__invalid_field_not_in_schema";
- @Override
- public void doTest() throws Exception {
+ @Test
+ public void test() throws Exception {
QueryResponse rsp = null;
int backupStress = stress; // make a copy so we can restore
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestHighlightDedupGrouping.java Sun Feb 8 23:53:14 2015
@@ -18,10 +18,10 @@
package org.apache.solr;
import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.TestUtil;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrInputDocument;
+import org.junit.Test;
import java.io.IOException;
@@ -35,14 +35,9 @@ public class TestHighlightDedupGrouping
private static final String group_ti1 = "group_ti1";
private static final String shard_i1 = "shard_i1";
- public TestHighlightDedupGrouping() {
- super();
- fixShardCount = true;
- shardCount = 2;
- }
-
- @Override
- public void doTest() throws Exception {
+ @Test
+ @ShardsFixed(num = 2)
+ public void test() throws Exception {
basicTest();
randomizedTest();
}
@@ -57,7 +52,7 @@ public class TestHighlightDedupGrouping
int docid = 1;
int group = 5;
- for (int shard = 0 ; shard < shardCount ; ++shard) {
+ for (int shard = 0 ; shard < getShardCount(); ++shard) {
addDoc(docid, group, shard); // add the same doc to both shards
clients.get(shard).commit();
}
@@ -67,7 +62,7 @@ public class TestHighlightDedupGrouping
"shards", shards,
"group", "true",
"group.field", id_s1,
- "group.limit", Integer.toString(shardCount),
+ "group.limit", Integer.toString(getShardCount()),
"hl", "true",
"hl.fl", id_s1
));
@@ -93,15 +88,15 @@ public class TestHighlightDedupGrouping
++docsInGroup[group];
boolean makeDuplicate = 0 == TestUtil.nextInt(random(), 0, numDocs / percentDuplicates);
if (makeDuplicate) {
- for (int shard = 0 ; shard < shardCount ; ++shard) {
+ for (int shard = 0 ; shard < getShardCount(); ++shard) {
addDoc(docid, group, shard);
}
} else {
- int shard = TestUtil.nextInt(random(), 0, shardCount - 1);
+ int shard = TestUtil.nextInt(random(), 0, getShardCount() - 1);
addDoc(docid, group, shard);
}
}
- for (int shard = 0 ; shard < shardCount ; ++shard) {
+ for (int shard = 0 ; shard < getShardCount(); ++shard) {
clients.get(shard).commit();
}
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java Sun Feb 8 23:53:14 2015
@@ -16,20 +16,21 @@
*/
package org.apache.solr;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Properties;
-
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Properties;
/**
* <p> Test for Loading core properties from a properties file </p>
@@ -39,6 +40,8 @@ import java.nio.charset.StandardCharsets
*/
public class TestSolrCoreProperties extends SolrJettyTestBase {
+ // TODO these properties files don't work with configsets
+
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = createTempDir().toFile();
@@ -68,7 +71,19 @@ public class TestSolrCoreProperties exte
p.store(fos, null);
IOUtils.close(fos);
- createJetty(homeDir.getAbsolutePath(), null, null);
+ Files.createFile(collDir.toPath().resolve("core.properties"));
+
+ jetty = new JettySolrRunner(homeDir.getAbsolutePath(), "/solr", 0, null, null, true, null, sslConfig);
+
+ // this sets the property for jetty starting SolrDispatchFilter
+ if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
+ jetty.setDataDir(createTempDir().toFile().getCanonicalPath());
+ }
+
+ jetty.start();
+ port = jetty.getLocalPort();
+
+ //createJetty(homeDir.getAbsolutePath(), null, null);
}
public void testSimple() throws Exception {
Modified: lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestTolerantSearch.java?rev=1658277&r1=1658276&r2=1658277&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestTolerantSearch.java (original)
+++ lucene/dev/branches/lucene6005/solr/core/src/test/org/apache/solr/TestTolerantSearch.java Sun Feb 8 23:53:14 2015
@@ -1,12 +1,8 @@
package org.apache.solr;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-
import org.apache.commons.io.FileUtils;
-import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -21,6 +17,10 @@ import org.apache.solr.response.SolrQuer
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -60,7 +60,7 @@ public class TestTolerantSearch extends
solrHome = createSolrHome();
createJetty(solrHome.getAbsolutePath(), null, null);
String url = jetty.getBaseUrl().toString();
- collection1 = new HttpSolrClient(url);
+ collection1 = new HttpSolrClient(url + "/collection1");
collection2 = new HttpSolrClient(url + "/collection2");
String urlCollection1 = jetty.getBaseUrl().toString() + "/" + "collection1";
@@ -69,10 +69,13 @@ public class TestTolerantSearch extends
shard2 = urlCollection2.replaceAll("https?://", "");
//create second core
- CoreAdminRequest.Create req = new CoreAdminRequest.Create();
- req.setCoreName("collection2");
- collection1.request(req);
-
+ try (HttpSolrClient nodeClient = new HttpSolrClient(url)) {
+ CoreAdminRequest.Create req = new CoreAdminRequest.Create();
+ req.setCoreName("collection2");
+ req.setConfigSet("collection1");
+ nodeClient.request(req);
+ }
+
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", "1");
doc.setField("subject", "batman");
@@ -96,8 +99,8 @@ public class TestTolerantSearch extends
@AfterClass
public static void destroyThings() throws Exception {
- collection1.shutdown();
- collection2.shutdown();
+ collection1.close();
+ collection2.close();
collection1 = null;
collection2 = null;
jetty.stop();