Author: markrmiller
Date: Sat Jan  2 19:06:14 2010
New Revision: 895265

URL: http://svn.apache.org/viewvc?rev=895265&view=rev
Log:
reorganization

Added:
    
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
    
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
    
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkClientConnectionStrategy.java
Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java
    
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
    
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractDistributedZooKeeperTestCase.java
    
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractZooKeeperTestCase.java
    
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
    lucene/solr/branches/cloud/src/webapp/web/admin/zookeeper.jsp

Added: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java?rev=895265&view=auto
==============================================================================
--- 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
 (added)
+++ 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
 Sat Jan  2 19:06:14 2010
@@ -0,0 +1,129 @@
+package org.apache.solr.cloud;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.Watcher.Event.KeeperState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class ConnectionManager implements Watcher {
+  protected static final Logger log = LoggerFactory
+      .getLogger(ConnectionManager.class);
+
+  private final String name;
+  private CountDownLatch clientConnected;
+  private KeeperState state;
+  private boolean connected;
+
+  private ZkClientConnectionStrategy connectionStrategy;
+
+  private String zkServerAddress;
+
+  private int zkClientTimeout;
+
+  public ConnectionManager(String name, String zkServerAddress, int 
zkClientTimeout, ZkClientConnectionStrategy strat) {
+    this.name = name;
+    this.connectionStrategy = strat;
+    this.zkServerAddress = zkServerAddress;
+    this.zkClientTimeout = zkClientTimeout;
+    reset();
+  }
+
+  private synchronized void reset() {
+    clientConnected = new CountDownLatch(1);
+    state = KeeperState.Disconnected;
+    connected = false;
+  }
+
+  public synchronized void process(WatchedEvent event) {
+    if (log.isInfoEnabled()) {
+      log.info("Watcher " + name + " got event " + event);
+    }
+
+    state = event.getState();
+    if (state == KeeperState.SyncConnected) {
+      connected = true;
+      clientConnected.countDown();
+    } else if (state == KeeperState.Expired) {
+      connected = false;
+      log.info("Attempting to reconnect to ZooKeeper...");
+      boolean connected = true;
+
+      // nocommit : close old ZooKeeper client?
+
+      try {
+        connectionStrategy.reconnect(zkServerAddress, zkClientTimeout, this);
+      } catch (IOException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
+
+      log.info("Connected:" + connected);
+      // nocommit: start reconnect attempts
+    } else if (state == KeeperState.Disconnected) {
+      connected = false;
+      // nocommit: start reconnect attempts
+    } else {
+      connected = false;
+    }
+    notifyAll();
+  }
+
+  public synchronized boolean isConnected() {
+    return connected;
+  }
+
+  public synchronized KeeperState state() {
+    return state;
+  }
+
+  public synchronized ZooKeeper waitForConnected(long waitForConnection)
+      throws InterruptedException, TimeoutException, IOException {
+    ZooKeeper keeper = new ZooKeeper(zkServerAddress, zkClientTimeout, this);
+    long expire = System.currentTimeMillis() + waitForConnection;
+    long left = waitForConnection;
+    while (!connected && left > 0) {
+      wait(left);
+      left = expire - System.currentTimeMillis();
+    }
+    if (!connected) {
+      throw new TimeoutException("Could not connect to ZooKeeper within " + 
waitForConnection + " ms");
+    }
+    return keeper;
+  }
+
+  public synchronized void waitForDisconnected(long timeout)
+      throws InterruptedException, TimeoutException {
+    long expire = System.currentTimeMillis() + timeout;
+    long left = timeout;
+    while (connected && left > 0) {
+      wait(left);
+      left = expire - System.currentTimeMillis();
+    }
+    if (connected) {
+      throw new TimeoutException("Did not disconnect");
+    }
+  }
+}

Added: 
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=895265&view=auto
==============================================================================
--- 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
 (added)
+++ 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/DefaultConnectionStrategy.java
 Sat Jan  2 19:06:14 2010
@@ -0,0 +1,37 @@
+package org.apache.solr.cloud;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+public class DefaultConnectionStrategy extends ZkClientConnectionStrategy {
+
+  @Override
+  public ZooKeeper connect(String serverAddress, int timeout, Watcher watcher) 
throws IOException {
+    return new ZooKeeper(serverAddress, timeout, watcher);
+  }
+
+  @Override
+  public ZooKeeper reconnect(String serverAddress, int timeout, Watcher 
watcher) throws IOException {
+    return new ZooKeeper(serverAddress, timeout, watcher);
+  }
+
+}

Modified: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java 
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java 
Sat Jan  2 19:06:14 2010
@@ -21,17 +21,14 @@
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.List;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeoutException;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
@@ -39,136 +36,33 @@
 
 public class SolrZkClient {
   static final String NEWL = System.getProperty("line.separator");
-  
+
   private static final int CONNECT_TIMEOUT = 5000;
 
   protected static final Logger log = LoggerFactory
       .getLogger(SolrZkClient.class);
 
-  private String zkHost;
-  private int zkClientTimeout;
-  
   boolean connected = false;
-  
-  private CountdownWatcher cw = new CountdownWatcher("ZooKeeperConnection 
Watcher");
 
-  private volatile ZooKeeper keeper;
+  private ConnectionManager connManager;
 
-  public SolrZkClient(String zkHost, int zkClientTimeout) {
-    this.zkHost = zkHost;
-    this.zkClientTimeout = zkClientTimeout;
-  }
-
-  public void connect() throws InterruptedException, TimeoutException,
-      IOException {
-    if(connected) {
-      return;
-    }
-    // nocommit
-    log.info("Connecting to ZooKeeper...");
-    
-    keeper = new ZooKeeper(zkHost, zkClientTimeout, cw);
-    cw.waitForConnected(CONNECT_TIMEOUT);
-
-    // nocommit
-    log.info("Connected");
-  }
+  private volatile ZooKeeper keeper;
   
-  public boolean connected() {
-    return keeper != null && keeper.getState() == ZooKeeper.States.CONNECTED;
+  public SolrZkClient(String zkServerAddress, int zkClientTimeout) throws 
InterruptedException, TimeoutException, IOException {
+    this(zkServerAddress, zkClientTimeout, new DefaultConnectionStrategy());
   }
 
-  class CountdownWatcher implements Watcher {
-
-    private final String name;
-    private CountDownLatch clientConnected;
-    private KeeperState state;
-    private boolean connected;
-
-    public CountdownWatcher(String name) {
-      this.name = name;
-      reset();
-    }
-
-    private synchronized void reset() {
-      clientConnected = new CountDownLatch(1);
-      state = KeeperState.Disconnected;
-      connected = false;
-    }
-
-    public synchronized void process(WatchedEvent event) {
-      if (log.isInfoEnabled()) {
-        log.info("Watcher " + name + " got event " + event);
-      }
-
-      state = event.getState();
-      if (state == KeeperState.SyncConnected) {
-        connected = true;
-        clientConnected.countDown();
-      } else if (state == KeeperState.Expired) {
-        connected = false;
-        log.info("Attempting to reconnect to ZooKeeper...");
-        boolean connected = true;
-
-        // nocommit : close old ZooKeeper client?
-
-        try {
-          connect();
-        } catch (InterruptedException e) {
-          // Restore the interrupted status
-          Thread.currentThread().interrupt();
-          connected = false;
-        } catch (TimeoutException e) {
-          connected = false;
-        } catch (IOException e) {
-          // nocommit
-          // TODO Auto-generated catch block
-          e.printStackTrace();
-        }
-        log.info("Connected:" + connected);
-        // nocommit: start reconnect attempts
-      } else if (state == KeeperState.Disconnected) {
-        connected = false;
-        // nocommit: start reconnect attempts
-      } else {
-        connected = false;
-      }
-      notifyAll();
-    }
-
-    public synchronized boolean isConnected() {
-      return connected;
-    }
-
-    public synchronized KeeperState state() {
-      return state;
-    }
-
-    public synchronized void waitForConnected(long timeout)
-        throws InterruptedException, TimeoutException {
-      long expire = System.currentTimeMillis() + timeout;
-      long left = timeout;
-      while (!connected && left > 0) {
-        wait(left);
-        left = expire - System.currentTimeMillis();
-      }
-      if (!connected) {
-        throw new TimeoutException("Did not connect");
-      }
-    }
+  public SolrZkClient(String zkServerAddress, int zkClientTimeout,
+      ZkClientConnectionStrategy strat) throws InterruptedException,
+      TimeoutException, IOException {
+    connManager = new ConnectionManager("ZooKeeperConnection Watcher",
+        zkServerAddress, zkClientTimeout, strat);
+    this.keeper = strat.connect(zkServerAddress, zkClientTimeout, connManager);
+    connManager.waitForConnected(CONNECT_TIMEOUT);
+  }
 
-    public synchronized void waitForDisconnected(long timeout)
-        throws InterruptedException, TimeoutException {
-      long expire = System.currentTimeMillis() + timeout;
-      long left = timeout;
-      while (connected && left > 0) {
-        wait(left);
-        left = expire - System.currentTimeMillis();
-      }
-      if (connected) {
-        throw new TimeoutException("Did not disconnect");
-      }
-    }
+  public boolean isConnected() {
+    return keeper != null && keeper.getState() == ZooKeeper.States.CONNECTED;
   }
 
   public Stat exists(final String path, Watcher watcher)
@@ -195,7 +89,7 @@
       throws KeeperException, InterruptedException {
     return keeper.setData(path, data, version);
   }
-  
+
   /**
    * 
    * @param path
@@ -208,10 +102,11 @@
   public String create(String path, byte[] data, CreateMode createMode,
       Watcher watcher) throws KeeperException, InterruptedException {
 
-    String zkPath = keeper.create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, 
createMode);
+    String zkPath = keeper.create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE,
+        createMode);
     // nocommit : race issue on keeper switch
     exists(zkPath, watcher);
-    
+
     return zkPath;
   }
 
@@ -337,8 +232,7 @@
     if (exists != null) {
       setData(path, data, -1);
     } else {
-      create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE,
-          CreateMode.PERSISTENT);
+      create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
     }
   }
 
@@ -353,14 +247,14 @@
    */
   public void write(String path, File file) throws IOException,
       KeeperException, InterruptedException {
-    if(log.isInfoEnabled()) {
+    if (log.isInfoEnabled()) {
       log.info("Write to ZooKeepeer " + file.getAbsolutePath() + " to " + 
path);
     }
 
     String data = FileUtils.readFileToString(file);
     write(path, data.getBytes());
   }
-  
+
   /**
    * Fills string with printout of current ZooKeeper layout.
    * 

Added: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkClientConnectionStrategy.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkClientConnectionStrategy.java?rev=895265&view=auto
==============================================================================
--- 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkClientConnectionStrategy.java
 (added)
+++ 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkClientConnectionStrategy.java
 Sat Jan  2 19:06:14 2010
@@ -0,0 +1,31 @@
+package org.apache.solr.cloud;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.ZooKeeper;
+
+/**
+ *
+ */
+public abstract class ZkClientConnectionStrategy {
+  public abstract ZooKeeper connect(String zkServerAddress, int 
zkClientTimeout, Watcher watcher) throws IOException;
+  public abstract ZooKeeper reconnect(String serverAddress, int 
zkClientTimeout, Watcher watcher) throws IOException;
+}

Modified: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java
 (original)
+++ 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java
 Sat Jan  2 19:06:14 2010
@@ -142,6 +142,8 @@
 
   private String zooKeeperHostName;
 
+  private int zkClientTimeout;
+
   /**
    * 
    * @param zkServerAddress ZooKeeper server host address
@@ -150,12 +152,16 @@
    * @param hostPort
    * @param hostContext
    * @param zkClientTimeout
+   * @throws IOException 
+   * @throws TimeoutException 
+   * @throws InterruptedException 
    */
   public ZooKeeperController(String zkServerAddress, String collection,
-      String hostUrl, String hostPort, String hostContext, int 
zkClientTimeout) {
+      String hostUrl, String hostPort, String hostContext, int 
zkClientTimeout) throws InterruptedException, TimeoutException, IOException {
 
     this.collectionName = collection;
     this.zkServerAddress = zkServerAddress;
+    this.zkClientTimeout = zkClientTimeout;
     this.hostPort = hostPort;
     this.hostContext = hostContext;
     zkClient = new SolrZkClient(zkServerAddress, zkClientTimeout);
@@ -168,10 +174,6 @@
   private void init() {
 
     try {
-      zkClient.connect();
-
-
-
       zooKeeperHostName = getHostAddress();
       Matcher m = URL_POST.matcher(zooKeeperHostName);
       if (m.matches()) {
@@ -199,10 +201,6 @@
     } catch (InterruptedException e) {
       // Restore the interrupted status
       Thread.currentThread().interrupt();
-    } catch (TimeoutException e) {
-      log.error("", e);
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
-          "Timeout waiting for ZooKeeper connection", e);
     } catch (KeeperException e) {
       log.error("KeeperException", e);
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "", e);

Modified: 
lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java 
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java 
Sat Jan  2 19:06:14 2010
@@ -21,6 +21,7 @@
 import java.nio.channels.FileChannel;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeoutException;
 import java.text.SimpleDateFormat;
 
 import org.slf4j.Logger;
@@ -101,7 +102,19 @@
     }
     
     if (zookeeperHost != null) {
-      zooKeeperController = new ZooKeeperController(zookeeperHost, collection, 
host,  hostPort, hostContext, zkClientTimeout);
+      try {
+        // nocommit : exceptions
+        zooKeeperController = new ZooKeeperController(zookeeperHost, 
collection, host,  hostPort, hostContext, zkClientTimeout);
+      } catch (InterruptedException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      } catch (TimeoutException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      } catch (IOException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
     }
   }
 

Modified: 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractDistributedZooKeeperTestCase.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractDistributedZooKeeperTestCase.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractDistributedZooKeeperTestCase.java
 (original)
+++ 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractDistributedZooKeeperTestCase.java
 Sat Jan  2 19:06:14 2010
@@ -95,7 +95,6 @@
   
   private void printeLayout() throws Exception {
     SolrZkClient zkClient = new 
SolrZkClient(AbstractZooKeeperTestCase.JUST_HOST_NAME, 
AbstractZooKeeperTestCase.TIMEOUT);
-    zkClient.connect();
     zkClient.printLayoutToStdOut();
     zkClient.close();
   }

Modified: 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractZooKeeperTestCase.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractZooKeeperTestCase.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractZooKeeperTestCase.java
 (original)
+++ 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/AbstractZooKeeperTestCase.java
 Sat Jan  2 19:06:14 2010
@@ -97,12 +97,10 @@
   static void buildZooKeeper(String config, String schema)
       throws Exception {
     SolrZkClient zkClient = new SolrZkClient(JUST_HOST_NAME, 
AbstractZooKeeperTestCase.TIMEOUT);
-    zkClient.connect();
     zkClient.makePath("/solr");
     zkClient.close();
 
     zkClient = new SolrZkClient(ZOO_KEEPER_HOST, 
AbstractZooKeeperTestCase.TIMEOUT);
-    zkClient.connect();
     
     zkClient.makePath("/collections/collection1/config=collection1");
 
@@ -135,7 +133,6 @@
         AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.substring(0,
             AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.indexOf('/')),
         AbstractZooKeeperTestCase.TIMEOUT);
-    zkClient.connect();
     zkClient.printLayoutToStdOut();
     zkClient.close();
   }

Modified: 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
 (original)
+++ 
lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
 Sat Jan  2 19:06:14 2010
@@ -63,7 +63,6 @@
     makeSolrZkNode();
     
     zkClient = new SolrZkClient(ZOO_KEEPER_ADDRESS, TIMEOUT);
-    zkClient.connect();
     String shardsPath = "/collections/collection1/shards";
     zkClient.makePath(shardsPath);
     
@@ -127,7 +126,6 @@
     makeSolrZkNode();
 
     SolrZkClient zkClient = new SolrZkClient(ZOO_KEEPER_ADDRESS, TIMEOUT);
-    zkClient.connect();
     String actualConfigName = "firstConfig";
       
     String shardsPath = "/collections/" + COLLECTION_NAME + "/config=" + 
actualConfigName;
@@ -162,7 +160,6 @@
 
   private void makeSolrZkNode() throws Exception {
     SolrZkClient zkClient = new SolrZkClient(ZOO_KEEPER_HOST, TIMEOUT);
-    zkClient.connect();
     zkClient.makePath("/solr");
     zkClient.close();
   }

Modified: lucene/solr/branches/cloud/src/webapp/web/admin/zookeeper.jsp
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/webapp/web/admin/zookeeper.jsp?rev=895265&r1=895264&r2=895265&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/webapp/web/admin/zookeeper.jsp (original)
+++ lucene/solr/branches/cloud/src/webapp/web/admin/zookeeper.jsp Sat Jan  2 
19:06:14 2010
@@ -44,7 +44,7 @@
 <tr>
   <td>
      <strong>   <%
-     XML.escapeCharData(printer.keeperConnection == null ? "Disconnected"
+     XML.escapeCharData(printer.zkClient == null ? "Disconnected"
          : ("Connected to zookeeper " + printer.keeperAddr), out);
    %>  </strong>
   </td>
@@ -78,7 +78,7 @@
 
     String keeperAddr; // the address we're connected to
 
-    ZooKeeperConnection keeperConnection;
+    SolrZkClient zkClient;
 
     JspWriter out;
 
@@ -100,29 +100,26 @@
         return;
       }
       
-      keeperConnection = new ZooKeeperConnection(addr, 10000);
-
       try {
-        keeperConnection.connect();
+        zkClient = new SolrZkClient(addr, 10000);
       } catch (TimeoutException e) {
-        out.println("Could not connect to zookeeper at " + addr);
-        return;
+       out.println("Could not connect to zookeeper at " + addr);
+       zkClient = null;
+       return;
       } catch (InterruptedException e) {
         // Restore the interrupted status
         Thread.currentThread().interrupt();
-      }
-
-      if (!keeperConnection.connected()) {
         out.println("Could not connect to zookeeper at " + addr);
-        keeperConnection = null;
+        zkClient = null;
         return;
       }
 
+
     }
 
     // main entry point
     void print(String path) throws IOException {
-      if (keeperConnection == null)
+      if (zkClient == null)
         return;
 
       out.print("<table>");
@@ -282,7 +279,7 @@
 
       Stat stat = new Stat();
       try {
-        byte[] data = keeperConnection.getData(path, null, stat);
+        byte[] data = zkClient.getData(path, null, stat);
 
         out.print("v=" + stat.getVersion());
         if (stat.getNumChildren() != 0) {
@@ -332,7 +329,7 @@
 
       List<String> children = null;
       try {
-        children = keeperConnection.getChildren(path, null);
+        children = zkClient.getChildren(path, null);
       } catch (KeeperException e) {
         exception(e);
         return;
@@ -355,7 +352,7 @@
       try {
 
         Stat stat = new Stat();
-        byte[] data = keeperConnection.getData(path, null, stat);
+        byte[] data = zkClient.getData(path, null, stat);
 
         out.print("<h2>");
         xmlescape(path);


Reply via email to