Package io.grpc.internal
Class ServerImpl.JumpToApplicationThreadServerStreamListener
- java.lang.Object
-
- io.grpc.internal.ServerImpl.JumpToApplicationThreadServerStreamListener
-
- All Implemented Interfaces:
ServerStreamListener
,StreamListener
- Enclosing class:
- ServerImpl
static final class ServerImpl.JumpToApplicationThreadServerStreamListener extends java.lang.Object implements ServerStreamListener
Dispatches callbacks onto an application-provided executor and correctly propagates exceptions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.grpc.internal.StreamListener
StreamListener.MessageProducer
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.Executor
callExecutor
private java.util.concurrent.Executor
cancelExecutor
private Context.CancellableContext
context
private ServerStreamListener
listener
private ServerStream
stream
private io.perfmark.Tag
tag
-
Constructor Summary
Constructors Constructor Description JumpToApplicationThreadServerStreamListener(java.util.concurrent.Executor executor, java.util.concurrent.Executor cancelExecutor, ServerStream stream, Context.CancellableContext context, io.perfmark.Tag tag)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closed(Status status)
Called when the stream is fully closed.private void
closedInternal(Status status)
private ServerStreamListener
getListener()
This call MUST be serialized on callExecutor to avoid races.void
halfClosed()
Called when the remote side of the transport gracefully closed, indicating the client had no more data to send.private void
internalClose(java.lang.Throwable t)
LikeServerCall.close(Status, Metadata)
, but thread-safe for internal use.void
messagesAvailable(StreamListener.MessageProducer producer)
Called upon receiving a message from the remote end-point.void
onReady()
This indicates that the transport is now capable of sending additional messages without requiring excessive buffering internally.(package private) void
setListener(ServerStreamListener listener)
-
-
-
Field Detail
-
callExecutor
private final java.util.concurrent.Executor callExecutor
-
cancelExecutor
private final java.util.concurrent.Executor cancelExecutor
-
context
private final Context.CancellableContext context
-
stream
private final ServerStream stream
-
tag
private final io.perfmark.Tag tag
-
listener
private ServerStreamListener listener
-
-
Constructor Detail
-
JumpToApplicationThreadServerStreamListener
public JumpToApplicationThreadServerStreamListener(java.util.concurrent.Executor executor, java.util.concurrent.Executor cancelExecutor, ServerStream stream, Context.CancellableContext context, io.perfmark.Tag tag)
-
-
Method Detail
-
getListener
private ServerStreamListener getListener()
This call MUST be serialized on callExecutor to avoid races.
-
setListener
void setListener(ServerStreamListener listener)
-
internalClose
private void internalClose(java.lang.Throwable t)
LikeServerCall.close(Status, Metadata)
, but thread-safe for internal use.
-
messagesAvailable
public void messagesAvailable(StreamListener.MessageProducer producer)
Description copied from interface:StreamListener
Called upon receiving a message from the remote end-point.Implementations must eventually drain the provided
producer
StreamListener.MessageProducer
completely by invokingStreamListener.MessageProducer.next()
to obtain deframed messages until the producer returns null.This method should return quickly, as the same thread may be used to process other streams.
- Specified by:
messagesAvailable
in interfaceStreamListener
- Parameters:
producer
- supplier of deframed messages.
-
halfClosed
public void halfClosed()
Description copied from interface:ServerStreamListener
Called when the remote side of the transport gracefully closed, indicating the client had no more data to send. No further messages will be received on the stream.This method should return quickly, as the same thread may be used to process other streams.
- Specified by:
halfClosed
in interfaceServerStreamListener
-
closed
public void closed(Status status)
Description copied from interface:ServerStreamListener
Called when the stream is fully closed. A status code ofStatus.Code.OK
implies normal termination of the stream. Any other value implies abnormal termination. Since clients cannot send status, the passed status is always library-generated and only is concerned with transport-level stream shutdown (the call itself may have had a failing status, but if the stream terminated cleanly with the status appearing to have been sent, then the passed status here would beOK
). This is guaranteed to always be the final call on a listener. No further callbacks will be issued.This method should return quickly, as the same thread may be used to process other streams.
- Specified by:
closed
in interfaceServerStreamListener
- Parameters:
status
- details about the remote closure
-
closedInternal
private void closedInternal(Status status)
-
onReady
public void onReady()
Description copied from interface:StreamListener
This indicates that the transport is now capable of sending additional messages without requiring excessive buffering internally. This event is just a suggestion and the application is free to ignore it, however doing so may result in excessive buffering within the transport.- Specified by:
onReady
in interfaceStreamListener
-
-