m-trieu commented on code in PR #32774:
URL: https://github.com/apache/beam/pull/32774#discussion_r1824930724
##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/GrpcCommitWorkStream.java:
##########
@@ -204,56 +224,64 @@ private void flushInternal(Map<Long, PendingRequest>
requests) {
}
}
- private void issueSingleRequest(final long id, PendingRequest
pendingRequest) {
+ private void issueSingleRequest(long id, PendingRequest pendingRequest) {
+ if (!prepareForSend(id, pendingRequest)) {
+ pendingRequest.abort();
+ return;
+ }
+
StreamingCommitWorkRequest.Builder requestBuilder =
StreamingCommitWorkRequest.newBuilder();
requestBuilder
.addCommitChunkBuilder()
- .setComputationId(pendingRequest.computation)
+ .setComputationId(pendingRequest.computationId())
.setRequestId(id)
- .setShardingKey(pendingRequest.request.getShardingKey())
- .setSerializedWorkItemCommit(pendingRequest.request.toByteString());
+ .setShardingKey(pendingRequest.shardingKey())
+ .setSerializedWorkItemCommit(pendingRequest.serializedCommit());
StreamingCommitWorkRequest chunk = requestBuilder.build();
- synchronized (this) {
- pending.put(id, pendingRequest);
- try {
- send(chunk);
- } catch (IllegalStateException e) {
- // Stream was broken, request will be retried when stream is reopened.
- }
+ try {
+ send(chunk);
+ } catch (IllegalStateException e) {
+ // Stream was broken, request will be retried when stream is reopened.
}
}
private void issueBatchedRequest(Map<Long, PendingRequest> requests) {
+ if (!prepareForSend(requests)) {
+ requests.forEach((ignored, pendingRequest) -> pendingRequest.abort());
+ return;
+ }
+
StreamingCommitWorkRequest.Builder requestBuilder =
StreamingCommitWorkRequest.newBuilder();
String lastComputation = null;
for (Map.Entry<Long, PendingRequest> entry : requests.entrySet()) {
PendingRequest request = entry.getValue();
StreamingCommitRequestChunk.Builder chunkBuilder =
requestBuilder.addCommitChunkBuilder();
- if (lastComputation == null ||
!lastComputation.equals(request.computation)) {
- chunkBuilder.setComputationId(request.computation);
- lastComputation = request.computation;
+ if (lastComputation == null ||
!lastComputation.equals(request.computationId())) {
+ chunkBuilder.setComputationId(request.computationId());
+ lastComputation = request.computationId();
}
- chunkBuilder.setRequestId(entry.getKey());
- chunkBuilder.setShardingKey(request.request.getShardingKey());
- chunkBuilder.setSerializedWorkItemCommit(request.request.toByteString());
+ chunkBuilder
+ .setRequestId(entry.getKey())
+ .setShardingKey(request.shardingKey())
+ .setSerializedWorkItemCommit(request.serializedCommit());
}
StreamingCommitWorkRequest request = requestBuilder.build();
- synchronized (this) {
- pending.putAll(requests);
- try {
- send(request);
- } catch (IllegalStateException e) {
- // Stream was broken, request will be retried when stream is reopened.
- }
+ try {
+ send(request);
+ } catch (IllegalStateException e) {
+ // Stream was broken, request will be retried when stream is reopened.
}
}
- private void issueMultiChunkRequest(final long id, PendingRequest
pendingRequest) {
- checkNotNull(pendingRequest.computation);
- final ByteString serializedCommit = pendingRequest.request.toByteString();
+ private void issueMultiChunkRequest(long id, PendingRequest pendingRequest) {
+ if (!prepareForSend(id, pendingRequest)) {
+ pendingRequest.abort();
+ return;
+ }
+ checkNotNull(pendingRequest.computationId(), "Cannot commit WorkItem w/o a
computationId.");
+ ByteString serializedCommit = pendingRequest.serializedCommit();
synchronized (this) {
- pending.put(id, pendingRequest);
for (int i = 0;
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]