本文整理汇总了Java中org.apache.curator.x.discovery.ServiceInstance.getAddress方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstance.getAddress方法的具体用法?Java ServiceInstance.getAddress怎么用?Java ServiceInstance.getAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.curator.x.discovery.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.getAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNativeTransport
import org.apache.curator.x.discovery.ServiceInstance; //导入方法依赖的package包/类
/**
* 根据rc的设置来确定创建什么类型的transport;
*
* @param instance
* @return
*/
protected TTransport createNativeTransport(
ServiceInstance<RpcPayload> instance) {
TSocket socket = new TSocket(instance.getAddress(), instance.getPort());
socket.setTimeout(socketTimeout);
RpcPayload server = instance.getPayload();
if ((server == null) || (server.getTransport() == null)
|| (server.getTransport().equals("socket"))) {
return socket;
} else if ("framed-transport".equals(server.getTransport())) {
return new TFramedTransport(socket);
}
// for default, use TSocket;
return socket;
}
示例2: getUniqueInstanceKey
import org.apache.curator.x.discovery.ServiceInstance; //导入方法依赖的package包/类
private static String getUniqueInstanceKey(ServiceInstance<MetaData> instance) {
if (instance.getPayload() != null && instance.getPayload().getParameters() != null) {
String ipv4 = instance.getPayload().getParameters().get(IpProtocolVersion.IPV4.getId());
String ipv6 = instance.getPayload().getParameters().get(IpProtocolVersion.IPV6.getId());
return ipv4 + ipv6;
} else {
return instance.getAddress();
}
}
示例3: getAddress
import org.apache.curator.x.discovery.ServiceInstance; //导入方法依赖的package包/类
public static String getAddress(ServiceInstance<MetaData> serviceInstance, IpProtocolVersion version) {
String result = null;
if (serviceInstance != null && serviceInstance.getPayload() != null && serviceInstance.getPayload().getParameters() != null) {
result = serviceInstance.getPayload().getParameters().get(version.getId());
}
if (StringUtils.isBlank(result) && version == IpProtocolVersion.IPV4) {
result = serviceInstance.getAddress();
}
return result;
}
示例4: ServerInfo
import org.apache.curator.x.discovery.ServiceInstance; //导入方法依赖的package包/类
public ServerInfo(ServiceInstance<MetaInfo> instance) {
this.host = instance.getAddress();
this.port = instance.getPort();
}