Class InProcessTransport.InProcessStream.InProcessServerStream

java.lang.Object
io.grpc.inprocess.InProcessTransport.InProcessStream.InProcessServerStream
All Implemented Interfaces:
ServerStream, Stream
Enclosing class:
InProcessTransport.InProcessStream

private class InProcessTransport.InProcessStream.InProcessServerStream extends Object implements ServerStream
  • Field Details

  • Constructor Details

  • Method Details

    • setListener

      private void setListener(ClientStreamListener listener)
    • setListener

      public void setListener(ServerStreamListener serverStreamListener)
      Description copied from interface: ServerStream
      Sets the server stream listener.
      Specified by:
      setListener in interface ServerStream
    • request

      public void request(int numMessages)
      Description copied from interface: Stream
      Requests up to the given number of messages from the call to be delivered via StreamListener.messagesAvailable(StreamListener.MessageProducer). No additional messages will be delivered. If the stream has a start() method, it must be called before requesting messages.
      Specified by:
      request in interface Stream
      Parameters:
      numMessages - the requested number of messages to be delivered to the listener.
    • clientRequested

      private boolean clientRequested(int numMessages)
      Client requested more messages.
      Returns:
      whether onReady should be called on the server
    • clientCancelled

      private void clientCancelled(Status status)
    • writeMessage

      public void writeMessage(InputStream message)
      Description copied from interface: Stream
      Writes a message payload to the remote end-point. The bytes from the stream are immediately read by the Transport. Where possible callers should use streams that are KnownLength to improve efficiency. This method will always return immediately and will not wait for the write to complete. If the stream has a start() method, it must be called before writing any messages.

      It is recommended that the caller consult Stream.isReady() before calling this method to avoid excessive buffering in the transport.

      This method takes ownership of the InputStream, and implementations are responsible for calling InputStream.close().

      Specified by:
      writeMessage in interface Stream
      Parameters:
      message - stream containing the serialized message to be sent
    • flush

      public void flush()
      Description copied from interface: Stream
      Flushes any internally buffered messages to the remote end-point.
      Specified by:
      flush in interface Stream
    • isReady

      public boolean isReady()
      Description copied from interface: Stream
      If true, indicates that the transport is capable of sending additional messages without requiring excessive buffering internally. Otherwise, StreamListener.onReady() will be called when it turns true.

      This 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:
      isReady in interface Stream
    • writeHeaders

      public void writeHeaders(Metadata headers, boolean flush)
      Description copied from interface: ServerStream
      Writes custom metadata as headers on the response stream sent to the client. This method may only be called once and cannot be called after calls to Stream.writeMessage(java.io.InputStream) or ServerStream.close(io.grpc.Status, io.grpc.Metadata).
      Specified by:
      writeHeaders in interface ServerStream
      Parameters:
      headers - to send to client.
    • close

      public void close(Status status, Metadata trailers)
      Description copied from interface: ServerStream
      Closes the stream for both reading and writing. A status code of Status.Code.OK implies normal termination of the stream. Any other value implies abnormal termination.

      Attempts to read from or write to the stream after closing should be ignored by implementations, and should not throw exceptions.

      Specified by:
      close in interface ServerStream
      Parameters:
      status - details of the closure
      trailers - an additional block of metadata to pass to the client on stream closure.
    • notifyClientClose

      private void notifyClientClose(Status status, Metadata trailers)
      clientStream.serverClosed() must be called before this method
    • cancel

      public void cancel(Status status)
      Description copied from interface: ServerStream
      Tears down the stream, typically in the event of a timeout. This method may be called multiple times and from any thread.
      Specified by:
      cancel in interface ServerStream
    • internalCancel

      private boolean internalCancel(Status clientStatus)
    • setMessageCompression

      public void setMessageCompression(boolean enable)
      Description copied from interface: Stream
      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.
      Specified by:
      setMessageCompression in interface Stream
    • optimizeForDirectExecutor

      public void optimizeForDirectExecutor()
      Description copied from interface: Stream
      Provides a hint that directExecutor is being used by the listener for callbacks to the application. No action is required. There is no requirement that this method actually matches the executor used.
      Specified by:
      optimizeForDirectExecutor in interface Stream
    • setCompressor

      public void setCompressor(Compressor compressor)
      Description copied from interface: Stream
      Sets the compressor on the framer.
      Specified by:
      setCompressor in interface Stream
      Parameters:
      compressor - the compressor to use
    • setDecompressor

      public void setDecompressor(Decompressor decompressor)
      Description copied from interface: ServerStream
      Sets the decompressor on the deframer. If the transport does not support compression, this may do nothing.
      Specified by:
      setDecompressor in interface ServerStream
      Parameters:
      decompressor - the decompressor to use.
    • getAttributes

      public Attributes getAttributes()
      Description copied from interface: ServerStream
      Attributes describing stream. This is inherited from the transport attributes, and used as the basis of ServerCall.getAttributes().
      Specified by:
      getAttributes in interface ServerStream
      Returns:
      Attributes container
    • getAuthority

      public String getAuthority()
      Description copied from interface: ServerStream
      Gets the authority this stream is addressed to.
      Specified by:
      getAuthority in interface ServerStream
      Returns:
      the authority string. null if not available.
    • statsTraceContext

      public StatsTraceContext statsTraceContext()
      Description copied from interface: ServerStream
      The context for recording stats and traces for this stream.
      Specified by:
      statsTraceContext in interface ServerStream
    • streamId

      public int streamId()
      Description copied from interface: ServerStream
      The HTTP/2 stream id, or -1 if not supported.
      Specified by:
      streamId in interface ServerStream
    • setOnReadyThreshold

      public void setOnReadyThreshold(int numBytes)
      Description copied from interface: ServerStream
      A hint to the stream that specifies how many bytes must be queued before Stream.isReady() will return false. A stream may ignore this property if unsupported. This may only be set during stream initialization before any messages are set.
      Specified by:
      setOnReadyThreshold in interface ServerStream
      Parameters:
      numBytes - The number of bytes that must be queued. Must be a positive integer.