@Test public void updateHeaders() { Metadata originalHeaders = new Metadata(); Metadata headers = retriableStream.updateHeaders(originalHeaders, 0); assertNotSame(originalHeaders, headers); assertNull(headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS)); headers = retriableStream.updateHeaders(originalHeaders, 345); assertEquals("345", headers.get(GRPC_PREVIOUS_RPC_ATTEMPTS)); assertNull(originalHeaders.get(GRPC_PREVIOUS_RPC_ATTEMPTS)); }
@VisibleForTesting final Metadata updateHeaders( Metadata originalHeaders, int previousAttempts) { Metadata newHeaders = new Metadata(); newHeaders.merge(originalHeaders); if (previousAttempts > 0) { newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttempts)); } return newHeaders; }
RetriableStream implements ClientStream { @VisibleForTesting final Metadata updateHeaders( Metadata originalHeaders, int previousAttempts) { Metadata newHeaders = new Metadata(); newHeaders.merge(originalHeaders); if (previousAttempts > 0) { newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttempts)); } return newHeaders; } }
RetriableStream implements ClientStream { @VisibleForTesting final Metadata updateHeaders( Metadata originalHeaders, int previousAttempts) { Metadata newHeaders = new Metadata(); newHeaders.merge(originalHeaders); if (previousAttempts > 0) { newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttempts)); } return newHeaders; } RetriableStream(
      MethodDescriptor<ReqT, ?> method, Metadata headers,
      ChannelBufferMeter channelBufferUsed, long perRpcBufferLimit, long channelBufferLimit,
      Executor callExecutor, ScheduledExecutorService scheduledExecutorService,
      RetryPolicy.Provider retryPolicyProvider, HedgingPolicy.Provider hedgingPolicyProvider,
      @Nullable Throttle throttle); }
RetriableStream implements ClientStream { @VisibleForTesting final Metadata updateHeaders( Metadata originalHeaders, int previousAttempts) { Metadata newHeaders = new Metadata(); newHeaders.merge(originalHeaders); if (previousAttempts > 0) { newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttempts)); } return newHeaders; } RetriableStream(
      MethodDescriptor<ReqT, ?> method, Metadata headers,
      ChannelBufferMeter channelBufferUsed, long perRpcBufferLimit, long channelBufferLimit,
      Executor callExecutor, ScheduledExecutorService scheduledExecutorService,
      RetryPolicy.Provider retryPolicyProvider, HedgingPolicy.Provider hedgingPolicyProvider,
      @Nullable Throttle throttle); @Override final void start(ClientStreamListener listener); @Override final void cancel(Status reason); @Override final void writeMessage(InputStream message); @Override final void request(final int numMessages); @Override final void flush(); @Override final boolean isReady(); @Override final void setCompressor(final Compressor compressor); @Override final void setFullStreamDecompression(final boolean fullStreamDecompression); @Override final void setMessageCompression(final boolean enable); @Override final void halfClose(); @Override final void setAuthority(final String authority); @Override final void setDecompressorRegistry(final DecompressorRegistry decompressorRegistry); @Override final void setMaxInboundMessageSize(final int maxSize); @Override final void setMaxOutboundMessageSize(final int maxSize); @Override final void setDeadline(final Deadline deadline); @Override final Attributes getAttributes(); }
RetriableStream implements ClientStream { @VisibleForTesting final Metadata updateHeaders( Metadata originalHeaders, int previousAttempts) { Metadata newHeaders = new Metadata(); newHeaders.merge(originalHeaders); if (previousAttempts > 0) { newHeaders.put(GRPC_PREVIOUS_RPC_ATTEMPTS, String.valueOf(previousAttempts)); } return newHeaders; } RetriableStream(
      MethodDescriptor<ReqT, ?> method, Metadata headers,
      ChannelBufferMeter channelBufferUsed, long perRpcBufferLimit, long channelBufferLimit,
      Executor callExecutor, ScheduledExecutorService scheduledExecutorService,
      RetryPolicy.Provider retryPolicyProvider, HedgingPolicy.Provider hedgingPolicyProvider,
      @Nullable Throttle throttle); @Override final void start(ClientStreamListener listener); @Override final void cancel(Status reason); @Override final void writeMessage(InputStream message); @Override final void request(final int numMessages); @Override final void flush(); @Override final boolean isReady(); @Override final void setCompressor(final Compressor compressor); @Override final void setFullStreamDecompression(final boolean fullStreamDecompression); @Override final void setMessageCompression(final boolean enable); @Override final void halfClose(); @Override final void setAuthority(final String authority); @Override final void setDecompressorRegistry(final DecompressorRegistry decompressorRegistry); @Override final void setMaxInboundMessageSize(final int maxSize); @Override final void setMaxOutboundMessageSize(final int maxSize); @Override final void setDeadline(final Deadline deadline); @Override final Attributes getAttributes();  }