summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2016-08-15 15:00:56 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2016-08-15 15:30:41 +0900
commit51d6be2b49b8136d594309743edf26a74948bd23 (patch)
tree254da5067406e492ebdbdb1450d9f4ca07de6254
parent7cbcfd2a3a507472eb244cf1a773b177d291d253 (diff)
Destination: Consider ref visibility when scheduling replicationv2.12.9v2.12.8v2.12.7v2.12.6v2.12.5v2.12.4upstream/stable-2.12
Bug: Issue 4398 Change-Id: I11856eabf61e734691e1b00f1c3083c017f96a01
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java23
1 files changed, 22 insertions, 1 deletions
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 e267da3..3b098cc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java
@@ -231,6 +231,27 @@ class Destination {
cfg, "remote", rc.getName(), name, defValue, unit);
}
+ private boolean isVisible(final Project.NameKey project, final String ref,
+ ReplicationState... states) {
+ try {
+ return threadScoper.scope(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws NoSuchProjectException {
+ ProjectControl projectControl = controlFor(project);
+ return projectControl.isVisible()
+ && (PushOne.ALL_REFS.equals(ref)
+ || projectControl.controlForRef(ref).isVisible());
+ }
+ }).call();
+ } catch (NoSuchProjectException err) {
+ stateLog.error(String.format("source project %s not available", project),
+ err, states);
+ } catch (Exception e) {
+ throw Throwables.propagate(e);
+ }
+ return false;
+ }
+
private boolean isVisible(final Project.NameKey project,
ReplicationState... states) {
try {
@@ -252,7 +273,7 @@ class Destination {
void schedule(final Project.NameKey project, final String ref,
final URIish uri, ReplicationState state) {
repLog.info("scheduling replication {}:{} => {}", project, ref, uri);
- if (!isVisible(project, state)) {
+ if (!isVisible(project, ref, state)) {
return;
}