Add an optional flag to force an online reindex
As discussed on Gerrit ML[1] and in referenced issue, there are situations where you may want to run an online reindex besides the upgrade gerrit use case. This change allows users to force an online reindex. [1] https://groups.google.com/d/msg/repo-discuss/pUn8fHVh58w/icsSFef2CAAJ feature: issue 3987 Change-Id: Ie88b7effda08996f7c0f325543be703bcf09c794
This commit is contained in:
@@ -163,11 +163,11 @@ public class LuceneVersionManager implements LifecycleListener {
|
||||
markNotReady(cfg, def.getName(), versions.values(), write);
|
||||
|
||||
int latest = write.get(0).version;
|
||||
OnlineReindexer<K, V, I> reindexer = new OnlineReindexer<>(def, latest);
|
||||
reindexers.put(def.getName(), reindexer);
|
||||
if (onlineUpgrade && latest != search.version) {
|
||||
OnlineReindexer<K, V, I> reindexer = new OnlineReindexer<>(def, latest);
|
||||
synchronized (this) {
|
||||
if (!reindexers.containsKey(def.getName())) {
|
||||
reindexers.put(def.getName(), reindexer);
|
||||
reindexer.start();
|
||||
}
|
||||
}
|
||||
@@ -177,14 +177,15 @@ public class LuceneVersionManager implements LifecycleListener {
|
||||
/**
|
||||
* Start the online reindexer if the current index is not already the latest.
|
||||
*
|
||||
* @param force start re-index
|
||||
* @return true if started, otherwise false.
|
||||
* @throws ReindexerAlreadyRunningException
|
||||
*/
|
||||
public synchronized boolean startReindexer(String name)
|
||||
public synchronized boolean startReindexer(String name, boolean force)
|
||||
throws ReindexerAlreadyRunningException {
|
||||
OnlineReindexer<?, ?, ?> reindexer = reindexers.get(name);
|
||||
validateReindexerNotRunning(reindexer);
|
||||
if (!isCurrentIndexVersionLatest(name, reindexer)) {
|
||||
if (force || !isCurrentIndexVersionLatest(name, reindexer)) {
|
||||
reindexer.start();
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user