Add ssh command to activate the latest index
In case the online indexer fails, this allows the admins to activate the latest index. Change-Id: I59ebf2bce02a599b87d0f7771fc806ff64a3ba64
This commit is contained in:
@@ -182,6 +182,22 @@ public class LuceneVersionManager implements LifecycleListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the latest index if the current index is not already the latest.
|
||||
*
|
||||
* @return true if index was activate, otherwise false.
|
||||
* @throws ReindexerAlreadyRunningException
|
||||
*/
|
||||
public synchronized boolean activateLatestIndex()
|
||||
throws ReindexerAlreadyRunningException {
|
||||
validateReindexerNotRunning();
|
||||
if (!isCurrentIndexVersionLatest()) {
|
||||
reindexer.activateIndex();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isCurrentIndexVersionLatest() {
|
||||
return reindexer == null
|
||||
|| reindexer.getVersion() == indexes.getSearchIndex().getSchema()
|
||||
|
@@ -43,6 +43,7 @@ public class OnlineReindexer {
|
||||
private final SiteIndexer batchIndexer;
|
||||
private final ProjectCache projectCache;
|
||||
private final int version;
|
||||
private ChangeIndex index;
|
||||
private final AtomicBoolean running = new AtomicBoolean();
|
||||
|
||||
@Inject
|
||||
@@ -88,7 +89,7 @@ public class OnlineReindexer {
|
||||
}
|
||||
|
||||
private void reindex() {
|
||||
ChangeIndex index = checkNotNull(indexes.getWriteIndex(version),
|
||||
index = checkNotNull(indexes.getWriteIndex(version),
|
||||
"not an active write schema version: %s", version);
|
||||
log.info("Starting online reindex from schema version {} to {}",
|
||||
version(indexes.getSearchIndex()), version(index));
|
||||
@@ -100,9 +101,13 @@ public class OnlineReindexer {
|
||||
version(index), result.doneCount(), result.failedCount());
|
||||
return;
|
||||
}
|
||||
log.info("Reindex to version {} complete", version(index));
|
||||
activateIndex();
|
||||
}
|
||||
|
||||
void activateIndex() {
|
||||
indexes.setSearchIndex(index);
|
||||
log.info("Reindex complete, using schema version {}", version(index));
|
||||
log.info("Using schema version {}", version(index));
|
||||
try {
|
||||
index.markReady(true);
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user