Search in sources :

Example 1 with NettyServerBuilder

use of io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder in project pravega by pravega.

the class ControllerImplTest method testKeepAliveWithServer.

@Test
public void testKeepAliveWithServer() throws Exception {
    // Verify that the same RPC with permissible keepalive time succeeds.
    int serverPort2 = TestUtils.getAvailableListenPort();
    NettyServerBuilder testServerBuilder = NettyServerBuilder.forPort(serverPort2).addService(testServerImpl).permitKeepAliveTime(KEEP_ALIVE_TEST_PERMIT_TIME_MILLIS, TimeUnit.MILLISECONDS);
    if (testSecure) {
        testServerBuilder = testServerBuilder.useTransportSecurity(new File(SecurityConfigDefaults.TLS_SERVER_CERT_PATH), new File(SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_PATH));
    }
    @Cleanup("shutdownNow") Server testServer = testServerBuilder.build().start();
    NettyChannelBuilder builder = NettyChannelBuilder.forAddress("localhost", serverPort2).keepAliveTime(KEEP_ALIVE_TEST_KEEP_ALIVE_MILLIS, TimeUnit.MILLISECONDS);
    if (testSecure) {
        builder = builder.sslContext(GrpcSslContexts.forClient().trustManager(new File(SecurityConfigDefaults.TLS_CA_CERT_PATH)).build());
    } else {
        builder = builder.usePlaintext();
    }
    @Cleanup final ControllerImpl controller1 = new ControllerImpl(builder, ControllerImplConfig.builder().clientConfig(ClientConfig.builder().trustStore(SecurityConfigDefaults.TLS_CA_CERT_PATH).controllerURI(URI.create((testSecure ? "tls://" : "tcp://") + "localhost:" + serverPort)).build()).retryAttempts(1).initialBackoffMillis(1).build(), this.executor);
    val createStreamStatus = controller1.createStream("scope1", "streamdelayed", StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
    assertTrue(createStreamStatus.get());
    testServer.shutdownNow();
}
Also used : lombok.val(lombok.val) NettyServerBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder) Server(io.grpc.Server) NettyChannelBuilder(io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder) File(java.io.File) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Aggregations

Server (io.grpc.Server)1 NettyChannelBuilder (io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder)1 NettyServerBuilder (io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder)1 File (java.io.File)1 Cleanup (lombok.Cleanup)1 lombok.val (lombok.val)1 Test (org.junit.Test)1