Tabnine Logo
GrpcCallContext.withChannel
Code IndexAdd Tabnine to your IDE (free)

How to use
withChannel
method
in
com.google.api.gax.grpc.GrpcCallContext

Best Java code snippets using com.google.api.gax.grpc.GrpcCallContext.withChannel (Showing top 7 results out of 315)

origin: com.google.api/gax-grpc

@Override
public GrpcCallContext withTransportChannel(TransportChannel inputChannel) {
 Preconditions.checkNotNull(inputChannel);
 if (!(inputChannel instanceof GrpcTransportChannel)) {
  throw new IllegalArgumentException(
    "Expected GrpcTransportChannel, got " + inputChannel.getClass().getName());
 }
 GrpcTransportChannel transportChannel = (GrpcTransportChannel) inputChannel;
 return withChannel(transportChannel.getChannel());
}
origin: googleapis/gax-java

@Test
public void testAffinity() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> clientCall0 = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> clientCall1 = Mockito.mock(ClientCall.class);
 ManagedChannel channel0 = Mockito.mock(ManagedChannel.class);
 ManagedChannel channel1 = Mockito.mock(ManagedChannel.class);
 Mockito.when(channel0.newCall(Mockito.eq(descriptor), Mockito.<CallOptions>any()))
   .thenReturn(clientCall0);
 Mockito.when(channel1.newCall(Mockito.eq(descriptor), Mockito.<CallOptions>any()))
   .thenReturn(clientCall1);
 Channel pool = new ChannelPool(Arrays.asList(channel0, channel1));
 GrpcCallContext context = GrpcCallContext.createDefault().withChannel(pool);
 ClientCall<Color, Money> gotCallA =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(0));
 ClientCall<Color, Money> gotCallB =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(0));
 ClientCall<Color, Money> gotCallC =
   GrpcClientCalls.newCall(descriptor, context.withChannelAffinity(1));
 assertThat(gotCallA).isSameAs(gotCallB);
 assertThat(gotCallA).isNotSameAs(gotCallC);
}
origin: googleapis/gax-java

@Override
public GrpcCallContext withTransportChannel(TransportChannel inputChannel) {
 Preconditions.checkNotNull(inputChannel);
 if (!(inputChannel instanceof GrpcTransportChannel)) {
  throw new IllegalArgumentException(
    "Expected GrpcTransportChannel, got " + inputChannel.getClass().getName());
 }
 GrpcTransportChannel transportChannel = (GrpcTransportChannel) inputChannel;
 return withChannel(transportChannel.getChannel());
}
origin: googleapis/gax-java

  GrpcCallContext.createDefault().withChannel(mockChannel).withExtraHeaders(extraHeaders);
GrpcClientCalls.newCall(descriptor, context).start(mockListener, emptyHeaders);
origin: googleapis/gax-java

@Test
public void testTimeoutToDeadlineConversion() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
 @SuppressWarnings("unchecked")
 Channel mockChannel = Mockito.mock(ManagedChannel.class);
 ArgumentCaptor<CallOptions> capturedCallOptions = ArgumentCaptor.forClass(CallOptions.class);
 Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), capturedCallOptions.capture()))
   .thenReturn(mockClientCall);
 Duration timeout = Duration.ofSeconds(10);
 Deadline minExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
 GrpcCallContext context =
   GrpcCallContext.createDefault().withChannel(mockChannel).withTimeout(timeout);
 GrpcClientCalls.newCall(descriptor, context).start(mockListener, new Metadata());
 Deadline maxExpectedDeadline = Deadline.after(timeout.getSeconds(), TimeUnit.SECONDS);
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtLeast(minExpectedDeadline);
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isAtMost(maxExpectedDeadline);
}
origin: googleapis/gax-java

@Test
public void testTimeoutAfterDeadline() {
 MethodDescriptor<Color, Money> descriptor = FakeServiceGrpc.METHOD_RECOGNIZE;
 @SuppressWarnings("unchecked")
 ClientCall<Color, Money> mockClientCall = Mockito.mock(ClientCall.class);
 @SuppressWarnings("unchecked")
 ClientCall.Listener<Money> mockListener = Mockito.mock(ClientCall.Listener.class);
 @SuppressWarnings("unchecked")
 Channel mockChannel = Mockito.mock(ManagedChannel.class);
 ArgumentCaptor<CallOptions> capturedCallOptions = ArgumentCaptor.forClass(CallOptions.class);
 Mockito.when(mockChannel.newCall(Mockito.eq(descriptor), capturedCallOptions.capture()))
   .thenReturn(mockClientCall);
 // Configure a timeout that occurs after the grpc deadline
 Deadline priorDeadline = Deadline.after(5, TimeUnit.SECONDS);
 Duration timeout = Duration.ofSeconds(10);
 GrpcCallContext context =
   GrpcCallContext.createDefault()
     .withChannel(mockChannel)
     .withCallOptions(CallOptions.DEFAULT.withDeadline(priorDeadline))
     .withTimeout(timeout);
 GrpcClientCalls.newCall(descriptor, context).start(mockListener, new Metadata());
 // Verify that the timeout is ignored
 Truth.assertThat(capturedCallOptions.getValue().getDeadline()).isEqualTo(priorDeadline);
}
origin: googleapis/gax-java

.withChannel(mockChannel)
.withCallOptions(CallOptions.DEFAULT.withDeadline(subsequentDeadline))
.withTimeout(timeout);
com.google.api.gax.grpcGrpcCallContextwithChannel

Javadoc

Returns a new instance with the channel set to the given channel.

Popular methods of GrpcCallContext

  • createDefault
    Returns an empty instance with a null channel and default CallOptions.
  • getCallOptions
    The CallOptions set on this context.
  • getChannel
    The Channel set on this context.
  • getExtraHeaders
    The extra header for this context.
  • getTimeout
  • nullToSelf
    Returns inputContext cast to GrpcCallContext, or an empty GrpcCallContext if inputContext is null.
  • of
    Returns an instance with the given channel and CallOptions.
  • withCallOptions
    Returns a new instance with the call options set to the given call options.
  • withChannelAffinity
  • withRequestParamsDynamicHeaderOption
  • <init>
  • getChannelAffinity
    The channel affinity for this context.
  • <init>,
  • getChannelAffinity,
  • getMetadata,
  • withExtraHeaders,
  • withStreamIdleTimeout,
  • withStreamWaitTimeout,
  • getStreamIdleTimeout,
  • getStreamWaitTimeout,
  • getTracer

Popular in Java

  • Running tasks concurrently on multiple threads
  • setContentView (Activity)
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • String (java.lang)
  • Permission (java.security)
    Legacy security code; do not use.
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now