lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1539343 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/core/CoreContainer.java core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java core/src/test/org/apache/solr/core/TestLazyCores.java
Date Wed, 06 Nov 2013 14:23:48 GMT
Author: erick
Date: Wed Nov  6 14:23:47 2013
New Revision: 1539343

URL: http://svn.apache.org/r1539343
Log:
SOLR-5318: create HTTP API command doesn't respect transient core property

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestLazyCores.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1539343&r1=1539342&r2=1539343&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Nov  6 14:23:47 2013
@@ -152,6 +152,9 @@ Bug Fixes
 
 * SOLR-5418: Background merge after field removed from solr.xml causes error. 
   (Reported on user's list, Robert M's patch via Erick Erickson)
+  
+ * SOLR-5318: Creating a core via the admin API doesn't respect transient property
+   (Olivier Soyez via Erick Erickson)
 
 Optimizations
 ----------------------  

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1539343&r1=1539342&r2=1539343&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/CoreContainer.java Wed Nov  6
14:23:47 2013
@@ -452,7 +452,16 @@ public class CoreContainer {
         name.indexOf( '\\' ) >= 0 ){
       throw new RuntimeException( "Invalid core name: "+name );
     }
-    
+    // We can register a core when creating them via the admin UI, so we need to insure that
the dynamic descriptors
+    // are up to date
+    CoreDescriptor cd = core.getCoreDescriptor();
+    if ((cd.isTransient() || ! cd.isLoadOnStartup())
+        && solrCores.getDynamicDescriptor(name) == null) {
+      // Store it away for later use. includes non-transient but not
+      // loaded at startup cores.
+      solrCores.putDynamicDescriptor(name, cd);
+    }
+
     SolrCore old = null;
 
     if (isShutDown) {
@@ -496,11 +505,11 @@ public class CoreContainer {
    * @return a previous core having the same name if it existed and returnPrev==true
    */
   public SolrCore register(SolrCore core, boolean returnPrev) {
-    return registerCore(false, core.getName(), core, returnPrev);
+    return registerCore(core.getCoreDescriptor().isTransient(), core.getName(), core, returnPrev);
   }
 
   public SolrCore register(String name, SolrCore core, boolean returnPrev) {
-    return registerCore(false, name, core, returnPrev);
+    return registerCore(core.getCoreDescriptor().isTransient(), name, core, returnPrev);
   }
 
   // Helper method to separate out creating a core from local configuration files. See create()

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=1539343&r1=1539342&r2=1539343&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
Wed Nov  6 14:23:47 2013
@@ -497,7 +497,7 @@ public class CoreAdminHandler extends Re
       
       SolrCore core = coreContainer.create(dcore);
       
-      coreContainer.register(dcore.getName(), core, false);
+      coreContainer.register(core, false);
       
       if (coreContainer.getCoresLocator() instanceof SolrXMLCoresLocator) {
         // hack - in this case we persist once more because a core create race might

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestLazyCores.java?rev=1539343&r1=1539342&r2=1539343&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestLazyCores.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestLazyCores.java Wed Nov  6
14:23:47 2013
@@ -338,6 +338,61 @@ public class TestLazyCores extends SolrT
     }
   }
 
+  private void createViaAdmin(CoreContainer cc, String name, String instanceDir, boolean
isTransient,
+                              boolean loadOnStartup) throws Exception {
+
+    final CoreAdminHandler admin = new CoreAdminHandler(cc);
+    SolrQueryResponse resp = new SolrQueryResponse();
+    admin.handleRequestBody
+        (req(CoreAdminParams.ACTION,
+            CoreAdminParams.CoreAdminAction.CREATE.toString(),
+            CoreAdminParams.INSTANCE_DIR, instanceDir,
+            CoreAdminParams.NAME, name,
+            CoreAdminParams.TRANSIENT, Boolean.toString(isTransient),
+            CoreAdminParams.LOAD_ON_STARTUP, Boolean.toString(loadOnStartup)),
+            resp);
+
+  }
+
+  // Make sure that creating a transient core from the admin handler correctly respects the
transient limits etc.
+  @Test
+  public void testCreateTransientFromAdmin() throws Exception {
+    final CoreContainer cc = init();
+    try {
+      copyMinConf(new File(solrHomeDirectory, "core1"));
+      copyMinConf(new File(solrHomeDirectory, "core2"));
+      copyMinConf(new File(solrHomeDirectory, "core3"));
+      copyMinConf(new File(solrHomeDirectory, "core4"));
+      copyMinConf(new File(solrHomeDirectory, "core5"));
+
+      createViaAdmin(cc, "core1", "./core1", true, true);
+      createViaAdmin(cc, "core2", "./core2", true, false);
+      createViaAdmin(cc, "core3", "./core3", true, true);
+      createViaAdmin(cc, "core4", "./core4", true, false);
+      createViaAdmin(cc, "core5", "./core5", true, false);
+
+      SolrCore c1 = cc.getCore("core1");
+      SolrCore c2 = cc.getCore("core2");
+      SolrCore c3 = cc.getCore("core3");
+      SolrCore c4 = cc.getCore("core4");
+      SolrCore c5 = cc.getCore("core5");
+
+      checkNotInCores(cc, "core1", "collectionLazy2", "collectionLazy3", "collectionLazy4",
"collectionLazy6"
+          , "collectionLazy7", "collectionLazy8", "collectionLazy9");
+
+      checkInCores(cc, "collection1", "collectionLazy5", "core2", "core3", "core4", "core5");
+
+      c1.close();
+      c2.close();
+      c3.close();
+      c4.close();
+      c5.close();
+
+    } finally {
+      cc.shutdown();
+    }
+  }
+
   //Make sure persisting not-loaded lazy cores is done. See SOLR-4347
 
   @Test



Mime
View raw message