Provides a static reference to a Config object modeling the main configuration data for a Solr core -- typically found in "solrconfig.xml".
| 97 | * core -- typically found in "solrconfig.xml". |
| 98 | */ |
| 99 | public class SolrConfig implements MapWriter { |
| 100 | |
| 101 | private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); |
| 102 | |
| 103 | public static final String DEFAULT_CONF_FILE = "solrconfig.xml"; |
| 104 | public static final String MIN_PREFIX_QUERY_TERM_LENGTH = "minPrefixQueryTermLength"; |
| 105 | public static final int DEFAULT_MIN_PREFIX_QUERY_TERM_LENGTH = -1; |
| 106 | private final String resourceName; |
| 107 | |
| 108 | private int znodeVersion; |
| 109 | ConfigNode root; |
| 110 | int rootDataHashCode; |
| 111 | private final SolrResourceLoader resourceLoader; |
| 112 | private Properties substituteProperties; |
| 113 | |
| 114 | private RequestParams requestParams; |
| 115 | |
| 116 | public enum PluginOpts { |
| 117 | MULTI_OK, |
| 118 | REQUIRE_NAME, |
| 119 | REQUIRE_NAME_IN_OVERLAY, |
| 120 | REQUIRE_CLASS, |
| 121 | LAZY, |
| 122 | // EnumSet.of and/or EnumSet.copyOf(Collection) are annoying |
| 123 | // because of type determination |
| 124 | NOOP |
| 125 | } |
| 126 | |
| 127 | private int multipartUploadLimitKB; |
| 128 | |
| 129 | private int formUploadLimitKB; |
| 130 | |
| 131 | private final SolrRequestParsers solrRequestParsers; |
| 132 | |
| 133 | /** |
| 134 | * TEST-ONLY: Creates a configuration instance from an instance directory and file name |
| 135 | * |
| 136 | * @param instanceDir the directory used to create the resource loader |
| 137 | * @param name the configuration name used by the loader if the stream is null |
| 138 | */ |
| 139 | public SolrConfig(Path instanceDir, String name) throws IOException { |
| 140 | this(new SolrResourceLoader(instanceDir), name, null); |
| 141 | } |
| 142 | |
| 143 | public static SolrConfig readFromResourceLoader( |
| 144 | SolrResourceLoader loader, String name, Properties substitutableProperties) { |
| 145 | try { |
| 146 | return new SolrConfig(loader, name, substitutableProperties); |
| 147 | } catch (Exception e) { |
| 148 | String resource; |
| 149 | if (loader instanceof ZkSolrResourceLoader) { |
| 150 | resource = name; |
| 151 | } else { |
| 152 | resource = loader.getConfigPath().resolve(name).toString(); |
| 153 | } |
| 154 | throw new SolrException( |
| 155 | ErrorCode.SERVER_ERROR, "Error loading solr config from " + resource, e); |
| 156 | } |