Extract QueueInfo into its own class This change is propedeutic to allow the injection of a QueuInfo singletlon to be shared among Sources to avoid triggering multiple fetches for the same project. Change-Id: I41e0b60ed8366f3bfa5a3b91aa3fa8d983c08811
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ListCommand.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ListCommand.java index d7d55ec..a37f554 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ListCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ListCommand.java
@@ -89,7 +89,7 @@ addProperty(obj, "AdminUrl", s.getAdminUrls()); addProperty(obj, "AuthGroup", s.getAuthGroupNames()); addProperty(obj, "Project", s.getProjects()); - Source.QueueInfo q = s.getQueueInfo(); + QueueInfo q = s.getQueueInfo(); addQueueDetails(obj, "InFlight", q.inFlight.values()); addQueueDetails(obj, "Pending", q.pending.values()); } @@ -114,7 +114,7 @@ out.append("Project: ").append(project).append("\n"); } - Source.QueueInfo q = s.getQueueInfo(); + QueueInfo q = s.getQueueInfo(); out.append("In Flight: ").append(q.inFlight.size()).append("\n"); addQueueDetails(out, q.inFlight.values()); out.append("Pending: ").append(q.pending.size()).append("\n");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/QueueInfo.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/QueueInfo.java new file mode 100644 index 0000000..5c1ee56 --- /dev/null +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/QueueInfo.java
@@ -0,0 +1,30 @@ +// Copyright (C) 2025 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.pull; + +import com.google.common.collect.ImmutableMap; +import com.google.gerrit.entities.Project; +import java.util.Map; + +public class QueueInfo { + public final Map<Project.NameKey, FetchOne> pending; + public final Map<Project.NameKey, FetchOne> inFlight; + + public QueueInfo( + Map<Project.NameKey, FetchOne> pending, Map<Project.NameKey, FetchOne> inFlight) { + this.pending = ImmutableMap.copyOf(pending); + this.inFlight = ImmutableMap.copyOf(inFlight); + } +}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index 097f058..563d51e 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -21,7 +21,6 @@ import com.google.common.base.Stopwatch; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Lists; @@ -133,17 +132,6 @@ REPOSITORY_MISSING } - public static class QueueInfo { - public final Map<Project.NameKey, FetchOne> pending; - public final Map<Project.NameKey, FetchOne> inFlight; - - public QueueInfo( - Map<Project.NameKey, FetchOne> pending, Map<Project.NameKey, FetchOne> inFlight) { - this.pending = ImmutableMap.copyOf(pending); - this.inFlight = ImmutableMap.copyOf(inFlight); - } - } - @Inject protected Source( Injector injector,