You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2012/03/27 03:29:50 UTC

svn commit: r1305703 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/core/src/ lucene/core/src/test/org/apache/lucene/analysis/ solr/ solr/core/src/java/org/apache/solr/core/

Author: hossman
Date: Tue Mar 27 01:29:49 2012
New Revision: 1305703

URL: http://svn.apache.org/viewvc?rev=1305703&view=rev
Log:
SOLR-3264: Fix CoreContainer and SolrResourceLoader logging to stop misleading people about SolrCore instanceDir's being the Solr Home Dir (merge r1305697 from trunk)

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/core/src/   (props changed)
    lucene/dev/branches/branch_3x/lucene/core/src/test/org/apache/lucene/analysis/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1305703&r1=1305702&r2=1305703&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Tue Mar 27 01:29:49 2012
@@ -291,6 +291,10 @@ Bug Fixes
 * SOLR-2291: fix JSONWriter to respect field list when writing SolrDocuments
   (Ahmet Arslan via hossman)
 
+* SOLR-3264: Fix CoreContainer and SolrResourceLoader logging to be more 
+  clear about when SolrCores are being created, and stop misleading people 
+  about SolrCore instanceDir's being the "Solr Home Dir" (hossman)
+
 Other Changes
 ----------------------
 * SOLR-2922: Upgrade commons-io and commons-lang to 2.1 and 2.6, respectively. (koji)

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1305703&r1=1305702&r2=1305703&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java Tue Mar 27 01:29:49 2012
@@ -78,15 +78,46 @@ public class CoreContainer 
   // default, said to abort on config error
   private int numCoresAbortOnConfigError = 0;
   
+  /**
+   * Deprecated
+   * @deprecated use the single arg constructure with locateSolrHome()
+   * @see SolrResourceLoader#locateSolrHome
+   */
+  @Deprecated
   public CoreContainer() {
-    solrHome = SolrResourceLoader.locateSolrHome();
+    this(SolrResourceLoader.locateSolrHome());
     log.info("New CoreContainer: solrHome=" + solrHome + " instance="+System.identityHashCode(this));
   }
 
+
   public Properties getContainerProperties() {
     return containerProperties;
   }
 
+  /**
+   * Initalize CoreContainer directly from the constructor
+   *
+   * @param dir
+   * @param configFile
+   * @throws ParserConfigurationException
+   * @throws IOException
+   * @throws SAXException
+   */
+  public CoreContainer(String dir, File configFile) throws ParserConfigurationException, IOException, SAXException
+  {
+    this(dir);
+    this.load(dir, configFile);
+  }
+
+  /**
+   * Minimal CoreContainer constructor.
+   * @param loader the CoreContainer resource loader
+   */
+  public CoreContainer(SolrResourceLoader loader) {
+    this(loader.getInstanceDir());
+    this.loader = loader;
+  }
+
   // Helper class to initialize the CoreContainer
   public static class Initializer {
     protected String solrConfigFilename = null;
@@ -122,7 +153,7 @@ public class CoreContainer 
       File fconf = new File(solrHome, solrConfigFilename == null ? "solr.xml"
           : solrConfigFilename);
       log.info("looking for solr.xml: " + fconf.getAbsolutePath());
-      cores = new CoreContainer();
+      cores = new CoreContainer(solrHome);
       cores.solrConfigFilenameOverride = solrConfigFilename;
       if (fconf.exists()) {
         // default abortOnConfigurationError ignored in multicore
@@ -167,29 +198,6 @@ public class CoreContainer 
     return p;
   }
 
-  /**
-   * Initalize CoreContainer directly from the constructor
-   * 
-   * @param dir
-   * @param configFile
-   * @throws ParserConfigurationException
-   * @throws IOException
-   * @throws SAXException
-   */
-  public CoreContainer(String dir, File configFile) throws ParserConfigurationException, IOException, SAXException 
-  {
-    this.load(dir, configFile);
-  }
-  
-  /**
-   * Minimal CoreContainer constructor. 
-   * @param loader the CoreContainer resource loader
-   */
-  public CoreContainer(SolrResourceLoader loader) {
-    this.loader = loader;
-    this.solrHome = loader.getInstanceDir();
-  }
-
   public CoreContainer(String solrHome) {
     this.solrHome = solrHome;
   }
@@ -222,6 +230,13 @@ public class CoreContainer 
    */
   public void load(String dir, InputSource cfgis)
       throws ParserConfigurationException, IOException, SAXException {
+
+    if (null == dir) {
+      // don't rely on SolrResourceLoader(), determine explicitly first
+      dir = SolrResourceLoader.locateSolrHome();
+    }
+    log.info("Loading CoreContainer using Solr Home: '{}'", dir);
+
     this.loader = new SolrResourceLoader(dir);
     solrHome = loader.getInstanceDir();
     Config cfg = new Config(loader, null, cfgis, null);
@@ -433,7 +448,8 @@ public class CoreContainer 
       idir = new File(solrHome, dcore.getInstanceDir());
     }
     String instanceDir = idir.getPath();
-    
+    log.info("Creating SolrCore '{}' using instanceDir: {}", 
+             dcore.getName(), instanceDir);
     // Initialize the solr config
     SolrResourceLoader solrLoader = new SolrResourceLoader(instanceDir, libLoader, getCoreProps(instanceDir, dcore.getPropertiesName(),dcore.getCoreProperties()));
     SolrConfig config = new SolrConfig(solrLoader, dcore.getConfigName(), null);
@@ -526,7 +542,10 @@ public class CoreContainer 
     if (core == null)
       throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name );
 
-    SolrCore newCore = create(core.getCoreDescriptor());
+    CoreDescriptor cd = core.getCoreDescriptor();
+    log.info("Reloading SolrCore '{}' using instanceDir: {}", 
+             cd.getName(), cd.getInstanceDir());
+    SolrCore newCore = create(cd);
     register(name, newCore, false);
   }
 
@@ -596,7 +615,8 @@ public class CoreContainer 
    * @return a CoreAdminHandler
    */
   protected CoreAdminHandler createMultiCoreHandler(final String adminHandlerClass) {
-    SolrResourceLoader loader = new SolrResourceLoader(null, libLoader, null);
+    // :TODO: why create a new SolrResourceLoader? why not use this.loader ???
+    SolrResourceLoader loader = new SolrResourceLoader(solrHome, libLoader, null);
     Object obj = loader.newAdminHandlerInstance(CoreContainer.this, adminHandlerClass);
     if ( !(obj instanceof CoreAdminHandler))
     {

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=1305703&r1=1305702&r2=1305703&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java Tue Mar 27 01:29:49 2012
@@ -87,17 +87,22 @@ public class SolrResourceLoader implemen
    * This loader will delegate to the context classloader when possible,
    * otherwise it will attempt to resolve resources using any jar files
    * found in the "lib/" directory in the specified instance directory.
-   * If the instance directory is not specified (=null), SolrResourceLoader#locateInstanceDir will provide one.
-   * <p>
+   * </p>
+   *
+   * @param instanceDir - base directory for this resource loader, if null locateSolrHome() will be used.
+   * @see #locateSolrHome
    */
   public SolrResourceLoader( String instanceDir, ClassLoader parent, Properties coreProperties )
   {
     if( instanceDir == null ) {
       this.instanceDir = SolrResourceLoader.locateSolrHome();
+      log.info("new SolrResourceLoader for deduced Solr Home: '{}'", 
+               this.instanceDir);
     } else{
       this.instanceDir = normalizeDir(instanceDir);
+      log.info("new SolrResourceLoader for directory: '{}'", 
+               this.instanceDir);
     }
-    log.info("Solr home set to '" + this.instanceDir + "'");
     
     this.classLoader = createClassLoader(null, parent);
     addToClassLoader("./lib/", null);
@@ -587,6 +592,7 @@ public class SolrResourceLoader implemen
    * @see #normalizeDir(String)
    */
   public static String locateSolrHome() {
+
     String home = null;
     // Try JNDI
     try {