You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2011/12/08 18:13:50 UTC

svn commit: r1211989 - in /lucene/dev/branches/solrcloud/solr: cloud-dev/solrcloud.sh core/src/java/org/apache/solr/cloud/ZkController.java

Author: markrmiller
Date: Thu Dec  8 17:13:50 2011
New Revision: 1211989

URL: http://svn.apache.org/viewvc?rev=1211989&view=rev
Log:
improve cmd line conf upload

Modified:
    lucene/dev/branches/solrcloud/solr/cloud-dev/solrcloud.sh
    lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java

Modified: lucene/dev/branches/solrcloud/solr/cloud-dev/solrcloud.sh
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/cloud-dev/solrcloud.sh?rev=1211989&r1=1211988&r2=1211989&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/cloud-dev/solrcloud.sh (original)
+++ lucene/dev/branches/solrcloud/solr/cloud-dev/solrcloud.sh Thu Dec  8 17:13:50 2011
@@ -20,7 +20,7 @@ rm -r -f example/solr/zoo_data
 
 ant example dist
 
-java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkController 127.0.0.1:9983 127.0.0.1 8983 solr example/solr/conf conf1 example/solr/zoo_data
+java -classpath lib/*:dist/*:build/lucene-libs/* org.apache.solr.cloud.ZkController 127.0.0.1:9983 example/solr 8983 example/solr/conf conf1
 
 cd example
 java -DzkRun -jar start.jar &

Modified: lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java?rev=1211989&r1=1211988&r2=1211989&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/java/org/apache/solr/cloud/ZkController.java Thu Dec  8 17:13:50 2011
@@ -99,20 +99,25 @@ public final class ZkController {
 
   public static void main(String[] args) throws Exception {
     // start up a tmp zk server first
-    SolrZkServer zkServer = new SolrZkServer("true", null, "example/solr", args[2]);
+    String zkServerAddress = args[0];
+    
+    String solrHome = args[1];
+    String solrPort = args[2];
+    
+    String confDir = args[3];
+    String confName = args[4];
+    
+    SolrZkServer zkServer = new SolrZkServer("true", null, solrHome, solrPort);
     zkServer.parseConfig();
     zkServer.start();
-    Thread.sleep(5000);
-    ZkController zkController = new ZkController(args[0], 15000, 5000, args[1], args[2], args[3], -1, new CurrentCoreDescriptorProvider() {
-      
-      @Override
-      public List<CoreDescriptor> getCurrentDescriptors() {
-        // do nothing
-        return null;
-      }
-    });
     
-    zkController.uploadConfigDir(new File(args[4]), args[5]);
+    SolrZkClient zkClient = new SolrZkClient(zkServerAddress, 15000, 5000,
+        new OnReconnect() {
+          @Override
+          public void command() {
+          }});
+    
+    uploadConfigDir(zkClient, new File(confDir), confName);
     
     zkServer.stop();
   }
@@ -613,19 +618,7 @@ public final class ZkController {
    * @throws InterruptedException
    */
   public void uploadToZK(File dir, String zkPath) throws IOException, KeeperException, InterruptedException {
-    File[] files = dir.listFiles();
-    if (files == null) {
-      throw new IllegalArgumentException("Illegal directory: " + dir);
-    }
-    for(File file : files) {
-      if (!file.getName().startsWith(".")) {
-        if (!file.isDirectory()) {
-          zkClient.makePath(zkPath + "/" + file.getName(), file);
-        } else {
-          uploadToZK(file, zkPath + "/" + file.getName());
-        }
-      }
-    }
+    uploadToZK(zkClient, dir, zkPath);
   }
   
   /**
@@ -636,7 +629,7 @@ public final class ZkController {
    * @throws InterruptedException
    */
   public void uploadConfigDir(File dir, String configName) throws IOException, KeeperException, InterruptedException {
-    uploadToZK(dir, ZkController.CONFIGS_ZKNODE + "/" + configName);
+    uploadToZK(zkClient, dir, ZkController.CONFIGS_ZKNODE + "/" + configName);
   }
 
   // convenience for testing
@@ -885,4 +878,24 @@ public final class ZkController {
   public RecoveryStrat getRecoveryStrat() {
     return recoveryStrat;
   }
+  
+  public static void uploadToZK(SolrZkClient zkClient, File dir, String zkPath) throws IOException, KeeperException, InterruptedException {
+    File[] files = dir.listFiles();
+    if (files == null) {
+      throw new IllegalArgumentException("Illegal directory: " + dir);
+    }
+    for(File file : files) {
+      if (!file.getName().startsWith(".")) {
+        if (!file.isDirectory()) {
+          zkClient.makePath(zkPath + "/" + file.getName(), file);
+        } else {
+          uploadToZK(zkClient, file, zkPath + "/" + file.getName());
+        }
+      }
+    }
+  }
+  
+  public static void uploadConfigDir(SolrZkClient zkClient, File dir, String configName) throws IOException, KeeperException, InterruptedException {
+    uploadToZK(zkClient, dir, ZkController.CONFIGS_ZKNODE + "/" + configName);
+  }
 }