You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cm...@apache.org on 2013/08/11 14:19:39 UTC
svn commit: r1512909 [35/38] - in /lucene/dev/branches/lucene4956: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/suggest/ dev-tools/idea/solr/contrib/dataimporthandler/
dev-tools/idea/solr/core/src/test/ dev-too...
Modified: lucene/dev/branches/lucene4956/solr/site/xsl/index.xsl
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/site/xsl/index.xsl?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/site/xsl/index.xsl (original)
+++ lucene/dev/branches/lucene4956/solr/site/xsl/index.xsl Sun Aug 11 12:19:13 2013
@@ -36,8 +36,23 @@
<title><xsl:text>Apache Solr </xsl:text><xsl:value-of select="$version"/><xsl:text> Documentation</xsl:text></title>
</head>
<body>
- <div><a href="http://lucene.apache.org/solr/"><img src="solr.png" title="Apache Solr Logo" alt="Solr" border="0"/></a></div>
- <h1><xsl:text>Apache Solr </xsl:text><xsl:value-of select="$version"/><xsl:text> Documentation</xsl:text></h1>
+ <div>
+ <a href="http://lucene.apache.org/solr/">
+ <img src="solr.png" title="Apache Solr Logo" alt="Solr" border="0"/>
+ </a>
+ <div style="z-index:100;position:absolute;top:25px;left:252px">
+ <span style="font-size: x-small">TM</span>
+ </div>
+ </div>
+ <h1>
+ <xsl:text>Apache Solr</xsl:text>
+ <span style="vertical-align: top; font-size: x-small">
+ <xsl:text>TM</xsl:text>
+ </span>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$version"/>
+ <xsl:text> Documentation</xsl:text>
+ </h1>
<p>Solr is the popular, blazing fast open source enterprise search platform from the Apache Lucene project.
Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering,
database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly scalable,
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java Sun Aug 11 12:19:13 2013
@@ -91,6 +91,13 @@ public class CloudSolrServer extends Sol
this.lbServer = new LBHttpSolrServer(myClient);
this.updatesToLeaders = true;
}
+
+ public CloudSolrServer(String zkHost, boolean updatesToLeaders) throws MalformedURLException {
+ this.zkHost = zkHost;
+ this.myClient = HttpClientUtil.createClient(null);
+ this.lbServer = new LBHttpSolrServer(myClient);
+ this.updatesToLeaders = updatesToLeaders;
+}
/**
* @param zkHost The client endpoint of the zookeeper quorum containing the cloud state,
@@ -124,6 +131,11 @@ public class CloudSolrServer extends Sol
this.defaultCollection = collection;
}
+ /** Gets the default collection for request */
+ public String getDefaultCollection() {
+ return defaultCollection;
+ }
+
/** Set the connect timeout to the zookeeper ensemble in ms */
public void setZkConnectTimeout(int zkConnectTimeout) {
this.zkConnectTimeout = zkConnectTimeout;
@@ -348,6 +360,10 @@ public class CloudSolrServer extends Sol
public LBHttpSolrServer getLbServer() {
return lbServer;
}
+
+ public boolean isUpdatesToLeaders() {
+ return updatesToLeaders;
+ }
// for tests
Map<String,List<String>> getUrlLists() {
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java Sun Aug 11 12:19:13 2013
@@ -658,7 +658,7 @@ public class HttpSolrServer extends Solr
* status code that may have been returned by the remote server or a
* proxy along the way.
*/
- protected static class RemoteSolrException extends SolrException {
+ public static class RemoteSolrException extends SolrException {
/**
* @param code Arbitrary HTTP status code
* @param msg Exception Message
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/impl/StreamingBinaryResponseParser.java Sun Aug 11 12:19:13 2013
@@ -16,17 +16,17 @@
*/
package org.apache.solr.client.solrj.impl;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
import org.apache.solr.client.solrj.StreamingResponseCallback;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.FastInputStream;
-import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.DataInputInputStream;
import org.apache.solr.common.util.JavaBinCodec;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
+import org.apache.solr.common.util.NamedList;
/**
* A BinaryResponseParser that sends callback events rather then build
@@ -49,14 +49,14 @@ public class StreamingBinaryResponsePars
JavaBinCodec codec = new JavaBinCodec() {
@Override
- public SolrDocument readSolrDocument(FastInputStream dis) throws IOException {
+ public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException {
SolrDocument doc = super.readSolrDocument(dis);
callback.streamSolrDocument( doc );
return null;
}
@Override
- public SolrDocumentList readSolrDocumentList(FastInputStream dis) throws IOException {
+ public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException {
SolrDocumentList solrDocs = new SolrDocumentList();
List list = (List) readVal(dis);
solrDocs.setNumFound((Long) list.get(0));
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/CoreAdminRequest.java Sun Aug 11 12:19:13 2013
@@ -17,22 +17,22 @@
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;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.CoreAdminParams;
-import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
/**
* This class is experimental and subject to change.
*
@@ -534,6 +534,7 @@ public class CoreAdminRequest extends So
return req.process( server );
}
+ @Deprecated
public static CoreAdminResponse persist(String fileName, SolrServer server) throws SolrServerException, IOException
{
CoreAdminRequest.Persist req = new CoreAdminRequest.Persist();
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/JavaBinUpdateRequestCodec.java Sun Aug 11 12:19:13 2013
@@ -16,18 +16,21 @@
*/
package org.apache.solr.client.solrj.request;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.FastInputStream;
+import org.apache.solr.common.util.DataInputInputStream;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.*;
-
/**
* Provides methods for marshalling an UpdateRequest to a NamedList which can be serialized in the javabin format and
* vice versa.
@@ -94,7 +97,7 @@ public class JavaBinUpdateRequestCodec {
private boolean seenOuterMostDocIterator = false;
@Override
- public NamedList readNamedList(FastInputStream dis) throws IOException {
+ public NamedList readNamedList(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
NamedList nl = new NamedList();
if (namedList[0] == null) {
@@ -109,7 +112,7 @@ public class JavaBinUpdateRequestCodec {
}
@Override
- public List readIterator(FastInputStream fis) throws IOException {
+ public List readIterator(DataInputInputStream fis) throws IOException {
// default behavior for reading any regular Iterator in the stream
if (seenOuterMostDocIterator) return super.readIterator(fis);
@@ -120,7 +123,7 @@ public class JavaBinUpdateRequestCodec {
return readOuterMostDocIterator(fis);
}
- private List readOuterMostDocIterator(FastInputStream fis) throws IOException {
+ private List readOuterMostDocIterator(DataInputInputStream fis) throws IOException {
NamedList params = (NamedList) namedList[0].getVal(0);
updateRequest.setParams(new ModifiableSolrParams(SolrParams.toSolrParams(params)));
if (handler == null) return super.readIterator(fis);
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/client/solrj/request/SolrPing.java Sun Aug 11 12:19:13 2013
@@ -17,50 +17,102 @@
package org.apache.solr.client.solrj.request;
+import java.io.IOException;
+import java.util.Collection;
+
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.response.SolrPingResponse;
+import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStream;
-import java.io.IOException;
-import java.util.Collection;
-
/**
* Verify that there is a working Solr core at the URL of a {@link SolrServer}.
* To use this class, the solrconfig.xml for the relevant core must include the
* request handler for <code>/admin/ping</code>.
- *
+ *
* @since solr 1.3
*/
-public class SolrPing extends SolrRequest
-{
+public class SolrPing extends SolrRequest {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 5828246236669090017L;
+
+ /** Request parameters. */
private ModifiableSolrParams params;
- public SolrPing()
- {
- super( METHOD.GET, "/admin/ping" );
+ /**
+ * Create a new SolrPing object.
+ */
+ public SolrPing() {
+ super(METHOD.GET, CommonParams.PING_HANDLER);
params = new ModifiableSolrParams();
}
-
+
@Override
public Collection<ContentStream> getContentStreams() {
return null;
}
-
+
@Override
public ModifiableSolrParams getParams() {
return params;
}
-
+
@Override
- public SolrPingResponse process( SolrServer server ) throws SolrServerException, IOException
- {
+ public SolrPingResponse process(SolrServer server)
+ throws SolrServerException, IOException {
long startTime = System.currentTimeMillis();
SolrPingResponse res = new SolrPingResponse();
- res.setResponse( server.request( this ) );
- res.setElapsedTime( System.currentTimeMillis()-startTime );
+ res.setResponse(server.request(this));
+ res.setElapsedTime(System.currentTimeMillis() - startTime);
return res;
}
+
+ /**
+ * Remove the action parameter from this request. This will result in the same
+ * behavior as {@code SolrPing#setActionPing()}. For Solr server version 4.0
+ * and later.
+ *
+ * @return this
+ */
+ public SolrPing removeAction() {
+ params.remove(CommonParams.ACTION);
+ return this;
+ }
+
+ /**
+ * Set the action parameter on this request to enable. This will delete the
+ * health-check file for the Solr core. For Solr server version 4.0 and later.
+ *
+ * @return this
+ */
+ public SolrPing setActionDisable() {
+ params.set(CommonParams.ACTION, CommonParams.DISABLE);
+ return this;
+ }
+
+ /**
+ * Set the action parameter on this request to enable. This will create the
+ * health-check file for the Solr core. For Solr server version 4.0 and later.
+ *
+ * @return this
+ */
+ public SolrPing setActionEnable() {
+ params.set(CommonParams.ACTION, CommonParams.ENABLE);
+ return this;
+ }
+
+ /**
+ * Set the action parameter on this request to ping. This is the same as not
+ * including the action at all. For Solr server version 4.0 and later.
+ *
+ * @return this
+ */
+ public SolrPing setActionPing() {
+ params.set(CommonParams.ACTION, CommonParams.PING);
+ return this;
+ }
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java Sun Aug 11 12:19:13 2013
@@ -165,15 +165,18 @@ public class ClusterState implements JSO
return Collections.unmodifiableSet(liveNodes);
}
- /**
- * Get the slice/shardId for a core.
- * @param coreNodeName in the form of nodeName_coreName (the name of the replica)
- */
- public String getShardId(String coreNodeName) {
- // System.out.println("###### getShardId("+coreNodeName+") in " + collectionStates);
+ public String getShardId(String baseUrl, String coreName) {
+ // System.out.println("###### getShardId(" + baseUrl + "," + coreName + ") in " + collectionStates);
for (DocCollection coll : collectionStates.values()) {
for (Slice slice : coll.getSlices()) {
- if (slice.getReplicasMap().containsKey(coreNodeName)) return slice.getName();
+ for (Replica replica : slice.getReplicas()) {
+ // TODO: for really large clusters, we could 'index' on this
+ String rbaseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
+ String rcore = replica.getStr(ZkStateReader.CORE_NAME_PROP);
+ if (baseUrl.equals(rbaseUrl) && coreName.equals(rcore)) {
+ return slice.getName();
+ }
+ }
}
}
return null;
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java Sun Aug 11 12:19:13 2013
@@ -95,7 +95,7 @@ class ConnectionManager implements Watch
// if keeper does not replace oldKeeper we must be sure to close it
synchronized (connectionUpdateLock) {
try {
- waitForConnected(SolrZkClient.DEFAULT_CLIENT_CONNECT_TIMEOUT);
+ waitForConnected(Long.MAX_VALUE);
} catch (Exception e1) {
closeKeeper(keeper);
throw new RuntimeException(e1);
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/DocRouter.java Sun Aug 11 12:19:13 2013
@@ -17,12 +17,11 @@ package org.apache.solr.common.cloud;
* limitations under the License.
*/
-import org.noggit.JSONWriter;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.util.Hash;
import org.apache.solr.common.util.StrUtils;
+import org.noggit.JSONWriter;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,6 +38,7 @@ import java.util.Map;
public abstract class DocRouter {
public static final String DEFAULT_NAME = CompositeIdRouter.NAME;
public static final DocRouter DEFAULT = new CompositeIdRouter();
+ public static final String ROUTE_FIELD = "routeField";
public static DocRouter getDocRouter(Object routerSpec) {
DocRouter router = routerMap.get(routerSpec);
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ImplicitDocRouter.java Sun Aug 11 12:19:13 2013
@@ -20,33 +20,53 @@ package org.apache.solr.common.cloud;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.SolrParams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
+
+import static org.apache.solr.common.params.ShardParams._ROUTE_;
/** This document router is for custom sharding
*/
public class ImplicitDocRouter extends DocRouter {
public static final String NAME = "implicit";
+// @Deprecated
+// public static final String DEFAULT_SHARD_PARAM = "_shard_";
+ private static Logger log = LoggerFactory
+ .getLogger(ImplicitDocRouter.class);
@Override
public Slice getTargetSlice(String id, SolrInputDocument sdoc, SolrParams params, DocCollection collection) {
String shard = null;
if (sdoc != null) {
- Object o = sdoc.getFieldValue("_shard_");
- if (o != null) {
- shard = o.toString();
+ String f = collection.getStr(ROUTE_FIELD);
+ if(f !=null) {
+ Object o = sdoc.getFieldValue(f);
+ if (o != null) shard = o.toString();
+ else throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No value for field "+f +" in " + sdoc);
+ }
+ if(shard == null) {
+ Object o = sdoc.getFieldValue(_ROUTE_);
+ if (o == null) o = sdoc.getFieldValue("_shard_");//deprecated . for backcompat remove later
+ if (o != null) {
+ shard = o.toString();
+ }
}
}
if (shard == null) {
- shard = params.get("_shard_");
+ shard = params.get(_ROUTE_);
+ if(shard == null) shard =params.get("_shard_"); //deperecated for back compat
}
if (shard != null) {
+
Slice slice = collection.getSlice(shard);
if (slice == null) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No _shard_=" + shard + " in " + collection);
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No shard called =" + shard + " in " + collection);
}
return slice;
}
@@ -56,12 +76,14 @@ public class ImplicitDocRouter extends D
@Override
public boolean isTargetSlice(String id, SolrInputDocument sdoc, SolrParams params, String shardId, DocCollection collection) {
+
// todo : how to handle this?
return false;
}
@Override
public Collection<Slice> getSearchSlicesSingle(String shardKey, SolrParams params, DocCollection collection) {
+
if (shardKey == null) {
return collection.getActiveSlices();
}
@@ -75,4 +97,8 @@ public class ImplicitDocRouter extends D
return Collections.singleton(slice);
}
+ @Override
+ public List<Range> partitionRange(int partitions, Range range) {
+ return null;
+ }
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java Sun Aug 11 12:19:13 2013
@@ -20,11 +20,9 @@ package org.apache.solr.common.cloud;
import org.noggit.JSONUtil;
import org.noggit.JSONWriter;
-import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
/**
@@ -108,6 +106,22 @@ public class ZkNodeProps implements JSON
return o == null ? null : o.toString();
}
+ /**
+ * Get a string property value.
+ */
+ public Integer getInt(String key, Integer def) {
+ Object o = propMap.get(key);
+ return o == null ? def : Integer.valueOf(o.toString());
+ }
+
+ /**
+ * Get a string property value.
+ */
+ public String getStr(String key,String def) {
+ Object o = propMap.get(key);
+ return o == null ? def : o.toString();
+ }
+
public Object get(String key) {
return propMap.get(key);
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java Sun Aug 11 12:19:13 2013
@@ -508,6 +508,7 @@ public class ZkStateReader {
public List<ZkCoreNodeProps> getReplicaProps(String collection,
String shardId, String thisCoreNodeName, String coreName, String mustMatchStateFilter, String mustNotMatchStateFilter) {
+ assert thisCoreNodeName != null;
ClusterState clusterState = this.clusterState;
if (clusterState == null) {
return null;
@@ -540,7 +541,7 @@ public class ZkStateReader {
}
}
if (nodes.size() == 0) {
- // no replicas - go local
+ // no replicas
return null;
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CollectionParams.java Sun Aug 11 12:19:13 2013
@@ -28,7 +28,7 @@ public interface CollectionParams
public enum CollectionAction {
- CREATE, DELETE, RELOAD, SYNCSHARD, CREATEALIAS, DELETEALIAS, SPLITSHARD;
+ CREATE, DELETE, RELOAD, SYNCSHARD, CREATEALIAS, DELETEALIAS, SPLITSHARD, DELETESHARD, CREATESHARD;
public static CollectionAction get( String p )
{
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CommonParams.java Sun Aug 11 12:19:13 2013
@@ -59,6 +59,23 @@ public interface CommonParams {
/** number of documents to return starting at "start" */
public static final String ROWS ="rows";
+
+ // SOLR-4228 start
+ /** handler value for SolrPing */
+ public static final String PING_HANDLER = "/admin/ping";
+
+ /** "action" parameter for SolrPing */
+ public static final String ACTION = "action";
+
+ /** "disable" value for SolrPing action */
+ public static final String DISABLE = "disable";
+
+ /** "enable" value for SolrPing action */
+ public static final String ENABLE = "enable";
+
+ /** "ping" value for SolrPing action */
+ public static final String PING = "ping";
+ // SOLR-4228 end
//Issue 1726 start
/** score of the last document of the previous page */
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/CoreAdminParams.java Sun Aug 11 12:19:13 2013
@@ -23,7 +23,7 @@ import java.util.Locale;
/**
* @since solr 1.3
*/
-public interface CoreAdminParams
+public abstract class CoreAdminParams
{
/** What Core are we talking about **/
public final static String CORE = "core";
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/RequiredSolrParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/RequiredSolrParams.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/RequiredSolrParams.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/RequiredSolrParams.java Sun Aug 11 12:19:13 2013
@@ -148,4 +148,8 @@ public class RequiredSolrParams extends
public String getFieldParam(String field, String param, String def) {
return params.getFieldParam(field, param, def);
}
+
+ public void check(String... params){
+ for (String param : params) get(param);
+ }
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/params/ShardParams.java Sun Aug 11 12:19:13 2013
@@ -47,5 +47,10 @@ public interface ShardParams {
public static final String SHARDS_TOLERANT = "shards.tolerant";
/** Should things fail if there is an error? (true/false) */
+ @Deprecated
public static final String SHARD_KEYS = "shard.keys";
+
+ public static final String _ROUTE_ = "_route_";
+
+
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/FastInputStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/FastInputStream.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/FastInputStream.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/FastInputStream.java Sun Aug 11 12:19:13 2013
@@ -22,7 +22,7 @@ import java.io.*;
/** Single threaded buffered InputStream
* Internal Solr use only, subject to change.
*/
-public class FastInputStream extends InputStream implements DataInput {
+public class FastInputStream extends DataInputInputStream {
protected final InputStream in;
protected final byte[] buf;
protected int pos;
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java Sun Aug 11 12:19:13 2013
@@ -113,7 +113,7 @@ public class JavaBinCodec {
}
- public SimpleOrderedMap<Object> readOrderedMap(FastInputStream dis) throws IOException {
+ public SimpleOrderedMap<Object> readOrderedMap(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
SimpleOrderedMap<Object> nl = new SimpleOrderedMap<Object>();
for (int i = 0; i < sz; i++) {
@@ -124,7 +124,7 @@ public class JavaBinCodec {
return nl;
}
- public NamedList<Object> readNamedList(FastInputStream dis) throws IOException {
+ public NamedList<Object> readNamedList(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
NamedList<Object> nl = new NamedList<Object>();
for (int i = 0; i < sz; i++) {
@@ -164,7 +164,7 @@ public class JavaBinCodec {
protected byte tagByte;
- public Object readVal(FastInputStream dis) throws IOException {
+ public Object readVal(DataInputInputStream dis) throws IOException {
tagByte = dis.readByte();
// if ((tagByte & 0xe0) == 0) {
@@ -304,7 +304,7 @@ public class JavaBinCodec {
daos.write(arr, offset, len);
}
- public byte[] readByteArray(FastInputStream dis) throws IOException {
+ public byte[] readByteArray(DataInputInputStream dis) throws IOException {
byte[] arr = new byte[readVInt(dis)];
dis.readFully(arr);
return arr;
@@ -321,7 +321,7 @@ public class JavaBinCodec {
}
}
- public SolrDocument readSolrDocument(FastInputStream dis) throws IOException {
+ public SolrDocument readSolrDocument(DataInputInputStream dis) throws IOException {
NamedList nl = (NamedList) readVal(dis);
SolrDocument doc = new SolrDocument();
for (int i = 0; i < nl.size(); i++) {
@@ -332,7 +332,7 @@ public class JavaBinCodec {
return doc;
}
- public SolrDocumentList readSolrDocumentList(FastInputStream dis) throws IOException {
+ public SolrDocumentList readSolrDocumentList(DataInputInputStream dis) throws IOException {
SolrDocumentList solrDocs = new SolrDocumentList();
List list = (List) readVal(dis);
solrDocs.setNumFound((Long) list.get(0));
@@ -356,7 +356,7 @@ public class JavaBinCodec {
writeArray(docs);
}
- public SolrInputDocument readSolrInputDocument(FastInputStream dis) throws IOException {
+ public SolrInputDocument readSolrInputDocument(DataInputInputStream dis) throws IOException {
int sz = readVInt(dis);
float docBoost = (Float)readVal(dis);
SolrInputDocument sdoc = new SolrInputDocument();
@@ -390,7 +390,7 @@ public class JavaBinCodec {
}
- public Map<Object,Object> readMap(FastInputStream dis)
+ public Map<Object,Object> readMap(DataInputInputStream dis)
throws IOException {
int sz = readVInt(dis);
Map<Object,Object> m = new LinkedHashMap<Object,Object>();
@@ -411,7 +411,7 @@ public class JavaBinCodec {
writeVal(END_OBJ);
}
- public List<Object> readIterator(FastInputStream fis) throws IOException {
+ public List<Object> readIterator(DataInputInputStream fis) throws IOException {
ArrayList<Object> l = new ArrayList<Object>();
while (true) {
Object o = readVal(fis);
@@ -444,7 +444,7 @@ public class JavaBinCodec {
}
}
- public List<Object> readArray(FastInputStream dis) throws IOException {
+ public List<Object> readArray(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
ArrayList<Object> l = new ArrayList<Object>(sz);
for (int i = 0; i < sz; i++) {
@@ -473,7 +473,7 @@ public class JavaBinCodec {
byte[] bytes;
CharArr arr = new CharArr();
- public String readStr(FastInputStream dis) throws IOException {
+ public String readStr(DataInputInputStream dis) throws IOException {
int sz = readSize(dis);
if (bytes == null || bytes.length < sz) bytes = new byte[sz];
dis.readFully(bytes, 0, sz);
@@ -501,7 +501,7 @@ public class JavaBinCodec {
}
}
- public int readSmallInt(FastInputStream dis) throws IOException {
+ public int readSmallInt(DataInputInputStream dis) throws IOException {
int v = tagByte & 0x0F;
if ((tagByte & 0x10) != 0)
v = (readVInt(dis) << 4) | v;
@@ -525,7 +525,7 @@ public class JavaBinCodec {
}
}
- public long readSmallLong(FastInputStream dis) throws IOException {
+ public long readSmallLong(DataInputInputStream dis) throws IOException {
long v = tagByte & 0x0F;
if ((tagByte & 0x10) != 0)
v = (readVLong(dis) << 4) | v;
@@ -607,7 +607,7 @@ public class JavaBinCodec {
}
- public int readSize(FastInputStream in) throws IOException {
+ public int readSize(DataInputInputStream in) throws IOException {
int sz = tagByte & 0x1f;
if (sz == 0x1f) sz += readVInt(in);
return sz;
@@ -634,7 +634,7 @@ public class JavaBinCodec {
*
* @throws IOException If there is a low-level I/O error.
*/
- public static int readVInt(FastInputStream in) throws IOException {
+ public static int readVInt(DataInputInputStream in) throws IOException {
byte b = in.readByte();
int i = b & 0x7F;
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
@@ -653,7 +653,7 @@ public class JavaBinCodec {
out.writeByte((byte) i);
}
- public static long readVLong(FastInputStream in) throws IOException {
+ public static long readVLong(DataInputInputStream in) throws IOException {
byte b = in.readByte();
long i = b & 0x7F;
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
@@ -683,7 +683,7 @@ public class JavaBinCodec {
}
- public String readExternString(FastInputStream fis) throws IOException {
+ public String readExternString(DataInputInputStream fis) throws IOException {
int idx = readSize(fis);
if (idx != 0) {// idx != 0 is the index of the extern string
return stringsList.get(idx - 1);
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-slave1.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-slave1.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-slave1.xml (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig-slave1.xml Sun Aug 11 12:19:13 2013
@@ -19,11 +19,12 @@
<config>
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
+ <indexConfig>
+ <useCompoundFile>${useCompoundFile:false}</useCompoundFile>
+ </indexConfig>
<dataDir>${solr.data.dir:}</dataDir>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
- <!-- <indexConfig> section could go here, but we want the defaults -->
-
<updateHandler class="solr.DirectUpdateHandler2">
</updateHandler>
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/collection1/conf/solrconfig.xml Sun Aug 11 12:19:13 2013
@@ -22,6 +22,9 @@
-->
<config>
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
+ <indexConfig>
+ <useCompoundFile>${useCompoundFile:false}</useCompoundFile>
+ </indexConfig>
<dataDir>${solr.data.dir:}</dataDir>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
@@ -49,7 +52,17 @@
<requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
<requestHandler name="/update" class="solr.UpdateRequestHandler" />
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
-
+
+ <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
+ <lst name="invariants">
+ <str name="q">*:*</str>
+ </lst>
+ <lst name="defaults">
+ <str name="echoParams">all</str>
+ </lst>
+ <str name="healthcheckFile">server-enabled.txt</str>
+ </requestHandler>
+
<!-- config for the admin interface -->
<admin>
<defaultQuery>solr</defaultQuery>
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/conf/solrconfig.xml Sun Aug 11 12:19:13 2013
@@ -22,6 +22,9 @@
-->
<config>
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
+ <indexConfig>
+ <useCompoundFile>${useCompoundFile:false}</useCompoundFile>
+ </indexConfig>
<dataDir>${tempDir}/data/${l10n:}-${version:}</dataDir>
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.RAMDirectoryFactory}"/>
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/solr.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/solr.xml (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/shared/solr.xml Sun Aug 11 12:19:13 2013
@@ -22,7 +22,7 @@
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="true">
+<solr persistent="false">
<property name="version" value="1.3"/>
<property name="lang" value="english, french"/>
@@ -30,7 +30,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
- <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000">
+ <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000" genericCoreNodeNames="${genericCoreNodeNames:true}">
<core name="collection1" instanceDir="." />
<core name="core0" instanceDir="${theInstanceDir:./}" dataDir="${dataDir1}" collection="${collection:acollection}">
<property name="version" value="3.5"/>
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/solr.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/solr.xml (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test-files/solrj/solr/solr.xml Sun Aug 11 12:19:13 2013
@@ -28,7 +28,7 @@
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="8000" numShards="${numShards:3}">
+ <cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="${hostContext:solr}" zkClientTimeout="8000" genericCoreNodeNames="${genericCoreNodeNames:true}">
<core name="collection1" instanceDir="collection1" shard="${shard:}" collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"/>
</cores>
</solr>
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MergeIndexesExampleTestBase.java Sun Aug 11 12:19:13 2013
@@ -17,10 +17,6 @@
package org.apache.solr.client.solrj;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -32,9 +28,12 @@ import org.apache.solr.common.params.Sol
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
/**
* Abstract base class for testing merge indexes command
*
@@ -42,7 +41,8 @@ import org.junit.BeforeClass;
*
*/
public abstract class MergeIndexesExampleTestBase extends SolrExampleTestBase {
- protected static CoreContainer cores;
+
+ protected CoreContainer cores;
private String saveProp;
private File dataDir2;
@@ -56,13 +56,12 @@ public abstract class MergeIndexesExampl
if (dataDir == null) {
createTempDir();
}
- cores = new CoreContainer();
}
-
- @AfterClass
- public static void afterClass() {
- cores.shutdown();
- cores = null;
+
+ protected void setupCoreContainer() {
+ cores = new CoreContainer(getSolrHome());
+ cores.load();
+ //cores = CoreContainer.createAndLoad(getSolrHome(), new File(TEMP_DIR, "solr.xml"));
}
@Override
@@ -71,17 +70,18 @@ public abstract class MergeIndexesExampl
System.setProperty("solr.directoryFactory", "solr.StandardDirectoryFactory");
super.setUp();
- SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
- cores.setPersistent(false);
-
// setup datadirs
- System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
-
+ System.setProperty( "solr.core0.data.dir", SolrTestCaseJ4.dataDir.getCanonicalPath() );
+
dataDir2 = new File(TEMP_DIR, getClass().getName() + "-"
+ System.currentTimeMillis());
dataDir2.mkdirs();
-
- System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
+
+ System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
+
+ setupCoreContainer();
+ SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
+
}
@Override
@@ -96,6 +96,8 @@ public abstract class MergeIndexesExampl
System.err.println("!!!! WARNING: best effort to remove " + dataDir2.getAbsolutePath() + " FAILED !!!!!");
}
}
+
+ cores.shutdown();
if (saveProp == null) System.clearProperty("solr.directoryFactory");
else System.setProperty("solr.directoryFactory", saveProp);
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java Sun Aug 11 12:19:13 2013
@@ -17,8 +17,6 @@
package org.apache.solr.client.solrj;
-import java.io.File;
-
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Unload;
@@ -30,10 +28,10 @@ import org.apache.solr.common.util.Named
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.ExternalPaths;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+
/**
*
@@ -41,30 +39,21 @@ import org.junit.Test;
*/
public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
{
- protected static CoreContainer cores;
+ protected CoreContainer cores;
private File dataDir2;
private File dataDir1;
@Override public String getSolrHome() { return ExternalPaths.EXAMPLE_MULTICORE_HOME; }
-
- @BeforeClass
- public static void beforeThisClass2() throws Exception {
+ protected void setupCoreContainer() {
cores = new CoreContainer();
- }
-
- @AfterClass
- public static void afterClass() {
- cores.shutdown();
+ cores.load();
}
@Override public void setUp() throws Exception {
super.setUp();
- SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
- cores.setPersistent(false);
-
dataDir1 = new File(TEMP_DIR, getClass().getName() + "-core0-"
+ System.currentTimeMillis());
dataDir1.mkdirs();
@@ -74,7 +63,13 @@ public abstract class MultiCoreExampleTe
dataDir2.mkdirs();
System.setProperty( "solr.core0.data.dir", this.dataDir1.getCanonicalPath() );
- System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
+ System.setProperty( "solr.core1.data.dir", this.dataDir2.getCanonicalPath() );
+
+ setupCoreContainer();
+
+ SolrCore.log.info("CORES=" + cores + " : " + cores.getCoreNames());
+
+
}
@Override
@@ -89,6 +84,8 @@ public abstract class MultiCoreExampleTe
System.err.println("!!!! WARNING: best effort to remove " + dataDir2.getAbsolutePath() + " FAILED !!!!!");
}
}
+
+ cores.shutdown();
}
@Override
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Sun Aug 11 12:19:13 2013
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.Atomi
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+
import junit.framework.Assert;
import org.apache.lucene.util._TestUtil;
@@ -209,6 +210,17 @@ abstract public class SolrExampleTests e
Assert.assertEquals("price:[* TO 2]", values.get(0));
Assert.assertEquals("price:[2 TO 4]", values.get(1));
+
+ if (jetty != null) {
+ // check system wide system handler + "/admin/info/system"
+ String url = jetty.getBaseUrl().toString();
+ HttpSolrServer client = new HttpSolrServer(url);
+ SolrQuery q = new SolrQuery();
+ q.set("qt", "/admin/info/system");
+ QueryResponse rsp = client.query(q);
+ assertNotNull(rsp.getResponse().get("mode"));
+ assertNotNull(rsp.getResponse().get("lucene"));
+ }
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/AbstractEmbeddedSolrServerTestCase.java Sun Aug 11 12:19:13 2013
@@ -51,6 +51,7 @@ public abstract class AbstractEmbeddedSo
super.setUp();
System.setProperty("solr.solr.home", SOLR_HOME.getAbsolutePath());
+ System.out.println("Solr home: " + SOLR_HOME.getAbsolutePath());
//The index is always stored within a temporary directory
createTempDir();
@@ -61,7 +62,8 @@ public abstract class AbstractEmbeddedSo
System.setProperty("dataDir2", dataDir2.getAbsolutePath());
System.setProperty("tempDir", tempDir.getAbsolutePath());
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
- cores = new CoreContainer(SOLR_HOME.getAbsolutePath(), getSolrXml());
+ cores = CoreContainer.createAndLoad(SOLR_HOME.getAbsolutePath(), getSolrXml());
+ //cores.setPersistent(false);
}
protected abstract File getSolrXml() throws Exception;
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/JettyWebappTest.java Sun Aug 11 12:19:13 2013
@@ -23,6 +23,7 @@ import java.util.Random;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.util.ExternalPaths;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
@@ -39,7 +40,7 @@ import com.carrotsearch.randomizedtestin
*
* @since solr 1.3
*/
-public class JettyWebappTest extends LuceneTestCase
+public class JettyWebappTest extends SolrTestCaseJ4
{
int port = 0;
static final String context = "/test";
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MergeIndexesEmbeddedTest.java Sun Aug 11 12:19:13 2013
@@ -17,8 +17,6 @@
package org.apache.solr.client.solrj.embedded;
-import java.io.File;
-
import org.apache.solr.client.solrj.MergeIndexesExampleTestBase;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.core.SolrCore;
@@ -36,10 +34,6 @@ public class MergeIndexesEmbeddedTest ex
// TODO: fix this test to use MockDirectoryFactory
System.clearProperty("solr.directoryFactory");
super.setUp();
-
- File home = new File(getSolrHome());
- File f = new File(home, "solr.xml");
- cores.load(getSolrHome(), f);
}
@Override
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreEmbeddedTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreEmbeddedTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreEmbeddedTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreEmbeddedTest.java Sun Aug 11 12:19:13 2013
@@ -17,8 +17,6 @@
package org.apache.solr.client.solrj.embedded;
-import java.io.File;
-
import org.apache.solr.client.solrj.MultiCoreExampleTestBase;
import org.apache.solr.client.solrj.SolrServer;
@@ -35,10 +33,6 @@ public class MultiCoreEmbeddedTest exten
// TODO: fix this test to use MockDirectoryFactory
System.clearProperty("solr.directoryFactory");
super.setUp();
-
- File home = new File( getSolrHome() );
- File f = new File( home, "solr.xml" );
- cores.load( getSolrHome(), f );
}
@Override
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/MultiCoreExampleJettyTest.java Sun Aug 11 12:19:13 2013
@@ -56,7 +56,6 @@ public class MultiCoreExampleJettyTest e
jetty.start(false);
port = jetty.getLocalPort();
- cores.setPersistent(false);
}
@Override public void tearDown() throws Exception
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java Sun Aug 11 12:19:13 2013
@@ -17,36 +17,26 @@
package org.apache.solr.client.solrj.embedded;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.*;
-
-import org.apache.commons.io.IOUtils;
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
-import org.apache.solr.client.solrj.request.*;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
+import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CoreAdminResponse;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.util.FileUtils;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.solr.core.SolrXMLCoresLocator;
+import org.apache.solr.util.TestHarness;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import java.io.File;
/**
*
@@ -56,45 +46,14 @@ public class TestSolrProperties extends
protected static Logger log = LoggerFactory.getLogger(TestSolrProperties.class);
private static final String SOLR_XML = "solr.xml";
- private static final String SOLR_PERSIST_XML = "solr-persist.xml";
@Rule
public TestRule solrTestRules =
RuleChain.outerRule(new SystemPropertiesRestoreRule());
- private static final XPathFactory xpathFactory = XPathFactory.newInstance();
-
- @Override
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- @After
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
@Override
protected File getSolrXml() throws Exception {
- //This test writes on the directory where the solr.xml is located. Better to copy the solr.xml to
- //the temporary directory where we store the index
- File origSolrXml = new File(SOLR_HOME, SOLR_XML);
- File solrXml = new File(tempDir, SOLR_XML);
- FileUtils.copyFile(origSolrXml, solrXml);
- return solrXml;
- }
-
- @Override
- protected void deleteAdditionalFiles() {
- super.deleteAdditionalFiles();
-
- //Cleans the solr.xml persisted while testing and the solr.xml copied to the temporary directory
- File persistedFile = new File(tempDir, SOLR_PERSIST_XML);
- assertTrue("Failed to delete "+persistedFile, persistedFile.delete());
- File solrXml = new File(tempDir, SOLR_XML);
- assertTrue("Failed to delete "+ solrXml, solrXml.delete());
+ return new File(SOLR_HOME, SOLR_XML);
}
protected SolrServer getSolrAdmin() {
@@ -107,6 +66,10 @@ public class TestSolrProperties extends
@Test
public void testProperties() throws Exception {
+
+ SolrXMLCoresLocator.NonPersistingLocator locator
+ = (SolrXMLCoresLocator.NonPersistingLocator) cores.getCoresLocator();
+
UpdateRequest up = new UpdateRequest();
up.setAction(ACTION.COMMIT, true, true);
up.deleteByQuery("*:*");
@@ -176,50 +139,22 @@ public class TestSolrProperties extends
long after = mcr.getStartTime(name).getTime();
assertTrue("should have more recent time: " + after + "," + before, after > before);
- mcr = CoreAdminRequest.persist(SOLR_PERSIST_XML, coreadmin);
-
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- FileInputStream fis = new FileInputStream(new File(tempDir, SOLR_PERSIST_XML));
- try {
- Document document = builder.parse(fis);
- fis.close();
- fis = new FileInputStream(new File(tempDir, SOLR_PERSIST_XML));
- String solrPersistXml = IOUtils.toString(new InputStreamReader(fis, "UTF-8"));
- //System.out.println("xml:" + solrPersistXml);
- assertTrue("\"/solr/cores[@defaultCoreName='core0']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@defaultCoreName='core0']", document));
- assertTrue("\"/solr/cores[@host='127.0.0.1']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@host='127.0.0.1']", document));
- assertTrue("\"/solr/cores[@hostPort='${hostPort:8983}']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@hostPort='${hostPort:8983}']", document));
- assertTrue("\"/solr/cores[@zkClientTimeout='8000']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@zkClientTimeout='8000']", document));
- assertTrue("\"/solr/cores[@hostContext='${hostContext:solr}']\" doesn't match in:\n" + solrPersistXml,
- exists("/solr/cores[@hostContext='${hostContext:solr}']", document));
-
- } finally {
- fis.close();
- }
+ TestHarness.validateXPath(locator.xml,
+ "/solr/cores[@defaultCoreName='core0']",
+ "/solr/cores[@host='127.0.0.1']",
+ "/solr/cores[@hostPort='${hostPort:8983}']",
+ "/solr/cores[@zkClientTimeout='8000']",
+ "/solr/cores[@hostContext='${hostContext:solr}']",
+ "/solr/cores[@genericCoreNodeNames='${genericCoreNodeNames:true}']"
+ );
CoreAdminRequest.renameCore(name, "renamed_core", coreadmin);
-
- mcr = CoreAdminRequest.persist(SOLR_PERSIST_XML, getRenamedSolrAdmin());
-
-// fis = new FileInputStream(new File(tempDir, SOLR_PERSIST_XML));
-// String solrPersistXml = IOUtils.toString(fis);
-// System.out.println("xml:" + solrPersistXml);
-// fis.close();
-
- fis = new FileInputStream(new File(tempDir, SOLR_PERSIST_XML));
- try {
- Document document = builder.parse(fis);
- assertTrue(exists("/solr/cores/core[@name='renamed_core']", document));
- assertTrue(exists("/solr/cores/core[@instanceDir='${theInstanceDir:./}']", document));
- assertTrue(exists("/solr/cores/core[@collection='${collection:acollection}']", document));
-
- } finally {
- fis.close();
- }
+
+ TestHarness.validateXPath(locator.xml,
+ "/solr/cores/core[@name='renamed_core']",
+ "/solr/cores/core[@instanceDir='${theInstanceDir:./}']",
+ "/solr/cores/core[@collection='${collection:acollection}']"
+ );
coreadmin = getRenamedSolrAdmin();
File dataDir = new File(tempDir,"data3");
@@ -229,49 +164,8 @@ public class TestSolrProperties extends
coreadmin, null, null, dataDir.getAbsolutePath(),
tlogDir.getAbsolutePath());
-// fis = new FileInputStream(new File(solrXml.getParent(), SOLR_PERSIST_XML));
-// solrPersistXml = IOUtils.toString(fis);
-// System.out.println("xml:" + solrPersistXml);
-// fis.close();
-
- mcr = CoreAdminRequest.persist(SOLR_PERSIST_XML, getRenamedSolrAdmin());
-
-// fis = new FileInputStream(new File(solrXml.getParent(), SOLR_PERSIST_XML));
-// solrPersistXml = IOUtils.toString(fis);
-// System.out.println("xml:" + solrPersistXml);
-// fis.close();
-
- fis = new FileInputStream(new File(tempDir, SOLR_PERSIST_XML));
- try {
- Document document = builder.parse(fis);
- assertTrue(exists("/solr/cores/core[@name='collection1' and (@instanceDir='./' or @instanceDir='.\\')]", document));
- } finally {
- fis.close();
- }
-
- // test reload and parse
- cores.shutdown();
-
-// fis = new FileInputStream(new File(getSolrXml().getParent(),
-// SOLR_PERSIST_XML));
-// String solrPersistXml = IOUtils.toString(fis);
-// System.out.println("xml:" + solrPersistXml);
-// fis.close();
-
- cores = new CoreContainer(SOLR_HOME.getAbsolutePath(), new File(tempDir, SOLR_PERSIST_XML));
-
- mcr = CoreAdminRequest.persist(SOLR_PERSIST_XML, getRenamedSolrAdmin());
-
-// fis = new FileInputStream(new File(solrXml.getParent(),
-// SOLR_PERSIST_XML));
-// solrPersistXml = IOUtils.toString(fis);
-// System.out.println("xml:" + solrPersistXml);
-// fis.close();
- }
-
- public static boolean exists(String xpathStr, Node node)
- throws XPathExpressionException {
- XPath xpath = xpathFactory.newXPath();
- return (Boolean) xpath.evaluate(xpathStr, node, XPathConstants.BOOLEAN);
+ TestHarness.validateXPath(locator.xml, "/solr/cores/core[@name='collection1' and @instanceDir='.']");
+
}
+
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrServerTest.java Sun Aug 11 12:19:13 2013
@@ -495,6 +495,22 @@ public class BasicHttpSolrServerTest ext
client.getConnectionManager().shutdown();
}
+ /**
+ * A trivial test that verifies the example keystore used for SSL testing can be
+ * found using the base class. this helps future-proof against hte possibility of
+ * something moving/breaking thekeystore path in a way that results in the SSL
+ * randomization logic being forced to silently never use SSL. (We can't enforce
+ * this type of check in the base class because then it would not be usable by client
+ * code depending on the test framework
+ */
+ public void testExampleKeystorePath() {
+ assertNotNull("Example keystore is null, meaning that something has changed in the " +
+ "structure of the example configs and/or ExternalPaths.java - " +
+ "SSL randomization is broken",
+ getExampleKeystoreFile());
+ }
+
+
private int findUnusedPort() {
for (int port = 0; port < 65535; port++) {
Socket s = new Socket();
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java Sun Aug 11 12:19:13 2013
@@ -102,35 +102,39 @@ public class CloudSolrServerTest extends
indexr(id, 0, "a_t", "to come to the aid of their country.");
- // compare leaders list
CloudJettyRunner shard1Leader = shardToLeaderJetty.get("shard1");
CloudJettyRunner shard2Leader = shardToLeaderJetty.get("shard2");
- assertEquals(2, cloudClient.getLeaderUrlLists().get("collection1").size());
- HashSet<String> leaderUrlSet = new HashSet<String>();
- leaderUrlSet.addAll(cloudClient.getLeaderUrlLists().get("collection1"));
- assertTrue("fail check for leader:" + shard1Leader.url + " in "
- + leaderUrlSet, leaderUrlSet.contains(shard1Leader.url + "/"));
- assertTrue("fail check for leader:" + shard2Leader.url + " in "
- + leaderUrlSet, leaderUrlSet.contains(shard2Leader.url + "/"));
-
- // compare replicas list
- Set<String> replicas = new HashSet<String>();
- List<CloudJettyRunner> jetties = shardToJetty.get("shard1");
- for (CloudJettyRunner cjetty : jetties) {
- replicas.add(cjetty.url);
- }
- jetties = shardToJetty.get("shard2");
- for (CloudJettyRunner cjetty : jetties) {
- replicas.add(cjetty.url);
- }
- replicas.remove(shard1Leader.url);
- replicas.remove(shard2Leader.url);
-
- assertEquals(replicas.size(), cloudClient.getReplicasLists().get("collection1").size());
- for (String url : cloudClient.getReplicasLists().get("collection1")) {
- assertTrue("fail check for replica:" + url + " in " + replicas,
- replicas.contains(stripTrailingSlash(url)));
+ if (cloudClient.isUpdatesToLeaders()) {
+ // compare leaders list
+ assertEquals(2, cloudClient.getLeaderUrlLists().get("collection1").size());
+ HashSet<String> leaderUrlSet = new HashSet<String>();
+ leaderUrlSet.addAll(cloudClient.getLeaderUrlLists().get("collection1"));
+ assertTrue("fail check for leader:" + shard1Leader.url + " in "
+ + leaderUrlSet, leaderUrlSet.contains(shard1Leader.url + "/"));
+ assertTrue("fail check for leader:" + shard2Leader.url + " in "
+ + leaderUrlSet, leaderUrlSet.contains(shard2Leader.url + "/"));
+
+ // compare replicas list
+ Set<String> replicas = new HashSet<String>();
+ List<CloudJettyRunner> jetties = shardToJetty.get("shard1");
+ for (CloudJettyRunner cjetty : jetties) {
+ replicas.add(cjetty.url);
+ }
+ jetties = shardToJetty.get("shard2");
+ for (CloudJettyRunner cjetty : jetties) {
+ replicas.add(cjetty.url);
+ }
+ replicas.remove(shard1Leader.url);
+ replicas.remove(shard2Leader.url);
+
+ assertEquals(replicas.size(),
+ cloudClient.getReplicasLists().get("collection1").size());
+
+ for (String url : cloudClient.getReplicasLists().get("collection1")) {
+ assertTrue("fail check for replica:" + url + " in " + replicas,
+ replicas.contains(stripTrailingSlash(url)));
+ }
}
}
Modified: lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java (original)
+++ lucene/dev/branches/lucene4956/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestCoreAdmin.java Sun Aug 11 12:19:13 2013
@@ -17,8 +17,8 @@
package org.apache.solr.client.solrj.request;
-import java.io.File;
-
+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrIgnoredThreadsFilter;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.embedded.AbstractEmbeddedSolrServerTestCase;
@@ -27,14 +27,13 @@ import org.apache.solr.common.SolrExcept
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
-import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
+import java.io.File;
@ThreadLeakFilters(defaultFilters = true, filters = {SolrIgnoredThreadsFilter.class})
public class TestCoreAdmin extends AbstractEmbeddedSolrServerTestCase {
@@ -67,6 +66,8 @@ public class TestCoreAdmin extends Abstr
File tmp = new File(TEMP_DIR, "solrtest-" + getTestClass().getSimpleName() + "-" + System.currentTimeMillis());
tmp.mkdirs();
+
+ log.info("Creating cores underneath {}", tmp);
File dataDir = new File(tmp, this.getTestName()
+ System.currentTimeMillis() + "-" + "data");
@@ -103,7 +104,7 @@ public class TestCoreAdmin extends Abstr
File logDir;
try {
- logDir = core.getUpdateHandler().getUpdateLog().getLogDir();
+ logDir = new File(core.getUpdateHandler().getUpdateLog().getLogDir());
} finally {
coreProveIt.close();
core.close();
Modified: lucene/dev/branches/lucene4956/solr/test-framework/ivy.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/test-framework/ivy.xml?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/test-framework/ivy.xml (original)
+++ lucene/dev/branches/lucene4956/solr/test-framework/ivy.xml Sun Aug 11 12:19:13 2013
@@ -16,6 +16,9 @@
specific language governing permissions and limitations
under the License.
-->
+<!DOCTYPE ivy-module [
+ <!ENTITY hadoop.version "2.0.5-alpha">
+]>
<ivy-module version="2.0">
<info organisation="org.apache.solr" module="solr-test-framework"/>
@@ -31,7 +34,9 @@
<dependencies defaultconf="default">
<dependency org="org.apache.ant" name="ant" rev="1.8.2" transitive="false" />
- <dependency org="junit" name="junit" rev="4.10" transitive="false" conf="default->*;junit4-stdalone->*" />
+ <dependency org="junit" name="junit" rev="4.10" transitive="false" conf="default->*;junit4-stdalone->*">
+ <exclude org="org.hamcrest" module="hamcrest-core"/>
+ </dependency>
<dependency org="com.carrotsearch.randomizedtesting" name="junit4-ant" rev="2.0.10" transitive="false" conf="default->*;junit4-stdalone->*" />
<dependency org="com.carrotsearch.randomizedtesting" name="randomizedtesting-runner" rev="2.0.10" transitive="false" conf="default->*;junit4-stdalone->*" />
Modified: lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java (original)
+++ lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java Sun Aug 11 12:19:13 2013
@@ -45,6 +45,7 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.client.solrj.response.UpdateResponse;
+import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
@@ -424,6 +425,9 @@ public abstract class BaseDistributedSea
indexDoc(doc);
}
+ /**
+ * Indexes the document in both the control client, and a randomly selected client
+ */
protected void indexDoc(SolrInputDocument doc) throws IOException, SolrServerException {
controlClient.add(doc);
@@ -432,6 +436,17 @@ public abstract class BaseDistributedSea
client.add(doc);
}
+ /**
+ * Indexes the document in both the control client and the specified client asserting
+ * that the respones are equivilent
+ */
+ protected UpdateResponse indexDoc(SolrServer server, SolrParams params, SolrInputDocument... sdocs) throws IOException, SolrServerException {
+ UpdateResponse controlRsp = add(controlClient, params, sdocs);
+ UpdateResponse specificRsp = add(server, params, sdocs);
+ compareSolrResponses(specificRsp, controlRsp);
+ return specificRsp;
+ }
+
protected UpdateResponse add(SolrServer server, SolrParams params, SolrInputDocument... sdocs) throws IOException, SolrServerException {
UpdateRequest ureq = new UpdateRequest();
ureq.setParams(new ModifiableSolrParams(params));
@@ -546,6 +561,9 @@ public abstract class BaseDistributedSea
}
public QueryResponse queryAndCompare(SolrParams params, SolrServer... servers) throws SolrServerException {
+ return queryAndCompare(params, Arrays.<SolrServer>asList(servers));
+ }
+ public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrServer> servers) throws SolrServerException {
QueryResponse first = null;
for (SolrServer server : servers) {
QueryResponse rsp = server.query(new ModifiableSolrParams(params));
@@ -783,8 +801,14 @@ public abstract class BaseDistributedSea
return null;
}
+ protected void compareSolrResponses(SolrResponse a, SolrResponse b) {
+ String cmp = compare(a.getResponse(), b.getResponse(), flags, handle);
+ if (cmp != null) {
+ log.error("Mismatched responses:\n" + a + "\n" + b);
+ Assert.fail(cmp);
+ }
+ }
protected void compareResponses(QueryResponse a, QueryResponse b) {
- String cmp;
if (System.getProperty("remove.version.field") != null) {
// we don't care if one has a version and the other doesnt -
// control vs distrib
@@ -800,11 +824,7 @@ public abstract class BaseDistributedSea
}
}
}
- cmp = compare(a.getResponse(), b.getResponse(), flags, handle);
- if (cmp != null) {
- log.error("Mismatched responses:\n" + a + "\n" + b);
- Assert.fail(cmp);
- }
+ compareSolrResponses(a, b);
}
@Test
Modified: lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java (original)
+++ lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java Sun Aug 11 12:19:13 2013
@@ -21,6 +21,8 @@ import org.noggit.ObjectBuilder;
import org.apache.solr.common.util.StrUtils;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class JSONTestUtil {
@@ -179,6 +181,13 @@ class CollectionTester {
// generic fallback
if (!expected.equals(val)) {
+ if (expected instanceof String) {
+ String str = (String)expected;
+ if (str.length() > 6 && str.startsWith("///") && str.endsWith("///")) {
+ return handleSpecialString(str);
+ }
+ }
+
// make an exception for some numerics
if ((expected instanceof Integer && val instanceof Long || expected instanceof Long && val instanceof Integer)
&& ((Number)expected).longValue() == ((Number)val).longValue()) {
@@ -197,6 +206,29 @@ class CollectionTester {
return true;
}
+ private boolean handleSpecialString(String str) {
+ String code = str.substring(3,str.length()-3);
+ if ("ignore".equals(code)) {
+ return true;
+ } else if (code.startsWith("regex:")) {
+ String regex = code.substring("regex:".length());
+ if (!(val instanceof String)) {
+ setErr("mismatch: '" + expected + "'!='" + val + "', value is not a string");
+ return false;
+ }
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher((String)val);
+ if (matcher.find()) {
+ return true;
+ }
+ setErr("mismatch: '" + expected + "'!='" + val + "', regex does not match");
+ return false;
+ }
+
+ setErr("mismatch: '" + expected + "'!='" + val + "'");
+ return false;
+ }
+
boolean matchList() {
List expectedList = (List)expected;
List v = asList();
Modified: lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java?rev=1512909&r1=1512908&r2=1512909&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java (original)
+++ lucene/dev/branches/lucene4956/solr/test-framework/src/java/org/apache/solr/SolrJettyTestBase.java Sun Aug 11 12:19:13 2013
@@ -44,18 +44,32 @@ abstract public class SolrJettyTestBase
public String getSolrHome() { return ExternalPaths.EXAMPLE_HOME; }
private static boolean manageSslProps = true;
- private static final File TEST_KEYSTORE = new File(ExternalPaths.SOURCE_HOME,
- "example/etc/solrtest.keystore");
+ private static File TEST_KEYSTORE;
private static final Map<String,String> SSL_PROPS = new HashMap<String,String>();
static {
+ TEST_KEYSTORE = (null == ExternalPaths.SOURCE_HOME)
+ ? null : new File(ExternalPaths.SOURCE_HOME, "example/etc/solrtest.keystore");
+ String keystorePath = null == TEST_KEYSTORE ? null : TEST_KEYSTORE.getAbsolutePath();
+
SSL_PROPS.put("tests.jettySsl","false");
SSL_PROPS.put("tests.jettySsl.clientAuth","false");
- SSL_PROPS.put("javax.net.ssl.keyStore", TEST_KEYSTORE.getAbsolutePath());
+ SSL_PROPS.put("javax.net.ssl.keyStore", keystorePath);
SSL_PROPS.put("javax.net.ssl.keyStorePassword","secret");
- SSL_PROPS.put("javax.net.ssl.trustStore", TEST_KEYSTORE.getAbsolutePath());
+ SSL_PROPS.put("javax.net.ssl.trustStore", keystorePath);
SSL_PROPS.put("javax.net.ssl.trustStorePassword","secret");
}
+ /**
+ * Returns the File object for the example keystore used when this baseclass randomly
+ * uses SSL. May be null ifthis test does not appear to be running as part of the
+ * standard solr distribution and does not have access to the example configs.
+ *
+ * @lucene.internal
+ */
+ protected static File getExampleKeystoreFile() {
+ return TEST_KEYSTORE;
+ }
+
@BeforeClass
public static void beforeSolrJettyTestBase() throws Exception {
@@ -63,20 +77,27 @@ abstract public class SolrJettyTestBase
final boolean trySsl = random().nextBoolean();
final boolean trySslClientAuth = random().nextBoolean();
+ // only randomize SSL if we are a solr test with access to the example keystore
+ if (null == getExampleKeystoreFile()) {
+ log.info("Solr's example keystore not defined (not a solr test?) skipping SSL randomization");
+ manageSslProps = false;
+ return;
+ }
+
+ assertTrue("test keystore does not exist, randomized ssl testing broken: " +
+ getExampleKeystoreFile().getAbsolutePath(),
+ getExampleKeystoreFile().exists() );
+
// only randomize SSL if none of the SSL_PROPS are already set
final Map<Object,Object> sysprops = System.getProperties();
for (String prop : SSL_PROPS.keySet()) {
if (sysprops.containsKey(prop)) {
log.info("System property explicitly set, so skipping randomized ssl properties: " + prop);
manageSslProps = false;
- break;
+ return;
}
}
- assertTrue("test keystore does not exist, can't be used for randomized " +
- "ssl testing: " + TEST_KEYSTORE.getAbsolutePath(),
- TEST_KEYSTORE.exists() );
-
if (manageSslProps) {
log.info("Randomized ssl ({}) and clientAuth ({})", trySsl, trySslClientAuth);
for (String prop : SSL_PROPS.keySet()) {