Merge branch 'stable-2.11' into stable-2.12
* stable-2.11:
Destination: parse replication delay and retry as time units
Remove obsolete remote.NAME.timeout from config documentation
Change-Id: I57016ead4f30def6153b66dee41922cddad36804
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
index 5e04bb9..ee8d08d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -29,6 +29,7 @@
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupBackends;
import com.google.gerrit.server.account.ListGroupMembership;
+import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.RequestScopedReviewDbProvider;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.PerThreadRequestScope;
@@ -107,8 +108,10 @@
gitManager = gitRepositoryManager;
this.stateLog = stateLog;
- delay = Math.max(0, getInt(rc, cfg, "replicationdelay", 15));
- retryDelay = Math.max(0, getInt(rc, cfg, "replicationretry", 1));
+ delay = Math.max(0,
+ getTimeUnit(rc, cfg, "replicationdelay", 15, TimeUnit.SECONDS));
+ retryDelay = Math.max(0,
+ getTimeUnit(rc, cfg, "replicationretry", 1, TimeUnit.MINUTES));
lockErrorMaxRetries = cfg.getInt("replication", "lockErrorMaxRetries", 0);
adminUrls = cfg.getStringList("remote", rc.getName(), "adminUrl");
urls = cfg.getStringList("remote", rc.getName(), "url");
@@ -204,6 +207,12 @@
return cfg.getInt("remote", rc.getName(), name, defValue);
}
+ private static int getTimeUnit(
+ RemoteConfig rc, Config cfg, String name, int defValue, TimeUnit unit) {
+ return (int)ConfigUtil.getTimeUnit(
+ cfg, "remote", rc.getName(), name, defValue, unit);
+ }
+
private boolean isVisible(final Project.NameKey project,
ReplicationState... states) {
try {
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index bea2d92..54251ce 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -182,31 +182,18 @@
[2]: #example_file
-remote.NAME.timeout
-: Number of seconds to wait for a network read or write to
- complete before giving up and declaring the remote side is not
- responding. If 0, there is no timeout, and the push client
- waits indefinitely.
-
- A timeout should be large enough to mostly transfer the
- objects to the other side. 1 second may be too small for
- larger projects, especially over a WAN link, while 10-30
- seconds is a much more reasonable timeout value.
-
- Defaults to 0 seconds, wait indefinitely.
-
remote.NAME.replicationDelay
-: Number of seconds to wait before scheduling a remote push
- operation. Setting the delay to 0 effectively disables the
- delay, causing the push to start as soon as possible.
+: Time to wait before scheduling a remote push operation. Setting
+ the delay to 0 effectively disables the delay, causing the push
+ to start as soon as possible.
This is a Gerrit specific extension to the Git remote block.
By default, 15 seconds.
remote.NAME.replicationRetry
-: Number of minutes to wait before scheduling a remote push
- operation previously failed due to an offline remote server.
+: Time to wait before scheduling a remote push operation previously
+ failed due to an offline remote server.
If a remote push operation fails because a remote server was
offline, all push operations to the same destination URL are