summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2019-10-24 10:54:59 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-10-24 10:54:59 +0000
commit94a465e0989ff8124aca3dca8e200aeb870cc9dd (patch)
treeb54c0f7640cc4b6511a690b2486b169e631ffbe4
parent6236969ab60c7f3b943bfafe822ab945c70838b7 (diff)
parent7b2e064ff3c59a35afb3313fac1ce07f2d5878f4 (diff)
Merge "Decouple observable queue implementation from ReplicationQueue"v3.1.0-rc3v3.1.0-rc2v3.1.0-rc1
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/AutoReloadRunnable.java8
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ObservableQueue.java32
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java1
-rw-r--r--src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java5
4 files changed, 41 insertions, 5 deletions
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/AutoReloadRunnable.java b/src/main/java/com/googlesource/gerrit/plugins/replication/AutoReloadRunnable.java
index 5b7c148..a1084a8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/AutoReloadRunnable.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/AutoReloadRunnable.java
@@ -29,7 +29,7 @@ public class AutoReloadRunnable implements Runnable {
private final SitePaths site;
private final Path pluginDataDir;
private final EventBus eventBus;
- private final Provider<ReplicationQueue> replicationQueue;
+ private final Provider<ObservableQueue> queueObserverProvider;
private final ReplicationConfigValidator configValidator;
private ReplicationFileBasedConfig loadedConfig;
@@ -43,21 +43,21 @@ public class AutoReloadRunnable implements Runnable {
SitePaths site,
@PluginData Path pluginDataDir,
EventBus eventBus,
- Provider<ReplicationQueue> replicationQueue) {
+ Provider<ObservableQueue> queueObserverProvider) {
this.loadedConfig = config;
this.loadedConfigVersion = config.getVersion();
this.lastFailedConfigVersion = "";
this.site = site;
this.pluginDataDir = pluginDataDir;
this.eventBus = eventBus;
- this.replicationQueue = replicationQueue;
+ this.queueObserverProvider = queueObserverProvider;
this.configValidator = configValidator;
}
@Override
public synchronized void run() {
String pendingConfigVersion = loadedConfig.getVersion();
- ReplicationQueue queue = replicationQueue.get();
+ ObservableQueue queue = queueObserverProvider.get();
if (pendingConfigVersion.equals(loadedConfigVersion)
|| pendingConfigVersion.equals(lastFailedConfigVersion)
|| !queue.isRunning()
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ObservableQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ObservableQueue.java
new file mode 100644
index 0000000..1007ae5
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ObservableQueue.java
@@ -0,0 +1,32 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.replication;
+
+/** Allows a queue activity to be observed */
+public interface ObservableQueue {
+ /**
+ * Indicates whether the observed queue is running
+ *
+ * @return true, when the queue is running, false otherwise
+ */
+ boolean isRunning();
+
+ /**
+ * Indicates whether the observed queue is replaying queued events
+ *
+ * @return true, when the queue is replaying, false otherwise
+ */
+ boolean isReplaying();
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java
index da2b1b5..979c8e3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationModule.java
@@ -52,6 +52,7 @@ class ReplicationModule extends AbstractModule {
protected void configure() {
install(new FactoryModuleBuilder().build(Destination.Factory.class));
bind(ReplicationQueue.class).in(Scopes.SINGLETON);
+ bind(ObservableQueue.class).to(ReplicationQueue.class);
bind(LifecycleListener.class)
.annotatedWith(UniqueAnnotations.create())
.to(ReplicationQueue.class);
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 4a3368b..e02fafc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -40,7 +40,8 @@ import org.slf4j.LoggerFactory;
/** Manages automatic replication to remote repositories. */
public class ReplicationQueue
- implements LifecycleListener,
+ implements ObservableQueue,
+ LifecycleListener,
GitReferenceUpdatedListener,
ProjectDeletedListener,
HeadUpdatedListener {
@@ -91,10 +92,12 @@ public class ReplicationQueue
}
}
+ @Override
public boolean isRunning() {
return running;
}
+ @Override
public boolean isReplaying() {
return replaying;
}