Define gerrit.replicateOnStartup to control replication

If this variable is set to false, we won't replicate to the remote
peers upon server startup.  This may be useful if a site restarts
their server multiple times per day and has a very big replication
URL set, or has many projects.

Bug: issue 685
Change-Id: I4b4d1b8621e508ad15fd13205a7f34880b839467
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-08-28 17:26:31 -07:00
parent ab6bea67b0
commit 75c76e2d67
2 changed files with 16 additions and 2 deletions

View File

@@ -797,6 +797,11 @@ By default unset, as the git daemon must be configured externally
by the system administrator, and might not even be running on the by the system administrator, and might not even be running on the
same host as Gerrit. same host as Gerrit.
[[gerrit.replicateOnStartup]]gerrit.replicateOnStartup::
+
If true, replicates to all remotes on startup to ensure they are
in-sync with this server. By default, true.
[[gitweb]]Section gitweb [[gitweb]]Section gitweb
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -20,6 +20,8 @@ import com.google.gerrit.server.git.PushAllProjectsOp;
import com.google.gerrit.server.git.ReloadSubmitQueueOp; import com.google.gerrit.server.git.ReloadSubmitQueueOp;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.eclipse.jgit.lib.Config;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** Configuration for a master node in a cluster of servers. */ /** Configuration for a master node in a cluster of servers. */
@@ -32,17 +34,24 @@ public class MasterNodeStartup extends LifecycleModule {
static class OnStart implements LifecycleListener { static class OnStart implements LifecycleListener {
private final PushAllProjectsOp.Factory pushAll; private final PushAllProjectsOp.Factory pushAll;
private final ReloadSubmitQueueOp.Factory submit; private final ReloadSubmitQueueOp.Factory submit;
private final boolean replicateOnStartup;
@Inject @Inject
OnStart(final PushAllProjectsOp.Factory pushAll, OnStart(final PushAllProjectsOp.Factory pushAll,
final ReloadSubmitQueueOp.Factory submit) { final ReloadSubmitQueueOp.Factory submit,
final @GerritServerConfig Config cfg) {
this.pushAll = pushAll; this.pushAll = pushAll;
this.submit = submit; this.submit = submit;
replicateOnStartup = cfg.getBoolean("gerrit", "replicateOnStartup", true);
} }
@Override @Override
public void start() { public void start() {
pushAll.create(null).start(30, TimeUnit.SECONDS); if (replicateOnStartup) {
pushAll.create(null).start(30, TimeUnit.SECONDS);
}
submit.create().start(15, TimeUnit.SECONDS); submit.create().start(15, TimeUnit.SECONDS);
} }