devabhishekpal commented on code in PR #1363:
URL: https://github.com/apache/ratis/pull/1363#discussion_r2916235511
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java:
##########
@@ -366,16 +382,73 @@ void onNext(AppendEntriesRequestProto proto)
while (!stream.isReady() && running) {
sleep(waitForReady, isHeartBeat);
}
- stream.onNext(proto);
+ try {
+ stream.onNext(proto);
+ } catch (Exception e) {
+ InterruptedIOException ioe =
+ new InterruptedIOException("Failed to send request via stream");
+ ioe.initCause(e);
+ throw ioe;
+ }
}
void stop() {
running = false;
}
void onCompleted() {
- appendLog.onCompleted();
- Optional.ofNullable(heartbeat).ifPresent(StreamObserver::onCompleted);
+ if (completed.compareAndSet(false, true)) {
+ completeStreamGracefully(appendLog, "appendLog");
+ Optional.ofNullable(heartbeat)
+ .ifPresent(s -> completeStreamGracefully(s, "heartbeat"));
+ }
+ final long delayMs = Math.max(1L,
completeGracePeriod.toLong(TimeUnit.MILLISECONDS));
+ closer.schedule(this::cancelIfStillNeeded, delayMs,
TimeUnit.MILLISECONDS);
Review Comment:
But if it is completed already aren't subsequent cancel calls queuing tasks
which are no longer required?
--
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]