You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2010/02/11 18:16:49 UTC
svn commit: r909080 - in
/lucene/solr/branches/cloud/src/java/org/apache/solr:
cloud/ZkController.java core/CoreContainer.java
Author: yonik
Date: Thu Feb 11 17:16:35 2010
New Revision: 909080
URL: http://svn.apache.org/viewvc?rev=909080&view=rev
Log:
start to unify coreadmin collection params with bootstrap params
Modified:
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java
lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java?rev=909080&r1=909079&r2=909080&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java Thu Feb 11 17:16:35 2010
@@ -60,6 +60,7 @@
private final static Pattern URL_POST = Pattern.compile("https?://(.*)");
private final static Pattern URL_PREFIX = Pattern.compile("(https?://).*");
+
// package private for tests
static final String SHARDS_ZKNODE = "/shards";
static final String CONFIGS_ZKNODE = "/configs";
@@ -68,6 +69,8 @@
public static final String URL_PROP = "url";
public static final String NODE_NAME = "node_name";
+ public final static String COLLECTION_PARAM_PREFIX="collection.";
+ public final static String CONFIGNAME_PROP="configName";
private SolrZkClient zkClient;
@@ -482,7 +485,7 @@
if(data != null) {
props.load(data);
- configName = props.get("configName");
+ configName = props.get(CONFIGNAME_PROP);
}
if (configName != null && !zkClient.exists(CONFIGS_ZKNODE + "/" + configName)) {
@@ -808,28 +811,39 @@
try {
ZkNodeProps collectionProps = new ZkNodeProps();
- // TODO: if bootstrap_confname isn't set, and there isn't already a conf in zk, just use that?
- String defaultConfigName = System.getProperty("bootstrap_confname", "configuration1");
+ // TODO: if collection.configName isn't set, and there isn't already a conf in zk, just use that?
+ String defaultConfigName = System.getProperty(COLLECTION_PARAM_PREFIX+CONFIGNAME_PROP, "configuration1");
// params passed in - currently only done via core admin (create core commmand).
if (params != null) {
Iterator<String> iter = params.getParameterNamesIterator();
while (iter.hasNext()) {
String paramName = iter.next();
- if (paramName.startsWith("collection.")) {
- collectionProps.put(paramName.substring("collection.".length()), params.get(paramName));
+ if (paramName.startsWith(COLLECTION_PARAM_PREFIX)) {
+ collectionProps.put(paramName.substring(COLLECTION_PARAM_PREFIX.length()), params.get(paramName));
}
}
// if the config name wasn't passed in, use the default
- if (!collectionProps.containsKey("configName"))
- collectionProps.put("configName", defaultConfigName);
+ if (!collectionProps.containsKey(CONFIGNAME_PROP))
+ collectionProps.put(CONFIGNAME_PROP, defaultConfigName);
} else if(System.getProperty("bootstrap_confdir") != null) {
// if we are bootstrapping a collection, default the config for
// a new collection to the collection we are bootstrapping
log.info("Setting config for collection:" + collection + " to " + defaultConfigName);
- collectionProps.put("configName", defaultConfigName);
+
+ Properties sysProps = System.getProperties();
+ for (String sprop : System.getProperties().stringPropertyNames()) {
+ if (sprop.startsWith(COLLECTION_PARAM_PREFIX)) {
+ collectionProps.put(sprop.substring(COLLECTION_PARAM_PREFIX.length()), sysProps.getProperty(sprop));
+ }
+ }
+
+ // if the config name wasn't passed in, use the default
+ if (!collectionProps.containsKey(CONFIGNAME_PROP))
+ collectionProps.put(CONFIGNAME_PROP, defaultConfigName);
+
} else {
// check for configName
log.info("Looking for collection configName");
@@ -838,7 +852,7 @@
if (zkClient.exists(collectionPath)) {
collectionProps = new ZkNodeProps();
collectionProps.load(zkClient.getData(collectionPath, null, null));
- if (collectionProps.containsKey("configName")) {
+ if (collectionProps.containsKey(CONFIGNAME_PROP)) {
break;
}
}
Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java?rev=909080&r1=909079&r2=909080&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java Thu Feb 11 17:16:35 2010
@@ -134,7 +134,7 @@
if(!dir.isDirectory()) {
throw new IllegalArgumentException("bootstrap_confdir must be a directory of configuration files");
}
- String confName = System.getProperty("bootstrap_confname", "configuration1");
+ String confName = System.getProperty(ZkController.COLLECTION_PARAM_PREFIX+ZkController.CONFIGNAME_PROP, "configuration1");
zkController.uploadConfigDir(dir, confName);
}
} catch (InterruptedException e) {