diff options
author | Marco Miller <marco.miller@ericsson.com> | 2020-03-13 12:14:31 -0400 |
---|---|---|
committer | Marco Miller <marco.miller@ericsson.com> | 2020-03-13 12:29:17 -0400 |
commit | 9f08729c294d327ed6ed34f78ca7a6bff5ac4393 (patch) | |
tree | a254fe459f922298ae5d770f7503709a09ad3566 | |
parent | 848027a18eb73822584eb658a467715db547574c (diff) | |
parent | 04bbb43e28f14b61412b71ecae19921ab67d62cc (diff) |
Merge branch 'stable-2.16' into stable-3.0v3.0.8
* stable-2.16:
Add method to push changes directly to given replica
Adapt the hereby merged UsedAt import addition to the c.g.g.common
package, differing from downstream c.g.g.server.
Change-Id: Ib630eb2be5a1167fddb949ee464b35bcf3f8db05
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java index 8030d28..4b25c8f 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java @@ -17,6 +17,7 @@ package com.googlesource.gerrit.plugins.replication; import com.google.auto.value.AutoValue; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Queues; +import com.google.gerrit.common.UsedAt; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.extensions.events.HeadUpdatedListener; import com.google.gerrit.extensions.events.LifecycleListener; @@ -139,17 +140,36 @@ public class ReplicationQueue Project.NameKey project = new Project.NameKey(projectName); for (Destination cfg : config.getDestinations(FilterType.ALL)) { - if (cfg.wouldPushProject(project) && cfg.wouldPushRef(refName)) { - for (URIish uri : cfg.getURIs(project, null)) { - replicationTasksStorage.persist( - new ReplicateRefUpdate(projectName, refName, uri, cfg.getRemoteConfigName())); - cfg.schedule(project, refName, uri, state); - } - } + pushReference(cfg, project, refName, state); } state.markAllPushTasksScheduled(); } + @UsedAt(UsedAt.Project.COLLABNET) + public void pushReference(Destination cfg, Project.NameKey project, String refName) { + pushReference(cfg, project, refName, null); + } + + private void pushReference( + Destination cfg, Project.NameKey project, String refName, ReplicationState state) { + boolean withoutState = state == null; + if (withoutState) { + state = new ReplicationState(new GitUpdateProcessing(dispatcher.get())); + } + + if (cfg.wouldPushProject(project) && cfg.wouldPushRef(refName)) { + for (URIish uri : cfg.getURIs(project, null)) { + replicationTasksStorage.persist( + new ReplicateRefUpdate(project.get(), refName, uri, cfg.getRemoteConfigName())); + cfg.schedule(project, refName, uri, state); + } + } + + if (withoutState) { + state.markAllPushTasksScheduled(); + } + } + private void firePendingEvents() { replaying = true; try { |