lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r891317 - in /lucene/solr/branches/cloud/src: java/org/apache/solr/core/CoreContainer.java java/org/apache/solr/core/ZooKeeperController.java test/test-files/solr/solr.xml
Date Wed, 16 Dec 2009 17:04:50 GMT
Author: markrmiller
Date: Wed Dec 16 17:04:50 2009
New Revision: 891317

URL: http://svn.apache.org/viewvc?rev=891317&view=rev
Log:
allow zkClientTimeout to be set with solr.xml as well as collection name and shard address
override

Added:
    lucene/solr/branches/cloud/src/test/test-files/solr/solr.xml
Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/ZooKeeperController.java

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=891317&r1=891316&r2=891317&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 Wed Dec 16
17:04:50 2009
@@ -58,6 +58,8 @@
   protected boolean persistent = false;
   protected String adminPath = null;
   protected String managementPath = null;
+  protected int zkClientTimeout;
+  protected String shardAddress;
   protected CoreAdminHandler coreAdminHandler = null;
   protected File configFile = null;
   protected String libDir = null;
@@ -72,21 +74,19 @@
   protected String solrHome;
   protected String solrConfigFilenameOverride;
   protected String solrDataDirOverride;
-  protected static final String collection = System.getProperty("collection", "collection1");
//nocommit: default;
-
+  protected String collection;
   private ZooKeeperController zooKeeperController;
 
   public CoreContainer() {
     solrHome = SolrResourceLoader.locateSolrHome();
-    initZooKeeper();
   }
   
-  private void initZooKeeper() {
+  private void initZooKeeper(int zkClientTimeout) {
     //nocommit: pull zookeeper integration into a new CoreContainer? leaning towards no.
     String zookeeperHost = System.getProperty("zkHost");
     
     if (zookeeperHost != null) {
-      zooKeeperController = new ZooKeeperController(zookeeperHost, collection);
+      zooKeeperController = new ZooKeeperController(zookeeperHost, collection, shardAddress,
zkClientTimeout);
     }
   }
 
@@ -189,12 +189,10 @@
   public CoreContainer(SolrResourceLoader loader) {
     this.loader = loader;
     this.solrHome = loader.getInstanceDir();
-    initZooKeeper();
   }
 
   public CoreContainer(String solrHome) {
     this.solrHome = solrHome;
-    initZooKeeper();
   }
 
   //-------------------------------------------------------------------
@@ -235,11 +233,16 @@
       libDir     = cfg.get(     "solr/@sharedLib", null);
       adminPath  = cfg.get(     "solr/cores/@adminPath", null );
       shareSchema = cfg.getBool("solr/cores/@shareSchema", false );
+      zkClientTimeout = cfg.getInt("solr/cores/@zkClientTimeout", 10000);
+      shardAddress = cfg.get("solr/cores/@shardAddress", null);
+      collection = cfg.get("solr/cores/@collection", "collection1"); //nocommit: default
collection
       if(shareSchema){
         indexSchemaCache = new ConcurrentHashMap<String ,IndexSchema>();
       }
       adminHandler  = cfg.get("solr/cores/@adminHandler", null );
       managementPath  = cfg.get("solr/cores/@managementPath", null );
+      
+      initZooKeeper(zkClientTimeout);
 
       if (libDir != null) {
         File f = FileUtils.resolvePath(new File(dir), libDir);

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/core/ZooKeeperController.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/core/ZooKeeperController.java?rev=891317&r1=891316&r2=891317&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/core/ZooKeeperController.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/core/ZooKeeperController.java Wed
Dec 16 17:04:50 2009
@@ -35,17 +35,23 @@
 
   private String collectionName;
 
+  private String shardAddress;
+
   /**
    * @param zookeeperHost ZooKeeper host service
+   * @param shardAddress
+   * @param zkClientTimeout
    * @param zkSolrPathPrefix Solr ZooKeeper node (default is /solr)
    */
-  public ZooKeeperController(String zookeeperHost, String collection) {
-
-
+  public ZooKeeperController(String zookeeperHost, String collection,
+      String shardAddress, int zkClientTimeout) {
     this.collectionName = collection;
-    CountdownWatcher countdownWatcher = new CountdownWatcher("ZooKeeperController"); 
+    this.shardAddress = shardAddress;
+    CountdownWatcher countdownWatcher = new CountdownWatcher(
+        "ZooKeeperController");
+    System.out.println("timeout:" + zkClientTimeout);
     try {
-      keeper = new ZooKeeper(zookeeperHost, 10000, countdownWatcher);
+      keeper = new ZooKeeper(zookeeperHost, zkClientTimeout, countdownWatcher);
 
       countdownWatcher.waitForConnected(5000);
 
@@ -66,9 +72,11 @@
   // nocommit: fooling around
   private void register() throws IOException {
     try {
-      String host = InetAddress.getLocalHost().getHostName();
+      if (shardAddress == null) {
+        shardAddress = InetAddress.getLocalHost().getHostName();
+      }
       ZooPut zooPut = new ZooPut(keeper);
-      zooPut.makePath("/hosts/" + host);
+      zooPut.makePath("/hosts/" + shardAddress);
     } catch (UnknownHostException e) {
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
           "Could not determine IP of host", e);
@@ -101,7 +109,7 @@
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
           "ZooKeeper Exception", e);
     } catch (InterruptedException e) {
-      //nocommit
+      // nocommit
     }
     if (configName == null) {
       throw new IllegalStateException("no config specified for collection:"
@@ -119,8 +127,8 @@
    */
   public IndexSchema getSchema(String schemaName, SolrConfig config,
       SolrResourceLoader resourceLoader) {
-    byte[] configBytes = getFile("/" + CONFIGS_NODE + "/"
-        + configName, schemaName);
+    byte[] configBytes = getFile("/" + CONFIGS_NODE + "/" + configName,
+        schemaName);
     InputStream is = new ByteArrayInputStream(configBytes);
     IndexSchema schema = new IndexSchema(config, schemaName, is);
     return schema;
@@ -139,8 +147,8 @@
   public SolrConfig getConfig(String solrConfigName,
       SolrResourceLoader resourceLoader) throws IOException,
       ParserConfigurationException, SAXException {
-    byte[] config = getFile("/" + CONFIGS_NODE + "/"
-        + configName, solrConfigName);
+    byte[] config = getFile("/" + CONFIGS_NODE + "/" + configName,
+        solrConfigName);
     InputStream is = new ByteArrayInputStream(config);
     SolrConfig cfg = solrConfigName == null ? new SolrConfig(resourceLoader,
         SolrConfig.DEFAULT_CONF_FILE, is) : new SolrConfig(resourceLoader,

Added: lucene/solr/branches/cloud/src/test/test-files/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/test-files/solr/solr.xml?rev=891317&view=auto
==============================================================================
--- lucene/solr/branches/cloud/src/test/test-files/solr/solr.xml (added)
+++ lucene/solr/branches/cloud/src/test/test-files/solr/solr.xml Wed Dec 16 17:04:50 2009
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+
+<!--
+ All (relative) paths are relative to the installation path
+  
+  persistent: Save changes made via the API to this file
+  sharedLib: path to a lib directory that will be shared across all cores
+-->
+<solr persistent="false">
+
+  <!--
+  adminPath: RequestHandler path to manage cores.  
+    If 'null' (or absent), cores will not be manageable via request handler
+  -->
+  <cores adminPath="/admin/cores" zkClientTimeout="10000">
+    <core name="DEFAULT_CORE" instanceDir="." />
+  </cores>
+</solr>



Mime
View raw message