summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2017-03-15 23:53:12 +0000
committerSebastian Schuberth <sschuberth@gmail.com>2017-05-29 10:22:50 +0200
commit033b6ec2b74ac506f6cb02bb25aecc4a51cdfde7 (patch)
tree843cc7c3926f1ab1f06cb3580e30c15bf0523391 /src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java
parent39bf331502ec3f6d6143c99905f8d5565946ff41 (diff)
Set max retries to avoid queue congestion
When servers have *a lot* of remote slaves, some of them unstable and potentially offline, a maximum retry policy is needed to prevent push events to stay in the replication queue and getting rescheduled forever. Keep backward-compatible configuration by setting maxRetry by default to zero, which means disabled. Change-Id: I060cc7bc3a4d1089b0815db02d2e1430f83a2015
Diffstat (limited to 'src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java')
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java b/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java
index 0d7d3ce..f79f616 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/DestinationConfiguration.java
@@ -35,6 +35,7 @@ class DestinationConfiguration {
private final ImmutableList<String> projects;
private final ImmutableList<String> authGroupNames;
private final RemoteConfig remoteConfig;
+ private final int maxRetries;
DestinationConfiguration(RemoteConfig remoteConfig, Config cfg) {
this.remoteConfig = remoteConfig;
@@ -62,6 +63,9 @@ class DestinationConfiguration {
cfg.getBoolean("remote", name, "replicateHiddenProjects", false);
remoteNameStyle = MoreObjects.firstNonNull(
cfg.getString("remote", name, "remoteNameStyle"), "slash");
+ maxRetries =
+ getInt(
+ remoteConfig, cfg, "replicationMaxRetries", cfg.getInt("replication", "maxRetries", 0));
}
public int getDelay() {
@@ -120,6 +124,10 @@ class DestinationConfiguration {
return remoteConfig;
}
+ public int getMaxRetries() {
+ return maxRetries;
+ }
+
private static int getInt(
RemoteConfig rc, Config cfg, String name, int defValue) {
return cfg.getInt("remote", rc.getName(), name, defValue);