Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8407BD218 for ; Wed, 19 Dec 2012 03:44:54 +0000 (UTC) Received: (qmail 71009 invoked by uid 500); 19 Dec 2012 03:44:53 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 70954 invoked by uid 99); 19 Dec 2012 03:44:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 03:44:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 03:44:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 80F6723889B8; Wed, 19 Dec 2012 03:44:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1423753 - in /lucene/dev/trunk/solr: core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Date: Wed, 19 Dec 2012 03:44:30 -0000 To: commits@lucene.apache.org From: yonik@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121219034430.80F6723889B8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: yonik Date: Wed Dec 19 03:44:29 2012 New Revision: 1423753 URL: http://svn.apache.org/viewvc?rev=1423753&view=rev Log: tests: start single jetty in cloud mode w/ manual shard assignment Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java?rev=1423753&r1=1423752&r2=1423753&view=diff ============================================================================== --- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java (original) +++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ShardRoutingCustomTest.java Wed Dec 19 03:44:29 2012 @@ -32,6 +32,8 @@ import java.util.Set; public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase { + String collection = DEFAULT_COLLECTION; // enable this to be configurable (more work needs to be done) + @BeforeClass public static void beforeShardHashingTest() throws Exception { useFactory(null); @@ -51,7 +53,7 @@ public class ShardRoutingCustomTest exte testFinished = true; } finally { if (!testFinished) { - printLayoutOnTearDown = true; + printLayout(); } } } @@ -59,8 +61,9 @@ public class ShardRoutingCustomTest exte private void doCustomSharding() throws Exception { printLayout(); + startCloudJetty(collection, "shardA"); - + printLayout(); } Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1423753&r1=1423752&r2=1423753&view=diff ============================================================================== --- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original) +++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Wed Dec 19 03:44:29 2012 @@ -259,6 +259,7 @@ public abstract class AbstractFullDistri controlClientCloud.connect(); waitForCollection(controlClientCloud.getZkStateReader(), "control_collection", 0); // NOTE: we are skipping creation of the chaos monkey by returning here + cloudClient = controlClientCloud; // temporary - some code needs/uses cloudClient return; } @@ -326,10 +327,10 @@ public abstract class AbstractFullDistri if (checkCreatedVsState) { // now wait until we see that the number of shards in the cluster state // matches what we expect - int numShards = getNumShards(DEFAULT_COLLECTION); + int numShards = getTotalReplicas(DEFAULT_COLLECTION); int retries = 0; while (numShards != shardCount) { - numShards = getNumShards(DEFAULT_COLLECTION); + numShards = getTotalReplicas(DEFAULT_COLLECTION); if (numShards == shardCount) break; if (retries++ == 60) { printLayoutOnTearDown = true; @@ -361,17 +362,53 @@ public abstract class AbstractFullDistri return jettys; } - protected int getNumShards(String collection) { - ZkStateReader zkStateReader = cloudClient.getZkStateReader(); - Map slices = zkStateReader.getClusterState().getSlicesMap(collection); - if (slices == null) { - throw new IllegalArgumentException("Could not find collection:" + collection); + + protected SolrServer startCloudJetty(String collection, String shard) throws Exception { + + // TODO: use the collection string!!!! + collection = DEFAULT_COLLECTION; + + int totalReplicas = getTotalReplicas(collection); + + + int cnt = this.jettyIntCntr.incrementAndGet(); + File jettyDir = new File(TEMP_DIR, + getClass().getName() + "-jetty" + cnt + "-" + System.currentTimeMillis()); + jettyDir.mkdirs(); + org.apache.commons.io.FileUtils.copyDirectory(new File(getSolrHome()), jettyDir); + JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null); + jettys.add(j); + SolrServer client = createNewSolrServer(j.getLocalPort()); + clients.add(client); + + int retries = 60; + while (--retries >= 0) { + // total replicas changed.. assume it was us + if (getTotalReplicas(collection) != totalReplicas) { + break; + } + Thread.sleep(500); } + + if (retries <= 0) { + fail("Timeout waiting for " + j + " to appear in clusterstate"); + printLayout(); + } + + updateMappingsFromZk(this.jettys, this.clients); + return client; + } + + + /* Total number of replicas (number of cores serving an index to the collection) shown by the cluster state */ + protected int getTotalReplicas(String collection) { + ZkStateReader zkStateReader = cloudClient.getZkStateReader(); + DocCollection coll = zkStateReader.getClusterState().getCollectionStates().get(collection); + if (coll == null) return 0; // support for when collection hasn't been created yet int cnt = 0; - for (Map.Entry entry : slices.entrySet()) { - cnt += entry.getValue().getReplicasMap().size(); + for (Slice slices : coll.getSlices()) { + cnt += slices.getReplicas().size(); } - return cnt; } @@ -842,24 +879,24 @@ public abstract class AbstractFullDistri } - private String toStr(SolrDocumentList lst) { - if (lst.size() <= 10) return lst.toString(); + private String toStr(SolrDocumentList lst, int maxSz) { + if (lst.size() <= maxSz) return lst.toString(); StringBuilder sb = new StringBuilder("SolrDocumentList[sz=" + lst.size()); if (lst.size() != lst.getNumFound()) { sb.append(" numFound=" + lst.getNumFound()); } sb.append("]="); - sb.append(lst.subList(0,5).toString()); + sb.append(lst.subList(0,maxSz/2).toString()); sb.append(" , [...] , "); - sb.append(lst.subList(lst.size()-5, lst.size()).toString()); + sb.append(lst.subList(lst.size()-maxSz/2, lst.size()).toString()); return sb.toString(); } Set showDiff(SolrDocumentList a, SolrDocumentList b, String aName, String bName) { - System.err.println("######"+aName+ ": " + toStr(a)); - System.err.println("######"+bName+ ": " + toStr(b)); + System.err.println("######"+aName+ ": " + toStr(a,10)); + System.err.println("######"+bName+ ": " + toStr(b,10)); System.err.println("###### sizes=" + a.size() + "," + b.size()); Set setA = new HashSet();