Java Code Examples for io.grpc.internal.GrpcUtil#authorityFromHostAndPort()
The following examples show how to use
io.grpc.internal.GrpcUtil#authorityFromHostAndPort() .
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: NettyClientTransportTest.java From grpc-java with Apache License 2.0 | 6 votes |
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException { server = new NettyServer( TestUtils.testServerAddress(new InetSocketAddress(0)), new ReflectiveChannelFactory<>(NioServerSocketChannel.class), new HashMap<ChannelOption<?>, Object>(), new HashMap<ChannelOption<?>, Object>(), new FixedObjectPool<>(group), new FixedObjectPool<>(group), false, negotiator, Collections.<ServerStreamTracer.Factory>emptyList(), TransportTracer.getDefaultFactory(), maxStreamsPerConnection, false, DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize, DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS, MAX_CONNECTION_IDLE_NANOS_DISABLED, MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0, channelz); server.start(serverListener); address = TestUtils.testServerAddress((InetSocketAddress) server.getListenSocketAddress()); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); }
Example 2
Source File: NettyClientTransportTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException { server = new NettyServer( TestUtils.testServerAddress(0), NioServerSocketChannel.class, new HashMap<ChannelOption<?>, Object>(), group, group, negotiator, Collections.<ServerStreamTracer.Factory>emptyList(), TransportTracer.getDefaultFactory(), maxStreamsPerConnection, DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize, DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS, MAX_CONNECTION_IDLE_NANOS_DISABLED, MAX_CONNECTION_AGE_NANOS_DISABLED, MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE, true, 0, channelz); server.start(serverListener); address = TestUtils.testServerAddress(server.getPort()); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); }
Example 3
Source File: NettyClientTransportTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void getEagAttributes_negotiatorHandler() throws Exception { address = TestUtils.testServerAddress(new InetSocketAddress(12345)); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); NoopProtocolNegotiator npn = new NoopProtocolNegotiator(); eagAttributes = Attributes.newBuilder() .set(Attributes.Key.create("trash"), "value") .build(); NettyClientTransport transport = newTransport(npn); callMeMaybe(transport.start(clientTransportListener)); // EAG Attributes are available before the negotiation is complete assertSame(eagAttributes, npn.grpcHandler.getEagAttributes()); }
Example 4
Source File: NettyChannelBuilder.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@CheckReturnValue private static String getAuthorityFromAddress(SocketAddress address) { if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; return GrpcUtil.authorityFromHostAndPort(inetAddress.getHostString(), inetAddress.getPort()); } else { return address.toString(); } }
Example 5
Source File: NettyClientTransportTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void testToString() throws Exception { address = TestUtils.testServerAddress(12345); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); String s = newTransport(newNegotiator()).toString(); transports.clear(); assertTrue("Unexpected: " + s, s.contains("NettyClientTransport")); assertTrue("Unexpected: " + s, s.contains(address.toString())); }
Example 6
Source File: NettyClientTransportTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void getAttributes_negotiatorHandler() throws Exception { address = TestUtils.testServerAddress(12345); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); NettyClientTransport transport = newTransport(new NoopProtocolNegotiator()); callMeMaybe(transport.start(clientTransportListener)); assertEquals(Attributes.EMPTY, transport.getAttributes()); }
Example 7
Source File: NettyClientTransportTest.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
@Test public void getEagAttributes_negotiatorHandler() throws Exception { address = TestUtils.testServerAddress(12345); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); NoopProtocolNegotiator npn = new NoopProtocolNegotiator(); eagAttributes = Attributes.newBuilder() .set(Attributes.Key.create("trash"), "value") .build(); NettyClientTransport transport = newTransport(npn); callMeMaybe(transport.start(clientTransportListener)); // EAG Attributes are available before the negotiation is complete assertSame(eagAttributes, npn.grpcHandler.getEagAttributes()); }
Example 8
Source File: NettyClientTransportTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void getAttributes_negotiatorHandler() throws Exception { address = TestUtils.testServerAddress(new InetSocketAddress(12345)); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); NettyClientTransport transport = newTransport(new NoopProtocolNegotiator()); callMeMaybe(transport.start(clientTransportListener)); assertNotNull(transport.getAttributes()); }
Example 9
Source File: NettyClientTransportTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void testToString() throws Exception { address = TestUtils.testServerAddress(new InetSocketAddress(12345)); authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort()); String s = newTransport(newNegotiator()).toString(); transports.clear(); assertTrue("Unexpected: " + s, s.contains("NettyClientTransport")); assertTrue("Unexpected: " + s, s.contains(address.toString())); }
Example 10
Source File: NettyChannelBuilder.java From grpc-java with Apache License 2.0 | 5 votes |
@CheckReturnValue private static String getAuthorityFromAddress(SocketAddress address) { if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; return GrpcUtil.authorityFromHostAndPort(inetAddress.getHostString(), inetAddress.getPort()); } else { return address.toString(); } }
Example 11
Source File: OkHttpChannelBuilder.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
protected OkHttpChannelBuilder(String host, int port) { this(GrpcUtil.authorityFromHostAndPort(host, port)); }
Example 12
Source File: NettyChannelBuilder.java From grpc-java with Apache License 2.0 | 4 votes |
@CheckReturnValue NettyChannelBuilder(String host, int port) { this(GrpcUtil.authorityFromHostAndPort(host, port)); }
Example 13
Source File: OkHttpChannelBuilder.java From grpc-java with Apache License 2.0 | 4 votes |
protected OkHttpChannelBuilder(String host, int port) { this(GrpcUtil.authorityFromHostAndPort(host, port)); }
Example 14
Source File: CronetChannelBuilder.java From grpc-java with Apache License 2.0 | 4 votes |
private CronetChannelBuilder(String host, int port, CronetEngine cronetEngine) { super( InetSocketAddress.createUnresolved(host, port), GrpcUtil.authorityFromHostAndPort(host, port)); this.cronetEngine = Preconditions.checkNotNull(cronetEngine, "cronetEngine"); }
Example 15
Source File: NettyChannelBuilder.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
@CheckReturnValue NettyChannelBuilder(String host, int port) { this(GrpcUtil.authorityFromHostAndPort(host, port)); }
Example 16
Source File: CronetChannelBuilder.java From grpc-nebula-java with Apache License 2.0 | 4 votes |
private CronetChannelBuilder(String host, int port, CronetEngine cronetEngine) { super( InetSocketAddress.createUnresolved(host, port), GrpcUtil.authorityFromHostAndPort(host, port)); this.cronetEngine = Preconditions.checkNotNull(cronetEngine, "cronetEngine"); }
Example 17
Source File: EtcdClient.java From etcd-java with Apache License 2.0 | 2 votes |
/** * * @param host * @param port * @return */ public static Builder forEndpoint(String host, int port) { String target = GrpcUtil.authorityFromHostAndPort(host, port); return new Builder(Collections.singletonList(target)); }