本文整理汇总了Java中io.grpc.internal.GrpcUtil.authorityFromHostAndPort方法的典型用法代码示例。如果您正苦于以下问题:Java GrpcUtil.authorityFromHostAndPort方法的具体用法?Java GrpcUtil.authorityFromHostAndPort怎么用?Java GrpcUtil.authorityFromHostAndPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.internal.GrpcUtil
的用法示例。
在下文中一共展示了GrpcUtil.authorityFromHostAndPort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributes_negotiatorHandler
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
@Test
public void getAttributes_negotiatorHandler() throws Exception {
address = TestUtils.testServerAddress(12345);
authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
NettyClientTransport transport = newTransport(
new ProtocolNegotiator() {
@Override
public Handler newHandler(GrpcHttp2ConnectionHandler handler) {
return null;
}
});
assertEquals(Attributes.EMPTY, transport.getAttributes());
transports.clear();
}
示例2: startServer
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
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);
server.start(serverListener);
address = TestUtils.testServerAddress(server.getPort());
authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
}
示例3: getAuthorityFromAddress
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
@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();
}
}
示例4: testToString
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
@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()));
}
示例5: CronetChannelBuilder
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
private CronetChannelBuilder(String host, int port, StreamBuilderFactory streamFactory) {
super(
InetSocketAddress.createUnresolved(host, port),
GrpcUtil.authorityFromHostAndPort(host, port));
this.streamFactory = Preconditions.checkNotNull(streamFactory, "streamFactory");
}
示例6: OkHttpChannelBuilder
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
protected OkHttpChannelBuilder(String host, int port) {
this(GrpcUtil.authorityFromHostAndPort(host, port));
}
示例7: NettyChannelBuilder
import io.grpc.internal.GrpcUtil; //导入方法依赖的package包/类
@CheckReturnValue
NettyChannelBuilder(String host, int port) {
this(GrpcUtil.authorityFromHostAndPort(host, port));
}