lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject lucene-solr:master: SOLR-10721: Provide a way to know when Core Discovery is finished and when all async cores are done loading
Date Tue, 23 May 2017 19:23:27 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 6a82b42b9 -> 28b8696d7


SOLR-10721: Provide a way to know when Core Discovery is finished and when all async cores
are done loading


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/28b8696d
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/28b8696d
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/28b8696d

Branch: refs/heads/master
Commit: 28b8696d771d6cccdbab673918cbf04d34b998ad
Parents: 6a82b42
Author: Erick <erick@apache.org>
Authored: Tue May 23 12:20:58 2017 -0700
Committer: Erick <erick@apache.org>
Committed: Tue May 23 12:20:58 2017 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 +++
 .../org/apache/solr/core/CoreContainer.java     | 17 ++++++++++++++++-
 .../org/apache/solr/core/TestCoreDiscovery.java | 20 ++++++++++++++++----
 3 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/28b8696d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9889945..6b91c4d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -222,6 +222,9 @@ New Features
 
 * SOLR-10307: Allow Passing SSL passwords through environment variables. (Mano Kovacs via
Mark Miller)
 
+* SOLR-10721: Provide a way to know when Core Discovery is finished and when all async cores
are done loading
+  (Erick Erickson)
+
 Bug Fixes
 ----------------------
 * SOLR-10723 JSON Facet API: resize() implemented incorrectly for CountSlotAcc, HllAgg.NumericAcc

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/28b8696d/solr/core/src/java/org/apache/solr/core/CoreContainer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 7471c08..505a235 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -186,6 +186,13 @@ public class CoreContainer {
 
   protected MetricsCollectorHandler metricsCollectorHandler;
 
+
+  // Bits for the state variable.
+  public final static long LOAD_COMPLETE = 0x1L;
+  public final static long CORE_DISCOVERY_COMPLETE = 0x2L;
+  public final static long INITIAL_CORE_LOAD_COMPLETE = 0x4L;
+  private volatile long status = 0L;
+
   private enum CoreInitFailedAction { fromleader, none }
 
   /**
@@ -579,7 +586,8 @@ public class CoreContainer {
         Collections.sort(cds, coreComparator::compare);
       }
       checkForDuplicateCoreNames(cds);
-
+      status |= CORE_DISCOVERY_COMPLETE;
+      
       for (final CoreDescriptor cd : cds) {
         if (cd.isTransient() || !cd.isLoadOnStartup()) {
           getTransientCacheHandler().addTransientDescriptor(cd.getName(), cd);
@@ -641,8 +649,11 @@ public class CoreContainer {
     if (isZooKeeperAware()) {
       zkSys.getZkController().checkOverseerDesignate();
     }
+    // This is a bit redundant but these are two distinct concepts for all they're accomplished
at the same time.
+    status |= LOAD_COMPLETE | INITIAL_CORE_LOAD_COMPLETE;
   }
 
+
   public TransientSolrCoreCache getTransientCacheHandler() {
 
     if (transientCoreCache == null) {
@@ -1533,6 +1544,10 @@ public class CoreContainer {
     return cfg;
   }
 
+  public long getStatus() {
+    return status;
+  }
+
 }
 
 class CloserThread extends Thread {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/28b8696d/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
index 0c05d83..95c8cb9 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
@@ -33,6 +33,9 @@ import org.junit.After;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import static org.apache.solr.core.CoreContainer.CORE_DISCOVERY_COMPLETE;
+import static org.apache.solr.core.CoreContainer.INITIAL_CORE_LOAD_COMPLETE;
+import static org.apache.solr.core.CoreContainer.LOAD_COMPLETE;
 import static org.hamcrest.CoreMatchers.not;
 import static org.junit.internal.matchers.StringContains.containsString;
 
@@ -107,14 +110,23 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
   }
 
   private CoreContainer init() throws Exception {
-    final CoreContainer cores = new CoreContainer();
+    final CoreContainer container = new CoreContainer();
     try {
-      cores.load();
+      container.load();
     } catch (Exception e) {
-      cores.shutdown();
+      container.shutdown();
       throw e;
     }
-    return cores;
+
+    long status = container.getStatus();
+
+    assertTrue("Load complete flag should be set", 
+        (status & LOAD_COMPLETE) == LOAD_COMPLETE);
+    assertTrue("Core discovery should be complete", 
+        (status & CORE_DISCOVERY_COMPLETE) == CORE_DISCOVERY_COMPLETE);
+    assertTrue("Initial core loading should be complete", 
+        (status & INITIAL_CORE_LOAD_COMPLETE) == INITIAL_CORE_LOAD_COMPLETE);
+    return container;
   }
 
   @After


Mime
View raw message