当前位置: 首页>>代码示例>>Java>>正文


Java Host.getAddress方法代码示例

本文整理汇总了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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:32,代码来源:SmartThriftClient.java

示例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();
}
 
开发者ID:digitalis-io,项目名称:cassandra-probe,代码行数:29,代码来源:ClusterProbe.java

示例3: HostDownException

import com.datastax.driver.core.Host; //导入方法依赖的package包/类
public HostDownException(Host hostName){
    super(hostName.getAddress()+" is down");
}
 
开发者ID:siddv29,项目名称:cfs,代码行数:4,代码来源:HostDownException.java

示例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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:6,代码来源:LimitedLocalNodeFirstLocalBalancingPolicy.java


注:本文中的com.datastax.driver.core.Host.getAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。