當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。