ChangeIndexer#reindexAfterIndexUpdate -> autoReindexIfStale

The name is confusingly similar to ReindexAfterUpdate, even though they
are completely different pieces of functionality with different goals.

Change-Id: I806f4061997bcc4644c3dcbf84937c68041c6059
This commit is contained in:
Dave Borowitz
2017-04-17 16:45:51 -04:00
parent aeccf371c0
commit 4e2d339e2f
3 changed files with 14 additions and 14 deletions

View File

@@ -517,7 +517,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
} }
@Test @Test
@GerritConfig(name = "index.testReindexAfterUpdate", value = "false") @GerritConfig(name = "index.testAutoReindexIfStale", value = "false")
public void getRelatedForStaleChange() throws Exception { public void getRelatedForStaleChange() throws Exception {
RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create(); RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create();

View File

@@ -120,7 +120,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
// unintentional auto-rebuilding of the change in NoteDb during the read // unintentional auto-rebuilding of the change in NoteDb during the read
// path of the reindex-if-stale check. For the purposes of this test, we // path of the reindex-if-stale check. For the purposes of this test, we
// want precise control over when auto-rebuilding happens. // want precise control over when auto-rebuilding happens.
cfg.setBoolean("index", null, "testReindexAfterUpdate", false); cfg.setBoolean("index", null, "testAutoReindexIfStale", false);
return cfg; return cfg;
} }

View File

@@ -107,7 +107,7 @@ public class ChangeIndexer {
private final ListeningExecutorService executor; private final ListeningExecutorService executor;
private final DynamicSet<ChangeIndexedListener> indexedListeners; private final DynamicSet<ChangeIndexedListener> indexedListeners;
private final StalenessChecker stalenessChecker; private final StalenessChecker stalenessChecker;
private final boolean reindexAfterIndexUpdate; private final boolean autoReindexIfStale;
@AssistedInject @AssistedInject
ChangeIndexer( ChangeIndexer(
@@ -131,7 +131,7 @@ public class ChangeIndexer {
this.indexedListeners = indexedListeners; this.indexedListeners = indexedListeners;
this.stalenessChecker = stalenessChecker; this.stalenessChecker = stalenessChecker;
this.batchExecutor = batchExecutor; this.batchExecutor = batchExecutor;
this.reindexAfterIndexUpdate = reindexAfterIndexUpdate(cfg); this.autoReindexIfStale = autoReindexIfStale(cfg);
this.index = index; this.index = index;
this.indexes = null; this.indexes = null;
} }
@@ -158,13 +158,13 @@ public class ChangeIndexer {
this.indexedListeners = indexedListeners; this.indexedListeners = indexedListeners;
this.stalenessChecker = stalenessChecker; this.stalenessChecker = stalenessChecker;
this.batchExecutor = batchExecutor; this.batchExecutor = batchExecutor;
this.reindexAfterIndexUpdate = reindexAfterIndexUpdate(cfg); this.autoReindexIfStale = autoReindexIfStale(cfg);
this.index = null; this.index = null;
this.indexes = indexes; this.indexes = indexes;
} }
private static boolean reindexAfterIndexUpdate(Config cfg) { private static boolean autoReindexIfStale(Config cfg) {
return cfg.getBoolean("index", null, "testReindexAfterUpdate", true); return cfg.getBoolean("index", null, "testAutoReindexIfStale", true);
} }
/** /**
@@ -221,7 +221,7 @@ public class ChangeIndexer {
// and fix the staleness. It doesn't matter which order the two // and fix the staleness. It doesn't matter which order the two
// reindexIfStale calls actually execute in; we are guaranteed that at least // reindexIfStale calls actually execute in; we are guaranteed that at least
// one of them will execute after the second index write, (4). // one of them will execute after the second index write, (4).
reindexAfterIndexUpdate(cd); autoReindexIfStale(cd);
} }
private void fireChangeIndexedEvent(int id) { private void fireChangeIndexedEvent(int id) {
@@ -253,7 +253,7 @@ public class ChangeIndexer {
public void index(ReviewDb db, Change change) throws IOException, OrmException { public void index(ReviewDb db, Change change) throws IOException, OrmException {
index(newChangeData(db, change)); index(newChangeData(db, change));
// See comment in #index(ChangeData). // See comment in #index(ChangeData).
reindexAfterIndexUpdate(change.getProject(), change.getId()); autoReindexIfStale(change.getProject(), change.getId());
} }
/** /**
@@ -268,7 +268,7 @@ public class ChangeIndexer {
ChangeData cd = newChangeData(db, project, changeId); ChangeData cd = newChangeData(db, project, changeId);
index(cd); index(cd);
// See comment in #index(ChangeData). // See comment in #index(ChangeData).
reindexAfterIndexUpdate(cd); autoReindexIfStale(cd);
} }
/** /**
@@ -304,16 +304,16 @@ public class ChangeIndexer {
return submit(new ReindexIfStaleTask(project, id), batchExecutor); return submit(new ReindexIfStaleTask(project, id), batchExecutor);
} }
private void reindexAfterIndexUpdate(ChangeData cd) throws IOException { private void autoReindexIfStale(ChangeData cd) throws IOException {
try { try {
reindexAfterIndexUpdate(cd.project(), cd.getId()); autoReindexIfStale(cd.project(), cd.getId());
} catch (OrmException e) { } catch (OrmException e) {
throw new IOException(e); throw new IOException(e);
} }
} }
private void reindexAfterIndexUpdate(Project.NameKey project, Change.Id id) { private void autoReindexIfStale(Project.NameKey project, Change.Id id) {
if (reindexAfterIndexUpdate) { if (autoReindexIfStale) {
// Don't retry indefinitely; if this fails the change will be stale. // Don't retry indefinitely; if this fails the change will be stale.
@SuppressWarnings("unused") @SuppressWarnings("unused")
Future<?> possiblyIgnoredError = reindexIfStale(project, id); Future<?> possiblyIgnoredError = reindexIfStale(project, id);