You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/03/10 16:05:21 UTC
svn commit: r1454862 [41/49] - in /lucene/dev/branches/lucene4258: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/
dev-tools/idea/.idea/libraries/ dev-tools/idea/lucene/demo/
dev-tools/idea/lucene/facet/ dev-tools/idea/lucene/highlighter/ dev-to...
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/RedirectServlet.java Sun Mar 10 15:04:57 2013
@@ -62,9 +62,4 @@ public class RedirectServlet extends Htt
res.setHeader("Location", destination);
}
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException,IOException {
- doGet(req,res);
- }
}
\ No newline at end of file
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Sun Mar 10 15:04:57 2013
@@ -17,13 +17,21 @@
package org.apache.solr.servlet;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.io.Writer;
+import java.net.HttpURLConnection;
+import java.net.URL;
import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -38,22 +46,27 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.io.IOUtils;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.Aliases;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.MapSolrParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.core.Config;
+import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.ContentStreamHandlerBase;
-import org.apache.solr.request.ServletSolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.request.SolrRequestHandler;
@@ -66,7 +79,6 @@ import org.apache.solr.servlet.cache.Met
import org.apache.solr.util.FastWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.xml.sax.InputSource;
/**
* This filter looks at the incoming URL maps them to handlers defined in solrconfig.xml
@@ -82,19 +94,9 @@ public class SolrDispatchFilter implemen
protected String pathPrefix = null; // strip this from the beginning of a path
protected String abortErrorMessage = null;
protected final Map<SolrConfig, SolrRequestParsers> parsers = new WeakHashMap<SolrConfig, SolrRequestParsers>();
- protected final SolrRequestParsers adminRequestParser;
private static final Charset UTF8 = Charset.forName("UTF-8");
- public SolrDispatchFilter() {
- try {
- adminRequestParser = new SolrRequestParsers(new Config(null,"solr",new InputSource(new ByteArrayInputStream("<root/>".getBytes("UTF-8"))),"") );
- } catch (Exception e) {
- //unlikely
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,e);
- }
- }
-
@Override
public void init(FilterConfig config) throws ServletException
{
@@ -133,9 +135,13 @@ public class SolrDispatchFilter implemen
cores = null;
}
}
-
+
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ doFilter(request, response, chain, false);
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain, boolean retry) throws IOException, ServletException {
if( abortErrorMessage != null ) {
((HttpServletResponse)response).sendError( 500, abortErrorMessage );
return;
@@ -148,12 +154,14 @@ public class SolrDispatchFilter implemen
CoreContainer cores = this.cores;
SolrCore core = null;
SolrQueryRequest solrReq = null;
+ Aliases aliases = null;
if( request instanceof HttpServletRequest) {
HttpServletRequest req = (HttpServletRequest)request;
HttpServletResponse resp = (HttpServletResponse)response;
SolrRequestHandler handler = null;
String corename = "";
+ String origCorename = null;
try {
// put the core container in request attribute
req.setAttribute("org.apache.solr.CoreContainer", cores);
@@ -180,14 +188,16 @@ public class SolrDispatchFilter implemen
// Check for the core admin page
if( path.equals( cores.getAdminPath() ) ) {
handler = cores.getMultiCoreHandler();
- solrReq = adminRequestParser.parse(null,path, req);
+ solrReq = SolrRequestParsers.DEFAULT.parse(null,path, req);
handleAdminRequest(req, response, handler, solrReq);
return;
}
+ boolean usingAliases = false;
+ List<String> collectionsList = null;
// Check for the core admin collections url
if( path.equals( "/admin/collections" ) ) {
handler = cores.getCollectionsHandler();
- solrReq = adminRequestParser.parse(null,path, req);
+ solrReq = SolrRequestParsers.DEFAULT.parse(null,path, req);
handleAdminRequest(req, response, handler, solrReq);
return;
}
@@ -197,7 +207,24 @@ public class SolrDispatchFilter implemen
if( idx > 1 ) {
// try to get the corename as a request parameter first
corename = path.substring( 1, idx );
+
+ // look at aliases
+ if (cores.isZooKeeperAware()) {
+ origCorename = corename;
+ ZkStateReader reader = cores.getZkController().getZkStateReader();
+ aliases = reader.getAliases();
+ if (aliases != null && aliases.collectionAliasSize() > 0) {
+ usingAliases = true;
+ String alias = aliases.getCollectionAlias(corename);
+ if (alias != null) {
+ collectionsList = StrUtils.splitSmart(alias, ",", true);
+ corename = collectionsList.get(0);
+ }
+ }
+ }
+
core = cores.getCore(corename);
+
if (core != null) {
path = path.substring( idx );
}
@@ -216,11 +243,30 @@ public class SolrDispatchFilter implemen
if (core != null) {
// we found a core, update the path
path = path.substring( idx );
- } else {
- // try the default core
+ }
+
+ // if we couldn't find it locally, look on other nodes
+ if (core == null && idx > 0) {
+ String coreUrl = getRemotCoreUrl(cores, corename, origCorename);
+ if (coreUrl != null) {
+ path = path.substring( idx );
+ remoteQuery(coreUrl + path, req, solrReq, resp);
+ return;
+ } else {
+ if (!retry) {
+ // we couldn't find a core to work with, try reloading aliases
+ ZkStateReader reader = cores.getZkController()
+ .getZkStateReader();
+ reader.updateAliases();
+ doFilter(request, response, chain, true);
+ }
+ }
+ }
+
+ // try the default core
+ if (core == null) {
core = cores.getCore("");
}
- // TODO: if we couldn't find it locally, look on other nodes
}
// With a valid core...
@@ -234,6 +280,20 @@ public class SolrDispatchFilter implemen
parsers.put(config, parser );
}
+ // Handle /schema/* paths via Restlet
+ if( path.startsWith("/schema") ) {
+ solrReq = parser.parse(core, path, req);
+ SolrRequestInfo.setRequestInfo(new SolrRequestInfo(solrReq, new SolrQueryResponse()));
+ if( path.equals(req.getServletPath()) ) {
+ // avoid endless loop - pass through to Restlet via webapp
+ chain.doFilter(request, response);
+ } else {
+ // forward rewritten URI (without path prefix and core/collection name) to Restlet
+ req.getRequestDispatcher(path).forward(request, response);
+ }
+ return;
+ }
+
// Determine the handler from the url path if not set
// (we might already have selected the cores handler)
if( handler == null && path.length() > 1 ) { // don't match "" or "/" as valid path
@@ -263,6 +323,10 @@ public class SolrDispatchFilter implemen
solrReq = parser.parse( core, path, req );
}
+ if (usingAliases) {
+ processAliases(solrReq, aliases, collectionsList);
+ }
+
final Method reqMethod = Method.getMethod(req.getMethod());
HttpCacheHeaderUtil.setCacheControlHeader(config, resp, reqMethod);
// unless we have been explicitly told not to, do cache validation
@@ -315,6 +379,161 @@ public class SolrDispatchFilter implemen
chain.doFilter(request, response);
}
+ private void processAliases(SolrQueryRequest solrReq, Aliases aliases,
+ List<String> collectionsList) {
+ String collection = solrReq.getParams().get("collection");
+ if (collection != null) {
+ collectionsList = StrUtils.splitSmart(collection, ",", true);
+ }
+ if (collectionsList != null) {
+ Set<String> newCollectionsList = new HashSet<String>(
+ collectionsList.size());
+ for (String col : collectionsList) {
+ String al = aliases.getCollectionAlias(col);
+ if (al != null) {
+ List<String> aliasList = StrUtils.splitSmart(al, ",", true);
+ newCollectionsList.addAll(aliasList);
+ } else {
+ newCollectionsList.add(col);
+ }
+ }
+ if (newCollectionsList.size() > 0) {
+ StringBuilder collectionString = new StringBuilder();
+ Iterator<String> it = newCollectionsList.iterator();
+ int sz = newCollectionsList.size();
+ for (int i = 0; i < sz; i++) {
+ collectionString.append(it.next());
+ if (i < newCollectionsList.size() - 1) {
+ collectionString.append(",");
+ }
+ }
+ ModifiableSolrParams params = new ModifiableSolrParams(
+ solrReq.getParams());
+ params.set("collection", collectionString.toString());
+ solrReq.setParams(params);
+ }
+ }
+ }
+
+ private void remoteQuery(String coreUrl, HttpServletRequest req,
+ SolrQueryRequest solrReq, HttpServletResponse resp) throws IOException {
+ try {
+ String urlstr = coreUrl;
+
+ String queryString = req.getQueryString();
+
+ urlstr += queryString == null ? "" : "?" + queryString;
+
+ URL url = new URL(urlstr);
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setRequestMethod(req.getMethod());
+ con.setUseCaches(false);
+
+ con.setDoOutput(true);
+ con.setDoInput(true);
+ for (Enumeration e = req.getHeaderNames(); e.hasMoreElements();) {
+ String headerName = e.nextElement().toString();
+ con.setRequestProperty(headerName, req.getHeader(headerName));
+ }
+ try {
+ con.connect();
+
+ InputStream is;
+ OutputStream os;
+ if ("POST".equals(req.getMethod())) {
+ is = req.getInputStream();
+ os = con.getOutputStream(); // side effect: method is switched to POST
+ try {
+ IOUtils.copyLarge(is, os);
+ } finally {
+ IOUtils.closeQuietly(os);
+ IOUtils.closeQuietly(is); // TODO: I thought we weren't supposed to explicitly close servlet streams
+ }
+ }
+
+ resp.setStatus(con.getResponseCode());
+
+ for (Iterator i = con.getHeaderFields().entrySet().iterator(); i
+ .hasNext();) {
+ Map.Entry mapEntry = (Map.Entry) i.next();
+ if (mapEntry.getKey() != null) resp.setHeader(mapEntry.getKey()
+ .toString(), ((List) mapEntry.getValue()).get(0).toString());
+ }
+
+ resp.setCharacterEncoding(con.getContentEncoding());
+ resp.setContentType(con.getContentType());
+
+ is = con.getInputStream();
+ os = resp.getOutputStream();
+ try {
+ IOUtils.copyLarge(is, os);
+ } finally {
+ IOUtils.closeQuietly(os); // TODO: I thought we weren't supposed to explicitly close servlet streams
+ IOUtils.closeQuietly(is);
+ }
+ } finally {
+ con.disconnect();
+ }
+ } catch (IOException e) {
+ sendError(null, solrReq, req, resp, new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "Error trying to proxy request for url: " + coreUrl, e));
+ }
+
+ }
+
+ private String getRemotCoreUrl(CoreContainer cores, String collectionName, String origCorename) {
+ ClusterState clusterState = cores.getZkController().getClusterState();
+ Collection<Slice> slices = clusterState.getSlices(collectionName);
+ boolean byCoreName = false;
+ if (slices == null) {
+ // look by core name
+ byCoreName = true;
+ Set<String> collections = clusterState.getCollections();
+ for (String collection : collections) {
+ slices = new ArrayList<Slice>();
+ slices.addAll(clusterState.getSlices(collection));
+ }
+ }
+
+ if (slices == null || slices.size() == 0) {
+ return null;
+ }
+
+ Set<String> liveNodes = clusterState.getLiveNodes();
+ Iterator<Slice> it = slices.iterator();
+ while (it.hasNext()) {
+ Slice slice = it.next();
+ Map<String,Replica> sliceShards = slice.getReplicasMap();
+ for (ZkNodeProps nodeProps : sliceShards.values()) {
+ ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps);
+ if (liveNodes.contains(coreNodeProps.getNodeName())
+ && coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) {
+ if (byCoreName && !collectionName.equals(coreNodeProps.getCoreName())) {
+ // if it's by core name, make sure they match
+ continue;
+ }
+ if (coreNodeProps.getBaseUrl().equals(cores.getZkController().getBaseUrl())) {
+ // don't count a local core
+ continue;
+ }
+ String coreUrl;
+ if (origCorename != null) {
+ coreUrl = coreNodeProps.getBaseUrl() + "/" + origCorename;
+ } else {
+ coreUrl = coreNodeProps.getCoreUrl();
+ if (coreUrl.endsWith("/")) {
+ coreUrl = coreUrl.substring(0, coreUrl.length() - 1);
+ }
+ }
+
+ return coreUrl;
+ }
+ }
+ }
+ return null;
+ }
+
private SolrCore getCoreByCollection(CoreContainer cores, String corename, String path) {
String collection = corename;
ZkStateReader zkStateReader = cores.getZkController().getZkStateReader();
@@ -366,19 +585,11 @@ public class SolrDispatchFilter implemen
private void handleAdminRequest(HttpServletRequest req, ServletResponse response, SolrRequestHandler handler,
SolrQueryRequest solrReq) throws IOException {
SolrQueryResponse solrResp = new SolrQueryResponse();
- final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
- solrResp.add("responseHeader", responseHeader);
- NamedList toLog = solrResp.getToLog();
- toLog.add("webapp", req.getContextPath());
- toLog.add("path", solrReq.getContext().get("path"));
- toLog.add("params", "{" + solrReq.getParamString() + "}");
+ SolrCore.preDecorateResponse(solrReq, solrResp);
handler.handleRequest(solrReq, solrResp);
- SolrCore.setResponseHeaderValues(handler, solrReq, solrResp);
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < toLog.size(); i++) {
- String name = toLog.getName(i);
- Object val = toLog.getVal(i);
- sb.append(name).append("=").append(val).append(" ");
+ SolrCore.postDecorateResponse(handler, solrReq, solrResp);
+ if (log.isInfoEnabled() && solrResp.getToLog().size() > 0) {
+ log.info(solrResp.getToLogAsString("[admin] "));
}
QueryResponseWriter respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get(solrReq.getParams().get(CommonParams.WT));
if (respWriter == null) respWriter = SolrCore.DEFAULT_RESPONSE_WRITERS.get("standard");
@@ -396,7 +607,7 @@ public class SolrDispatchFilter implemen
if (solrRsp.getException() != null) {
NamedList info = new SimpleOrderedMap();
- int code = getErrorInfo(solrRsp.getException(),info);
+ int code = ResponseUtils.getErrorInfo(solrRsp.getException(), info, log);
solrRsp.add("error", info);
((HttpServletResponse) response).setStatus(code);
}
@@ -418,38 +629,6 @@ public class SolrDispatchFilter implemen
//else http HEAD request, nothing to write out, waited this long just to get ContentType
}
- protected int getErrorInfo(Throwable ex, NamedList info) {
- int code=500;
- if( ex instanceof SolrException ) {
- code = ((SolrException)ex).code();
- }
-
- String msg = null;
- for (Throwable th = ex; th != null; th = th.getCause()) {
- msg = th.getMessage();
- if (msg != null) break;
- }
- if(msg != null) {
- info.add("msg", msg);
- }
-
- // For any regular code, don't include the stack trace
- if( code == 500 || code < 100 ) {
- StringWriter sw = new StringWriter();
- ex.printStackTrace(new PrintWriter(sw));
- SolrException.log(log, null, ex);
- info.add("trace", sw.toString());
-
- // non standard codes have undefined results with various servers
- if( code < 100 ) {
- log.warn( "invalid return code: "+code );
- code = 500;
- }
- }
- info.add("code", new Integer(code));
- return code;
- }
-
protected void execute( HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) {
// a custom filter could add more stuff to the request before passing it on.
// for example: sreq.getContext().put( "HttpServletRequest", req );
@@ -475,14 +654,22 @@ public class SolrDispatchFilter implemen
core = cores.getCore(""); // default core
}
if(req==null) {
- req = new SolrQueryRequestBase(core,new ServletSolrParams(request)) {};
+ final SolrParams solrParams;
+ if (request instanceof HttpServletRequest) {
+ // use GET parameters if available:
+ solrParams = SolrRequestParsers.parseQueryString(((HttpServletRequest) request).getQueryString());
+ } else {
+ // we have no params at all, use empty ones:
+ solrParams = new MapSolrParams(Collections.<String,String>emptyMap());
+ }
+ req = new SolrQueryRequestBase(core, solrParams) {};
}
QueryResponseWriter writer = core.getQueryResponseWriter(req);
writeResponse(solrResp, response, writer, req, Method.GET);
}
catch( Throwable t ) { // This error really does not matter
SimpleOrderedMap info = new SimpleOrderedMap();
- int code=getErrorInfo(ex, info);
+ int code = ResponseUtils.getErrorInfo(ex, info, log);
response.sendError( code, info.toString() );
}
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java Sun Mar 10 15:04:57 2013
@@ -20,9 +20,13 @@ package org.apache.solr.servlet;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CodingErrorAction;
import java.net.URL;
-import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -38,15 +42,16 @@ import javax.servlet.http.HttpServletReq
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.lucene.util.IOUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.common.util.FastInputStream;
import org.apache.solr.core.Config;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.request.ServletSolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase;
@@ -57,47 +62,63 @@ public class SolrRequestParsers
// Should these constants be in a more public place?
public static final String MULTIPART = "multipart";
+ public static final String FORMDATA = "formdata";
public static final String RAW = "raw";
public static final String SIMPLE = "simple";
public static final String STANDARD = "standard";
- private HashMap<String, SolrRequestParser> parsers;
- private boolean enableRemoteStreams = false;
- private boolean handleSelect = true;
+ private final HashMap<String, SolrRequestParser> parsers =
+ new HashMap<String, SolrRequestParser>();
+ private final boolean enableRemoteStreams;
private StandardRequestParser standard;
+ private boolean handleSelect = true;
+
+ /** Default instance for e.g. admin requests. Limits to 2 MB uploads and does not allow remote streams. */
+ public static final SolrRequestParsers DEFAULT = new SolrRequestParsers();
/**
* Pass in an xml configuration. A null configuration will enable
- * everythign with maximum values.
+ * everything with maximum values.
*/
- public SolrRequestParsers( Config globalConfig )
- {
- long uploadLimitKB = 1048; // 2MB default
+ public SolrRequestParsers( Config globalConfig ) {
+ final int multipartUploadLimitKB, formUploadLimitKB;
if( globalConfig == null ) {
- uploadLimitKB = Long.MAX_VALUE;
+ multipartUploadLimitKB = formUploadLimitKB = Integer.MAX_VALUE;
enableRemoteStreams = true;
handleSelect = true;
- }
- else {
- uploadLimitKB = globalConfig.getInt(
- "requestDispatcher/requestParsers/@multipartUploadLimitInKB", (int)uploadLimitKB );
+ } else {
+ multipartUploadLimitKB = globalConfig.getInt(
+ "requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2048 );
+
+ formUploadLimitKB = globalConfig.getInt(
+ "requestDispatcher/requestParsers/@formdataUploadLimitInKB", 2048 );
enableRemoteStreams = globalConfig.getBool(
"requestDispatcher/requestParsers/@enableRemoteStreaming", false );
// Let this filter take care of /select?xxx format
handleSelect = globalConfig.getBool(
- "requestDispatcher/@handleSelect", handleSelect );
+ "requestDispatcher/@handleSelect", true );
}
-
- MultipartRequestParser multi = new MultipartRequestParser( uploadLimitKB );
+ init(multipartUploadLimitKB, formUploadLimitKB);
+ }
+
+ private SolrRequestParsers() {
+ enableRemoteStreams = false;
+ handleSelect = false;
+ init(2048, 2048);
+ }
+
+ private void init( int multipartUploadLimitKB, int formUploadLimitKB) {
+ MultipartRequestParser multi = new MultipartRequestParser( multipartUploadLimitKB );
RawRequestParser raw = new RawRequestParser();
- standard = new StandardRequestParser( multi, raw );
+ FormDataRequestParser formdata = new FormDataRequestParser( formUploadLimitKB );
+ standard = new StandardRequestParser( multi, raw, formdata );
// I don't see a need to have this publicly configured just yet
// adding it is trivial
- parsers = new HashMap<String, SolrRequestParser>();
parsers.put( MULTIPART, multi );
+ parsers.put( FORMDATA, formdata );
parsers.put( RAW, raw );
parsers.put( SIMPLE, new SimpleRequestParser() );
parsers.put( STANDARD, standard );
@@ -175,35 +196,145 @@ public class SolrRequestParsers
return q;
}
-
/**
- * Given a standard query string map it into solr params
+ * Given a url-encoded query string (UTF-8), map it into solr params
*/
- public static MultiMapSolrParams parseQueryString(String queryString)
- {
+ public static MultiMapSolrParams parseQueryString(String queryString) {
Map<String,String[]> map = new HashMap<String, String[]>();
- if( queryString != null && queryString.length() > 0 ) {
+ parseQueryString(queryString, map);
+ return new MultiMapSolrParams(map);
+ }
+
+ /**
+ * Given a url-encoded query string (UTF-8), map it into the given map
+ * @param queryString as given from URL
+ * @param map place all parameters in this map
+ */
+ static void parseQueryString(final String queryString, final Map<String,String[]> map) {
+ if (queryString != null && queryString.length() > 0) {
try {
- for( String kv : queryString.split( "&" ) ) {
- int idx = kv.indexOf( '=' );
- if( idx > 0 ) {
- String name = URLDecoder.decode( kv.substring( 0, idx ), "UTF-8");
- String value = URLDecoder.decode( kv.substring( idx+1 ), "UTF-8");
- MultiMapSolrParams.addParam( name, value, map );
+ final int len = queryString.length();
+ // this input stream emulates to get the raw bytes from the URL as passed to servlet container, it disallows any byte > 127 and enforces to %-escape them:
+ final InputStream in = new InputStream() {
+ int pos = 0;
+ @Override
+ public int read() {
+ if (pos < len) {
+ final char ch = queryString.charAt(pos);
+ if (ch > 127) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: The query string contains a not-%-escaped byte > 127 at position " + pos);
+ }
+ pos++;
+ return ch;
+ } else {
+ return -1;
+ }
+ }
+ };
+ parseFormDataContent(in, Long.MAX_VALUE, IOUtils.CHARSET_UTF_8, map);
+ } catch (IOException ioe) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ioe);
+ }
+ }
+ }
+
+ /**
+ * Given a url-encoded form from POST content (as InputStream), map it into the given map.
+ * The given InputStream should be buffered!
+ * @param postContent to be parsed
+ * @param charset to be used to decode resulting bytes after %-decoding
+ * @param map place all parameters in this map
+ */
+ @SuppressWarnings("fallthrough")
+ static long parseFormDataContent(final InputStream postContent, final long maxLen, final Charset charset, final Map<String,String[]> map) throws IOException {
+ final CharsetDecoder charsetDecoder = charset.newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT)
+ .onUnmappableCharacter(CodingErrorAction.REPORT);
+ long len = 0L, keyPos = 0L, valuePos = 0L;
+ final ByteArrayOutputStream2 keyStream = new ByteArrayOutputStream2(),
+ valueStream = new ByteArrayOutputStream2();
+ ByteArrayOutputStream2 currentStream = keyStream;
+ for(;;) {
+ int b = postContent.read();
+ switch (b) {
+ case -1: // end of stream
+ case '&': // separator
+ if (keyStream.size() > 0) {
+ final String key = decodeChars(keyStream, keyPos, charsetDecoder), value = decodeChars(valueStream, valuePos, charsetDecoder);
+ MultiMapSolrParams.addParam(key, value, map);
+ } else if (valueStream.size() > 0) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded invalid: missing key");
}
- else {
- String name = URLDecoder.decode( kv, "UTF-8" );
- MultiMapSolrParams.addParam( name, "", map );
+ keyStream.reset();
+ valueStream.reset();
+ keyPos = valuePos = len + 1;
+ currentStream = keyStream;
+ break;
+ case '+': // space replacement
+ currentStream.write(' ');
+ break;
+ case '%': // escape
+ final int upper = digit16(b = postContent.read());
+ len++;
+ final int lower = digit16(b = postContent.read());
+ len++;
+ currentStream.write(((upper << 4) + lower));
+ break;
+ case '=': // kv separator
+ if (currentStream == keyStream) {
+ valuePos = len + 1;
+ currentStream = valueStream;
+ break;
}
- }
+ // fall-through
+ default:
+ currentStream.write(b);
}
- catch( UnsupportedEncodingException uex ) {
- throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, uex );
+ if (b == -1) {
+ break;
+ }
+ len++;
+ if (len > maxLen) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content exceeds upload limit of " + (maxLen/1024L) + " KB");
}
}
- return new MultiMapSolrParams( map );
+ return len;
}
-
+
+ private static String decodeChars(ByteArrayOutputStream2 stream, long position, CharsetDecoder charsetDecoder) {
+ try {
+ return charsetDecoder.decode(ByteBuffer.wrap(stream.buffer(), 0, stream.size())).toString();
+ } catch (CharacterCodingException cce) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+ "URLDecoder: Invalid character encoding detected after position " + position +
+ " of query string / form data (while parsing as " + charsetDecoder.charset().name() + ")"
+ );
+ }
+ }
+
+ /** Makes the buffer of ByteArrayOutputStream available without copy. */
+ static final class ByteArrayOutputStream2 extends ByteArrayOutputStream {
+ byte[] buffer() {
+ return buf;
+ }
+ }
+
+ private static int digit16(int b) {
+ if (b == -1) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: Incomplete trailing escape (%) pattern");
+ }
+ if (b >= '0' && b <= '9') {
+ return b - '0';
+ }
+ if (b >= 'A' && b <= 'F') {
+ return b - ('A' - 10);
+ }
+ if (b >= 'a' && b <= 'f') {
+ return b - ('a' - 10);
+ }
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "URLDecoder: Invalid digit (" + ((char) b) + ") in escape (%) pattern");
+ }
+
public boolean isHandleSelect() {
return handleSelect;
}
@@ -228,7 +359,7 @@ interface SolrRequestParser
//-----------------------------------------------------------------
/**
- * The simple parser just uses the params directly
+ * The simple parser just uses the params directly, does not support POST URL-encoded forms
*/
class SimpleRequestParser implements SolrRequestParser
{
@@ -236,7 +367,7 @@ class SimpleRequestParser implements Sol
public SolrParams parseParamsAndFillStreams(
final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
{
- return new ServletSolrParams(req);
+ return SolrRequestParsers.parseQueryString(req.getQueryString());
}
}
@@ -298,13 +429,6 @@ class RawRequestParser implements SolrRe
public SolrParams parseParamsAndFillStreams(
final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
{
- // The javadocs for HttpServletRequest are clear that req.getReader() should take
- // care of any character encoding issues. BUT, there are problems while running on
- // some servlet containers: including Tomcat 5 and resin.
- //
- // Rather than return req.getReader(), this uses the default ContentStreamBase method
- // that checks for charset definitions in the ContentType.
-
streams.add( new HttpRequestContentStream( req ) );
return SolrRequestParsers.parseQueryString( req.getQueryString() );
}
@@ -317,9 +441,9 @@ class RawRequestParser implements SolrRe
*/
class MultipartRequestParser implements SolrRequestParser
{
- private long uploadLimitKB;
+ private final int uploadLimitKB;
- public MultipartRequestParser( long limit )
+ public MultipartRequestParser( int limit )
{
uploadLimitKB = limit;
}
@@ -343,7 +467,7 @@ class MultipartRequestParser implements
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
- upload.setSizeMax( uploadLimitKB*1024 );
+ upload.setSizeMax( ((long) uploadLimitKB) * 1024L );
// Parse the request
List items = upload.parseRequest(req);
@@ -368,17 +492,102 @@ class MultipartRequestParser implements
/**
+ * Extract application/x-www-form-urlencoded form data for POST requests
+ */
+class FormDataRequestParser implements SolrRequestParser
+{
+ private final int uploadLimitKB;
+
+ public FormDataRequestParser( int limit )
+ {
+ uploadLimitKB = limit;
+ }
+
+ @Override
+ public SolrParams parseParamsAndFillStreams(
+ final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
+ {
+ if (!isFormData(req)) {
+ throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Not application/x-www-form-urlencoded content: "+req.getContentType() );
+ }
+
+ final Map<String,String[]> map = new HashMap<String, String[]>();
+
+ // also add possible URL parameters and include into the map (parsed using UTF-8):
+ final String qs = req.getQueryString();
+ if (qs != null) {
+ SolrRequestParsers.parseQueryString(qs, map);
+ }
+
+ // may be -1, so we check again later. But if its already greater we can stop processing!
+ final long totalLength = req.getContentLength();
+ final long maxLength = ((long) uploadLimitKB) * 1024L;
+ if (totalLength > maxLength) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "application/x-www-form-urlencoded content length (" +
+ totalLength + " bytes) exceeds upload limit of " + uploadLimitKB + " KB");
+ }
+
+ // get query String from request body, using the charset given in content-type:
+ final String cs = ContentStreamBase.getCharsetFromContentType(req.getContentType());
+ final Charset charset = (cs == null) ? IOUtils.CHARSET_UTF_8 : Charset.forName(cs);
+ InputStream in = null;
+ try {
+ in = req.getInputStream();
+ final long bytesRead = SolrRequestParsers.parseFormDataContent(FastInputStream.wrap(in), maxLength, charset, map);
+ if (bytesRead == 0L && totalLength > 0L) {
+ throw getParameterIncompatibilityException();
+ }
+ } catch (IOException ioe) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, ioe);
+ } catch (IllegalStateException ise) {
+ throw (SolrException) getParameterIncompatibilityException().initCause(ise);
+ } finally {
+ IOUtils.closeWhileHandlingException(in);
+ }
+
+ return new MultiMapSolrParams(map);
+ }
+
+ private SolrException getParameterIncompatibilityException() {
+ return new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ "Solr requires that request parameters sent using application/x-www-form-urlencoded " +
+ "content-type can be read through the request input stream. Unfortunately, the " +
+ "stream was empty / not available. This may be caused by another servlet filter calling " +
+ "ServletRequest.getParameter*() before SolrDispatchFilter, please remove it."
+ );
+ }
+
+ public boolean isFormData(HttpServletRequest req) {
+ String contentType = req.getContentType();
+ if (contentType != null) {
+ int idx = contentType.indexOf( ';' );
+ if( idx > 0 ) { // remove the charset definition "; charset=utf-8"
+ contentType = contentType.substring( 0, idx );
+ }
+ contentType = contentType.trim();
+ if( "application/x-www-form-urlencoded".equalsIgnoreCase(contentType)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
+
+/**
* The default Logic
*/
class StandardRequestParser implements SolrRequestParser
{
MultipartRequestParser multipart;
RawRequestParser raw;
+ FormDataRequestParser formdata;
- StandardRequestParser( MultipartRequestParser multi, RawRequestParser raw )
+ StandardRequestParser(MultipartRequestParser multi, RawRequestParser raw, FormDataRequestParser formdata)
{
this.multipart = multi;
this.raw = raw;
+ this.formdata = formdata;
}
@Override
@@ -386,22 +595,15 @@ class StandardRequestParser implements S
final HttpServletRequest req, ArrayList<ContentStream> streams ) throws Exception
{
String method = req.getMethod().toUpperCase(Locale.ROOT);
- if( "GET".equals( method ) || "HEAD".equals( method )) {
- return new ServletSolrParams(req);
+ if ("GET".equals(method) || "HEAD".equals(method)) {
+ return SolrRequestParsers.parseQueryString(req.getQueryString());
}
- if( "POST".equals( method ) ) {
- String contentType = req.getContentType();
- if( contentType != null ) {
- int idx = contentType.indexOf( ';' );
- if( idx > 0 ) { // remove the charset definition "; charset=utf-8"
- contentType = contentType.substring( 0, idx );
- }
- if( "application/x-www-form-urlencoded".equals( contentType.toLowerCase(Locale.ROOT) ) ) {
- return new ServletSolrParams(req); // just get the params from parameterMap
- }
- if( ServletFileUpload.isMultipartContent(req) ) {
- return multipart.parseParamsAndFillStreams(req, streams);
- }
+ if ("POST".equals( method ) ) {
+ if (formdata.isFormData(req)) {
+ return formdata.parseParamsAndFillStreams(req, streams);
+ }
+ if (ServletFileUpload.isMultipartContent(req)) {
+ return multipart.parseParamsAndFillStreams(req, streams);
}
return raw.parseParamsAndFillStreams(req, streams);
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java Sun Mar 10 15:04:57 2013
@@ -18,21 +18,28 @@
package org.apache.solr.servlet;
import java.io.IOException;
-import java.io.PrintWriter;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.IOUtils;
import org.apache.noggit.CharArr;
import org.apache.noggit.JSONWriter;
import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.util.FastWriter;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
@@ -46,7 +53,7 @@ import org.slf4j.LoggerFactory;
*/
public final class ZookeeperInfoServlet extends HttpServlet {
static final Logger log = LoggerFactory.getLogger(ZookeeperInfoServlet.class);
-
+
@Override
public void init() {
}
@@ -54,28 +61,42 @@ public final class ZookeeperInfoServlet
@Override
public void doGet(HttpServletRequest request,
HttpServletResponse response)
- throws IOException {
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application/json");
-
+ throws ServletException,IOException {
// This attribute is set by the SolrDispatchFilter
CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
+ if (cores == null) {
+ throw new ServletException("Missing request attribute org.apache.solr.CoreContainer.");
+ }
+
+ final SolrParams params;
+ try {
+ params = SolrRequestParsers.DEFAULT.parse(null, request.getServletPath(), request).getParams();
+ } catch (Exception e) {
+ int code=500;
+ if (e instanceof SolrException) {
+ code = Math.min(599, Math.max(100, ((SolrException)e).code()));
+ }
+ response.sendError(code, e.toString());
+ return;
+ }
- String path = request.getParameter("path");
- String addr = request.getParameter("addr");
+ String path = params.get("path");
+ String addr = params.get("addr");
if (addr != null && addr.length() == 0) {
addr = null;
}
- String detailS = request.getParameter("detail");
+ String detailS = params.get("detail");
boolean detail = detailS != null && detailS.equals("true");
- String dumpS = request.getParameter("dump");
+ String dumpS = params.get("dump");
boolean dump = dumpS != null && dumpS.equals("true");
- PrintWriter out = response.getWriter();
+ response.setCharacterEncoding("UTF-8");
+ response.setContentType("application/json");
+ Writer out = new FastWriter(new OutputStreamWriter(response.getOutputStream(), IOUtils.CHARSET_UTF_8));
ZKPrinter printer = new ZKPrinter(response, out, cores.getZkController(), addr);
printer.detail = detail;
@@ -86,12 +107,14 @@ public final class ZookeeperInfoServlet
} finally {
printer.close();
}
+
+ out.flush();
}
@Override
public void doPost(HttpServletRequest request,
HttpServletResponse response)
- throws IOException {
+ throws ServletException,IOException {
doGet(request, response);
}
@@ -114,13 +137,13 @@ public final class ZookeeperInfoServlet
boolean doClose; // close the client after done if we opened it
final HttpServletResponse response;
- final PrintWriter out;
+ final Writer out;
SolrZkClient zkClient;
int level;
int maxData = 95;
- public ZKPrinter(HttpServletResponse response, PrintWriter out, ZkController controller, String addr) throws IOException {
+ public ZKPrinter(HttpServletResponse response, Writer out, ZkController controller, String addr) throws IOException {
this.response = response;
this.out = out;
this.addr = addr;
@@ -207,10 +230,10 @@ public final class ZookeeperInfoServlet
}
json.endArray();
json.endObject();
- out.println(chars.toString());
+ out.write(chars.toString());
}
- void writeError(int code, String msg) {
+ void writeError(int code, String msg) throws IOException {
response.setStatus(code);
CharArr chars = new CharArr();
@@ -227,7 +250,7 @@ public final class ZookeeperInfoServlet
w.writeString(msg);
w.endObject();
- out.println(chars.toString());
+ out.write(chars.toString());
}
@@ -352,7 +375,7 @@ public final class ZookeeperInfoServlet
json.write(v);
}
- boolean printZnode(JSONWriter json, String path) {
+ boolean printZnode(JSONWriter json, String path) throws IOException {
try {
Stat stat = new Stat();
// Trickily, the call to zkClient.getData fills in the stat variable
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/CommitUpdateCommand.java Sun Mar 10 15:04:57 2013
@@ -54,6 +54,7 @@ public class CommitUpdateCommand extends
+",waitSearcher="+waitSearcher
+",expungeDeletes="+expungeDeletes
+",softCommit="+softCommit
+ +",prepareCommit="+prepareCommit
+'}';
}
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java Sun Mar 10 15:04:57 2013
@@ -18,12 +18,15 @@ package org.apache.solr.update;
*/
import java.io.IOException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.solr.cloud.RecoveryStrategy;
import org.apache.solr.common.SolrException;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.RefCounted;
@@ -52,11 +55,13 @@ public final class DefaultSolrCoreState
private boolean pauseWriter;
private boolean writerFree = true;
+ protected final ReentrantLock commitLock = new ReentrantLock();
+
public DefaultSolrCoreState(DirectoryFactory directoryFactory) {
this.directoryFactory = directoryFactory;
}
- private synchronized void closeIndexWriter(IndexWriterCloser closer) {
+ private void closeIndexWriter(IndexWriterCloser closer) {
try {
log.info("SolrCoreState ref count has reached 0 - closing IndexWriter");
if (closer != null) {
@@ -72,7 +77,7 @@ public final class DefaultSolrCoreState
}
@Override
- public synchronized RefCounted<IndexWriter> getIndexWriter(SolrCore core)
+ public RefCounted<IndexWriter> getIndexWriter(SolrCore core)
throws IOException {
if (closed) {
@@ -135,6 +140,7 @@ public final class DefaultSolrCoreState
pauseWriter = true;
// then lets wait until its out of use
log.info("Waiting until IndexWriter is unused... core=" + coreName);
+
while (!writerFree) {
try {
writerPauseLock.wait(100);
@@ -194,7 +200,7 @@ public final class DefaultSolrCoreState
}
@Override
- public void doRecovery(CoreContainer cc, String name) {
+ public void doRecovery(CoreContainer cc, CoreDescriptor cd) {
if (SKIP_AUTO_RECOVERY) {
log.warn("Skipping recovery according to sys prop solrcloud.skip.autorecovery");
return;
@@ -226,7 +232,7 @@ public final class DefaultSolrCoreState
// if true, we are recovering after startup and shouldn't have (or be receiving) additional updates (except for local tlog recovery)
boolean recoveringAfterStartup = recoveryStrat == null;
- recoveryStrat = new RecoveryStrategy(cc, name, this);
+ recoveryStrat = new RecoveryStrategy(cc, cd, this);
recoveryStrat.setRecoveringAfterStartup(recoveringAfterStartup);
recoveryStrat.start();
recoveryRunning = true;
@@ -272,4 +278,9 @@ public final class DefaultSolrCoreState
closeIndexWriter(closer);
}
+ @Override
+ public Lock getCommitLock() {
+ return commitLock;
+ }
+
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java Sun Mar 10 15:04:57 2013
@@ -29,8 +29,6 @@ import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
@@ -70,7 +68,6 @@ import org.apache.solr.util.RefCounted;
*/
public class DirectUpdateHandler2 extends UpdateHandler implements SolrCoreState.IndexWriterCloser {
protected final SolrCoreState solrCoreState;
- protected final Lock commitLock = new ReentrantLock();
// stats
AtomicLong addCommands = new AtomicLong();
@@ -91,6 +88,8 @@ public class DirectUpdateHandler2 extend
// tracks when auto-commit should occur
protected final CommitTracker commitTracker;
protected final CommitTracker softCommitTracker;
+
+ protected boolean commitWithinSoftCommit;
public DirectUpdateHandler2(SolrCore core) {
super(core);
@@ -106,6 +105,8 @@ public class DirectUpdateHandler2 extend
int softCommitDocsUpperBound = updateHandlerInfo.autoSoftCommmitMaxDocs; // getInt("updateHandler/autoSoftCommit/maxDocs", -1);
int softCommitTimeUpperBound = updateHandlerInfo.autoSoftCommmitMaxTime; // getInt("updateHandler/autoSoftCommit/maxTime", -1);
softCommitTracker = new CommitTracker("Soft", core, softCommitDocsUpperBound, softCommitTimeUpperBound, true, true);
+
+ commitWithinSoftCommit = updateHandlerInfo.commitWithinSoftCommit;
}
public DirectUpdateHandler2(SolrCore core, UpdateHandler updateHandler) {
@@ -126,6 +127,8 @@ public class DirectUpdateHandler2 extend
if (this.ulog != null) {
this.ulog.init(this, core);
}
+
+ commitWithinSoftCommit = updateHandlerInfo.commitWithinSoftCommit;
}
private void deleteAll() throws IOException {
@@ -229,8 +232,13 @@ public class DirectUpdateHandler2 extend
}
if ((cmd.getFlags() & UpdateCommand.IGNORE_AUTOCOMMIT) == 0) {
- commitTracker.addedDocument(-1);
- softCommitTracker.addedDocument(cmd.commitWithin);
+ if (commitWithinSoftCommit) {
+ commitTracker.addedDocument(-1);
+ softCommitTracker.addedDocument(cmd.commitWithin);
+ } else {
+ softCommitTracker.addedDocument(-1);
+ commitTracker.addedDocument(cmd.commitWithin);
+ }
}
rc = 1;
@@ -252,7 +260,11 @@ public class DirectUpdateHandler2 extend
private void updateDeleteTrackers(DeleteUpdateCommand cmd) {
if ((cmd.getFlags() & UpdateCommand.IGNORE_AUTOCOMMIT) == 0) {
- softCommitTracker.deletedDocument(cmd.commitWithin);
+ if (commitWithinSoftCommit) {
+ softCommitTracker.deletedDocument(cmd.commitWithin);
+ } else {
+ commitTracker.deletedDocument(cmd.commitWithin);
+ }
if (commitTracker.getTimeUpperBound() > 0) {
commitTracker.scheduleCommitWithin(commitTracker.getTimeUpperBound());
@@ -487,7 +499,7 @@ public class DirectUpdateHandler2 extend
try {
// only allow one hard commit to proceed at once
if (!cmd.softCommit) {
- commitLock.lock();
+ solrCoreState.getCommitLock().lock();
}
log.info("start "+cmd);
@@ -581,7 +593,7 @@ public class DirectUpdateHandler2 extend
}
finally {
if (!cmd.softCommit) {
- commitLock.unlock();
+ solrCoreState.getCommitLock().unlock();
}
addCommands.set(0);
@@ -665,7 +677,7 @@ public class DirectUpdateHandler2 extend
@Override
public void closeWriter(IndexWriter writer) throws IOException {
boolean clearRequestInfo = false;
- commitLock.lock();
+ solrCoreState.getCommitLock().lock();
try {
SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
SolrQueryResponse rsp = new SolrQueryResponse();
@@ -730,7 +742,7 @@ public class DirectUpdateHandler2 extend
if (writer != null) writer.close();
} finally {
- commitLock.unlock();
+ solrCoreState.getCommitLock().unlock();
if (clearRequestInfo) SolrRequestInfo.clearRequestInfo();
}
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java Sun Mar 10 15:04:57 2013
@@ -23,10 +23,7 @@ import java.util.List;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
-import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.SolrInputField;
@@ -58,33 +55,19 @@ public class DocumentBuilder {
// we don't check for a null val ourselves because a solr.FieldType
// might actually want to map it to something. If createField()
// returns null, then we don't store the field.
- if (sfield.isPolyField()) {
- StorableField[] fields = sfield.createFields(val, boost);
- if (fields.length > 0) {
- if (!sfield.multiValued()) {
- String oldValue = map.put(sfield.getName(), val);
- if (oldValue != null) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "ERROR: multiple values encountered for non multiValued field " + sfield.getName()
- + ": first='" + oldValue + "' second='" + val + "'");
- }
- }
- // Add each field
- for (StorableField field : fields) {
- doc.add((Field) field);
+ List<StorableField> fields = sfield.createFields(val, boost);
+ if (!fields.isEmpty()) {
+ if (!sfield.multiValued()) {
+ String oldValue = map.put(sfield.getName(), val);
+ if (oldValue != null) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "ERROR: multiple values encountered for non multiValued field " + sfield.getName()
+ + ": first='" + oldValue + "' second='" + val + "'");
}
}
- } else {
- StorableField field = sfield.createField(val, boost);
- if (field != null) {
- if (!sfield.multiValued()) {
- String oldValue = map.put(sfield.getName(), val);
- if (oldValue != null) {
- throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"ERROR: multiple values encountered for non multiValued field " + sfield.getName()
- + ": first='" + oldValue + "' second='" + val + "'");
- }
- }
+ // Add each field
+ for (StorableField field : fields) {
+ doc.add((Field) field);
}
- doc.add((Field) field);
}
}
@@ -192,14 +175,8 @@ public class DocumentBuilder {
private static void addField(Document doc, SchemaField field, Object val, float boost) {
- if (field.isPolyField()) {
- StorableField[] farr = field.getType().createFields(field, val, boost);
- for (StorableField f : farr) {
- if (f != null) doc.add((Field) f); // null fields are not added
- }
- } else {
- StorableField f = field.createField(val, boost);
- if (f != null) doc.add((Field) f); // null fields are not added
+ for (StorableField f : field.getType().createFields(field, val, boost)) {
+ if (f != null) doc.add((Field) f); // null fields are not added
}
}
@@ -298,7 +275,7 @@ public class DocumentBuilder {
// we can't copy any boost unless the dest field is
// indexed & !omitNorms, but which boost we copy depends
- // on wether the dest field already contains values (we
+ // on whether the dest field already contains values (we
// don't want to apply the compounded docBoost more then once)
final float destBoost =
(destinationField.indexed() && !destinationField.omitNorms()) ?
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/PeerSync.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/PeerSync.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/PeerSync.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/PeerSync.java Sun Mar 10 15:04:57 2013
@@ -443,10 +443,11 @@ public class PeerSync {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(DISTRIB_UPDATE_PARAM, FROMLEADER.toString());
- // params.set("peersync",true); // debugging
+ params.set("peersync",true); // debugging
SolrQueryRequest req = new LocalSolrQueryRequest(uhandler.core, params);
SolrQueryResponse rsp = new SolrQueryResponse();
+ // TODO: use the standard update processor chain now that it has support to skip processors before the DistributedUpdateProcessor?
RunUpdateProcessorFactory runFac = new RunUpdateProcessorFactory();
DistributedUpdateProcessorFactory magicFac = new DistributedUpdateProcessorFactory();
runFac.init(new NamedList());
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java Sun Mar 10 15:04:57 2013
@@ -40,6 +40,7 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.Diagnostics;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.AdjustableSemaphore;
import org.slf4j.Logger;
@@ -359,6 +360,8 @@ public class SolrCmdDistributor {
}
+ public static Diagnostics.Callable testing_errorHook; // called on error when forwarding request. Currently data=[this, Request]
+
void checkResponses(boolean block) {
while (pending != null && pending.size() > 0) {
@@ -372,7 +375,9 @@ public class SolrCmdDistributor {
Request sreq = future.get();
if (sreq.rspCode != 0) {
// error during request
-
+
+ if (testing_errorHook != null) Diagnostics.call(testing_errorHook, this, sreq);
+
// if there is a retry url, we want to retry...
boolean isRetry = sreq.node.checkRetry();
boolean doRetry = false;
@@ -402,7 +407,6 @@ public class SolrCmdDistributor {
SolrException.log(SolrCmdDistributor.log, "forwarding update to " + sreq.node.getUrl() + " failed - retrying ... ");
Thread.sleep(500);
submit(sreq);
- checkResponses(block);
} else {
Exception e = sreq.exception;
Error error = new Error();
@@ -451,26 +455,20 @@ public class SolrCmdDistributor {
}
public static class StdNode extends Node {
- protected String url;
- protected String baseUrl;
- protected String coreName;
- private ZkCoreNodeProps nodeProps;
+ protected ZkCoreNodeProps nodeProps;
public StdNode(ZkCoreNodeProps nodeProps) {
- this.url = nodeProps.getCoreUrl();
- this.baseUrl = nodeProps.getBaseUrl();
- this.coreName = nodeProps.getCoreName();
this.nodeProps = nodeProps;
}
@Override
public String getUrl() {
- return url;
+ return nodeProps.getCoreUrl();
}
@Override
public String toString() {
- return this.getClass().getSimpleName() + ": " + url;
+ return this.getClass().getSimpleName() + ": " + nodeProps.getCoreUrl();
}
@Override
@@ -480,18 +478,21 @@ public class SolrCmdDistributor {
@Override
public String getBaseUrl() {
- return baseUrl;
+ return nodeProps.getBaseUrl();
}
@Override
public String getCoreName() {
- return coreName;
+ return nodeProps.getCoreName();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
+ String baseUrl = nodeProps.getBaseUrl();
+ String coreName = nodeProps.getCoreName();
+ String url = nodeProps.getCoreUrl();
result = prime * result + ((baseUrl == null) ? 0 : baseUrl.hashCode());
result = prime * result + ((coreName == null) ? 0 : coreName.hashCode());
result = prime * result + ((url == null) ? 0 : url.hashCode());
@@ -504,15 +505,18 @@ public class SolrCmdDistributor {
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
StdNode other = (StdNode) obj;
+ String baseUrl = nodeProps.getBaseUrl();
+ String coreName = nodeProps.getCoreName();
+ String url = nodeProps.getCoreUrl();
if (baseUrl == null) {
- if (other.baseUrl != null) return false;
- } else if (!baseUrl.equals(other.baseUrl)) return false;
+ if (other.nodeProps.getBaseUrl() != null) return false;
+ } else if (!baseUrl.equals(other.nodeProps.getBaseUrl())) return false;
if (coreName == null) {
- if (other.coreName != null) return false;
- } else if (!coreName.equals(other.coreName)) return false;
+ if (other.nodeProps.getCoreName() != null) return false;
+ } else if (!coreName.equals(other.nodeProps.getCoreName())) return false;
if (url == null) {
- if (other.url != null) return false;
- } else if (!url.equals(other.url)) return false;
+ if (other.nodeProps.getCoreUrl() != null) return false;
+ } else if (!url.equals(other.nodeProps.getCoreUrl())) return false;
return true;
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCoreState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCoreState.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCoreState.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrCoreState.java Sun Mar 10 15:04:57 2013
@@ -18,12 +18,16 @@ package org.apache.solr.update;
*/
import java.io.IOException;
+import java.util.concurrent.locks.Lock;
import org.apache.lucene.index.IndexWriter;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.DirectoryFactory;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.RefCounted;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The state in this class can be easily shared between SolrCores across
@@ -31,12 +35,50 @@ import org.apache.solr.util.RefCounted;
*
*/
public abstract class SolrCoreState {
+ public static Logger log = LoggerFactory.getLogger(SolrCoreState.class);
+
private final Object deleteLock = new Object();
public Object getUpdateLock() {
return deleteLock;
}
+ private int solrCoreStateRefCnt = 1;
+
+ public synchronized int getSolrCoreStateRefCnt() {
+ return solrCoreStateRefCnt;
+ }
+
+ public void increfSolrCoreState() {
+ synchronized (this) {
+ if (solrCoreStateRefCnt == 0) {
+ throw new IllegalStateException("IndexWriter has been closed");
+ }
+ solrCoreStateRefCnt++;
+ }
+ }
+
+ public void decrefSolrCoreState(IndexWriterCloser closer) {
+ boolean close = false;
+ synchronized (this) {
+ solrCoreStateRefCnt--;
+ if (solrCoreStateRefCnt == 0) {
+ close = true;
+ }
+ }
+
+ if (close) {
+ try {
+ log.info("Closing SolrCoreState");
+ close(closer);
+ } catch (Throwable t) {
+ log.error("Error closing SolrCoreState", t);
+ }
+ }
+ }
+
+ public abstract Lock getCommitLock();
+
/**
* Force the creation of a new IndexWriter using the settings from the given
* SolrCore.
@@ -72,7 +114,7 @@ public abstract class SolrCoreState {
public void closeWriter(IndexWriter writer) throws IOException;
}
- public abstract void doRecovery(CoreContainer cc, String name);
+ public abstract void doRecovery(CoreContainer cc, CoreDescriptor cd);
public abstract void cancelRecovery();
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java Sun Mar 10 15:04:57 2013
@@ -32,6 +32,7 @@ import org.apache.lucene.util.InfoStream
import org.apache.lucene.util.PrintStreamInfoStream;
import org.apache.lucene.util.ThreadInterruptedException;
import org.apache.solr.core.DirectoryFactory;
+import org.apache.solr.core.DirectoryFactory.DirContext;
import org.apache.solr.schema.IndexSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,7 +59,7 @@ public class SolrIndexWriter extends Ind
public static SolrIndexWriter create(String name, String path, DirectoryFactory directoryFactory, boolean create, IndexSchema schema, SolrIndexConfig config, IndexDeletionPolicy delPolicy, Codec codec, boolean forceNewDirectory) throws IOException {
SolrIndexWriter w = null;
- final Directory d = directoryFactory.get(path, config.lockType, forceNewDirectory);
+ final Directory d = directoryFactory.get(path, DirContext.DEFAULT, config.lockType, forceNewDirectory);
try {
w = new SolrIndexWriter(name, path, d, create, schema,
config, delPolicy, codec);
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateCommand.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateCommand.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateCommand.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateCommand.java Sun Mar 10 15:04:57 2013
@@ -44,7 +44,19 @@ public abstract class UpdateCommand impl
@Override
public String toString() {
- return name() + "{flags="+flags+",_version_="+version;
+ StringBuilder sb = new StringBuilder(50);
+ sb.append(name());
+ sb.append('{');
+ boolean needComma = false;
+ if (flags != 0) {
+ sb.append("flags=").append(Integer.toHexString(flags));
+ needComma = true;
+ }
+ if (version != 0) {
+ if (needComma) sb.append(',');
+ sb.append("_version_=").append(version);
+ }
+ return sb.toString();
}
public long getVersion() {
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateHandler.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateHandler.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateHandler.java Sun Mar 10 15:04:57 2013
@@ -22,6 +22,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Vector;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.core.PluginInfo;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrEventListener;
@@ -87,13 +89,15 @@ public abstract class UpdateHandler impl
private void clearLog(PluginInfo ulogPluginInfo) {
if (ulogPluginInfo == null) return;
File tlogDir = UpdateLog.getTlogDir(core, ulogPluginInfo);
+ log.info("Clearing tlog files, tlogDir=" + tlogDir);
if (tlogDir.exists()) {
String[] files = UpdateLog.getLogList(tlogDir);
for (String file : files) {
- File f = new File(file);
+ File f = new File(tlogDir, file);
boolean s = f.delete();
if (!s) {
- log.error("Could not remove tlog file:" + f);
+ log.error("Could not remove tlog file:" + f.getAbsolutePath());
+ //throw new SolrException(ErrorCode.SERVER_ERROR, "Could not remove tlog file:" + f.getAbsolutePath());
}
}
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateLog.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateLog.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateLog.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateLog.java Sun Mar 10 15:04:57 2013
@@ -820,8 +820,8 @@ public class UpdateLog implements Plugin
public void close(boolean committed, boolean deleteOnClose) {
synchronized (this) {
try {
- ExecutorUtil.shutdownAndAwaitTermination(recoveryExecutor);
- } catch (Exception e) {
+ ExecutorUtil.shutdownNowAndAwaitTermination(recoveryExecutor);
+ } catch (Throwable e) {
SolrException.log(log, e);
}
@@ -917,10 +917,11 @@ public class UpdateLog implements Plugin
reader = oldLog.getReverseReader();
while (numUpdates < numRecordsToKeep) {
- Object o = reader.next();
- if (o==null) break;
+ Object o = null;
try {
-
+ o = reader.next();
+ if (o==null) break;
+
// should currently be a List<Oper,Ver,Doc/Id>
List entry = (List)o;
@@ -1397,16 +1398,16 @@ public class UpdateLog implements Plugin
public static File getTlogDir(SolrCore core, PluginInfo info) {
String dataDir = (String) info.initArgs.get("dir");
- if (dataDir == null) {
- String ulogDir = core.getCoreDescriptor().getUlogDir();
- if (ulogDir != null) {
- dataDir = ulogDir;
- }
-
- if (dataDir == null || dataDir.length() == 0) {
- dataDir = core.getDataDir();
- }
+
+ String ulogDir = core.getCoreDescriptor().getUlogDir();
+ if (ulogDir != null) {
+ dataDir = ulogDir;
}
+
+ if (dataDir == null || dataDir.length() == 0) {
+ dataDir = core.getDataDir();
+ }
+
return new File(dataDir, TLOG_NAME);
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java Sun Mar 10 15:04:57 2013
@@ -44,8 +44,8 @@ public class UpdateShardHandler {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 500);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 16);
- params.set(HttpClientUtil.PROP_SO_TIMEOUT, distribUpdateConnTimeout);
- params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, distribUpdateSoTimeout);
+ params.set(HttpClientUtil.PROP_SO_TIMEOUT, distribUpdateSoTimeout);
+ params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, distribUpdateConnTimeout);
client = HttpClientUtil.createClient(params);
}
@@ -60,7 +60,7 @@ public class UpdateShardHandler {
public void close() {
try {
- ExecutorUtil.shutdownAndAwaitTermination(cmdDistribExecutor);
+ ExecutorUtil.shutdownNowAndAwaitTermination(cmdDistribExecutor);
} catch (Throwable e) {
SolrException.log(log, e);
}
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/VersionInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/VersionInfo.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/VersionInfo.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/VersionInfo.java Sun Mar 10 15:04:57 2013
@@ -71,7 +71,7 @@ public class VersionInfo {
if ( sf.multiValued() ) {
throw new SolrException
(SolrException.ErrorCode.SERVER_ERROR,
- errPrefix + " (" + VERSION_FIELD + " is not multiValued");
+ errPrefix + " (" + VERSION_FIELD + " is multiValued");
}
return sf;
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/ConcatFieldUpdateProcessorFactory.java Sun Mar 10 15:04:57 2013
@@ -51,18 +51,15 @@ import org.apache.commons.lang.StringUti
* </p>
*
* <pre class="prettyprint">
- * <updateRequestProcessorChain>
- * <processor class="solr.ConcatFieldUpdateProcessorFactory">
- * <str name="delimiter">; </str>
- * <lst name="exclude">
- * <str name="fieldName">primary_author</str>
- * </lst>
- * </processor>
- * <processor class="solr.FirstFieldValueUpdateProcessorFactory">
- * <str name="fieldName">primary_author</str>
- * </processor>
- * </updateRequestProcessorChain>
- * </pre>
+ * <processor class="solr.ConcatFieldUpdateProcessorFactory">
+ * <str name="delimiter">; </str>
+ * <lst name="exclude">
+ * <str name="fieldName">primary_author</str>
+ * </lst>
+ * </processor>
+ * <processor class="solr.FirstFieldValueUpdateProcessorFactory">
+ * <str name="fieldName">primary_author</str>
+ * </processor></pre>
*/
public final class ConcatFieldUpdateProcessorFactory extends FieldMutatingUpdateProcessorFactory {
Modified: lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java?rev=1454862&r1=1454861&r2=1454862&view=diff
==============================================================================
--- lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java (original)
+++ lucene/dev/branches/lucene4258/solr/core/src/java/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.java Sun Mar 10 15:04:57 2013
@@ -50,20 +50,17 @@ import org.apache.commons.lang.StringUti
* </p>
*
* <pre class="prettyprint">
- * <updateRequestProcessorChain>
- * <processor class="solr.CloneFieldUpdateProcessorFactory">
- * <str name="source">category</str>
- * <str name="dest">category_count</str>
- * </processor>
- * <processor class="solr.CountFieldValuesUpdateProcessorFactory">
- * <str name="fieldName">category_count</str>
- * </processor>
- * <processor class="solr.DefaultValueUpdateProcessorFactory">
- * <str name="fieldName">category_count</str>
- * <int name="value">0</int>
- * </processor>
- * </updateRequestProcessorChain>
- * </pre>
+ * <processor class="solr.CloneFieldUpdateProcessorFactory">
+ * <str name="source">category</str>
+ * <str name="dest">category_count</str>
+ * </processor>
+ * <processor class="solr.CountFieldValuesUpdateProcessorFactory">
+ * <str name="fieldName">category_count</str>
+ * </processor>
+ * <processor class="solr.DefaultValueUpdateProcessorFactory">
+ * <str name="fieldName">category_count</str>
+ * <int name="value">0</int>
+ * </processor></pre>
*
* <p>
* <b>NOTE:</b> The use of {@link DefaultValueUpdateProcessorFactory} is