You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by md...@apache.org on 2021/05/11 20:37:20 UTC

[solr] branch main updated: SOLR-15222: userfiles dir will only be created in SolrCloud mode (#121)

This is an automated email from the ASF dual-hosted git repository.

mdrob pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new f94d347  SOLR-15222: userfiles dir will only be created in SolrCloud mode (#121)
f94d347 is described below

commit f94d3471c3d5a678e8f6f2f61aa4a57151d7c265
Author: Mike Drob <md...@apache.org>
AuthorDate: Tue May 11 15:37:11 2021 -0500

    SOLR-15222: userfiles dir will only be created in SolrCloud mode (#121)
---
 solr/CHANGES.txt                                     |  2 ++
 .../src/java/org/apache/solr/core/CoreContainer.java | 20 +++++++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7a5cd5c..cccc193 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -287,6 +287,8 @@ Other Changes
 
 * SOLR-15369: PackageStoreAPI will only be loaded in SolrCloud mode (Mike Drob)
 
+* SOLR-15222: userfiles dir will only be created in SolrCloud mode (Mike Drob)
+
 Bug Fixes
 ---------------------
 * SOLR-14546: Fix for a relatively hard to hit issue in OverseerTaskProcessor that could lead to out of order execution
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 a47dc9b..998a822 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -409,13 +409,6 @@ public class CoreContainer {
     this.allowPaths = allowPathBuilder.build();
 
     this.allowListUrlChecker = AllowListUrlChecker.create(config);
-
-    Path userFilesPath = getUserFilesPath(); // TODO make configurable on cfg?
-    try {
-      Files.createDirectories(userFilesPath); // does nothing if already exists
-    } catch (Exception e) {
-      log.warn("Unable to create [{}].  Features requiring this directory may fail.", userFilesPath, e);
-    }
   }
 
   @SuppressWarnings({"unchecked"})
@@ -873,6 +866,8 @@ public class CoreContainer {
       metricManager.loadClusterReporters(metricReporters, this);
     }
 
+    // Do this before cores get created
+    createUserFilesDirectory();
 
     // setup executor to load cores in parallel
     ExecutorService coreLoadExecutor = MetricUtils.instrumentedExecutorService(
@@ -982,6 +977,17 @@ public class CoreContainer {
     status |= LOAD_COMPLETE | INITIAL_CORE_LOAD_COMPLETE;
   }
 
+  private void createUserFilesDirectory() {
+    if (isZooKeeperAware()) {
+      Path userFilesPath = getUserFilesPath(); // TODO make configurable on cfg?
+      try {
+        Files.createDirectories(userFilesPath); // does nothing if already exists
+      } catch (Exception e) {
+        log.warn("Unable to create [{}].  Features requiring this directory may fail.", userFilesPath, e);
+      }
+    }
+  }
+
   // MetricsHistoryHandler supports both cloud and standalone configs
   @SuppressWarnings({"unchecked"})
   private void createMetricsHistoryHandler() {