You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by ma...@apache.org on 2010/01/14 01:15:48 UTC

svn commit: r899007 - in /lucene/solr/branches/cloud/src: java/org/apache/solr/cloud/ test/org/apache/solr/cloud/

Author: markrmiller
Date: Thu Jan 14 00:15:48 2010
New Revision: 899007

URL: http://svn.apache.org/viewvc?rev=899007&view=rev
Log:
minor name refactoring and updates

Added:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java
      - copied, changed from r898977, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudInfo.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionState.java
      - copied, changed from r898977, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java
Removed:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudInfo.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java
Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ShardsWatcher.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java

Copied: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java (from r898977, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudInfo.java)
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java?p2=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java&p1=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudInfo.java&r1=898977&r2=899007&rev=899007&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudInfo.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java Thu Jan 14 00:15:48 2010
@@ -20,15 +20,15 @@
 import java.util.HashMap;
 import java.util.Map;
 
-public class CloudInfo {
-  private Map<String,CollectionInfo> collectionInfos = new HashMap<String,CollectionInfo>();
+public class CloudState {
+  private Map<String,CollectionState> collectionStates = new HashMap<String,CollectionState>();
   
   //nocommit
-  public void addCollectionInfo(String collection, CollectionInfo collectionInfo) {
-    collectionInfos.put(collection, collectionInfo);
+  public void addCollectionInfo(String collection, CollectionState collectionInfo) {
+    collectionStates.put(collection, collectionInfo);
   }
   
-  public CollectionInfo getCollectionInfo(String collection) {
-    return collectionInfos.get(collection);
+  public CollectionState getCollectionInfo(String collection) {
+    return collectionStates.get(collection);
   }
 }

Copied: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionState.java (from r898977, 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/CollectionState.java?p2=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionState.java&p1=lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CollectionInfo.java&r1=898977&r2=899007&rev=899007&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/CollectionState.java Thu Jan 14 00:15:48 2010
@@ -34,10 +34,10 @@
  * Information about the Collection.
  * 
  */
-public final class CollectionInfo {
+public final class CollectionState {
 
   protected static final Logger log = LoggerFactory
-      .getLogger(CollectionInfo.class);
+      .getLogger(CollectionState.class);
   
   static final String SHARD_LIST_PROP = "shard_list";
   static final String URL_PROP = "url";
@@ -51,7 +51,7 @@
 
 
 
-  public CollectionInfo(Map<String,Properties> shards, List<String> nodes) {
+  public CollectionState(Map<String,Properties> shards, List<String> nodes) {
     //nocommit: defensive copy?
     this.shards = shards;
     this.updateTime = System.currentTimeMillis();

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ShardsWatcher.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ShardsWatcher.java?rev=899007&r1=899006&r2=899007&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ShardsWatcher.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ShardsWatcher.java Thu Jan 14 00:15:48 2010
@@ -52,7 +52,7 @@
       // nocommit : rewatch
       controller.getZkClient().exists(event.getPath(), this);
 
-      // TODO: need to load whole state?
+      // nocommit : just see what has changed
       controller.readCloudInfo();
 
     } catch (KeeperException e) {

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=899007&r1=899006&r2=899007&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 Thu Jan 14 00:15:48 2010
@@ -25,7 +25,6 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.cloud.ZkClientConnectionStrategy.ZkUpdate;
-import org.apache.solr.common.SolrException;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.Watcher;

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java?rev=899007&r1=899006&r2=899007&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java Thu Jan 14 00:15:48 2010
@@ -23,7 +23,6 @@
 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.HashSet;
@@ -82,7 +81,7 @@
 
   private SolrZkClient zkClient;
 
-  private volatile CloudInfo cloudInfo;
+  private volatile CloudState cloudInfo;
 
   private String zkServerAddress;
 
@@ -175,7 +174,7 @@
 
     // now watch the shards node
     try {
-      zkClient.exists(shardsZkPath, shardWatcher);
+      zkClient.getChildren(shardsZkPath, shardWatcher);
     } catch (KeeperException e) {
       log.error("ZooKeeper Exception", e);
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
@@ -214,7 +213,7 @@
   /**
    * @return information about the cluster from ZooKeeper
    */
-  public CloudInfo getCloudInfo() {
+  public CloudState getCloudInfo() {
     return cloudInfo;
   }
 
@@ -400,7 +399,7 @@
     log.info("Updating cloud state from ZooKeeper... :" + zkClient.keeper);
     
     // build immutable CloudInfo
-    CloudInfo cloudInfo = new CloudInfo();
+    CloudState cloudInfo = new CloudState();
     List<String> collections = getCollectionNames();
     // nocommit : load all collection info
     for (String collection : collections) {
@@ -410,7 +409,7 @@
       List<String> nodes = zkClient.getChildren(shardsZkPath, null);
       Map<String,Properties> shards = readShardsInfo(collection, shardsZkPath, nodes);
  
-      CollectionInfo collectionInfo = new CollectionInfo(shards, nodes);
+      CollectionState collectionInfo = new CollectionState(shards, nodes);
       cloudInfo.addCollectionInfo(collection, collectionInfo);
     }
 
@@ -561,14 +560,14 @@
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     // nocommit: could do xml
     Properties props = new Properties();
-    props.put(CollectionInfo.URL_PROP, shardUrl);
+    props.put(CollectionState.URL_PROP, shardUrl);
 
     String shardList = cloudDesc.getShardList();
 
-    props.put(CollectionInfo.SHARD_LIST_PROP, shardList == null ? ""
+    props.put(CollectionState.SHARD_LIST_PROP, shardList == null ? ""
         : shardList);
 
-    props.put(CollectionInfo.ROLE_PROP, cloudDesc.getRole());
+    props.put(CollectionState.ROLE_PROP, cloudDesc.getRole());
 
     props.store(baos, PROPS_DESC);
 

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java?rev=899007&r1=899006&r2=899007&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java (original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java Thu Jan 14 00:15:48 2010
@@ -84,8 +84,8 @@
       zkController = new ZkController(ZOO_KEEPER_ADDRESS, TIMEOUT,
           "localhost", "8983", "/solr");
       zkController.readCloudInfo();
-      CloudInfo cloudInfo = zkController.getCloudInfo();
-      CollectionInfo collectionInfo = cloudInfo.getCollectionInfo("collection1");
+      CloudState cloudInfo = zkController.getCloudInfo();
+      CollectionState collectionInfo = cloudInfo.getCollectionInfo("collection1");
       assertNotNull(collectionInfo);
 
 
@@ -174,8 +174,8 @@
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     // nocommit: could do xml
     Properties props = new Properties();
-    props.put(CollectionInfo.URL_PROP, url);
-    props.put(CollectionInfo.SHARD_LIST_PROP, shardList);
+    props.put(CollectionState.URL_PROP, url);
+    props.put(CollectionState.SHARD_LIST_PROP, shardList);
     props.store(baos, ZkController.PROPS_DESC);
 
     zkClient.create(shardsPath + ZkController.CORE_ZKPREFIX,