io.grpc.ServerStreamTracer.Factory Java Examples

The following examples show how to use io.grpc.ServerStreamTracer.Factory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InProcessServerBuilderTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Test
public void scheduledExecutorService_default() {
  InProcessServerBuilder builder = InProcessServerBuilder.forName("foo");
  InProcessServer server = builder.buildTransportServer(new ArrayList<Factory>());

  ObjectPool<ScheduledExecutorService> scheduledExecutorServicePool =
      server.getScheduledExecutorServicePool();
  ObjectPool<ScheduledExecutorService> expectedPool =
      SharedResourcePool.forResource(TIMER_SERVICE);

  ScheduledExecutorService expected = expectedPool.getObject();
  ScheduledExecutorService actual = scheduledExecutorServicePool.getObject();
  assertSame(expected, actual);

  expectedPool.returnObject(expected);
  scheduledExecutorServicePool.returnObject(actual);
}
 
Example #2
Source File: InProcessServerBuilderTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Test
public void scheduledExecutorService_custom() {
  InProcessServerBuilder builder = InProcessServerBuilder.forName("foo");
  ScheduledExecutorService scheduledExecutorService =
      new FakeClock().getScheduledExecutorService();

  InProcessServerBuilder builder1 = builder.scheduledExecutorService(scheduledExecutorService);
  assertSame(builder, builder1);

  InProcessServer server = builder1.buildTransportServer(new ArrayList<Factory>());
  ObjectPool<ScheduledExecutorService> scheduledExecutorServicePool =
      server.getScheduledExecutorServicePool();

  assertSame(scheduledExecutorService, scheduledExecutorServicePool.getObject());

  scheduledExecutorServicePool.returnObject(scheduledExecutorService);
}
 
Example #3
Source File: InProcessServerBuilderTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Test
public void scheduledExecutorService_default() {
  InProcessServerBuilder builder = InProcessServerBuilder.forName("foo");
  InProcessServer server =
      Iterables.getOnlyElement(builder.buildTransportServers(new ArrayList<Factory>()));

  ObjectPool<ScheduledExecutorService> scheduledExecutorServicePool =
      server.getScheduledExecutorServicePool();
  ObjectPool<ScheduledExecutorService> expectedPool =
      SharedResourcePool.forResource(TIMER_SERVICE);

  ScheduledExecutorService expected = expectedPool.getObject();
  ScheduledExecutorService actual = scheduledExecutorServicePool.getObject();
  assertSame(expected, actual);

  expectedPool.returnObject(expected);
  scheduledExecutorServicePool.returnObject(actual);
}
 
Example #4
Source File: InProcessServerBuilderTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Test
public void scheduledExecutorService_custom() {
  InProcessServerBuilder builder = InProcessServerBuilder.forName("foo");
  ScheduledExecutorService scheduledExecutorService =
      new FakeClock().getScheduledExecutorService();

  InProcessServerBuilder builder1 = builder.scheduledExecutorService(scheduledExecutorService);
  assertSame(builder, builder1);

  InProcessServer server =
      Iterables.getOnlyElement(builder1.buildTransportServers(new ArrayList<Factory>()));
  ObjectPool<ScheduledExecutorService> scheduledExecutorServicePool =
      server.getScheduledExecutorServicePool();

  assertSame(scheduledExecutorService, scheduledExecutorServicePool.getObject());

  scheduledExecutorServicePool.returnObject(scheduledExecutorService);
}
 
Example #5
Source File: NettyServerBuilderTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void createMultipleServers() {
  builder.addListenAddress(new InetSocketAddress(8081));
  List<NettyServer> servers = builder.buildTransportServers(ImmutableList.<Factory>of());

  Truth.assertThat(servers).hasSize(2);
}
 
Example #6
Source File: AltsServerBuilder.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public AltsServerBuilder addStreamTracerFactory(Factory factory) {
  delegate.addStreamTracerFactory(factory);
  return this;
}
 
Example #7
Source File: DropwizardServerBuilder.java    From dropwizard-grpc with Apache License 2.0 4 votes vote down vote up
@Override
public DropwizardServerBuilder addStreamTracerFactory(final Factory factory) {
    origin.addStreamTracerFactory(factory);
    return this;
}
 
Example #8
Source File: AltsServerBuilder.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public AltsServerBuilder addStreamTracerFactory(Factory factory) {
  delegate.addStreamTracerFactory(factory);
  return this;
}