Apache Solr open-source search software
SOLR-14880: Support coreRootDirectory setting when create new cores from command line, in standalone mode
Alexandre Rafalovitch16115864177a
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d4d35f60fec..0b5027155de 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -50,6 +50,8 @@ Improvements* SOLR-14878: Report solr.xml's coreRootDirectory property via System Settings API, when set (Alexandre Rafalovitch)+* SOLR-14880: Support coreRootDirectory setting when create new cores from command line, in standalone mode (Alexandre Rafalovitch)+Other Changes----------------------* SOLR-14656: Autoscaling framework removed (Ishan Chattopadhyaya, noble, Ilan Ginzburg)diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.javaindex 5e37ccb04ad..ef7a7e8fc0f 100755--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java@@ -1666,7 +1666,7 @@ public class SolrCLI implements CLIO {String systemInfoUrl = solrUrl+"admin/info/system";CloseableHttpClient httpClient = getHttpClient();- String solrHome = null;+ String coreRootDirectory = null; //usually same as solr home, but not alwaystry {Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2, true);if ("solrcloud".equals(systemInfo.get("mode"))) {@@ -1675,9 +1675,11 @@ public class SolrCLI implements CLIO {}// convert raw JSON into user-friendly output- solrHome = (String)systemInfo.get("solr_home");- if (solrHome == null)- solrHome = configsetsDir.getParentFile().getAbsolutePath();+ coreRootDirectory = (String)systemInfo.get("core_root");++ //Fall back to solr_home, in case we are running against older server that does not return the property+ if (coreRootDirectory == null) coreRootDirectory = (String)systemInfo.get("solr_home");+ if (coreRootDirectory == null) coreRootDirectory = configsetsDir.getParentFile().getAbsolutePath();} finally {closeHttpClient(httpClient);@@ -1689,7 +1691,7 @@ public class SolrCLI implements CLIO {"' already exists!\nChecked core existence using Core API command:\n"+coreStatusUrl);}- File coreInstanceDir = new File(solrHome, coreName);+ File coreInstanceDir = new File(coreRootDirectory, coreName);File confDir = new File(configSetDir,"conf");if (!coreInstanceDir.isDirectory()) {coreInstanceDir.mkdirs();