本文整理汇总了Java中com.datastax.driver.core.Host.getAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Host.getAddress方法的具体用法?Java Host.getAddress怎么用?Java Host.getAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.Host
的用法示例。
在下文中一共展示了Host.getAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import com.datastax.driver.core.Host; //导入方法依赖的package包/类
private Client get(ByteBuffer pk)
{
Set<Host> hosts = metadata.getReplicas(metadata.quote(keyspace), pk);
InetAddress address = null;
if (hosts.size() > 0)
{
int pos = roundrobin.incrementAndGet() % hosts.size();
for (int i = 0 ; address == null && i < hosts.size() ; i++)
{
if (pos < 0)
pos = -pos;
Host host = Iterators.get(hosts.iterator(), (pos + i) % hosts.size());
if (whiteset == null || whiteset.contains(host.getAddress()))
address = host.getAddress();
}
}
if (address == null)
address = whitelist.get(ThreadLocalRandom.current().nextInt(whitelist.size()));
ConcurrentLinkedQueue<Client> q = cache.get(address);
if (q == null)
{
ConcurrentLinkedQueue<Client> newQ = new ConcurrentLinkedQueue<Client>();
q = cache.putIfAbsent(address, newQ);
if (q == null)
q = newQ;
}
Client tclient = q.poll();
if (tclient != null)
return tclient;
return new Client(settings.getRawThriftClient(address.getHostAddress()), address);
}
示例2: prettyHost
import com.datastax.driver.core.Host; //导入方法依赖的package包/类
public static String prettyHost(final Host host) {
Preconditions.checkNotNull(host);
InetAddress address = host.getAddress();
VersionNumber v = host.getCassandraVersion();
String datacenter = host.getDatacenter();
String rack = host.getRack();
InetSocketAddress socketAddress = host.getSocketAddress();
int port = socketAddress.getPort();
InetAddress sockAddress = socketAddress.getAddress();
StringBuilder b = new StringBuilder();
b.append("\n\tHost (" + address.getCanonicalHostName() + ") [");
b.append("\n\t\tHostAddress:\t\t" + address.getHostAddress());
b.append("\n\t\tHostName:\t\t" + address.getHostName());
b.append("\n\t\tSocket Canonical:\t" + sockAddress.getCanonicalHostName());
b.append("\n\t\tSocket HostAddress:\t" + sockAddress.getHostAddress());
b.append("\n\t\tSocket HostName:\t" + sockAddress.getHostName());
b.append("\n\t\tSocket Port:\t\t" + port);
b.append("\n\t\tDataCenter:\t\t" + datacenter);
b.append("\n\t\tRack:\t\t\t" + rack);
b.append("\n\t\tIs Up:\t\t\t" + host.isUp());
b.append("\n\t\tCassandra Version:\t" + v.getMajor() + "." + v.getMinor() + "." + v.getPatch());
b.append("\n\t\tDSE Patch:\t\t" + v.getDSEPatch());
b.append("\n\t]");
return b.toString();
}
示例3: HostDownException
import com.datastax.driver.core.Host; //导入方法依赖的package包/类
public HostDownException(Host hostName){
super(hostName.getAddress()+" is down");
}
示例4: isLocalHost
import com.datastax.driver.core.Host; //导入方法依赖的package包/类
private static boolean isLocalHost(Host host)
{
InetAddress hostAddress = host.getAddress();
return hostAddress.isLoopbackAddress() || localAddresses.contains(hostAddress);
}