lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r895087 - in /lucene/solr/branches/cloud/src: java/org/apache/solr/cloud/ java/org/apache/solr/core/ test/org/apache/solr/cloud/
Date Fri, 01 Jan 2010 22:47:54 GMT
Author: markrmiller
Date: Fri Jan  1 22:47:53 2010
New Revision: 895087

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

Added:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java
      - copied, changed from r895056, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperConnection.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
      - copied, changed from r894959, lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperReaderTest.java
Removed:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperConnection.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperReader.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperWriter.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperReaderTest.java
Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperController.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperSolrResourceLoader.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/BasicDistributedZooKeeperTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/TestShardInfoList.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperTestServer.java

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java?rev=895087&r1=895086&r2=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java Fri Jan
 1 22:47:53 2010
@@ -17,9 +17,18 @@
  * limitations under the License.
  */
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
+
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Information about the Collection.
@@ -27,6 +36,13 @@
  */
 public final class CollectionInfo {
 
+  protected static final Logger log = LoggerFactory
+      .getLogger(CollectionInfo.class);
+  
+  static final String SHARD_LIST_PROP = "shard_list";
+
+  static final String URL_PROP = "url";
+  
   // maps shard name to the shard addresses and roles
   private final Map<String,ShardInfoList> shardNameToShardInfoList;
   private final long updateTime;
@@ -36,6 +52,68 @@
     this.shardNameToShardInfoList = shardNameToShardInfoList;
     this.updateTime = System.currentTimeMillis();
   }
+  
+  public CollectionInfo(SolrZkClient client, String path) throws KeeperException, InterruptedException,
IOException {
+    //nocommit: 
+    // build immutable CollectionInfo
+    shardNameToShardInfoList = readShardInfo(client, path);
+    
+    this.updateTime = System.currentTimeMillis();
+  }
+  
+  /**
+   * Read info on the available Shards and Nodes.
+   * @param zkClient 
+   * 
+   * @param path to the shards zkNode
+   * @return Map from shard name to a {@link ShardInfoList}
+   * @throws InterruptedException
+   * @throws KeeperException
+   * @throws IOException
+   */
+  public Map<String,ShardInfoList> readShardInfo(SolrZkClient zkClient, String path)
+      throws KeeperException, InterruptedException, IOException {
+    // for now, just reparse everything
+    HashMap<String,ShardInfoList> shardNameToShardList = new HashMap<String,ShardInfoList>();
+
+    if (zkClient.exists(path, null) == null) {
+      throw new IllegalStateException("Cannot find zk node that should exist:"
+          + path);
+    }
+    List<String> nodes = zkClient.getChildren(path, null);
+
+    for (String zkNodeName : nodes) {
+      byte[] data = zkClient.getData(path + "/" + zkNodeName, null,
+          null);
+
+      Properties props = new Properties();
+      props.load(new ByteArrayInputStream(data));
+
+      String url = (String) props.get(URL_PROP);
+      String shardNameList = (String) props.get(SHARD_LIST_PROP);
+      String[] shardsNames = shardNameList.split(",");
+      for (String shardName : shardsNames) {
+        ShardInfoList sList = shardNameToShardList.get(shardName);
+        List<ShardInfo> shardList;
+        if (sList == null) {
+          shardList = new ArrayList<ShardInfo>(1);
+        } else {
+          List<ShardInfo> oldShards = sList.getShards();
+          shardList = new ArrayList<ShardInfo>(oldShards.size() + 1);
+          shardList.addAll(oldShards);
+        }
+
+        ShardInfo shard = new ShardInfo(url);
+        shardList.add(shard);
+        ShardInfoList list = new ShardInfoList(shardList);
+
+        shardNameToShardList.put(shardName, list);
+      }
+
+    }
+
+    return Collections.unmodifiableMap(shardNameToShardList);
+  }
 
   /**
    * //nocommit

Copied: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java (from
r895056, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperConnection.java)
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java?p2=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java&p1=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperConnection.java&r1=895056&r2=895087&rev=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperConnection.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java Fri Jan  1
22:47:53 2010
@@ -17,15 +17,19 @@
  * the License.
  */
 
+import java.io.File;
 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;
@@ -33,11 +37,13 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ZooKeeperConnection {
+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(ZooKeeperConnection.class);
+      .getLogger(SolrZkClient.class);
 
   private String zkHost;
   private int zkClientTimeout;
@@ -48,13 +54,16 @@
 
   private volatile ZooKeeper keeper;
 
-  public ZooKeeperConnection(String zkHost, int zkClientTimeout) {
+  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...");
     
@@ -186,7 +195,228 @@
       throws KeeperException, InterruptedException {
     return keeper.setData(path, data, version);
   }
+  
+  /**
+   * 
+   * @param path
+   * @param data
+   * @param watcher
+   * @return
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  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);
+    // nocommit : race issue on keeper switch
+    exists(zkPath, watcher);
+    
+    return zkPath;
+  }
+
+  /**
+   * Creates the path in ZooKeeper, creating each node as necessary.
+   * 
+   * e.g. If <code>path=/solr/group/node</code> and none of the nodes, solr,
+   * group, node exist, each will be created.
+   * 
+   * @param path
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void makePath(String path) throws KeeperException,
+      InterruptedException {
+    makePath(path, null, CreateMode.PERSISTENT);
+  }
+
+  /**
+   * Creates the path in ZooKeeper, creating each node as necessary.
+   * 
+   * @param path
+   * @param data to set on the last zkNode
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void makePath(String path, byte[] data) throws KeeperException,
+      InterruptedException {
+    makePath(path, data, CreateMode.PERSISTENT);
+  }
+
+  /**
+   * Creates the path in ZooKeeper, creating each node as necessary.
+   * 
+   * e.g. If <code>path=/solr/group/node</code> and none of the nodes, solr,
+   * group, node exist, each will be created.
+   * 
+   * @param path
+   * @param data to set on the last zkNode
+   * @param createMode
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void makePath(String path, byte[] data, CreateMode createMode)
+      throws KeeperException, InterruptedException {
+    makePath(path, data, createMode, null);
+  }
+
+  /**
+   * Creates the path in ZooKeeper, creating each node as necessary.
+   * 
+   * e.g. If <code>path=/solr/group/node</code> and none of the nodes, solr,
+   * group, node exist, each will be created.
+   * 
+   * @param path
+   * @param data to set on the last zkNode
+   * @param createMode
+   * @param watcher
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void makePath(String path, byte[] data, CreateMode createMode,
+      Watcher watcher) throws KeeperException, InterruptedException {
+    if (log.isInfoEnabled()) {
+      log.info("makePath: " + path);
+    }
+
+    if (path.startsWith("/")) {
+      path = path.substring(1, path.length());
+    }
+    String[] paths = path.split("/");
+    StringBuilder sbPath = new StringBuilder();
+    for (int i = 0; i < paths.length; i++) {
+      byte[] bytes = null;
+      String pathPiece = paths[i];
+      sbPath.append("/" + pathPiece);
+      String currentPath = sbPath.toString();
+      Object exists = exists(currentPath, watcher);
+      if (exists == null) {
+        CreateMode mode = CreateMode.PERSISTENT;
+        if (i == paths.length - 1) {
+          mode = createMode;
+          bytes = data;
+        }
+        create(currentPath, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, mode);
+        // set new watch
+        exists(currentPath, watcher);
+      } else if (i == paths.length - 1) {
+        // nocommit: version ?
+        setData(currentPath, data, -1);
+        // set new watch
+        exists(currentPath, watcher);
+      }
+    }
+  }
+
+  /**
+   * @param zkPath
+   * @param createMode
+   * @param watcher
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void makePath(String zkPath, CreateMode createMode, Watcher watcher)
+      throws KeeperException, InterruptedException {
+    makePath(zkPath, null, createMode, watcher);
+  }
+
+  /**
+   * Write data to ZooKeeper.
+   * 
+   * @param path
+   * @param data
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void write(String path, byte[] data) throws KeeperException,
+      InterruptedException {
+
+    makePath(path);
+
+    Object exists = exists(path, null);
+    if (exists != null) {
+      setData(path, data, -1);
+    } else {
+      create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE,
+          CreateMode.PERSISTENT);
+    }
+  }
+
+  /**
+   * Write file to ZooKeeper - default system encoding used.
+   * 
+   * @param path path to upload file to e.g. /solr/conf/solrconfig.xml
+   * @param file path to file to be uploaded
+   * @throws IOException
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void write(String path, File file) throws IOException,
+      KeeperException, InterruptedException {
+    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.
+   * 
+   * @param path
+   * @param indent
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void printLayout(String path, int indent, StringBuilder string)
+      throws KeeperException, InterruptedException {
+    byte[] data = getData(path, null, null);
+    List<String> children = getChildren(path, null);
+    StringBuilder dent = new StringBuilder();
+    for (int i = 0; i < indent; i++) {
+      dent.append(" ");
+    }
+    string.append(dent + path + " (" + children.size() + ")" + NEWL);
+    if (data != null) {
+      try {
+        String dataString = new String(data, "UTF-8");
+        if (!path.endsWith(".txt") && !path.endsWith(".xml")) {
+          string.append(dent + "DATA:\n" + dent + "    "
+              + dataString.replaceAll("\n", "\n" + dent + "    ") + NEWL);
+        } else {
+          string.append(dent + "DATA: ...supressed..." + NEWL);
+        }
+      } catch (UnsupportedEncodingException e) {
+        throw new RuntimeException(e);
+      }
+    }
+
+    for (String child : children) {
+      if (!child.equals("quota")) {
+        printLayout(path + (path.equals("/") ? "" : "/") + child, indent + 1,
+            string);
+      }
+    }
+
+  }
+
+  /**
+   * Prints current ZooKeeper layout to stdout.
+   * 
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  public void printLayoutToStdOut() throws KeeperException,
+      InterruptedException {
+    StringBuilder sb = new StringBuilder();
+    printLayout("/", 0, sb);
+    System.out.println(sb.toString());
+  }
 
+  /**
+   * @throws InterruptedException
+   */
   public void close() throws InterruptedException {
     keeper.close();
   }

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=895087&r1=895086&r2=895087&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 Fri
Jan  1 22:47:53 2010
@@ -17,9 +17,14 @@
  * limitations under the License.
  */
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -27,14 +32,21 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.apache.solr.common.SolrException;
+import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.SolrResourceLoader;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
+import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.xml.sax.SAXException;
 
 /**
  * Handle ZooKeeper interactions.
@@ -45,6 +57,8 @@
  * TODO: handle ZooKeeper goes down / failures, Solr still runs
  */
 public final class ZooKeeperController {
+  static final String NEWL = System.getProperty("line.separator");
+  
   private static final String COLLECTIONS_ZKNODE = "/collections/";
 
   static final String NODE_ZKPREFIX = "/node";
@@ -53,9 +67,11 @@
 
   static final String PROPS_DESC = "NodeDesc";
 
-  static final String SHARD_LIST_PROP = "shard_list";
 
-  static final String URL_PROP = "url";
+
+
+  private static final String CONFIGS_ZKNODE = "/configs/";
+
 
   // nocommit - explore handling shard changes
   // watches the shards zkNode
@@ -79,11 +95,16 @@
         controller.loadCollectionInfo();
 
       } catch (KeeperException e) {
+        log.error("", e);
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
             "ZooKeeper Exception", e);
       } catch (InterruptedException e) {
         // Restore the interrupted status
         Thread.currentThread().interrupt();
+      } catch (IOException e) {
+        log.error("", e);
+        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+            "IOException", e);
       }
 
     }
@@ -99,26 +120,20 @@
   private static Logger log = LoggerFactory
       .getLogger(ZooKeeperController.class);
 
+  private SolrZkClient zkClient;
 
-  private ZooKeeperConnection keeperConnection;
-
-  ZooKeeperConnection getKeeperConnection() {
-    return keeperConnection;
+  SolrZkClient getKeeperConnection() {
+    return zkClient;
   }
 
-  private ZooKeeperReader zkReader;
-
   private String collectionName;
 
   private volatile CollectionInfo collectionInfo;
 
   private String shardsZkPath;
 
-  private ZooKeeperWriter zkWriter;
-
   private String zkServerAddress;
 
-
   private String hostPort;
 
   private String hostContext;
@@ -127,7 +142,6 @@
 
   private String zooKeeperHostName;
 
-
   /**
    * 
    * @param zkServerAddress ZooKeeper server host address
@@ -144,23 +158,19 @@
     this.zkServerAddress = zkServerAddress;
     this.hostPort = hostPort;
     this.hostContext = hostContext;
-    keeperConnection = new ZooKeeperConnection(zkServerAddress, zkClientTimeout);
- 
+    zkClient = new SolrZkClient(zkServerAddress, zkClientTimeout);
+
     shardsZkPath = COLLECTIONS_ZKNODE + collectionName + SHARDS_ZKNODE;
 
     init();
   }
-  
+
   private void init() {
 
     try {
-      keeperConnection.connect();
-      
-      // nocommit : consider losing these and having everything on ZooKeeperConnection
-      zkReader = new ZooKeeperReader(keeperConnection);
-      zkWriter = new ZooKeeperWriter(keeperConnection);
+      zkClient.connect();
+
 
-      configName = zkReader.readConfigName(collectionName);
 
       zooKeeperHostName = getHostAddress();
       Matcher m = URL_POST.matcher(zooKeeperHostName);
@@ -168,7 +178,7 @@
         String hostName = m.group(1);
 
         // register host
-        zkWriter.makePath(hostName);
+        zkClient.makePath(hostName);
       } else {
         // nocommit
         throw new IllegalStateException("Bad host:" + zooKeeperHostName);
@@ -176,6 +186,8 @@
 
       // build layout if not exists
       buildZkLayoutZkNodes();
+      
+      configName = readConfigName(collectionName);
 
       // load the state of the cloud
       loadCollectionInfo();
@@ -197,9 +209,10 @@
     }
 
   }
-  
-  public boolean configFileExists(String fileName) throws KeeperException, InterruptedException
{
-    return zkReader.configFileExists(configName, fileName);
+
+  public boolean configFileExists(String fileName) throws KeeperException,
+      InterruptedException {
+    return configFileExists(configName, fileName);
   }
 
   /**
@@ -209,12 +222,12 @@
   private void buildZkLayoutZkNodes() throws IOException {
     try {
       // shards node
-      if (!zkReader.exists(shardsZkPath)) {
+      if (!exists(shardsZkPath)) {
         if (log.isInfoEnabled()) {
           log.info("creating zk shards node:" + shardsZkPath);
         }
         // makes shards zkNode if it doesn't exist
-        zkWriter.makePath(shardsZkPath, CreateMode.PERSISTENT, SHARD_WATCHER);
+        zkClient.makePath(shardsZkPath, CreateMode.PERSISTENT, SHARD_WATCHER);
       }
     } catch (KeeperException e) {
       // its okay if another beats us creating the node
@@ -234,7 +247,7 @@
    */
   public void close() {
     try {
-      keeperConnection.close();
+      zkClient.close();
     } catch (InterruptedException e) {
       // Restore the interrupted status
       Thread.currentThread().interrupt();
@@ -249,51 +262,19 @@
   }
 
   /**
-   * @return an object that encapsulates most of the ZooKeeper read util operations.
-   */
-  public ZooKeeperReader getZkReader() {
-    return zkReader;
-  }
-
-  /**
-   * @return an object that encapsulates most of the ZooKeeper write util operations.
-   */
-  public ZooKeeperWriter getZkWriter() {
-    return zkWriter;
-  }
-  
-
-  /**
    * @return
    */
-  public String getZooKeeperHost() {
+  public String getZkServerAddress() {
     return zkServerAddress;
   }
 
   // load and publish a new CollectionInfo
-  private void loadCollectionInfo() {
+  private void loadCollectionInfo() throws KeeperException, InterruptedException, IOException
{
     // build immutable CollectionInfo
-    boolean updateCollectionInfo = false;
-    Map<String,ShardInfoList> shardNameToShardList = null;
-    try {
-      shardNameToShardList = zkReader.readShardInfo(shardsZkPath);
-      updateCollectionInfo = true;
-    } catch (KeeperException e) {
-      // nocommit: its okay if we cannot access ZK - just log
-      // and continue
-      log.error("", e);
-    } catch (IOException e) {
-      log.error("", e);
-    } catch (InterruptedException e) {
-      // Restore the interrupted status
-      Thread.currentThread().interrupt();
-    }
-
-    if(updateCollectionInfo) {
-      CollectionInfo collectionInfo = new CollectionInfo(shardNameToShardList);
+    
+      CollectionInfo collectionInfo = new CollectionInfo(zkClient, shardsZkPath);
       // update volatile
       this.collectionInfo = collectionInfo;
-    }
   }
 
   /**
@@ -331,8 +312,8 @@
    */
   public void registerShard(SolrCore core) {
     String coreName = core.getCoreDescriptor().getName();
-    String shardUrl = zooKeeperHostName + ":" + hostPort + "/" + hostContext + "/"
-        + coreName;
+    String shardUrl = zooKeeperHostName + ":" + hostPort + "/" + hostContext
+        + "/" + coreName;
 
     // nocommit:
     if (log.isInfoEnabled()) {
@@ -345,15 +326,15 @@
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       // nocommit: could do xml
       Properties props = new Properties();
-      props.put(URL_PROP, shardUrl);
-      
+      props.put(CollectionInfo.URL_PROP, shardUrl);
+
       String shardList = core.getCoreDescriptor().getShardList();
-      
-      props.put(SHARD_LIST_PROP, shardList == null ? "" : shardList);
+
+      props.put(CollectionInfo.SHARD_LIST_PROP, shardList == null ? "" : shardList);
       props.store(baos, PROPS_DESC);
 
-      zkWriter.makeEphemeralSeqPath(shardsZkPath + NODE_ZKPREFIX, baos
-          .toByteArray(), SHARD_WATCHER);
+      zkClient.create(shardsZkPath + NODE_ZKPREFIX, baos
+          .toByteArray(), CreateMode.EPHEMERAL_SEQUENTIAL, SHARD_WATCHER);
 
     } catch (InterruptedException e) {
       // Restore the interrupted status
@@ -385,4 +366,195 @@
 
     return host;
   }
+
+  /**
+   * Check if path exists in ZooKeeper.
+   * 
+   * @param path ZooKeeper path
+   * @return true if path exists in ZooKeeper
+   * @throws InterruptedException
+   * @throws KeeperException
+   */
+  public boolean exists(String path) throws KeeperException,
+      InterruptedException {
+    Object exists = zkClient.exists(path, null);
+
+    return exists != null;
+  }
+
+  /**
+   * Load SolrConfig from ZooKeeper.
+   * 
+   * TODO: consider *many* cores firing up at once and loading the same files
+   * from ZooKeeper
+   * 
+   * @param resourceLoader
+   * @param solrConfigFileName
+   * @return
+   * @throws IOException
+   * @throws ParserConfigurationException
+   * @throws SAXException
+   * @throws InterruptedException
+   * @throws KeeperException
+   */
+  public SolrConfig getConfig(String zkConfigName, String solrConfigFileName,
+      SolrResourceLoader resourceLoader) throws IOException,
+      ParserConfigurationException, SAXException, KeeperException,
+      InterruptedException {
+    byte[] config = zkClient.getData(CONFIGS_ZKNODE + zkConfigName
+        + "/" + solrConfigFileName, null, null);
+    InputStream is = new ByteArrayInputStream(config);
+    SolrConfig cfg = solrConfigFileName == null ? new SolrConfig(
+        resourceLoader, SolrConfig.DEFAULT_CONF_FILE, is) : new SolrConfig(
+        resourceLoader, solrConfigFileName, is);
+
+    return cfg;
+  }
+
+  public byte[] getConfigFileData(String zkConfigName, String fileName)
+      throws KeeperException, InterruptedException {
+    return zkClient.getData(CONFIGS_ZKNODE + zkConfigName, null, null);
+  }
+
+  // /**
+  // * Get data at zkNode path/fileName.
+  // *
+  // * @param path to zkNode
+  // * @param fileName name of zkNode
+  // * @return data at path/file
+  // * @throws InterruptedException
+  // * @throws KeeperException
+  // */
+  // public byte[] getFile(String path, String fileName) throws KeeperException,
+  // InterruptedException {
+  // byte[] bytes = null;
+  // String configPath = path + "/" + fileName;
+  //
+  // if (log.isInfoEnabled()) {
+  // log.info("Reading " + fileName + " from zookeeper at " + configPath);
+  // }
+  // bytes = keeperConnection.getData(configPath, null, null);
+  //
+  // return bytes;
+  // }
+
+  /**
+   * Load IndexSchema from ZooKeeper.
+   * 
+   * TODO: consider *many* cores firing up at once and loading the same files
+   * from ZooKeeper
+   * 
+   * @param resourceLoader
+   * @param schemaName
+   * @param config
+   * @return
+   * @throws InterruptedException
+   * @throws KeeperException
+   */
+  public IndexSchema getSchema(String zkConfigName, String schemaName,
+      SolrConfig config, SolrResourceLoader resourceLoader)
+      throws KeeperException, InterruptedException {
+    byte[] configBytes = zkClient.getData(CONFIGS_ZKNODE + zkConfigName
+        + "/" + schemaName, null, null);
+    InputStream is = new ByteArrayInputStream(configBytes);
+    IndexSchema schema = new IndexSchema(config, schemaName, is);
+    return schema;
+  }
+
+  public String readConfigName(String collection) throws KeeperException,
+      InterruptedException {
+    // nocommit: load all config at once or organize differently (Properties?)
+    String configName = null;
+
+    String path = COLLECTIONS_ZKNODE + collection;
+    if (log.isInfoEnabled()) {
+      log.info("Load collection config from:" + path);
+    }
+    List<String> children;
+    try {
+      children = zkClient.getChildren(path, null);
+    } catch(KeeperException.NoNodeException e) {
+      log.error("Could not find config name to use for collection:" + collection, e);
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+          "Timeout waiting for ZooKeeper connection", e);
+    }
+    for (String node : children) {
+      // nocommit
+      System.out.println("check child:" + node);
+      // nocommit: do we actually want to handle settings in the node name?
+      if (node.startsWith("config=")) {
+        configName = node.substring(node.indexOf("=") + 1);
+        if (log.isInfoEnabled()) {
+          log.info("Using collection config:" + configName);
+        }
+      }
+    }
+
+    if (configName == null) {
+      throw new IllegalStateException("no config specified for collection:"
+          + collection);
+    }
+
+    return configName;
+  }
+
+  /**
+   * Read info on the available Shards and Nodes.
+   * 
+   * @param path to the shards zkNode
+   * @return Map from shard name to a {@link ShardInfoList}
+   * @throws InterruptedException
+   * @throws KeeperException
+   * @throws IOException
+   */
+  public Map<String,ShardInfoList> readShardInfo(String path)
+      throws KeeperException, InterruptedException, IOException {
+    // for now, just reparse everything
+    HashMap<String,ShardInfoList> shardNameToShardList = new HashMap<String,ShardInfoList>();
+
+    if (!exists(path)) {
+      throw new IllegalStateException("Cannot find zk node that should exist:"
+          + path);
+    }
+    List<String> nodes = zkClient.getChildren(path, null);
+
+    for (String zkNodeName : nodes) {
+      byte[] data = zkClient.getData(path + "/" + zkNodeName, null,
+          null);
+
+      Properties props = new Properties();
+      props.load(new ByteArrayInputStream(data));
+
+      String url = (String) props.get(CollectionInfo.URL_PROP);
+      String shardNameList = (String) props.get(CollectionInfo.SHARD_LIST_PROP);
+      String[] shardsNames = shardNameList.split(",");
+      for (String shardName : shardsNames) {
+        ShardInfoList sList = shardNameToShardList.get(shardName);
+        List<ShardInfo> shardList;
+        if (sList == null) {
+          shardList = new ArrayList<ShardInfo>(1);
+        } else {
+          List<ShardInfo> oldShards = sList.getShards();
+          shardList = new ArrayList<ShardInfo>(oldShards.size() + 1);
+          shardList.addAll(oldShards);
+        }
+
+        ShardInfo shard = new ShardInfo(url);
+        shardList.add(shard);
+        ShardInfoList list = new ShardInfoList(shardList);
+
+        shardNameToShardList.put(shardName, list);
+      }
+
+    }
+
+    return Collections.unmodifiableMap(shardNameToShardList);
+  }
+
+  public boolean configFileExists(String configName, String fileName)
+      throws KeeperException, InterruptedException {
+    Stat stat = zkClient.exists(CONFIGS_ZKNODE + configName, null);
+    return stat != null;
+  }
+
 }

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperSolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperSolrResourceLoader.java?rev=895087&r1=895086&r2=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperSolrResourceLoader.java
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZooKeeperSolrResourceLoader.java
Fri Jan  1 22:47:53 2010
@@ -30,13 +30,12 @@
 public class ZooKeeperSolrResourceLoader extends SolrResourceLoader {
 
   private String collection;
-
-  private ZooKeeperReader zkReader;
+  private ZooKeeperController zkController;
 
   public ZooKeeperSolrResourceLoader(String instanceDir, String collection,
       ZooKeeperController zooKeeperController) {
     super(instanceDir);
-    this.zkReader = zooKeeperController.getZkReader();
+    this.zkController = zooKeeperController;
     this.collection = collection;
   }
 
@@ -52,7 +51,7 @@
       Properties coreProperties, ZooKeeperController zooKeeperController) {
     super(instanceDir, parent, coreProperties);
     this.collection = collection;
-    this.zkReader = zooKeeperController.getZkReader();
+    this.zkController = zooKeeperController;
   }
 
   /**
@@ -70,8 +69,8 @@
     //nocommit:
     System.out.println("look for:" + file);
     try {
-      if (zkReader.exists(file)) {
-        byte[] bytes = zkReader.getFile(getConfigDir(), resource);
+      if (zkController.exists(file)) {
+        byte[] bytes = zkController.getKeeperConnection().getData(getConfigDir() + "/" +
resource, null, null);
         return new ByteArrayInputStream(bytes);
       }
     } catch (Exception 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=895087&r1=895086&r2=895087&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 Fri Jan  1
22:47:53 2010
@@ -479,7 +479,7 @@
     } else {
       solrLoader = new ZooKeeperSolrResourceLoader(instanceDir, collection, libLoader, getCoreProps(instanceDir,
dcore.getPropertiesName(),dcore.getCoreProperties()), zooKeeperController);
       try {
-        config = zooKeeperController.getZkReader().getConfig(zooKeeperController.getConfigName(),
dcore.getConfigName(), solrLoader);
+        config = zooKeeperController.getConfig(zooKeeperController.getConfigName(), dcore.getConfigName(),
solrLoader);
       } catch (KeeperException e) {
         log.error("ZooKeeper Exception", e);
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
@@ -522,7 +522,7 @@
     if(schema == null){
       if(zooKeeperController != null) {
         try {
-          schema = zooKeeperController.getZkReader().getSchema(zooKeeperController.getConfigName(),
dcore.getSchemaName(), config, solrLoader);
+          schema = zooKeeperController.getSchema(zooKeeperController.getConfigName(), dcore.getSchemaName(),
config, solrLoader);
         } catch (KeeperException e) {
           log.error("ZooKeeper Exception", e);
           throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,

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=895087&r1=895086&r2=895087&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
Fri Jan  1 22:47:53 2010
@@ -94,12 +94,9 @@
   }
   
   private void printeLayout() throws Exception {
-    ZooKeeperReader zkReader = new ZooKeeperReader(
-        AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.substring(0,
-            AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.indexOf('/')),
-        AbstractZooKeeperTestCase.TIMEOUT);
-
-    zkReader.printLayoutToStdOut();
-    zkReader.close();
+    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=895087&r1=895086&r2=895087&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
Fri Jan  1 22:47:53 2010
@@ -90,30 +90,37 @@
 
   }
 
+  final static String JUST_HOST_NAME = AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.substring(0,
+      AbstractZooKeeperTestCase.ZOO_KEEPER_HOST.indexOf('/'));
+  
   // static to share with distrib test
   static void buildZooKeeper(String config, String schema)
       throws Exception {
-    ZooKeeperWriter zkWriter = new ZooKeeperWriter(ZOO_KEEPER_HOST.substring(0, ZOO_KEEPER_HOST
-        .indexOf('/')), TIMEOUT);
-
-    zkWriter.makePath("/solr");
-    zkWriter.close();
-
-    zkWriter = new ZooKeeperWriter(ZOO_KEEPER_HOST, TIMEOUT);
-
-    zkWriter.makePath("/collections/collection1/config=collection1");
-
-    putConfig(zkWriter, config);
-    putConfig(zkWriter, schema);
-    putConfig(zkWriter, "stopwords.txt");
-    putConfig(zkWriter, "protwords.txt");
-    putConfig(zkWriter, "mapping-ISOLatin1Accent.txt");
-    putConfig(zkWriter, "old_synonyms.txt");
-    zkWriter.close();
+    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");
+
+    putConfig(zkClient, config);
+    putConfig(zkClient, schema);
+    putConfig(zkClient, "stopwords.txt");
+    putConfig(zkClient, "protwords.txt");
+    putConfig(zkClient, "mapping-ISOLatin1Accent.txt");
+    putConfig(zkClient, "old_synonyms.txt");
+    
+    //nocommit
+    zkClient.printLayoutToStdOut();
+    
+    zkClient.close();
   }
 
-  private static void putConfig(ZooKeeperWriter zkWriter, String name) throws Exception {
-    zkWriter.write("/configs/collection1/" + name, new File("solr"
+  private static void putConfig(SolrZkClient zkConnection, String name) throws Exception
{
+    zkConnection.write("/configs/collection1/" + name, new File("solr"
         + File.separator + "conf" + File.separator + name));
   }
 
@@ -124,10 +131,12 @@
   }
 
   private void printLayout() throws Exception {
-    ZooKeeperReader zkReader = new ZooKeeperReader(ZOO_KEEPER_HOST.substring(0, ZOO_KEEPER_HOST
-        .indexOf('/')), TIMEOUT);
-
-    zkReader.printLayoutToStdOut();
-    zkReader.close();
+    SolrZkClient zkClient = new SolrZkClient(
+        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/BasicDistributedZooKeeperTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZooKeeperTest.java?rev=895087&r1=895086&r2=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZooKeeperTest.java
(original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZooKeeperTest.java
Fri Jan  1 22:47:53 2010
@@ -17,7 +17,6 @@
  * limitations under the License.
  */
 
-import java.io.File;
 import java.util.HashSet;
 
 import org.apache.solr.client.solrj.SolrServerException;

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/TestShardInfoList.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/TestShardInfoList.java?rev=895087&r1=895086&r2=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/TestShardInfoList.java (original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/TestShardInfoList.java Fri Jan
 1 22:47:53 2010
@@ -1,7 +1,5 @@
 package org.apache.solr.cloud;
 
-import junit.framework.TestCase;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements. See the NOTICE file distributed with this
@@ -19,6 +17,8 @@
  * the License.
  */
 
+import junit.framework.TestCase;
+
 public class TestShardInfoList extends TestCase {
 
   public void testBasic() {

Copied: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
(from r894959, lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperReaderTest.java)
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java?p2=lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java&p1=lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperReaderTest.java&r1=894959&r2=895087&rev=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperReaderTest.java (original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperControllerTest.java
Fri Jan  1 22:47:53 2010
@@ -1,5 +1,22 @@
 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.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
@@ -10,9 +27,10 @@
 
 import junit.framework.TestCase;
 
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 
-public class ZooKeeperReaderTest extends TestCase {
+public class ZooKeeperControllerTest extends TestCase {
 
   private static final String COLLECTION_NAME = "collection1";
 
@@ -20,7 +38,8 @@
 
   private static final String SHARD1 = "shard1";
 
-  static final String ZOO_KEEPER_HOST = "localhost:2181/solr";
+  static final String ZOO_KEEPER_ADDRESS = "localhost:2181/solr";
+  static final String ZOO_KEEPER_HOST = "localhost:2181";
 
   static final int TIMEOUT = 10000;
 
@@ -35,28 +54,34 @@
   public void testReadShards() throws Exception {
     String zkDir = tmpDir.getAbsolutePath() + File.separator
         + "zookeeper/server1/data";
-
-    ZooKeeperTestServer server = new ZooKeeperTestServer(zkDir);
+    ZooKeeperTestServer server = null;
+      SolrZkClient zkClient = null;
+    try {
+    server = new ZooKeeperTestServer(zkDir);
     server.run();
 
     makeSolrZkNode();
-
-    ZooKeeperWriter writer = new ZooKeeperWriter(ZOO_KEEPER_HOST, TIMEOUT);
+    
+    zkClient = new SolrZkClient(ZOO_KEEPER_ADDRESS, TIMEOUT);
+    zkClient.connect();
     String shardsPath = "/collections/collection1/shards";
-    writer.makePath(shardsPath);
+    zkClient.makePath(shardsPath);
+    
+    zkClient.makePath("collections/collection1/config=collection1");
 
-    addShardToZk(writer, shardsPath, URL1, SHARD1 + "," + SHARD2);
-    addShardToZk(writer, shardsPath, "http://localhost:3123/solr/core1", SHARD1);
-    addShardToZk(writer, shardsPath, "http://localhost:3133/solr/core1", SHARD1);
+    addShardToZk(zkClient, shardsPath, URL1, SHARD1 + "," + SHARD2);
+    addShardToZk(zkClient, shardsPath, "http://localhost:3123/solr/core1", SHARD1);
+    addShardToZk(zkClient, shardsPath, "http://localhost:3133/solr/core1", SHARD1);
 
-    ZooKeeperReader reader = new ZooKeeperReader(ZOO_KEEPER_HOST, TIMEOUT);
 
     if (DEBUG) {
-      reader.printLayoutToStdOut();
+      zkClient.printLayoutToStdOut();
     }
 
-    Map<String,ShardInfoList> shardInfoMap = reader.readShardInfo(shardsPath);
+    ZooKeeperController zkController = new ZooKeeperController(ZOO_KEEPER_ADDRESS, "collection1",
"localhost", "8983", "/solr", TIMEOUT);
+    Map<String,ShardInfoList> shardInfoMap = zkController.readShardInfo(shardsPath);
     assertTrue(shardInfoMap.size() > 0);
+    
     Set<Entry<String,ShardInfoList>> entries = shardInfoMap.entrySet();
 
     if (DEBUG) {
@@ -82,8 +107,14 @@
     assertEquals(1, shardInfoList.getShards().size());
 
     assertEquals(URL1, shardInfoList.getShards().get(0).getUrl());
-
-    server.shutdown();
+    } finally {
+      if(zkClient != null) {
+        zkClient.close();
+      }
+      if(server != null) {
+        server.shutdown();
+      }
+    }
   }
 
   public void testReadConfigName() throws Exception {
@@ -95,42 +126,44 @@
 
     makeSolrZkNode();
 
-    ZooKeeperWriter writer = new ZooKeeperWriter(ZOO_KEEPER_HOST, TIMEOUT);
+    SolrZkClient zkClient = new SolrZkClient(ZOO_KEEPER_ADDRESS, TIMEOUT);
+    zkClient.connect();
     String actualConfigName = "firstConfig";
       
     String shardsPath = "/collections/" + COLLECTION_NAME + "/config=" + actualConfigName;
-    writer.makePath(shardsPath);
-    
-    ZooKeeperReader reader = new ZooKeeperReader(ZOO_KEEPER_HOST, TIMEOUT);
+    zkClient.makePath(shardsPath);
 
     if (DEBUG) {
-      reader.printLayoutToStdOut();
+      zkClient.printLayoutToStdOut();
     }
     
-    String configName = reader.readConfigName(COLLECTION_NAME);
+    ZooKeeperController zkController = new ZooKeeperController(ZOO_KEEPER_ADDRESS, "collection1",
"localhost", "8983", "/solr", TIMEOUT);
+    String configName = zkController.readConfigName(COLLECTION_NAME);
     assertEquals(configName, actualConfigName);
     
+    zkClient.close();
+    server.shutdown();
+    
   }
 
-  private void addShardToZk(ZooKeeperWriter writer, String shardsPath,
+  private void addShardToZk(SolrZkClient zkClient, String shardsPath,
       String url, String shardList) throws IOException, KeeperException,
       InterruptedException {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     // nocommit: could do xml
     Properties props = new Properties();
-    props.put(ZooKeeperController.URL_PROP, url);
-    props.put(ZooKeeperController.SHARD_LIST_PROP, shardList);
+    props.put(CollectionInfo.URL_PROP, url);
+    props.put(CollectionInfo.SHARD_LIST_PROP, shardList);
     props.store(baos, ZooKeeperController.PROPS_DESC);
 
-    writer.makeEphemeralSeqPath(shardsPath
-        + ZooKeeperController.NODE_ZKPREFIX, baos.toByteArray(), null);
+    zkClient.create(shardsPath
+        + ZooKeeperController.NODE_ZKPREFIX, baos.toByteArray(), CreateMode.EPHEMERAL_SEQUENTIAL,
null);
   }
 
   private void makeSolrZkNode() throws Exception {
-    ZooKeeperWriter zkWriter = new ZooKeeperWriter(ZOO_KEEPER_HOST.substring(0,
-        ZOO_KEEPER_HOST.indexOf('/')), TIMEOUT);
-
-    zkWriter.makePath("/solr");
-    zkWriter.close();
+    SolrZkClient zkClient = new SolrZkClient(ZOO_KEEPER_HOST, TIMEOUT);
+    zkClient.connect();
+    zkClient.makePath("/solr");
+    zkClient.close();
   }
 }

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperTestServer.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperTestServer.java?rev=895087&r1=895086&r2=895087&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperTestServer.java (original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZooKeeperTestServer.java Fri
Jan  1 22:47:53 2010
@@ -1,5 +1,22 @@
 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 org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
 



Mime
View raw message