scwhittle commented on code in PR #30255:
URL: https://github.com/apache/beam/pull/30255#discussion_r1500931469
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/WindmillStream.java:
##########
@@ -77,14 +79,19 @@ interface CommitWorkStream extends WindmillStream {
* <p>onDone will be called with the status of the commit.
*/
boolean commitWorkItem(
- String computation,
- Windmill.WorkItemCommitRequest request,
- Consumer<Windmill.CommitStatus> onDone);
+ String computation, WorkItemCommitRequest request,
Consumer<Windmill.CommitStatus> onDone);
/** Flushes any pending work items to the wire. */
void flush();
}
+ @ThreadSafe
+ interface AsyncCommitWorkStream extends CommitWorkStream {
+ void queueCommit(Commit commit);
Review Comment:
add comments to methods
in particular, is this required not to block?
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/GrpcDirectCommitWorkStream.java:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.beam.runners.dataflow.worker.windmill.client.grpc;
+
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import javax.annotation.Nullable;
+import org.apache.beam.runners.dataflow.worker.streaming.Commit;
+import org.apache.beam.runners.dataflow.worker.streaming.WeightedBoundedQueue;
+import org.apache.beam.runners.dataflow.worker.streaming.Work;
+import org.apache.beam.runners.dataflow.worker.windmill.Windmill.JobHeader;
+import
org.apache.beam.runners.dataflow.worker.windmill.Windmill.StreamingCommitResponse;
+import
org.apache.beam.runners.dataflow.worker.windmill.Windmill.StreamingCommitWorkRequest;
+import
org.apache.beam.runners.dataflow.worker.windmill.client.AbstractWindmillStream;
+import org.apache.beam.runners.dataflow.worker.windmill.client.CompleteCommit;
+import
org.apache.beam.runners.dataflow.worker.windmill.client.WindmillStream.AsyncCommitWorkStream;
+import
org.apache.beam.runners.dataflow.worker.windmill.client.grpc.observers.StreamObserverFactory;
+import
org.apache.beam.runners.dataflow.worker.windmill.client.throttling.ThrottleTimer;
+import org.apache.beam.sdk.util.BackOff;
+import org.apache.beam.vendor.grpc.v1p60p1.io.grpc.stub.StreamObserver;
+import
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.annotations.VisibleForTesting;
+import
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions;
+import
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.util.concurrent.ThreadFactoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of {@link
+ *
org.apache.beam.runners.dataflow.worker.windmill.client.WindmillStream.CommitWorkStream}
that
+ * manages its own commit queue, and asynchronously CommitWork RPCs to
Streaming Engine as callers
+ * queue commits on the internal queue.
+ *
+ * <p>Callers should call {@link #queueCommit(Commit)} when work is ready to
be committed.
+ */
+public class GrpcDirectCommitWorkStream extends GrpcCommitWorkStream
Review Comment:
could we use composition instead of inheritence? it seems like functionality
is just added on top of the existing stream and could just be a separate object
containing a stream it delegates to.
https://en.wikipedia.org/wiki/Composition_over_inheritance#:~:text=Composition%20over%20inheritance%20(or%20composite,from%20a%20base%20or%20parent
It seems like https://github.com/apache/beam/pull/30312 is ending up there,
with a committer object that is wrapping the stream. Perhaps we should just get
that one in first and then integrate that object for direct path.
--
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]