Author: markrmiller
Date: Tue Jan 19 16:56:25 2010
New Revision: 900843

URL: http://svn.apache.org/viewvc?rev=900843&view=rev
Log:
update zkclient reconnection test

Modified:
    
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
    
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkSolrClientTest.java

Modified: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java?rev=900843&r1=900842&r2=900843&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
 (original)
+++ 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
 Tue Jan 19 16:56:25 2010
@@ -34,7 +34,7 @@
 public class DefaultConnectionStrategy extends ZkClientConnectionStrategy {
 
   private static Logger log = 
LoggerFactory.getLogger(DefaultConnectionStrategy.class);
-  private ScheduledExecutorService executor = 
Executors.newScheduledThreadPool(1);
+  private ScheduledExecutorService executor;
   
   @Override
   public void connect(String serverAddress, int timeout, Watcher watcher, 
ZkUpdate updater) throws IOException, InterruptedException, TimeoutException {
@@ -45,6 +45,7 @@
   public void reconnect(final String serverAddress, final int zkClientTimeout,
       final Watcher watcher, final ZkUpdate updater) throws IOException {
     log.info("Starting reconnect to ZooKeeper attempts ...");
+    executor = Executors.newScheduledThreadPool(1);
     executor.schedule(new Runnable() {
       private int delay = 1000;
       public void run() {

Modified: 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkSolrClientTest.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkSolrClientTest.java?rev=900843&r1=900842&r2=900843&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkSolrClientTest.java 
(original)
+++ 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkSolrClientTest.java 
Tue Jan 19 16:56:25 2010
@@ -62,6 +62,7 @@
     server.shutdown();
   }
   
+  // nocommit : must be a clear way to do this
   public void testReconnect() throws Exception {
     String zkDir = tmpDir.getAbsolutePath() + File.separator
         + "zookeeper/server1/data";
@@ -73,8 +74,7 @@
 
       AbstractZkTestCase.makeSolrZkNode();
 
-      zkClient = new SolrZkClient(AbstractZkTestCase.ZOO_KEEPER_ADDRESS,
-          AbstractZkTestCase.TIMEOUT);
+      zkClient = new SolrZkClient(AbstractZkTestCase.ZOO_KEEPER_ADDRESS, 5);
       String shardsPath = "/collections/collection1/shards";
       zkClient.makePath(shardsPath);
 
@@ -106,6 +106,19 @@
       
       
assertNotNull(zkClient.exists("/collections/collection1/config=collection3", 
null));
       
assertNotNull(zkClient.exists("/collections/collection1/config=collection1", 
null));
+      
+      // cause expiration
+      for(int i = 0; i < 1000; i++) {
+        System.gc();
+      }
+      
+      Thread.sleep(3000); // pause for reconnect
+      
+      zkClient.makePath("collections/collection1/config=collection4");
+      
+      zkClient.printLayoutToStdOut();
+      
+      
assertNotNull(zkClient.exists("/collections/collection1/config=collection4", 
null));
 
     } catch(Exception e) {
       // nocommit


Reply via email to