lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1206383 - in /lucene/dev/branches/solrcloud/solr: core/src/java/org/apache/solr/client/solrj/embedded/ core/src/java/org/apache/solr/cloud/ core/src/java/org/apache/solr/core/ core/src/java/org/apache/solr/handler/ core/src/java/org/apache...
Date Sat, 26 Nov 2011 00:24:52 GMT
Author: markrmiller
Date: Sat Nov 26 00:24:47 2011
New Revision: 1206383

URL: http://svn.apache.org/viewvc?rev=1206383&view=rev
Log:
track SolrZkClient open/closes and assert they match in tests, remove many system.outs, make
zk tests quieter in ant test

Modified:
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/core/CoreContainer.java
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullDistributedZkTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkLockTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/lock/WriteLockTest.java
    lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
    lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
    lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
    lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
Sat Nov 26 00:24:47 2011
@@ -105,7 +105,6 @@ public class JettySolrRunner {
 
       public void lifeCycleStarted(LifeCycle arg0) {
         lastPort = getLocalPort();
-        System.out.println("start on port:" + lastPort);
         System.setProperty("hostPort", Integer.toString(lastPort));
         if (solrConfigFilename != null) System.setProperty("solrconfig",
             solrConfigFilename);

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
Sat Nov 26 00:24:47 2011
@@ -193,7 +193,7 @@ public final class ZkController {
     } catch (InterruptedException e) {
       // Restore the interrupted status
       Thread.currentThread().interrupt();
-      log.error("", e);
+      log.warn("", e);
       throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
           "", e);
     }
@@ -449,8 +449,6 @@ public final class ZkController {
     
     String leaderUrl = zkStateReader.getLeader(collection, cloudDesc.getShardId());
     
-    System.out.println("leader url: "+ leaderUrl);
-    System.out.println("shard url: "+ shardUrl);
     boolean iamleader = false;
     boolean doRecovery = true;
     if (leaderUrl.equals(shardUrl)) {
@@ -477,8 +475,6 @@ public final class ZkController {
     
     if (doRecovery) {
       doRecovery(collection, desc, cloudDesc, iamleader);
-    } else {
-      System.out.println("dont do recovery");
     }
     addToZk(collection, desc, cloudDesc, shardUrl, shardZkNodeName, ZkStateReader.ACTIVE);
 
@@ -586,16 +582,12 @@ public final class ZkController {
   private void doRecovery(String collection, final CoreDescriptor desc,
       final CloudDescriptor cloudDesc, boolean iamleader) throws Exception,
       SolrServerException, IOException {
-    System.out.println("do recovery");
-    
     // start buffer updates to tran log
     // and do recovery - either replay via realtime get 
     // or full index replication
 
     // seems perhaps we cannot do this here since we are not fully running - 
     // we may need to trigger a recovery that happens later
-    System.out.println("shard is:" + cloudDesc.getShardId());
-    System.out.println("leader:" + iamleader);
     
     String leaderUrl = zkStateReader.getLeader(collection, cloudDesc.getShardId());
     

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/core/CoreContainer.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/core/CoreContainer.java
Sat Nov 26 00:24:47 2011
@@ -447,7 +447,13 @@ public class CoreContainer 
     }
     return properties;
   }
+  
   private boolean isShutDown = false;
+  
+  public boolean isShutDown() {
+    return isShutDown;
+  }
+
   /**
    * Stops all cores.
    */

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
Sat Nov 26 00:24:47 2011
@@ -146,7 +146,6 @@ public class ReplicationHandler extends 
         // the CMD_GET_FILE_LIST command.
         //
         core.getDeletionPolicy().setReserveDuration(commitPoint.getVersion(), reserveCommitDuration);
-        System.out.println("return version: " + commitPoint.getVersion());
         rsp.add(CMD_INDEX_VERSION, commitPoint.getVersion());
         rsp.add(GENERATION, commitPoint.getGeneration());
       } else {
@@ -777,7 +776,6 @@ public class ReplicationHandler extends 
 
   void refreshCommitpoint(boolean force) {
     IndexCommit commitPoint = core.getDeletionPolicy().getLatestCommit();
-    System.out.println("refresh commit point to:" + commitPoint.getVersion());
     if(force || replicateOnCommit || (replicateOnOptimize && commitPoint.getSegmentCount()
== 1)) {
       indexCommitPoint = commitPoint;
     }

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/SnapPuller.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/handler/SnapPuller.java
Sat Nov 26 00:24:47 2011
@@ -548,8 +548,6 @@ public class SnapPuller {
   private void downloadIndexFiles(boolean downloadCompleteIndex, File tmpIdxDir, long latestVersion)
throws Exception {
     for (Map<String, Object> file : filesToDownload) {
       File localIndexFile = new File(solrCore.getNewIndexDir(), (String) file.get(NAME));
-      System.out.println("look at file:" + localIndexFile);
-      System.out.println("exits" + localIndexFile.exists());
       if (!localIndexFile.exists() || downloadCompleteIndex) {
         fileFetcher = new FileFetcher(tmpIdxDir, file, (String) file.get(NAME), false, latestVersion);
         currentFile = file;

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
Sat Nov 26 00:24:47 2011
@@ -430,8 +430,10 @@ public class DistributedUpdateProcessor 
     CloudState cloudState = req.getCore().getCoreDescriptor()
         .getCoreContainer().getZkController().getCloudState();
     Slice replicas = cloudState.getSlices(collection).get(shardId);
+    
+    // nocommit: ignore shards on nodes that are down
     Map<String,ZkNodeProps> shardMap = replicas.getShards();
-    //String self = null;
+
     StringBuilder replicasUrl = new StringBuilder();
     for (Entry<String,ZkNodeProps> entry : shardMap.entrySet()) {
       if (replicasUrl.length() > 0) {

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractDistributedZkTestCase.java
Sat Nov 26 00:24:47 2011
@@ -23,6 +23,7 @@ import org.apache.solr.BaseDistributedSe
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.core.SolrConfig;
+import org.junit.AfterClass;
 import org.junit.Before;
 
 public abstract class AbstractDistributedZkTestCase extends BaseDistributedSearchTestCase
{
@@ -90,4 +91,10 @@ public abstract class AbstractDistribute
     zkClient.printLayoutToStdOut();
     zkClient.close();
   }
+  
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
 }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/AbstractZkTestCase.java
Sat Nov 26 00:24:47 2011
@@ -111,11 +111,14 @@ public abstract class AbstractZkTestCase
   }
   
   @AfterClass
-  public static void azt_afterClass() throws IOException {
+  public static void azt_afterClass() throws Exception {
     zkServer.shutdown();
     System.clearProperty("zkHost");
     System.clearProperty("solr.test.sys.prop1");
     System.clearProperty("solr.test.sys.prop2");
+
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
   }
 
   protected void printLayout(String zkHost) throws Exception {

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
Sat Nov 26 00:24:47 2011
@@ -270,6 +270,9 @@ public class BasicDistributedZkTest exte
   @Override
   public void tearDown() throws Exception {
     super.tearDown();
+    if (solrj != null) {
+      solrj.close();
+    }
     System.clearProperty("CLOUD_UPDATE_DELAY");
     System.clearProperty("zkHost");
   }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/CloudStateUpdateTest.java
Sat Nov 26 00:24:47 2011
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
  */
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Map;
 import java.util.Set;
 
@@ -27,14 +26,13 @@ import org.apache.solr.common.cloud.Clou
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkNodeProps;
-import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreContainer.Initializer;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
 import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -72,6 +70,12 @@ public class CloudStateUpdateTest extend
   @BeforeClass
   public static void beforeClass() throws Exception {
   }
+  
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
 
   @Override
   public void setUp() throws Exception {
@@ -231,7 +235,9 @@ public class CloudStateUpdateTest extend
     }
     container1.shutdown();
     container2.shutdown();
-    container3.shutdown();
+    if (!container3.isShutDown()) {
+      container3.shutdown();
+    }
     zkServer.shutdown();
     super.tearDown();
     System.clearProperty("zkClientTimeout");

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullDistributedZkTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullDistributedZkTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullDistributedZkTest.java
Sat Nov 26 00:24:47 2011
@@ -53,7 +53,7 @@ import org.junit.BeforeClass;
 public class FullDistributedZkTest extends AbstractDistributedZkTestCase {
   
   private static final String DEFAULT_COLLECTION = "collection1";
-  private static final boolean DEBUG = true;
+  private static final boolean DEBUG = false;
   String t1="a_t";
   String i1="a_si";
   String nint = "n_i";
@@ -79,7 +79,7 @@ public class FullDistributedZkTest exten
   protected Map<String,List<CloudJettyRunner>> shardToJetty = new HashMap<String,List<CloudJettyRunner>>();
   private AtomicInteger i = new AtomicInteger(0);
   private ChaosMonkey chaosMonkey;
-  private volatile ZkStateReader zk;
+  private volatile ZkStateReader zkStateReader;
   
   class CloudJettyRunner {
     JettySolrRunner jetty;
@@ -100,10 +100,6 @@ public class FullDistributedZkTest exten
     }
     
     private JettySolrRunner killShard(String slice, int index) throws Exception {
-      // kill
-      System.out.println(" KILL:" + shardToClient);
-      System.out.println(shardToJetty.get(slice));
-      
       // kill first shard in shard2
       JettySolrRunner jetty = shardToJetty.get(slice).get(index).jetty;
       jetty.stop();
@@ -120,8 +116,8 @@ public class FullDistributedZkTest exten
     
     private JettySolrRunner killRandomShard(String slice) throws Exception {
       // get latest cloud state
-      zk.updateCloudState(true);
-      Slice theShards = zk.getCloudState().getSlices(DEFAULT_COLLECTION)
+      zkStateReader.updateCloudState(true);
+      Slice theShards = zkStateReader.getCloudState().getSlices(DEFAULT_COLLECTION)
           .get(slice);
       int numRunning = 0;
       
@@ -134,7 +130,7 @@ public class FullDistributedZkTest exten
         
         if (!cloudJetty.jetty.isRunning()
             || state.equals(ZkStateReader.RECOVERING)
-            || !zk.getCloudState().liveNodesContain(nodeName)) {
+            || !zkStateReader.getCloudState().liveNodesContain(nodeName)) {
           running = false;
         }
         
@@ -161,7 +157,7 @@ public class FullDistributedZkTest exten
   @Override
   public void setUp() throws Exception {
     super.setUp();
-    zk = new ZkStateReader(zkServer.getZkAddress(), 10000,
+    zkStateReader = new ZkStateReader(zkServer.getZkAddress(), 10000,
         AbstractZkTestCase.TIMEOUT);
   }
   
@@ -243,8 +239,8 @@ public class FullDistributedZkTest exten
     for (SolrServer client : clients) {
       // find info for this client in zk
 
-      zk.updateCloudState(true);
-      Map<String,Slice> slices = zk.getCloudState().getSlices(
+      zkStateReader.updateCloudState(true);
+      Map<String,Slice> slices = zkStateReader.getCloudState().getSlices(
           DEFAULT_COLLECTION);
 
       
@@ -254,11 +250,7 @@ public class FullDistributedZkTest exten
           String shardName = new URI(
               ((CommonsHttpSolrServer) client).getBaseURL()).getPort()
               + "_solr_";
-          // System.out.println("key:" + shard.getKey() + " try:" + shardName);
           if (shard.getKey().endsWith(shardName)) {
-            System.out.println("shard:" + slice.getKey());
-            System.out.println(shard.getValue());
-            
             clientToInfo.put(client, shard.getValue());
             List<SolrServer> list = shardToClient.get(slice.getKey());
             if (list == null) {
@@ -280,17 +272,13 @@ public class FullDistributedZkTest exten
       
       Map<String,Slice> slices = zk.getCloudState().getSlices(
           DEFAULT_COLLECTION);
-      zk.updateCloudState(true);
+      zk.close();
       
       for (Map.Entry<String,Slice> slice : slices.entrySet()) {
         Map<String,ZkNodeProps> theShards = slice.getValue().getShards();
         for (Map.Entry<String,ZkNodeProps> shard : theShards.entrySet()) {
           String shardName = jetty.getLocalPort() + "_solr_";
-          // System.out.println("key:" + shard.getKey() + " try:" + shardName);
           if (shard.getKey().endsWith(shardName)) {
-//            System.out.println("shard:" + slice.getKey());
-//            System.out.println(shard.getValue());
-            
             List<CloudJettyRunner> list = shardToJetty.get(slice.getKey());
             if (list == null) {
               list = new ArrayList<CloudJettyRunner>();
@@ -303,7 +291,6 @@ public class FullDistributedZkTest exten
           }
         }
       }
-      
     }
   }
   
@@ -568,11 +555,11 @@ public class FullDistributedZkTest exten
     query("q", "*:*", "sort", "n_tl1 desc");
     
     // TMP: try adding a doc with CloudSolrServer
-    CloudSolrServer server = new CloudSolrServer(zkServer.getZkAddress());
-    server.setDefaultCollection(DEFAULT_COLLECTION);
+    CloudSolrServer cloudClient = new CloudSolrServer(zkServer.getZkAddress());
+    cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
     SolrQuery query = new SolrQuery("*:*");
     query.add("distrib", "true");
-    long numFound1 = server.query(query).getResults().getNumFound();
+    long numFound1 = cloudClient.query(query).getResults().getNumFound();
     
     SolrInputDocument doc = new SolrInputDocument();
     doc.addField("id", 1001);
@@ -582,13 +569,15 @@ public class FullDistributedZkTest exten
     UpdateRequest ureq = new UpdateRequest();
     ureq.add(doc);
     ureq.setParam("update.chain", "distrib-update-chain");
-    ureq.process(server);
+    ureq.process(cloudClient);
     
     commit();
     
     query("q", "*:*", "sort", "n_tl1 desc");
     
-    long numFound2 = server.query(query).getResults().getNumFound();
+    long numFound2 = cloudClient.query(query).getResults().getNumFound();
+    
+    cloudClient.close();
     
     // lets just check that the one doc since last commit made it in...
     assertEquals(numFound1 + 1, numFound2);
@@ -621,8 +610,6 @@ public class FullDistributedZkTest exten
     deadShard.start(true);
     
     List<SolrServer> s2c = shardToClient.get("shard2");
-    System.out.println("shard2_1 port:" + ((CommonsHttpSolrServer)s2c.get(0)).getBaseURL());
-    System.out.println("shard2_2 port:" + ((CommonsHttpSolrServer)s2c.get(1)).getBaseURL());
     
 
     //assertDocCounts();
@@ -661,7 +648,7 @@ public class FullDistributedZkTest exten
     
     // expire a session...
     CloudJettyRunner cloudJetty = shardToJetty.get("shard1").get(0);
-    chaosMonkey.expireSession(cloudJetty);
+    //chaosMonkey.expireSession(cloudJetty);
     
     // should cause another recovery...
     
@@ -672,18 +659,17 @@ public class FullDistributedZkTest exten
   private void assertDocCounts() throws Exception {
     // TODO: as we create the clients, we should build a map from shard to node/client
     // and node/client to shard?
-    System.out.println("after first doc:");
+
     long controlCount = controlClient.query(new SolrQuery("*:*")).getResults().getNumFound();
-    System.out.println("control:" + controlClient.query(new SolrQuery("*:*")).getResults().getNumFound());
+
     // do some really inefficient mapping...
     ZkStateReader zk = new ZkStateReader(zkServer.getZkAddress(), 10000, AbstractZkTestCase.TIMEOUT);
     zk.createClusterStateWatchersAndUpdate();
   //  Map<SolrServer,ZkNodeProps> clientToInfo = new HashMap<SolrServer,ZkNodeProps>();
     Map<String,Slice> slices = zk.getCloudState().getSlices(DEFAULT_COLLECTION);
  
-    zk.updateCloudState(true);
-    
-    long clientCount = 0;
+    zk.close();
+
     for (SolrServer client : clients) {
       for (Map.Entry<String,Slice> slice : slices.entrySet()) {
         Map<String,ZkNodeProps> theShards = slice.getValue().getShards();
@@ -700,7 +686,6 @@ public class FullDistributedZkTest exten
       long count = client.query(new SolrQuery("*:*")).getResults().getNumFound();
       
       System.out.println("docs:" + count + "\n\n");
-      clientCount += count;
     }
     SolrQuery query = new SolrQuery("*:*");
     query.add("distrib", "true");
@@ -722,6 +707,12 @@ public class FullDistributedZkTest exten
     if (DEBUG) {
       super.printLayout();
     }
+    if (cloudClient != null) {
+      cloudClient.close();
+    }
+    if (zkStateReader != null) {
+      zkStateReader.close();
+    }
     super.tearDown();
     System.clearProperty("CLOUD_UPDATE_DELAY");
     System.clearProperty("zkHost");

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
Sat Nov 26 00:24:47 2011
@@ -35,6 +35,7 @@ import org.apache.solr.common.cloud.ZkNo
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreContainer.Initializer;
 import org.apache.solr.core.SolrConfig;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -136,7 +137,7 @@ public class LeaderElectionIntegrationTe
       shard1Ports.remove(leaderPort);
       
       // kill the leader
-      System.out.println("Killing " + leaderPort);
+      if (VERBOSE) System.out.println("Killing " + leaderPort);
       containerMap.get(leaderPort).shutdown();
       
       //printLayout(zkServer.getZkAddress());
@@ -171,7 +172,7 @@ public class LeaderElectionIntegrationTe
     // first leader should not be leader anymore
     assertNotSame(leaderPort, getLeaderPort(getLeader()));
     
-    System.out.println("kill everyone");
+    if (VERBOSE) System.out.println("kill everyone");
     // kill everyone but the first leader that should have reconnected by now
     for (Map.Entry<Integer,CoreContainer> entry : containerMap.entrySet()) {
       if (entry.getKey() != leaderPort) {
@@ -214,7 +215,7 @@ public class LeaderElectionIntegrationTe
     int leaderPort = 0;
     if (m.matches()) {
       leaderPort = Integer.parseInt(m.group(1));
-      System.out.println("The leader is:" + Integer.parseInt(m.group(1)));
+      if (VERBOSE) System.out.println("The leader is:" + Integer.parseInt(m.group(1)));
     } else {
       throw new IllegalStateException();
     }
@@ -229,7 +230,9 @@ public class LeaderElectionIntegrationTe
     zkClient.close();
     
     for (CoreContainer cc : containerMap.values()) {
-      cc.shutdown();
+      if (!cc.isShutDown()) {
+        cc.shutdown();
+      }
     }
     zkServer.shutdown();
     super.tearDown();
@@ -246,4 +249,10 @@ public class LeaderElectionIntegrationTe
     zkClient.printLayoutToStdOut();
     zkClient.close();
   }
+  
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
 }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/LeaderElectionTest.java
Sat Nov 26 00:24:47 2011
@@ -31,6 +31,7 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.core.SolrConfig;
 import org.apache.zookeeper.KeeperException;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -47,6 +48,12 @@ public class LeaderElectionTest extends 
     createTempDir();
   }
   
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
+  
   @Override
   public void setUp() throws Exception {
     super.setUp();
@@ -89,8 +96,10 @@ public class LeaderElectionTest extends 
     }
     
     public void close() throws InterruptedException {
-      zkClient.close();
-      super.stop();
+      if (!zkClient.isClosed()) {
+        zkClient.close();
+      }
+      this.stop();
     }
   }
   
@@ -104,6 +113,7 @@ public class LeaderElectionTest extends 
     
     elector.setupForSlice("shard2", "collection1");
     elector.joinElection("shard2", "collection1", "dummynode1", null);
+    zkClient1.close();
     
     SolrZkClient zkClient2 = new SolrZkClient(server.getZkAddress(), TIMEOUT);
     
@@ -112,6 +122,8 @@ public class LeaderElectionTest extends 
     elector2.setupForSlice("shard2", "collection1");
     elector2.joinElection("shard2", "collection1", "dummynode2", null);
     
+    zkClient2.close();
+    
     List<ClientThread> threads = new ArrayList<ClientThread>();
     
     for (int i = 0; i < 15; i++) {
@@ -236,6 +248,13 @@ public class LeaderElectionTest extends 
     
     Thread.sleep(1000);
     
+    scheduler.shutdownNow();
+    
+    // cleanup any threads still running
+    for (ClientThread thread : threads) {
+      thread.close();
+    }
+    
     for (Thread thread : threads) {
       thread.join();
     }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
Sat Nov 26 00:24:47 2011
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
  */
 
 import java.io.File;
-import java.io.IOException;
 import java.util.List;
 
 import org.apache.solr.SolrTestCaseJ4;
@@ -28,29 +27,15 @@ import org.apache.solr.common.cloud.ZkSt
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrConfig;
 import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class ZkControllerTest extends SolrTestCaseJ4 {
 
-  private static final String TEST_NODE_NAME = "test_node_name";
-
-  private static final String URL3 = "http://localhost:3133/solr/core1";
-
-  private static final String URL2 = "http://localhost:3123/solr/core1";
-
-  private static final String SHARD3 = "localhost:3123_solr_core3";
-
-  private static final String SHARD2 = "localhost:3123_solr_core2";
-
-  private static final String SHARD1 = "localhost:3123_solr_core1";
-
   private static final String COLLECTION_NAME = "collection1";
 
-  static final int TIMEOUT = 10000;
-
-  private static final String URL1 = "http://localhost:3133/solr/core0";
+  static final int TIMEOUT = 1000;
 
   private static final boolean DEBUG = false;
   
@@ -83,7 +68,7 @@ public class ZkControllerTest extends So
         zkClient.printLayoutToStdOut();
       }
       zkClient.close();
-      ZkController zkController = new ZkController(server.getZkAddress(), TIMEOUT, TIMEOUT,
+      ZkController zkController = new ZkController(server.getZkAddress(), TIMEOUT, 10000,
           "localhost", "8983", "/solr", 3, new CurrentCoreDescriptorProvider() {
             
             @Override
@@ -223,23 +208,16 @@ public class ZkControllerTest extends So
     }
 
   }
-
-  private void addShardToZk(SolrZkClient zkClient, String shardsPath,
-      String zkNodeName, String url) throws IOException,
-      KeeperException, InterruptedException {
-
-    ZkNodeProps props = new ZkNodeProps();
-    props.put(ZkStateReader.URL_PROP, url);
-    props.put(ZkStateReader.NODE_NAME_PROP, TEST_NODE_NAME);
-    byte[] bytes = props.store();
-
-    zkClient
-        .create(shardsPath + "/" + zkNodeName, bytes, CreateMode.PERSISTENT);
-  }
   
   @Override
   public void tearDown() throws Exception {
     SolrConfig.severeErrors.clear();
     super.tearDown();
   }
+  
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
 }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkLockTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkLockTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkLockTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkLockTest.java
Sat Nov 26 00:24:47 2011
@@ -25,6 +25,7 @@ import org.apache.solr.cloud.lock.LockLi
 import org.apache.solr.cloud.lock.WriteLock;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.core.SolrConfig;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -64,20 +65,20 @@ public class ZkLockTest extends SolrTest
           
           @Override
           public void lockReleased() {
-            // TODO Auto-generated method stub
             
           }
           
           @Override
           public void lockAcquired() {
-            System.out.println("I got the lock!");
+         // TODO this is only a dumb observation test now
+            if (VERBOSE) System.out.println("I got the lock!");
             
           }
         });
     
     lock.lock();
-    System.out.println("zk:");
-    printLayout(server.getZkHost());
+   
+    if (VERBOSE) printLayout(server.getZkHost());
   }
   
   @Override
@@ -94,4 +95,10 @@ public class ZkLockTest extends SolrTest
     zkClient.close();
   }
   
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
+  
 }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
Sat Nov 26 00:24:47 2011
@@ -28,6 +28,7 @@ import org.apache.solr.util.AbstractSolr
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.junit.AfterClass;
 
 public class ZkSolrClientTest extends AbstractSolrTestCase {
   private static final boolean DEBUG = false;
@@ -238,4 +239,9 @@ public class ZkSolrClientTest extends Ab
     super.tearDown();
   }
   
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
 }

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/ZkTestServer.java
Sat Nov 26 00:24:47 2011
@@ -236,7 +236,7 @@ public class ZkTestServer {
       } catch(IllegalStateException e) {
         
       }
-      if (cnt == 40) {
+      if (cnt == 100) {
         throw new RuntimeException("Could not get the port for ZooKeeper server");
       }
       cnt++;

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/lock/WriteLockTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/lock/WriteLockTest.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/lock/WriteLockTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/lock/WriteLockTest.java
Sat Nov 26 00:24:47 2011
@@ -27,6 +27,7 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.cloud.AbstractZkTestCase;
 import org.apache.solr.cloud.ZkTestServer;
 import org.apache.solr.common.cloud.SolrZkClient;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -34,6 +35,7 @@ import org.junit.Test;
  * test for writelock
  */
 public class WriteLockTest extends SolrTestCaseJ4 {
+  private static boolean VERBOSE = false;
   private static int TIMEOUT = 30 * 1000;
   protected String dir = "/" + getClass().getName();
   protected WriteLock[] nodes;
@@ -50,6 +52,12 @@ public class WriteLockTest extends SolrT
     createTempDir();
   }
   
+  @AfterClass
+  public static void afterClass() throws InterruptedException {
+    // wait just a bit for any zk client threads to outlast timeout
+    Thread.sleep(2000);
+  }
+  
   @Override
   public void setUp() throws Exception {
     super.setUp();
@@ -109,7 +117,7 @@ public class WriteLockTest extends SolrT
     
     if (count > 1) {
       if (killLeader) {
-        System.out.println("Now killing the leader");
+        if (VERBOSE) System.out.println("Now killing the leader");
         // now lets kill the leader
         latch = new CountDownLatch(1);
         first.unlock();
@@ -131,7 +139,7 @@ public class WriteLockTest extends SolrT
       
       if (restartServer) {
         // now lets stop the server
-        System.out.println("Now stopping the server");
+        if (VERBOSE) System.out.println("Now stopping the server");
         server.shutdown();
         Thread.sleep(10000);
         
@@ -145,11 +153,11 @@ public class WriteLockTest extends SolrT
         server.run();
         
         for (int i = 0; i < count - 1; i++) {
-          System.out.println("Calling acquire for node: " + i);
+          if (VERBOSE) System.out.println("Calling acquire for node: " + i);
           //nodes[i].lock();
         }
         dumpNodes(count);
-        System.out.println("Now closing down...");
+        if (VERBOSE) System.out.println("Now closing down...");
       }
     }
   }
@@ -163,7 +171,7 @@ public class WriteLockTest extends SolrT
   protected void dumpNodes(int count) {
     for (int i = 0; i < count; i++) {
       WriteLock node = nodes[i];
-      System.out.println("node: " + i + " id: " + node.getId() + " is leader: "
+      if (VERBOSE) System.out.println("node: " + i + " id: " + node.getId() + " is leader:
"
           + node.isOwner());
     }
   }
@@ -174,14 +182,14 @@ public class WriteLockTest extends SolrT
       for (int i = 0; i < nodes.length; i++) {
         WriteLock node = nodes[i];
         if (node != null) {
-          System.out.println("Closing node: " + i);
+          if (VERBOSE) System.out.println("Closing node: " + i);
           node.close();
           if (workAroundClosingLastZNodeFails && i == nodes.length - 1) {
-            System.out.println("Not closing zookeeper: " + i + " due to bug!");
+            if (VERBOSE) System.out.println("Not closing zookeeper: " + i + " due to bug!");
           } else {
-            System.out.println("Closing zookeeper: " + i);
+            if (VERBOSE) System.out.println("Closing zookeeper: " + i);
             node.getZookeeper().close();
-            System.out.println("Closed zookeeper: " + i);
+
           }
         }
       }

Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
(original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
Sat Nov 26 00:24:47 2011
@@ -24,6 +24,8 @@ import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
 import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Source;
@@ -53,6 +55,10 @@ import org.slf4j.LoggerFactory;
  *
  */
 public class SolrZkClient {
+  // These should *only* be used for debugging or monitoring purposes
+  public static final AtomicLong numOpens = new AtomicLong();
+  public static final AtomicLong numCloses = new AtomicLong();
+  
   static final String NEWL = System.getProperty("line.separator");
 
   static final int DEFAULT_CLIENT_CONNECT_TIMEOUT = 30000;
@@ -63,6 +69,8 @@ public class SolrZkClient {
   private ConnectionManager connManager;
 
   private volatile SolrZooKeeper keeper;
+
+  private volatile boolean isClosed = false;
   
   /**
    * @param zkServerAddress
@@ -107,6 +115,7 @@ public class SolrZkClient {
   public SolrZkClient(String zkServerAddress, int zkClientTimeout,
       ZkClientConnectionStrategy strat, final OnReconnect onReconnect, int clientConnectTimeout)
throws InterruptedException,
       TimeoutException, IOException {
+    numOpens.incrementAndGet();
     connManager = new ConnectionManager("ZooKeeperConnection Watcher:"
         + zkServerAddress, this, zkServerAddress, zkClientTimeout, strat, onReconnect);
     strat.connect(zkServerAddress, zkClientTimeout, connManager,
@@ -503,7 +512,13 @@ public class SolrZkClient {
    * @throws InterruptedException
    */
   public void close() throws InterruptedException {
+    isClosed = true;
     keeper.close();
+    numCloses.incrementAndGet();
+  }
+
+  public boolean isClosed() {
+    return isClosed;
   }
 
   /**

Modified: lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
(original)
+++ lucene/dev/branches/solrcloud/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
Sat Nov 26 00:24:47 2011
@@ -158,9 +158,8 @@ public class ZkStateReader {
         } catch (InterruptedException e) {
           // Restore the interrupted status
           Thread.currentThread().interrupt();
-          log.error("", e);
-          throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
-              "", e);
+          log.warn("", e);
+          return;
         } /*
            * catch(IOException e){ log.error("", e); throw new
            * ZooKeeperException( SolrException.ErrorCode.SERVER_ERROR, "", e); }
@@ -197,9 +196,8 @@ public class ZkStateReader {
             } catch (InterruptedException e) {
               // Restore the interrupted status
               Thread.currentThread().interrupt();
-              log.error("", e);
-              throw new ZooKeeperException(
-                  SolrException.ErrorCode.SERVER_ERROR, "", e);
+              log.warn("", e);
+              return;
             }
           }
           

Modified: lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
(original)
+++ lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
Sat Nov 26 00:24:47 2011
@@ -226,6 +226,7 @@ public abstract class BaseDistributedSea
     for (JettySolrRunner jetty : jettys) jetty.stop();
     clients.clear();
     jettys.clear();
+    Thread.sleep(10000);
   }
   
   public JettySolrRunner createJetty(File baseDir, String dataDir) throws Exception {

Modified: lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java?rev=1206383&r1=1206382&r2=1206383&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
(original)
+++ lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
Sat Nov 26 00:24:47 2011
@@ -27,6 +27,7 @@ import org.apache.noggit.ObjectBuilder;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
+import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
@@ -64,6 +65,7 @@ public abstract class SolrTestCaseJ4 ext
   @BeforeClass
   public static void beforeClassSolrTestCase() throws Exception {
     startTrackingSearchers();
+    startTrackingZkClients();
     ignoreException("ignore_exception");
   }
 
@@ -72,6 +74,7 @@ public abstract class SolrTestCaseJ4 ext
     deleteCore();
     resetExceptionIgnores();
     endTrackingSearchers();
+    endTrackingZkClients();
   }
 
   @Override
@@ -110,6 +113,12 @@ public abstract class SolrTestCaseJ4 ext
     numOpens = SolrIndexSearcher.numOpens.get();
     numCloses = SolrIndexSearcher.numCloses.get();
   }
+  static long zkClientNumOpens;
+  static long zkClientNumCloses;
+  public static void startTrackingZkClients() {
+    zkClientNumOpens = SolrIndexSearcher.numOpens.get();
+    zkClientNumCloses = SolrIndexSearcher.numCloses.get();
+  }
 
   public static void endTrackingSearchers() {
      long endNumOpens = SolrIndexSearcher.numOpens.get();
@@ -127,6 +136,22 @@ public abstract class SolrTestCaseJ4 ext
      }
   }
   
+  public static void endTrackingZkClients() {
+    long endNumOpens = SolrZkClient.numOpens.get();
+    long endNumCloses = SolrZkClient.numCloses.get();
+
+    SolrZkClient.numOpens.getAndSet(0);
+    SolrZkClient.numCloses.getAndSet(0);
+
+    
+    if (endNumOpens-numOpens != endNumCloses-numCloses) {
+      String msg = "ERROR: SolrZkClient opens=" + (endNumOpens-zkClientNumOpens) + " closes="
+ (endNumCloses-zkClientNumCloses);
+      log.error(msg);
+      testsFailed = true;
+      fail(msg);
+    }
+ }
+  
   /** Causes an exception matching the regex pattern to not be logged. */
   public static void ignoreException(String pattern) {
     if (SolrException.ignorePatterns == null)



Mime
View raw message