Class ClientCallImpl<ReqT,RespT>
- java.lang.Object
-
- io.grpc.ClientCall<ReqT,RespT>
-
- io.grpc.internal.ClientCallImpl<ReqT,RespT>
-
final class ClientCallImpl<ReqT,RespT> extends ClientCall<ReqT,RespT>
Implementation ofClientCall
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ClientCallImpl.CancellationHandler
private class
ClientCallImpl.ClientStreamListenerImpl
(package private) static interface
ClientCallImpl.ClientStreamProvider
Provider ofClientStream
s.-
Nested classes/interfaces inherited from class io.grpc.ClientCall
ClientCall.Listener<T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.Executor
callExecutor
private boolean
callExecutorIsDirect
private CallOptions
callOptions
private boolean
cancelCalled
private ClientCallImpl.CancellationHandler
cancellationHandler
private CallTracer
channelCallsTracer
private ClientCallImpl.ClientStreamProvider
clientStreamProvider
private CompressorRegistry
compressorRegistry
private Context
context
private java.util.concurrent.ScheduledExecutorService
deadlineCancellationExecutor
private DecompressorRegistry
decompressorRegistry
private static byte[]
FULL_STREAM_DECOMPRESSION_ENCODINGS
private boolean
fullStreamDecompression
private boolean
halfCloseCalled
private static java.util.logging.Logger
log
private MethodDescriptor<ReqT,RespT>
method
private static double
NANO_TO_SECS
private ClientStream
stream
private io.perfmark.Tag
tag
private boolean
unaryRequest
-
Constructor Summary
Constructors Constructor Description ClientCallImpl(MethodDescriptor<ReqT,RespT> method, java.util.concurrent.Executor executor, CallOptions callOptions, ClientCallImpl.ClientStreamProvider clientStreamProvider, java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor, CallTracer channelCallsTracer, InternalConfigSelector configSelector)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
applyMethodConfig()
void
cancel(java.lang.String message, java.lang.Throwable cause)
Prevent any further processing for thisClientCall
.private void
cancelInternal(java.lang.String message, java.lang.Throwable cause)
private void
closeObserver(ClientCall.Listener<RespT> observer, Status status, Metadata trailers)
private Deadline
effectiveDeadline()
Attributes
getAttributes()
Returns additional properties of the call.void
halfClose()
Close the call for request message sending.private void
halfCloseInternal()
boolean
isReady()
Iftrue
, indicates that the call is capable of sending additional messages without requiring excessive buffering internally.private static Deadline
min(Deadline deadline0, Deadline deadline1)
(package private) static void
prepareHeaders(Metadata headers, DecompressorRegistry decompressorRegistry, Compressor compressor, boolean fullStreamDecompression)
void
request(int numMessages)
Requests up to the given number of messages from the call to be delivered toClientCall.Listener.onMessage(Object)
.void
sendMessage(ReqT message)
Send a request message to the server.private void
sendMessageInternal(ReqT message)
(package private) ClientCallImpl<ReqT,RespT>
setCompressorRegistry(CompressorRegistry compressorRegistry)
(package private) ClientCallImpl<ReqT,RespT>
setDecompressorRegistry(DecompressorRegistry decompressorRegistry)
(package private) ClientCallImpl<ReqT,RespT>
setFullStreamDecompression(boolean fullStreamDecompression)
void
setMessageCompression(boolean enabled)
Enables per-message compression, if an encoding type has been negotiated.void
start(ClientCall.Listener<RespT> observer, Metadata headers)
Start a call, usingresponseListener
for processing response messages.private void
startInternal(ClientCall.Listener<RespT> observer, Metadata headers)
java.lang.String
toString()
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
FULL_STREAM_DECOMPRESSION_ENCODINGS
private static final byte[] FULL_STREAM_DECOMPRESSION_ENCODINGS
-
NANO_TO_SECS
private static final double NANO_TO_SECS
-
method
private final MethodDescriptor<ReqT,RespT> method
-
tag
private final io.perfmark.Tag tag
-
callExecutor
private final java.util.concurrent.Executor callExecutor
-
callExecutorIsDirect
private final boolean callExecutorIsDirect
-
channelCallsTracer
private final CallTracer channelCallsTracer
-
context
private final Context context
-
cancellationHandler
private ClientCallImpl.CancellationHandler cancellationHandler
-
unaryRequest
private final boolean unaryRequest
-
callOptions
private CallOptions callOptions
-
stream
private ClientStream stream
-
cancelCalled
private boolean cancelCalled
-
halfCloseCalled
private boolean halfCloseCalled
-
clientStreamProvider
private final ClientCallImpl.ClientStreamProvider clientStreamProvider
-
deadlineCancellationExecutor
private final java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor
-
fullStreamDecompression
private boolean fullStreamDecompression
-
decompressorRegistry
private DecompressorRegistry decompressorRegistry
-
compressorRegistry
private CompressorRegistry compressorRegistry
-
-
Constructor Detail
-
ClientCallImpl
ClientCallImpl(MethodDescriptor<ReqT,RespT> method, java.util.concurrent.Executor executor, CallOptions callOptions, ClientCallImpl.ClientStreamProvider clientStreamProvider, java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor, CallTracer channelCallsTracer, @Nullable InternalConfigSelector configSelector)
-
-
Method Detail
-
setFullStreamDecompression
ClientCallImpl<ReqT,RespT> setFullStreamDecompression(boolean fullStreamDecompression)
-
setDecompressorRegistry
ClientCallImpl<ReqT,RespT> setDecompressorRegistry(DecompressorRegistry decompressorRegistry)
-
setCompressorRegistry
ClientCallImpl<ReqT,RespT> setCompressorRegistry(CompressorRegistry compressorRegistry)
-
prepareHeaders
static void prepareHeaders(Metadata headers, DecompressorRegistry decompressorRegistry, Compressor compressor, boolean fullStreamDecompression)
-
start
public void start(ClientCall.Listener<RespT> observer, Metadata headers)
Description copied from class:ClientCall
Start a call, usingresponseListener
for processing response messages.It must be called prior to any other method on this class, except for
ClientCall.cancel(java.lang.String, java.lang.Throwable)
which may be called at any time.Since
Metadata
is not thread-safe, the caller must not access (read or write)headers
after this point.- Specified by:
start
in classClientCall<ReqT,RespT>
- Parameters:
observer
- receives response messagesheaders
- which can contain extra call metadata, e.g. authentication credentials.
-
startInternal
private void startInternal(ClientCall.Listener<RespT> observer, Metadata headers)
-
applyMethodConfig
private void applyMethodConfig()
-
effectiveDeadline
@Nullable private Deadline effectiveDeadline()
-
min
@Nullable private static Deadline min(@Nullable Deadline deadline0, @Nullable Deadline deadline1)
-
request
public void request(int numMessages)
Description copied from class:ClientCall
Requests up to the given number of messages from the call to be delivered toClientCall.Listener.onMessage(Object)
. No additional messages will be delivered.Message delivery is guaranteed to be sequential in the order received. In addition, the listener methods will not be accessed concurrently. While it is not guaranteed that the same thread will always be used, it is guaranteed that only a single thread will access the listener at a time.
If it is desired to bypass inbound flow control, a very large number of messages can be specified (e.g.
Integer.MAX_VALUE
).If called multiple times, the number of messages able to delivered will be the sum of the calls.
This method is safe to call from multiple threads without external synchronization.
- Specified by:
request
in classClientCall<ReqT,RespT>
- Parameters:
numMessages
- the requested number of messages to be delivered to the listener. Must be non-negative.
-
cancel
public void cancel(@Nullable java.lang.String message, @Nullable java.lang.Throwable cause)
Description copied from class:ClientCall
Prevent any further processing for thisClientCall
. No further messages may be sent or will be received. The server is informed of cancellations, but may not stop processing the call. Cancellation is permitted even if previouslyClientCall.halfClose()
d. Cancelling an alreadycancel()
edClientCall
has no effect.No other methods on this class can be called after this method has been called.
It is recommended that at least one of the arguments to be non-
null
, to provide useful debug information. Both argument being null may log warnings and result in suboptimal performance. Also note that the provided information will not be sent to the server.- Specified by:
cancel
in classClientCall<ReqT,RespT>
- Parameters:
message
- if notnull
, will appear as the description of the CANCELLED statuscause
- if notnull
, will appear as the cause of the CANCELLED status
-
cancelInternal
private void cancelInternal(@Nullable java.lang.String message, @Nullable java.lang.Throwable cause)
-
halfClose
public void halfClose()
Description copied from class:ClientCall
Close the call for request message sending. Incoming response messages are unaffected. This should be called when no more messages will be sent from the client.- Specified by:
halfClose
in classClientCall<ReqT,RespT>
-
halfCloseInternal
private void halfCloseInternal()
-
sendMessage
public void sendMessage(ReqT message)
Description copied from class:ClientCall
Send a request message to the server. May be called zero or more times depending on how many messages the server is willing to accept for the operation.- Specified by:
sendMessage
in classClientCall<ReqT,RespT>
- Parameters:
message
- message to be sent to the server.
-
sendMessageInternal
private void sendMessageInternal(ReqT message)
-
setMessageCompression
public void setMessageCompression(boolean enabled)
Description copied from class:ClientCall
Enables per-message compression, if an encoding type has been negotiated. If no message encoding has been negotiated, this is a no-op. By default per-message compression is enabled, but may not have any effect if compression is not enabled on the call.- Overrides:
setMessageCompression
in classClientCall<ReqT,RespT>
-
isReady
public boolean isReady()
Description copied from class:ClientCall
Iftrue
, indicates that the call is 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 call.If
false
,ClientCall.Listener.onReady()
will be called afterisReady()
transitions totrue
.If the type of the call is either
MethodDescriptor.MethodType.UNARY
orMethodDescriptor.MethodType.SERVER_STREAMING
, this method may persistently return false. Calls that send exactly one message should not check this method.This abstract class's implementation always returns
true
. Implementations generally override the method.- Overrides:
isReady
in classClientCall<ReqT,RespT>
-
getAttributes
public Attributes getAttributes()
Description copied from class:ClientCall
Returns additional properties of the call. May only be called afterClientCall.Listener.onHeaders(io.grpc.Metadata)
orClientCall.Listener.onClose(io.grpc.Status, io.grpc.Metadata)
. If called prematurely, the implementation may throwIllegalStateException
or return arbitraryAttributes
.- Overrides:
getAttributes
in classClientCall<ReqT,RespT>
- Returns:
- non-
null
attributes
-
closeObserver
private void closeObserver(ClientCall.Listener<RespT> observer, Status status, Metadata trailers)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-