Returns the indexdir as given in index.properties. If index.properties exists in dataDir and there is a property index available, and it points to a valid directory in dataDir that is returned. Else dataDir/index is returned. Only called for creating new indexSearchers and indexwriters. Use t
()
| 396 | /** |
| 397 | * Returns the indexdir as given in index.properties. If index.properties exists in dataDir and |
| 398 | * there is a property <i>index</i> available, and it points to a valid directory in dataDir that |
| 399 | * is returned. Else dataDir/index is returned. Only called for creating new indexSearchers and |
| 400 | * indexwriters. Use the getIndexDir() method to know the active index directory |
| 401 | * |
| 402 | * @return the indexdir as given in index.properties |
| 403 | * @throws SolrException if for any reason an index directory cannot be determined. |
| 404 | */ |
| 405 | public String getNewIndexDir() { |
| 406 | Directory dir = null; |
| 407 | try { |
| 408 | dir = |
| 409 | getDirectoryFactory() |
| 410 | .get(getDataDir(), DirContext.META_DATA, getSolrConfig().indexConfig.lockType); |
| 411 | String result = getIndexPropertyFromPropFile(dir); |
| 412 | if (!result.equals(lastNewIndexDir)) { |
| 413 | log.debug("New index directory detected: old={} new={}", lastNewIndexDir, result); |
| 414 | } |
| 415 | lastNewIndexDir = result; |
| 416 | return result; |
| 417 | } catch (IOException e) { |
| 418 | String errorMessage = "Error in getNewIndexDir, exception: "; |
| 419 | log.error(errorMessage, e); |
| 420 | // See SOLR-11687. It is inadvisable to assume we can do the right thing for any but a small |
| 421 | // number of exceptions that were caught and swallowed in getIndexProperty. |
| 422 | throw new SolrException(ErrorCode.SERVER_ERROR, errorMessage, e); |
| 423 | } finally { |
| 424 | if (dir != null) { |
| 425 | try { |
| 426 | getDirectoryFactory().release(dir); |
| 427 | } catch (IOException e) { |
| 428 | log.error("Exception releasing {}", dir, e); |