From 51d6be2b49b8136d594309743edf26a74948bd23 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Mon, 15 Aug 2016 15:00:56 +0900 Subject: Destination: Consider ref visibility when scheduling replication Bug: Issue 4398 Change-Id: I11856eabf61e734691e1b00f1c3083c017f96a01 --- .../gerrit/plugins/replication/Destination.java | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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() { + @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; } -- cgit v1.2.3