diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2014-10-24 00:16:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-10-24 00:16:03 +0000 |
commit | 50e3b57294f445a51252c6d858aaf402ea3a24c7 (patch) | |
tree | 062e8f70a8f1c8a1beb7e27940e84c36179c95b6 | |
parent | 44b951dd29b915e69b466a484f5efec6534bfd06 (diff) | |
parent | e88c762d02d82d0160c11c75ce776cb2d63b2a36 (diff) |
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java | 32 |
1 files changed, 19 insertions, 13 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 14337d6..ef659f2 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java @@ -199,28 +199,30 @@ class Destination { return cfg.getInt("remote", rc.getName(), name, defValue); } - void schedule(final Project.NameKey project, final String ref, - final URIish uri, ReplicationState state) { + private boolean isVisible(final Project.NameKey project, + ReplicationState... states) { try { - repLog.info("scheduling replication {}:{} => {}", project, ref, uri); - boolean visible = threadScoper.scope(new Callable<Boolean>(){ + return threadScoper.scope(new Callable<Boolean>() { @Override public Boolean call() throws NoSuchProjectException { return controlFor(project).isVisible(); } }).call(); - if (!visible) { - stateLog.warn(String.format("project %s is not visible", project), - state); - return; - } } catch (NoSuchProjectException err) { - stateLog.error(String.format( - "source project %s not available", project), err, state); - return; + stateLog.error(String.format("source project %s not available", project), + err, states); } catch (Exception e) { throw Throwables.propagate(e); } + return false; + } + + 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)) { + return; + } if (!replicatePermissions) { PushOne e; @@ -384,7 +386,11 @@ class Destination { } } - boolean wouldPushProject(Project.NameKey project) { + boolean wouldPushProject(final Project.NameKey project) { + if (!isVisible(project)) { + return false; + } + // by default push all projects if (projects.length < 1) { return true; |