Author: markrmiller
Date: Tue Jan 19 17:05:39 2010
New Revision: 900848

URL: http://svn.apache.org/viewvc?rev=900848&view=rev
Log:
add initial code for live nodes in cloud state

Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java

Modified: 
lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java?rev=900848&r1=900847&r2=900848&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java 
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java 
Tue Jan 19 17:05:39 2010
@@ -25,7 +25,7 @@
 // effectively immutable
 public class CloudState {
   private Map<String,Slice> collectionStates = new HashMap<String,Slice>();
-  private final List<String> nodes = null;
+  private List<String> nodes = null;
   
   // nocommit
   public void addSlice(String collection, Slice slice) {
@@ -40,4 +40,9 @@
   public List<String> getNodes() {
     return Collections.unmodifiableList(nodes);
   }
+  
+  // nocommit
+  public void setNodes(List<String> nodes) {
+    this.nodes = nodes;
+  }
 }

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=900848&r1=900847&r2=900848&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 
Tue Jan 19 17:05:39 2010
@@ -217,7 +217,7 @@
     return cloudState;
   }
 
-  public List<String> getCollectionNames() throws KeeperException,
+  private List<String> getCollectionNames() throws KeeperException,
       InterruptedException {
     // nocommit : watch for new collections?
     List<String> collectionNodes = zkClient.getChildren(COLLECTIONS_ZKNODE,
@@ -393,6 +393,8 @@
     
     // build immutable CloudInfo
     CloudState cloudInfo = new CloudState();
+    List<String> liveNodes = getLiveNodes();
+    cloudInfo.setNodes(liveNodes);
     List<String> collections = getCollectionNames();
     // nocommit : load all collection info
     for (String collection : collections) {
@@ -410,6 +412,12 @@
     this.cloudState = cloudInfo;
   }
 
+  private List<String> getLiveNodes() throws KeeperException, 
InterruptedException {
+    // nocomit : incremental update
+    List<String> liveNodes = zkClient.getChildren(NODES_ZKNODE, null);
+    return liveNodes;
+  }
+
   /**
    * @param path
    * @return


Reply via email to