m-trieu commented on code in PR #32905:
URL: https://github.com/apache/beam/pull/32905#discussion_r1829864394
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/WeightedBoundedQueue.java:
##########
@@ -18,49 +18,40 @@
package org.apache.beam.runners.dataflow.worker.streaming;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import java.util.function.Function;
+import
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
import org.checkerframework.checker.nullness.qual.Nullable;
-/** Bounded set of queues, with a maximum total weight. */
+/** Queue bounded by a {@link WeightedSemaphore}. */
public final class WeightedBoundedQueue<V> {
private final LinkedBlockingQueue<V> queue;
- private final int maxWeight;
- private final Semaphore limit;
- private final Function<V, Integer> weigher;
+ private final WeightedSemaphore<V> weightedSemaphore;
private WeightedBoundedQueue(
- LinkedBlockingQueue<V> linkedBlockingQueue,
- int maxWeight,
- Semaphore limit,
- Function<V, Integer> weigher) {
+ LinkedBlockingQueue<V> linkedBlockingQueue, WeightedSemaphore<V>
weightedSemaphore) {
this.queue = linkedBlockingQueue;
- this.maxWeight = maxWeight;
- this.limit = limit;
- this.weigher = weigher;
+ this.weightedSemaphore = weightedSemaphore;
}
- public static <V> WeightedBoundedQueue<V> create(int maxWeight, Function<V,
Integer> weigherFn) {
- return new WeightedBoundedQueue<>(
- new LinkedBlockingQueue<>(), maxWeight, new Semaphore(maxWeight,
true), weigherFn);
+ public static <V> WeightedBoundedQueue<V> create(WeightedSemaphore<V>
weigher) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]