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 Object
implements ServerStreamListener
Dispatches callbacks onto an application-provided executor and correctly propagates
exceptions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface StreamListener
StreamListener.MessageProducer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Executorprivate final Executorprivate final Context.CancellableContextprivate ServerStreamListenerprivate final ServerStreamprivate final io.perfmark.Tag -
Constructor Summary
ConstructorsConstructorDescriptionJumpToApplicationThreadServerStreamListener(Executor executor, Executor cancelExecutor, ServerStream stream, Context.CancellableContext context, io.perfmark.Tag tag) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled when the stream is fully closed.private voidclosedInternal(Status status) private ServerStreamListenerThis call MUST be serialized on callExecutor to avoid races.voidCalled when the remote side of the transport gracefully closed, indicating the client had no more data to send.private voidLikeServerCall.close(Status, Metadata), but thread-safe for internal use.voidCalled upon receiving a message from the remote end-point.voidonReady()This indicates that the transport is now capable of sending additional messages without requiring excessive buffering internally.(package private) voidsetListener(ServerStreamListener listener)
-
Field Details
-
callExecutor
-
cancelExecutor
-
context
-
stream
-
tag
private final io.perfmark.Tag tag -
listener
-
-
Constructor Details
-
JumpToApplicationThreadServerStreamListener
public JumpToApplicationThreadServerStreamListener(Executor executor, Executor cancelExecutor, ServerStream stream, Context.CancellableContext context, io.perfmark.Tag tag)
-
-
Method Details
-
getListener
This call MUST be serialized on callExecutor to avoid races. -
setListener
-
internalClose
LikeServerCall.close(Status, Metadata), but thread-safe for internal use. -
messagesAvailable
Description copied from interface:StreamListenerCalled upon receiving a message from the remote end-point.Implementations must eventually drain the provided
producerStreamListener.MessageProducercompletely 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:
messagesAvailablein interfaceStreamListener- Parameters:
producer- supplier of deframed messages.
-
halfClosed
public void halfClosed()Description copied from interface:ServerStreamListenerCalled 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:
halfClosedin interfaceServerStreamListener
-
closed
Description copied from interface:ServerStreamListenerCalled when the stream is fully closed. A status code ofStatus.Code.OKimplies 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:
closedin interfaceServerStreamListener- Parameters:
status- details about the remote closure
-
closedInternal
-
onReady
public void onReady()Description copied from interface:StreamListenerThis 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:
onReadyin interfaceStreamListener
-