Skip to content

Commit

Permalink
Add the necessary steps for lucene replace
Browse files Browse the repository at this point in the history
  • Loading branch information
garyluoex committed Oct 13, 2017
1 parent bdb3d60 commit 9bec355
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ Current

### Fixed:

- [Fix lucene search provider replace method](https://github.com/yahoo/fili/pull/551)
* Reopen the search index

- [Fix ConstantMaker make method with LogicalMetricInfo class](https://github.com/yahoo/fili/pull/540)
* The ConstantMaker make method needs to be rewritten with the LogicalMetricInfo class.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,25 +327,34 @@ private void updateDimensionRow(

@Override
public void replaceIndex(String newLuceneIndexPathString) {
LOG.debug(
"Replacing Lucene indexes at {} for dimension {} with new index at {}",
luceneDirectory.toString(),
dimension.getApiName(),
newLuceneIndexPathString
);

lock.writeLock().lock();
try {
Path oldLuceneIndexPath = Paths.get(luceneIndexPath);
String tempDir = oldLuceneIndexPath.resolveSibling(oldLuceneIndexPath.getFileName() + "_old").toString();

LOG.debug("Moving old Lucene index directory from {} to {} ...", luceneIndexPath, tempDir);
LOG.trace("Moving old Lucene index directory from {} to {} ...", luceneIndexPath, tempDir);
moveDirEntries(luceneIndexPath, tempDir);

LOG.debug("Moving all new Lucene indexes from {} to {} ...", newLuceneIndexPathString, luceneIndexPath);
LOG.trace("Moving all new Lucene indexes from {} to {} ...", newLuceneIndexPathString, luceneIndexPath);
moveDirEntries(newLuceneIndexPathString, luceneIndexPath);

LOG.debug(
LOG.trace(
"Deleting {} since new Lucene indexes have been moved away from there and is now empty",
newLuceneIndexPathString
);
deleteDir(newLuceneIndexPathString);

LOG.debug("Deleting old Lucene indexes in {} ...", tempDir);
LOG.trace("Deleting old Lucene indexes in {} ...", tempDir);
deleteDir(tempDir);

reopenIndexSearcher(false);
} finally {
lock.writeLock().unlock();
}
Expand Down

0 comments on commit 9bec355

Please sign in to comment.