ss77892 commented on code in PR #11874:
URL: https://github.com/apache/ozone/pull/11874#discussion_r4744650213
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/XceiverClientGrpc.java:
##########
@@ -981,5 +1321,101 @@ public boolean isChannelInactive() {
|| channel.isTerminated()
|| channel.isShutdown();
}
+
+ /** Takes an idle pooled stream, or opens a new one. */
+ PooledStream leaseStream() {
+ for (PooledStream stream = idleStreams.poll(); stream != null; stream =
idleStreams.poll()) {
+ if (!stream.isClosed()) {
+ return stream;
+ }
+ }
+ if (watchingState.compareAndSet(false, true)) {
+ onStateChange();
+ }
+ final PooledStream stream = new PooledStream(this);
+ stub.withExecutor(stream).send(stream);
+ return stream;
+ }
+
+ int getIdleStreamCount() {
+ int count = 0;
+ for (PooledStream stream : idleStreams) {
+ if (!stream.isClosed()) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ void releaseStream(PooledStream stream) {
+ if (stream.isClosed()) {
+ return;
+ }
+ stream.setIdleSince(System.nanoTime());
+ idleStreams.push(stream);
+ if (channel.getState(false) != ConnectivityState.READY) {
Review Comment:
Added streamOfARequestInFlightDoesNotHoldUpServerShutdown: the datanode
shuts down while serving a request, and the stream released after GOAWAY must
not keep the server alive. It fails without the check. trimIdleStreams doesn't
need it: it only takes streams out of the pool, and onStateChange closes every
idle stream when the channel leaves READY.
--
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]