本文整理汇总了Java中com.lambdaworks.redis.RedisURI.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java RedisURI.getPort方法的具体用法?Java RedisURI.getPort怎么用?Java RedisURI.getPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lambdaworks.redis.RedisURI
的用法示例。
在下文中一共展示了RedisURI.getPort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
/**
* Resolves a {@link com.lambdaworks.redis.RedisURI} to a {@link java.net.SocketAddress}.
*
* @param redisURI must not be {@literal null}
* @param dnsResolver must not be {@literal null}
* @return the resolved {@link SocketAddress}
*/
public static SocketAddress resolve(RedisURI redisURI, DnsResolver dnsResolver) {
if (redisURI.getSocket() != null) {
return redisURI.getResolvedAddress();
}
try {
InetAddress[] inetAddress = dnsResolver.resolve(redisURI.getHost());
if (inetAddress.length == 0) {
return InetSocketAddress.createUnresolved(redisURI.getHost(), redisURI.getPort());
}
return new InetSocketAddress(inetAddress[0], redisURI.getPort());
} catch (UnknownHostException e) {
return redisURI.getResolvedAddress();
}
}
示例2: findNodeByHostAndPort
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
/**
* Lookup a {@link RedisNodeDescription} by {@code host} and {@code port}.
*
* @param nodes
* @param host
* @param port
* @return the {@link RedisNodeDescription} or {@literal null}
*/
static RedisNodeDescription findNodeByHostAndPort(Collection<RedisNodeDescription> nodes, String host, int port) {
for (RedisNodeDescription node : nodes) {
RedisURI nodeUri = node.getUri();
if (nodeUri.getHost().equals(host) && nodeUri.getPort() == port) {
return node;
}
}
return null;
}
示例3: compare
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
@Override
public int compare(RedisURI o1, RedisURI o2) {
String h1 = "";
String h2 = "";
if (o1 != null) {
h1 = o1.getHost() + ":" + o1.getPort();
}
if (o2 != null) {
h2 = o2.getHost() + ":" + o2.getPort();
}
return h1.compareToIgnoreCase(h2);
}
示例4: toConnectionKey
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
private ConnectionKey toConnectionKey(RedisURI redisURI) {
return new ConnectionKey(redisURI.getHost(), redisURI.getPort());
}
示例5: equals
import com.lambdaworks.redis.RedisURI; //导入方法依赖的package包/类
private static boolean equals(RedisURI redisURI, RedisNodeDescription node) {
return node.getUri().getHost().equals(redisURI.getHost()) && node.getUri().getPort() == redisURI.getPort();
}