lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r900856 - in /lucene/solr/branches/cloud/src: java/org/apache/solr/cloud/ java/org/apache/solr/core/ java/org/apache/solr/handler/component/ test/org/apache/solr/ test/org/apache/solr/cloud/
Date Tue, 19 Jan 2010 17:29:40 GMT
Author: markrmiller
Date: Tue Jan 19 17:29:40 2010
New Revision: 900856

URL: http://svn.apache.org/viewvc?rev=900856&view=rev
Log:
some name refactoring to drop public facing slice and addition of Slices for multiple slices
per collection

Added:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slice.java
      - copied unchanged from r900847, lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slice.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slices.java
Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudDescriptor.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudState.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ZkController.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/QueryComponent.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/ZkControllerTest.java

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudDescriptor.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudDescriptor.java?rev=900856&r1=900855&r2=900856&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudDescriptor.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/CloudDescriptor.java Tue Jan
19 17:29:40 2010
@@ -19,7 +19,7 @@
 
 public class CloudDescriptor {
 
-  private String slice;
+  private String shardId;
   private String collectionName;
   private String role = "none";
   
@@ -31,12 +31,12 @@
     this.role = role;
   }
 
-  public void setSlice(String slice) {
-    this.slice = slice;
+  public void setShardId(String shardId) {
+    this.shardId = shardId;
   }
   
-  public String getSlice() {
-    return slice;
+  public String getShardId() {
+    return shardId;
   }
   
   public String getCollectionName() {

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=900856&r1=900855&r2=900856&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:29:40
2010
@@ -24,16 +24,16 @@
 
 // effectively immutable
 public class CloudState {
-  private Map<String,Slice> collectionStates = new HashMap<String,Slice>();
+  private Map<String,Slices> collectionStates = new HashMap<String,Slices>();
   private List<String> nodes = null;
   
   // nocommit
-  public void addSlice(String collection, Slice slice) {
-    collectionStates.put(collection, slice);
+  public void addSlices(String collection, Slices slices) {
+    collectionStates.put(collection, slices);
   }
   
   // nocommit
-  public Slice getSlice(String collection) {
+  public Slices getSlices(String collection) {
     return collectionStates.get(collection);
   }
   

Added: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slices.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slices.java?rev=900856&view=auto
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slices.java (added)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/Slices.java Tue Jan 19 17:29:40
2010
@@ -0,0 +1,25 @@
+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.util.ArrayList;
+
+
+public class Slices extends ArrayList<Slice> {
+
+}

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=900856&r1=900855&r2=900856&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:29:40 2010
@@ -68,7 +68,7 @@
   private final static Pattern URL_PREFIX = Pattern.compile("(https?://).*");
 
   // package private for tests
-  static final String SLICES_ZKNODE = "/slices";
+  static final String SHARDS_ZKNODE = "/shards";
   // nocommit : ok to be public? for corecontainer access
   public static final String CONFIGS_ZKNODE = "/configs";
   static final String COLLECTIONS_ZKNODE = "/collections";
@@ -150,9 +150,9 @@
    * conditions
    * @param collection2 
    */
-  private void addZkShardsNode(String slice, String collection) throws IOException {
+  private void addZkShardsNode(String shardId, String collection) throws IOException {
 
-    String shardsZkPath = COLLECTIONS_ZKNODE + "/" + collection + SLICES_ZKNODE + "/" + slice;
+    String shardsZkPath = COLLECTIONS_ZKNODE + "/" + collection + SHARDS_ZKNODE + "/" + shardId;
     
     try {
       // shards node
@@ -163,7 +163,7 @@
         // makes shards zkNode if it doesn't exist
         zkClient.makePath(shardsZkPath, CreateMode.PERSISTENT, null);
         
-        // ping that there is a new collection (nocommit : or now possibly a new slice)
+        // ping that there is a new collection (nocommit : or now possibly a new shardId?)
         zkClient.setData(COLLECTIONS_ZKNODE, (byte[])null);
       }
     } catch (KeeperException e) {
@@ -398,13 +398,15 @@
     List<String> collections = getCollectionNames();
     // nocommit : load all collection info
     for (String collection : collections) {
-      String slicePaths = COLLECTIONS_ZKNODE + "/" + collection + SLICES_ZKNODE;
-      List<String> sliceNames = zkClient.getChildren(slicePaths, null);
-      for(String sliceZkPath : sliceNames) {
-        Map<String,ZkNodeProps> shards = readShards(slicePaths + "/" + sliceZkPath);
-        Slice slice = new Slice(shards);
-        cloudInfo.addSlice(collection, slice);
+      String shardIdPaths = COLLECTIONS_ZKNODE + "/" + collection + SHARDS_ZKNODE;
+      List<String> shardIdNames = zkClient.getChildren(shardIdPaths, null);
+      Slices slices = new Slices();
+      for(String shardIdZkPath : shardIdNames) {
+        Map<String,ZkNodeProps> shardsMap = readShards(shardIdPaths + "/" + shardIdZkPath);
+        Slice slice = new Slice(shardsMap);
+        slices.add(slice);
       }
+      cloudInfo.addSlices(collection, slices);
       
     }
 
@@ -549,11 +551,11 @@
 
     String collection = cloudDesc.getCollectionName();
     String nodePath = null;
-    String shardsZkPath = COLLECTIONS_ZKNODE + "/" + collection + SLICES_ZKNODE + "/" + cloudDesc.getSlice();
+    String shardsZkPath = COLLECTIONS_ZKNODE + "/" + collection + SHARDS_ZKNODE + "/" + cloudDesc.getShardId();
 
     // build layout if not exists
     // nocommit : consider how we watch shards on all collections
-    addZkShardsNode(cloudDesc.getSlice(), collection);
+    addZkShardsNode(cloudDesc.getShardId(), collection);
 
     // create node
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -629,8 +631,8 @@
     
     collections = zkClient.getChildren(COLLECTIONS_ZKNODE, null);
     for(String collection : collections) {
-      for(String slice : zkClient.getChildren(COLLECTIONS_ZKNODE + "/" + collection + SLICES_ZKNODE,
null)) {
-        zkClient.getChildren(COLLECTIONS_ZKNODE + "/" + collection + SLICES_ZKNODE + "/"
+ slice, shardWatcher);
+      for(String shardId : zkClient.getChildren(COLLECTIONS_ZKNODE + "/" + collection + SHARDS_ZKNODE,
null)) {
+        zkClient.getChildren(COLLECTIONS_ZKNODE + "/" + collection + SHARDS_ZKNODE + "/"
+ shardId, shardWatcher);
       }
     }
   }

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=900856&r1=900855&r2=900856&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 Tue Jan 19
17:29:40 2010
@@ -80,7 +80,7 @@
   protected String solrConfigFilenameOverride;
   protected String solrDataDirOverride;
   protected String zkPortOverride;
-  private String testSliceOverride;
+  private String testShardIdOverride;
   private ZkController zooKeeperController;
 
   private String zkHost;
@@ -185,7 +185,7 @@
       cores = new CoreContainer();
       cores.solrDataDirOverride = dataDir;
       cores.zkPortOverride = zkPortOverride;
-      cores.testSliceOverride = testShardListOverride;
+      cores.testShardIdOverride = testShardListOverride;
       if (fconf.exists())
         cores.load(solrHome, fconf);
       else {
@@ -363,14 +363,14 @@
             p.setSchemaName(opt);
           }
           // nocommit : default shard list to SHARD: + host:port + context + core
-          opt = DOMUtil.getAttr(node, "slice", null);
-          if(testSliceOverride != null && name.equals("")) {
-            p.getCloudDescriptor().setSlice(testSliceOverride);
+          opt = DOMUtil.getAttr(node, "shardId", null);
+          if(testShardIdOverride != null && name.equals("")) {
+            p.getCloudDescriptor().setShardId(testShardIdOverride);
           } else if(zooKeeperController != null) {
             if(opt == null) {
-              opt = "SLICE:" + zooKeeperController.getHostName() + ":" + hostPort + "_" +
hostContext + "_" + (name.length() == 0 ? "" : "_" + name);
+              opt = "SHARDID:" + zooKeeperController.getHostName() + ":" + hostPort + "_"
+ hostContext + "_" + (name.length() == 0 ? "" : "_" + name);
             }
-            p.getCloudDescriptor().setSlice(opt);
+            p.getCloudDescriptor().setShardId(opt);
           }
           opt = DOMUtil.getAttr(node, "role", null);
           if(opt != null) {

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=900856&r1=900855&r2=900856&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/QueryComponent.java
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/QueryComponent.java
Tue Jan 19 17:29:40 2010
@@ -41,6 +41,7 @@
 import org.apache.solr.util.SolrPluginUtils;
 import org.apache.solr.cloud.CloudState;
 import org.apache.solr.cloud.Slice;
+import org.apache.solr.cloud.Slices;
 import org.apache.solr.cloud.ZkNodeProps;
 
 
@@ -150,14 +151,16 @@
               cloudState =  req.getCore().getCoreDescriptor().getCoreContainer().getZooKeeperController().getCloudState();
           }
           String sliceStr = rb.slices[i];
-          Slice slice = cloudState.getSlice(sliceStr);
+          Slices slices = cloudState.getSlices(sliceStr);
 
-          if (slice==null) {
+          if (slices==null || slices.size() == 0) {
             // TODO: we could treat this as "all servers down" for a slice if partial results
are enabled.
             throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "no such slice:
" + sliceStr);
           }
 
-          Map<String, ZkNodeProps> sliceShards = slice.getShards();
+          
+          // nocommit : just using the first slice
+          Map<String, ZkNodeProps> sliceShards = slices.get(0).getShards();
 
           // For now, recreate the | delimited list of equivalent servers
           StringBuilder sliceShardsStr = new StringBuilder();

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java?rev=900856&r1=900855&r2=900856&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
(original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
Tue Jan 19 17:29:40 2010
@@ -192,8 +192,8 @@
     return createJetty(baseDir, dataDirName, null, null);
   }
 
-  public JettySolrRunner createJetty(File baseDir, String dataDirName, String slice) throws
Exception {
-    return createJetty(baseDir, dataDirName, slice, null);
+  public JettySolrRunner createJetty(File baseDir, String dataDirName, String shardId) throws
Exception {
+    return createJetty(baseDir, dataDirName, shardId, null);
   }
   
   public JettySolrRunner createJetty(File baseDir, String dataDirName, String shardList,
String solrConfigOverride) throws Exception {

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=900856&r1=900855&r2=900856&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
(original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
Tue Jan 19 17:29:40 2010
@@ -57,13 +57,13 @@
   String invalidField="invalid_field_not_in_schema";
   
   protected void createServers(int numShards) throws Exception {
-    controlJetty = createJetty(testDir, "control", "control_slice");
+    controlJetty = createJetty(testDir, "control", "control_shardId");
     controlClient = createNewSolrServer(controlJetty.getLocalPort());
 
     StringBuilder sb = new StringBuilder();
     for (int i = 1; i <= numShards; i++) {
       if (sb.length() > 0) sb.append(',');
-      JettySolrRunner j = createJetty(testDir, "jetty" + i, "slice" + (i + 2));
+      JettySolrRunner j = createJetty(testDir, "jetty" + i, "shardId" + (i + 2));
       jettys.add(j);
       clients.add(createNewSolrServer(j.getLocalPort()));
       sb.append("localhost:").append(j.getLocalPort()).append(context);

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=900856&r1=900855&r2=900856&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 Tue Jan
19 17:29:40 2010
@@ -57,7 +57,7 @@
       AbstractZkTestCase.makeSolrZkNode();
 
       zkClient = new SolrZkClient(ZOO_KEEPER_ADDRESS, TIMEOUT);
-      String shardsPath = "/collections/collection1/slices/slice1";
+      String shardsPath = "/collections/collection1/shards/shardid1";
       zkClient.makePath(shardsPath);
 
       zkClient.makePath("collections/collection1/config=collection1");
@@ -76,13 +76,15 @@
           "localhost", "8983", "/solr");
       zkController.updateCloudState();
       CloudState cloudInfo = zkController.getCloudState();
-      Slice slice = cloudInfo.getSlice("collection1");
-      assertNotNull(slice);
+      Slices slices = cloudInfo.getSlices("collection1");
+      assertNotNull(slices);
 
 
       if (DEBUG) {
-        for (String shard : slice.getShards().keySet()) {
-          System.out.println("shard:" + shard);
+        for(Slice slice : slices) {
+          for (String shard : slice.getShards().keySet()) {
+            System.out.println("shard:" + shard);
+          }
         }
       }
 



Mime
View raw message