3131import org .apache .solr .cloud .ZkController ;
3232import org .apache .solr .common .ConfigNode ;
3333import org .apache .solr .common .SolrException ;
34+ import org .apache .solr .common .util .EnvUtils ;
3435import org .apache .solr .common .util .NamedList ;
35- import org .apache .solr .common .util .StrUtils ;
3636import org .apache .solr .handler .admin .ConfigSetsHandler ;
3737import org .apache .solr .schema .IndexSchema ;
3838import org .apache .solr .schema .IndexSchemaFactory ;
@@ -85,22 +85,17 @@ private static ConfigSetService instantiate(CoreContainer coreContainer) {
8585 }
8686
8787 private void bootstrapConfigSet (CoreContainer coreContainer ) {
88- // bootstrap _default conf, bootstrap_confdir and bootstrap_conf if provided via system property
88+ // bootstrap _default conf and solr.configset.bootstrap.confdir if specified.
8989 try {
9090 // _default conf
9191 bootstrapDefaultConf ();
9292
93- // bootstrap_confdir
94- String confDir = System .getProperty ("bootstrap_confdir " );
93+ // solr.configset.bootstrap.confdir
94+ String confDir = EnvUtils .getProperty ("solr.configset.bootstrap.confdir " );
9595 if (confDir != null ) {
9696 bootstrapConfDir (confDir );
9797 }
9898
99- // bootstrap_conf
100- boolean boostrapConf = Boolean .getBoolean ("bootstrap_conf" );
101- if (boostrapConf == true ) {
102- bootstrapConf (coreContainer );
103- }
10499 } catch (IOException e ) {
105100 throw new SolrException (
106101 SolrException .ErrorCode .SERVER_ERROR , "Config couldn't be uploaded " , e );
@@ -114,23 +109,27 @@ private void bootstrapDefaultConf() throws IOException {
114109 log .warn (
115110 "The _default configset could not be uploaded. Please provide 'solr.configset.default.confdir' parameter that points to a configset {} {}" ,
116111 "intended to be the default. Current 'solr.configset.default.confdir' value:" ,
117- System .getProperty (SolrDispatchFilter .SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE ));
112+ EnvUtils .getProperty (SolrDispatchFilter .SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE ));
118113 } else {
119114 this .uploadConfig (ConfigSetsHandler .DEFAULT_CONFIGSET_NAME , configDirPath );
120115 }
121116 }
122117 }
123118
124119 private void bootstrapConfDir (String confDir ) throws IOException {
125- Path configPath = Path .of (confDir );
120+ if (!confDir .endsWith ("conf" )) {
121+ throw new IllegalArgumentException (
122+ "solr.configset.bootstrap.confdir must point to 'conf' directory, confDir: " + confDir );
123+ }
124+
125+ Path configPath = resolvePathWithSolrInstallDir (confDir );
126+
126127 if (!Files .isDirectory (configPath )) {
127128 throw new IllegalArgumentException (
128- "bootstrap_confdir must be a directory of configuration files, configPath: "
129+ "solr.configset.bootstrap.confdir must be a directory of configuration files, configPath: "
129130 + configPath );
130131 }
131- String confName =
132- System .getProperty (
133- ZkController .COLLECTION_PARAM_PREFIX + ZkController .CONFIGNAME_PROP , "configuration1" );
132+ String confName = EnvUtils .getProperty ("solr.collection.config.name" , "configuration1" );
134133 this .uploadConfig (confName , configPath );
135134 }
136135
@@ -139,23 +138,23 @@ private void bootstrapConfDir(String confDir) throws IOException {
139138 * sysprop "solr.configset.default.confdir". If not found, tries to find the _default dir relative
140139 * to the sysprop "solr.install.dir". Returns null if not found anywhere.
141140 *
142- * @lucene.internal
143141 * @see SolrDispatchFilter#SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE
144142 */
145143 public static Path getDefaultConfigDirPath () {
146144 String confDir =
147- System .getProperty (SolrDispatchFilter .SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE );
145+ EnvUtils .getProperty (SolrDispatchFilter .SOLR_CONFIGSET_DEFAULT_CONFDIR_ATTRIBUTE );
148146 if (confDir != null ) {
149- Path path = Path . of (confDir );
147+ Path path = resolvePathWithSolrInstallDir (confDir );
150148 if (Files .exists (path )) {
151149 return path ;
152150 }
153151 }
154152
155- String installDir = System .getProperty (SolrDispatchFilter .SOLR_INSTALL_DIR_ATTRIBUTE );
153+ String installDir = EnvUtils .getProperty (SolrDispatchFilter .SOLR_INSTALL_DIR_ATTRIBUTE );
156154 if (installDir != null ) {
155+ Path installPath = resolvePathWithSolrInstallDir (installDir );
157156 Path subPath = Path .of ("server" , "solr" , "configsets" , "_default" , "conf" );
158- Path path = Path . of ( installDir ) .resolve (subPath );
157+ Path path = installPath .resolve (subPath );
159158 if (Files .exists (path )) {
160159 return path ;
161160 }
@@ -164,6 +163,27 @@ public static Path getDefaultConfigDirPath() {
164163 return null ;
165164 }
166165
166+ /**
167+ * Resolves a path string into a Path object, handling both absolute and relative paths. If the
168+ * path is relative then it resolves it against Solr installation directory by looking up the
169+ * solr.install.dir system property.
170+ *
171+ * @param pathStr The path of the directory to resolve
172+ * @return The resolved Path object
173+ * @see SolrDispatchFilter#SOLR_INSTALL_DIR_ATTRIBUTE
174+ */
175+ public static Path resolvePathWithSolrInstallDir (String pathStr ) {
176+ Path path = Path .of (pathStr );
177+
178+ // Convert to absolute path if it's relative
179+ if (!path .isAbsolute ()) {
180+ String installDir = EnvUtils .getProperty (SolrDispatchFilter .SOLR_INSTALL_DIR_ATTRIBUTE );
181+ path = Path .of (installDir ).resolve (path ).normalize ();
182+ }
183+
184+ return path ;
185+ }
186+
167187 // Order is important here since "confDir" may be
168188 // 1> a full path to the parent of a solrconfig.xml or parent of /conf/solrconfig.xml
169189 // 2> one of the canned config sets only, e.g. _default
@@ -198,28 +218,6 @@ public static Path getConfigsetPath(String confDir, String configSetDir) {
198218 Path .of (configSetDir , confDir , "conf" , "solrconfig.xml" ).normalize ().toAbsolutePath ()));
199219 }
200220
201- /** If in SolrCloud mode, upload configSets for each SolrCore in solr.xml. */
202- public static void bootstrapConf (CoreContainer cc ) throws IOException {
203- // List<String> allCoreNames = cfg.getAllCoreNames();
204- List <CoreDescriptor > cds = cc .getCoresLocator ().discover (cc );
205-
206- if (log .isInfoEnabled ()) {
207- log .info (
208- "bootstrapping config for {} cores into ZooKeeper using solr.xml from {}" ,
209- cds .size (),
210- cc .getSolrHome ());
211- }
212-
213- for (CoreDescriptor cd : cds ) {
214- String coreName = cd .getName ();
215- String confName = cd .getCollectionName ();
216- if (StrUtils .isNullOrEmpty (confName )) confName = coreName ;
217- Path udir = cd .getInstanceDir ().resolve ("conf" );
218- log .info ("Uploading directory {} with name {} for solrCore {}" , udir , confName , coreName );
219- cc .getConfigSetService ().uploadConfig (confName , udir );
220- }
221- }
222-
223221 /**
224222 * Load the ConfigSet for a core
225223 *
0 commit comments