ss77892 commented on code in PR #11874:
URL: https://github.com/apache/ozone/pull/11874#discussion_r4514562395
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -815,63 +771,337 @@ protected boolean shouldBlockAndWaitAsyncReply(
return !HddsUtils.isReadOnly(request);
}
+ /**
+ * Sends the request to the given datanode for a caller that waits for the
+ * reply with {@link CompletableFuture#get()}: the response is delivered on
+ * the waiting thread, see {@link CallerRunsReplyFuture}.
+ */
@VisibleForTesting
public XceiverClientReply sendCommandAsync(
ContainerCommandRequestProto request, DatanodeDetails dn)
throws IOException, InterruptedException {
+ return sendCommandAsync(request, dn, new CallerRunsReplyFuture());
+ }
+
+ /**
+ * @param replyFuture completed with the reply; if it is an {@link Executor}
+ * the call's callbacks run on it, otherwise on gRPC's default
executor
+ */
+ private XceiverClientReply sendCommandAsync(
+ ContainerCommandRequestProto request, DatanodeDetails dn,
+ CompletableFuture<ContainerCommandResponseProto> replyFuture)
+ throws IOException, InterruptedException {
checkOpen(dn);
DatanodeID dnId = dn.getID();
if (LOG.isDebugEnabled()) {
LOG.debug("Send command {} to datanode {}",
request.getCmdType(), dn);
}
- final CompletableFuture<ContainerCommandResponseProto> replyFuture =
- new CompletableFuture<>();
semaphore.acquire();
long requestTime = Time.monotonicNow();
metrics.incrPendingContainerOpsMetrics(request.getCmdType());
+ final ChannelInfo channelInfo = dnChannelInfoMap.get(dnId);
+ final ReplyObserver reply = new ReplyObserver(request, dn, replyFuture,
requestTime);
+ if (replyFuture instanceof CallerRunsReplyFuture &&
!Span.current().getSpanContext().isValid()) {
+ // No trace context to send, so a pooled stream carries the same headers
as a new one would.
+ channelInfo.leaseStream().send(request, reply, (CallerRunsReplyFuture)
replyFuture,
+ System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeout));
Review Comment:
The sum does wrap negative, but the deadline is only ever compared as
deadline - System.nanoTime(), which wraps back. With Long.MAX_VALUE ms simple
test produces deadline=-9221477772253477306 and remaining=9223372036854756476,
so the request doesn't fail immediately.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]