You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/03/25 15:23:04 UTC

svn commit: r1581347 - in /lucene/dev/branches/lucene_solr_4_7: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java

Author: shalin
Date: Tue Mar 25 14:23:04 2014
New Revision: 1581347

URL: http://svn.apache.org/r1581347
Log:
SOLR-5906: Collection create API ignores property.instanceDir parameter

Modified:
    lucene/dev/branches/lucene_solr_4_7/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
    lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java

Modified: lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt?rev=1581347&r1=1581346&r2=1581347&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/CHANGES.txt Tue Mar 25 14:23:04 2014
@@ -118,6 +118,9 @@ Bug Fixes
 * SOLR-5905: CollapsingQParserPlugin throws a NPE if required 'field' param is missing.
   (Spyros Kapnissis via shalin)
 
+* SOLR-5906: Collection create API ignores property.instanceDir parameter.
+  (Varun Thacker, shalin)
+
 Other Changes
 ---------------------
 

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1581347&r1=1581346&r2=1581347&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Tue Mar 25 14:23:04 2014
@@ -449,11 +449,6 @@ public class CoreAdminHandler extends Re
 
     String name = checkNotEmpty(params.get(CoreAdminParams.NAME),
         "Missing parameter [" + CoreAdminParams.NAME + "]");
-    String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
-    if (StringUtils.isEmpty(instancedir)) {
-      instancedir = name; // will be resolved later against solr.home
-      //instancedir = container.getSolrHome() + "/" + name;
-    }
 
     Properties coreProps = new Properties();
     for (String param : paramToProp.keySet()) {
@@ -472,6 +467,14 @@ public class CoreAdminHandler extends Re
       coreProps.setProperty(propName, propValue);
     }
 
+    String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
+    if (StringUtils.isEmpty(instancedir) && coreProps.getProperty(CoreAdminParams.INSTANCE_DIR) != null) {
+      instancedir = coreProps.getProperty(CoreAdminParams.INSTANCE_DIR);
+    } else if (StringUtils.isEmpty(instancedir)){
+      instancedir = name; // will be resolved later against solr.home
+      //instancedir = container.getSolrHome() + "/" + name;
+    }
+
     return new CoreDescriptor(container, name, instancedir, coreProps, params);
   }
 

Modified: lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java?rev=1581347&r1=1581346&r2=1581347&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java (original)
+++ lucene/dev/branches/lucene_solr_4_7/solr/core/src/test/org/apache/solr/handler/admin/CoreAdminCreateDiscoverTest.java Tue Mar 25 14:23:04 2014
@@ -22,6 +22,7 @@ import org.apache.lucene.util.IOUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.CoreAdminParams;
+import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.CorePropertiesLocator;
 import org.apache.solr.response.SolrQueryResponse;
 import org.junit.AfterClass;
@@ -193,6 +194,43 @@ public class CoreAdminCreateDiscoverTest
   }
 
   @Test
+  public void testInstanceDirAsPropertyParam() throws Exception {
+
+    setupCore("testInstanceDirAsPropertyParam-XYZ", true);
+
+    // make sure workDir is different even if core name is used as instanceDir
+    File workDir = new File(solrHomeDirectory, "testInstanceDirAsPropertyParam-XYZ");
+    File data = new File(workDir, "data");
+
+    // Create one core
+    SolrQueryResponse resp = new SolrQueryResponse();
+    admin.handleRequestBody
+        (req(CoreAdminParams.ACTION,
+                CoreAdminParams.CoreAdminAction.CREATE.toString(),
+                CoreAdminParams.NAME, "testInstanceDirAsPropertyParam",
+                "property.instanceDir", workDir.getAbsolutePath(),
+                CoreAdminParams.CONFIG, "solrconfig_ren.xml",
+                CoreAdminParams.SCHEMA, "schema_ren.xml",
+                CoreAdminParams.DATA_DIR, data.getAbsolutePath()),
+            resp);
+    assertNull("Exception on create", resp.getException());
+
+    resp = new SolrQueryResponse();
+    admin.handleRequestBody
+        (req(CoreAdminParams.ACTION,
+                CoreAdminParams.CoreAdminAction.STATUS.toString(),
+                CoreAdminParams.CORE, "testInstanceDirAsPropertyParam"),
+            resp);
+    NamedList status = (NamedList) resp.getValues().get("status");
+    assertNotNull(status);
+    NamedList coreProps = (NamedList) status.get("testInstanceDirAsPropertyParam");
+    assertNotNull(status);
+    String instanceDir = (String) coreProps.get("instanceDir");
+    assertNotNull(instanceDir);
+    assertEquals("Instance dir does not match param given in property.instanceDir syntax", workDir.getAbsolutePath(), new File(instanceDir).getAbsolutePath());
+  }
+
+  @Test
   public void testCreateSavesRegProps() throws Exception {
 
     setupCore(coreNormal, true);