mirror of https://github.com/apache/lucene.git
SOLR-1051 -- Fix NPE and change comma separated indexDirs parameter to multiple indexDir parameters
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@781688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa807c01d7
commit
b007152303
|
@ -55,7 +55,7 @@ public interface CoreAdminParams
|
|||
|
||||
/** If you merge indexes, what are the index directories.
|
||||
* The directories are separated by ",". */
|
||||
public final static String INDEX_DIRS = "indexDirs";
|
||||
public final static String INDEX_DIR = "indexDir";
|
||||
|
||||
public enum CoreAdminAction {
|
||||
STATUS,
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.solr.core.DirectoryFactory;
|
|||
import org.apache.solr.handler.RequestHandlerBase;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryResponse;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.util.RefCounted;
|
||||
import org.apache.solr.update.MergeIndexesCommand;
|
||||
|
@ -177,8 +178,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
try {
|
||||
doPersist = coreContainer.isPersistent();
|
||||
|
||||
String p = required.get(CoreAdminParams.INDEX_DIRS);
|
||||
String[] dirNames = p.split(",");
|
||||
String[] dirNames = required.getParams(CoreAdminParams.INDEX_DIR);
|
||||
|
||||
DirectoryFactory dirFactory = core.getDirectoryFactory();
|
||||
Directory[] dirs = new Directory[dirNames.length];
|
||||
|
@ -188,8 +188,9 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
|||
|
||||
UpdateRequestProcessorChain processorChain =
|
||||
core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));
|
||||
SolrQueryRequest wrappedReq = new LocalSolrQueryRequest(core, req.getParams());
|
||||
UpdateRequestProcessor processor =
|
||||
processorChain.createProcessor(req, rsp);
|
||||
processorChain.createProcessor(wrappedReq, rsp);
|
||||
processor.processMergeIndexes(new MergeIndexesCommand(dirs));
|
||||
} finally {
|
||||
core.close();
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.solr.client.solrj.request;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServer;
|
||||
|
@ -110,17 +112,17 @@ public class CoreAdminRequest extends SolrRequest
|
|||
}
|
||||
|
||||
public static class MergeIndexes extends CoreAdminRequest {
|
||||
protected String indexDirs;
|
||||
protected List<String> indexDirs;
|
||||
|
||||
public MergeIndexes() {
|
||||
action = CoreAdminAction.MERGEINDEXES;
|
||||
}
|
||||
|
||||
public void setIndexDirs(String indexDirs) {
|
||||
public void setIndexDirs(List<String> indexDirs) {
|
||||
this.indexDirs = indexDirs;
|
||||
}
|
||||
|
||||
public String getIndexDirs() {
|
||||
public List<String> getIndexDirs() {
|
||||
return indexDirs;
|
||||
}
|
||||
|
||||
|
@ -132,7 +134,11 @@ public class CoreAdminRequest extends SolrRequest
|
|||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(CoreAdminParams.ACTION, action.toString());
|
||||
params.set(CoreAdminParams.CORE, core);
|
||||
params.set(CoreAdminParams.INDEX_DIRS, indexDirs);
|
||||
if (indexDirs != null) {
|
||||
for (String indexDir : indexDirs) {
|
||||
params.set(CoreAdminParams.INDEX_DIR, indexDir);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
}
|
||||
|
@ -281,17 +287,7 @@ public class CoreAdminRequest extends SolrRequest
|
|||
IOException {
|
||||
CoreAdminRequest.MergeIndexes req = new CoreAdminRequest.MergeIndexes();
|
||||
req.setCoreName(name);
|
||||
String p = null;
|
||||
if (indexDirs.length == 1) {
|
||||
p = indexDirs[0];
|
||||
} else if (indexDirs.length > 1) {
|
||||
StringBuilder s = new StringBuilder(indexDirs[0]);
|
||||
for (int i = 1; i < indexDirs.length; i++) {
|
||||
s.append(",").append(indexDirs[i]);
|
||||
}
|
||||
p = s.toString();
|
||||
}
|
||||
req.setIndexDirs(p);
|
||||
req.setIndexDirs(Arrays.asList(indexDirs));
|
||||
return req.process(server);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue