lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r900889 - in /lucene/solr/branches/cloud/src/java/org/apache/solr/cloud: CloudState.java ZkController.java
Date Tue, 19 Jan 2010 18:29:16 GMT
Author: markrmiller
Date: Tue Jan 19 18:29:15 2010
New Revision: 900889

URL: http://svn.apache.org/viewvc?rev=900889&view=rev
Log:
live nodes as Set and shard prop for node name

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=900889&r1=900888&r2=900889&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 18:29:15
2010
@@ -21,13 +21,14 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 // effectively immutable
 public class CloudState {
   private Map<String,List<Slice>> collectionStates = new HashMap<String,List<Slice>>();
-  private List<String> liveNodes = null;
+  private Set<String> liveNodes = null;
   
-  public CloudState(List<String> liveNodes) {
+  public CloudState(Set<String> liveNodes) {
     this.liveNodes = liveNodes;
   }
   
@@ -41,8 +42,12 @@
     return Collections.unmodifiableList(collectionStates.get(collection));
   }
   
-  public List<String> getLiveNodes() {
-    return Collections.unmodifiableList(liveNodes);
+  public Set<String> getLiveNodes() {
+    return Collections.unmodifiableSet(liveNodes);
+  }
+  
+  public boolean liveNodesContain(String name) {
+    return liveNodes.contains(name);
   }
 
 }

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=900889&r1=900888&r2=900889&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
18:29:15 2010
@@ -28,8 +28,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeoutException;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -77,6 +79,7 @@
 
   static final String URL_PROP = "url";
   static final String ROLE_PROP = "role";
+  static final String NODE_NAME = "node_name";
 
   final ShardsWatcher shardWatcher = new ShardsWatcher(this);
 
@@ -380,9 +383,13 @@
 
   private void createEphemeralNode() throws KeeperException,
       InterruptedException {
-    String nodeName = hostName + ":" + localHostPort + "_"+ localHostContext;
+    String nodeName = getNodeUrl();
     zkClient.makePath(NODES_ZKNODE + "/" + nodeName, CreateMode.EPHEMERAL);
   }
+  
+  private String getNodeUrl() {
+    return hostName + ":" + localHostPort + "_"+ localHostContext;
+  }
 
   // load and publish a new CollectionInfo
   public synchronized void updateCloudState() throws KeeperException, InterruptedException,
@@ -414,10 +421,13 @@
     this.cloudState = cloudInfo;
   }
 
-  private List<String> getLiveNodes() throws KeeperException, InterruptedException
{
+  private Set<String> getLiveNodes() throws KeeperException, InterruptedException {
     // nocomit : incremental update
     List<String> liveNodes = zkClient.getChildren(NODES_ZKNODE, null);
-    return liveNodes;
+    Set<String> liveNodesSet = new HashSet<String>(liveNodes.size());
+    liveNodesSet.addAll(liveNodes);
+
+    return liveNodesSet;
   }
 
   /**
@@ -564,6 +574,8 @@
     props.put(URL_PROP, shardUrl);
 
     props.put(ROLE_PROP, cloudDesc.getRole());
+    
+    props.put(NODE_NAME, getNodeUrl());
 
     props.store(new DataOutputStream(baos));
 



Mime
View raw message