You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Yonik Seeley <yo...@lucidimagination.com> on 2010/02/09 21:22:52 UTC
Re: svn commit: r908194 - in /lucene/solr/branches/cloud/src:
solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java
test/org/apache/solr/BaseDistributedSearchTestCase.java test/org/apache/solr/cloud/BasicDistributedZkTest.java
On Tue, Feb 9, 2010 at 3:10 PM, <yo...@apache.org> wrote:
> Author: yonik
> Date: Tue Feb 9 20:10:12 2010
> New Revision: 908194
>
> URL: http://svn.apache.org/viewvc?rev=908194&view=rev
> Log:
> solrj distrib test code - test currently fails when enabled
Scratch that - it was only failing because I had another solr server
up at port 8983, and the test framework incorrectly registers a node
at that same port.
-Yonik
http://www.lucidimagination.com
> Modified:
> lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java
> lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
> lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
>
> Modified: lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java
> URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java?rev=908194&r1=908193&r2=908194&view=diff
> ==============================================================================
> --- lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java (original)
> +++ lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/CloudSolrServer.java Tue Feb 9 20:10:12 2010
> @@ -118,7 +118,7 @@
> }
>
> Collections.shuffle(urlList, rand);
> -
> + // System.out.println("########################## MAKING REQUEST TO " + urlList);
> // TODO: set distrib=true if we detected more than one shard?
> LBHttpSolrServer.Req req = new LBHttpSolrServer.Req(request, urlList);
> LBHttpSolrServer.Rsp rsp = lbServer.request(req);
>
> Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
> URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java?rev=908194&r1=908193&r2=908194&view=diff
> ==============================================================================
> --- lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java (original)
> +++ lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java Tue Feb 9 20:10:12 2010
> @@ -290,6 +290,14 @@
> for (SolrServer client : clients) client.commit();
> }
>
> + protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
> + // query a random server
> + int which = r.nextInt(clients.size());
> + SolrServer client = clients.get(which);
> + QueryResponse rsp = client.query(params);
> + return rsp;
> + }
> +
> protected void query(Object... q) throws Exception {
> final ModifiableSolrParams params = new ModifiableSolrParams();
>
> @@ -300,10 +308,8 @@
> final QueryResponse controlRsp = controlClient.query(params);
>
> setDistributedParams(params);
> - // query a random server
> - int which = r.nextInt(clients.size());
> - SolrServer client = clients.get(which);
> - QueryResponse rsp = client.query(params);
> +
> + QueryResponse rsp = queryServer(params);
>
> //compareResponses(rsp, controlRsp);
>
>
> Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
> URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=908194&r1=908193&r2=908194&view=diff
> ==============================================================================
> --- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
> +++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Tue Feb 9 20:10:12 2010
> @@ -17,10 +17,14 @@
> * limitations under the License.
> */
>
> +import java.net.MalformedURLException;
> import java.util.HashSet;
>
> +import org.apache.solr.client.solrj.SolrServer;
> import org.apache.solr.client.solrj.SolrServerException;
> import org.apache.solr.client.solrj.embedded.JettySolrRunner;
> +import org.apache.solr.client.solrj.impl.CloudSolrServer;
> +import org.apache.solr.client.solrj.response.QueryResponse;
> import org.apache.solr.common.params.ModifiableSolrParams;
> import org.apache.solr.core.CoreDescriptor;
> import org.apache.solr.core.SolrCore;
> @@ -259,4 +263,29 @@
> super.printLayout();
>
> }
> +
> +
> + volatile CloudSolrServer solrj;
> +
> + @Override
> + protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
> + if (true || r.nextBoolean())
> + return super.queryServer(params);
> +
> + // use the distributed solrj client
> + if (solrj == null) {
> + synchronized(this) {
> + try {
> + CloudSolrServer server = new CloudSolrServer(AbstractZkTestCase.ZOO_KEEPER_ADDRESS);
> + server.setDefaultCollection("collection1");
> + solrj = server;
> + } catch (MalformedURLException e) {
> + throw new RuntimeException(e);
> + }
> + }
> + }
> +
> + QueryResponse rsp = solrj.query(params);
> + return rsp;
> + }
> }
>
>
>