From 4e2d339e2f45b1e5248904b219f66c7edcbb7adc Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Mon, 17 Apr 2017 16:45:51 -0400 Subject: [PATCH] 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 --- .../server/change/GetRelatedIT.java | 2 +- .../server/notedb/ChangeRebuilderIT.java | 2 +- .../server/index/change/ChangeIndexer.java | 24 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java index b4f68fa871..fcbad4f676 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/change/GetRelatedIT.java @@ -517,7 +517,7 @@ public class GetRelatedIT extends AbstractDaemonTest { } @Test - @GerritConfig(name = "index.testReindexAfterUpdate", value = "false") + @GerritConfig(name = "index.testAutoReindexIfStale", value = "false") public void getRelatedForStaleChange() throws Exception { RevCommit c1_1 = commitBuilder().add("a.txt", "1").message("subject: 1").create(); diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java index 9d15daf118..15b74bde87 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/server/notedb/ChangeRebuilderIT.java @@ -120,7 +120,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest { // 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 // want precise control over when auto-rebuilding happens. - cfg.setBoolean("index", null, "testReindexAfterUpdate", false); + cfg.setBoolean("index", null, "testAutoReindexIfStale", false); return cfg; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java index a788f8cdd7..4edfab2783 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/change/ChangeIndexer.java @@ -107,7 +107,7 @@ public class ChangeIndexer { private final ListeningExecutorService executor; private final DynamicSet indexedListeners; private final StalenessChecker stalenessChecker; - private final boolean reindexAfterIndexUpdate; + private final boolean autoReindexIfStale; @AssistedInject ChangeIndexer( @@ -131,7 +131,7 @@ public class ChangeIndexer { this.indexedListeners = indexedListeners; this.stalenessChecker = stalenessChecker; this.batchExecutor = batchExecutor; - this.reindexAfterIndexUpdate = reindexAfterIndexUpdate(cfg); + this.autoReindexIfStale = autoReindexIfStale(cfg); this.index = index; this.indexes = null; } @@ -158,13 +158,13 @@ public class ChangeIndexer { this.indexedListeners = indexedListeners; this.stalenessChecker = stalenessChecker; this.batchExecutor = batchExecutor; - this.reindexAfterIndexUpdate = reindexAfterIndexUpdate(cfg); + this.autoReindexIfStale = autoReindexIfStale(cfg); this.index = null; this.indexes = indexes; } - private static boolean reindexAfterIndexUpdate(Config cfg) { - return cfg.getBoolean("index", null, "testReindexAfterUpdate", true); + private static boolean autoReindexIfStale(Config cfg) { + 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 // reindexIfStale calls actually execute in; we are guaranteed that at least // one of them will execute after the second index write, (4). - reindexAfterIndexUpdate(cd); + autoReindexIfStale(cd); } private void fireChangeIndexedEvent(int id) { @@ -253,7 +253,7 @@ public class ChangeIndexer { public void index(ReviewDb db, Change change) throws IOException, OrmException { index(newChangeData(db, change)); // 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); index(cd); // See comment in #index(ChangeData). - reindexAfterIndexUpdate(cd); + autoReindexIfStale(cd); } /** @@ -304,16 +304,16 @@ public class ChangeIndexer { return submit(new ReindexIfStaleTask(project, id), batchExecutor); } - private void reindexAfterIndexUpdate(ChangeData cd) throws IOException { + private void autoReindexIfStale(ChangeData cd) throws IOException { try { - reindexAfterIndexUpdate(cd.project(), cd.getId()); + autoReindexIfStale(cd.project(), cd.getId()); } catch (OrmException e) { throw new IOException(e); } } - private void reindexAfterIndexUpdate(Project.NameKey project, Change.Id id) { - if (reindexAfterIndexUpdate) { + private void autoReindexIfStale(Project.NameKey project, Change.Id id) { + if (autoReindexIfStale) { // Don't retry indefinitely; if this fails the change will be stale. @SuppressWarnings("unused") Future possiblyIgnoredError = reindexIfStale(project, id);