Add 'Forwarded-BatchIndex-Event' to events skipped from high-availability Currently only events generated by threads named '/plugins/high-availability/' or 'Forwarded-Index-Event' are skipped. Events generated by 'Forwarded-BatchIndex-Event' thread should be skipped as well. Bug: Issue 13307 Change-Id: I3bd4a57be766cdc4b80f82cf6c9daf99a3e45750
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java index 1315a9c..49e6e1e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/broker/BrokerForwarder.java
@@ -22,6 +22,8 @@ public abstract class BrokerForwarder { private static final CharSequence HIGH_AVAILABILITY_PLUGIN = "/plugins/high-availability/"; private static final CharSequence HIGH_AVAILABILITY_FORWARDER = "Forwarded-Index-Event"; + private static final CharSequence HIGH_AVAILABILITY_BATCH_FORWARDER = + "Forwarded-BatchIndex-Event"; private final BrokerApiWrapper broker; @@ -33,7 +35,8 @@ String currentThreadName = task.getCallerThread().getName(); return currentThreadName.contains(HIGH_AVAILABILITY_PLUGIN) - || currentThreadName.contains(HIGH_AVAILABILITY_FORWARDER); + || currentThreadName.contains(HIGH_AVAILABILITY_FORWARDER) + || currentThreadName.contains(HIGH_AVAILABILITY_BATCH_FORWARDER); } protected boolean send(ForwarderTask task, EventTopic eventTopic, MultiSiteEvent event) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java index ed8920d..5aaa2c8 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/BrokerForwarderTest.java
@@ -38,6 +38,7 @@ public class BrokerForwarderTest { private static final String HIGH_AVAILABILITY_PLUGIN = "/plugins/high-availability/"; private static final String HIGH_AVAILABILITY_FORWARDED = "Forwarded-Index-Event"; + private static final String HIGH_AVAILABILITY_BATCH_FORWARDED = "Forwarded-BatchIndex-Event"; private static final long TEST_TIMEOUT_SEC = 5L; @Mock private BrokerApiWrapper brokerMock; @@ -103,6 +104,13 @@ verifyZeroInteractions(brokerMock); } + @Test + public void shouldSkipEventFromHighAvailabilityPluginBatchForwardedThread() { + brokerForwarder.send(newForwarderTask(HIGH_AVAILABILITY_BATCH_FORWARDED), testTopic, testEvent); + + verifyZeroInteractions(brokerMock); + } + private ForwarderTask newForwarderTask(String threadName) { try { return executor