當前位置: 首頁>>代碼示例>>Java>>正文


Java Host.getDatacenter方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.Host.getDatacenter方法的典型用法代碼示例。如果您正苦於以下問題:Java Host.getDatacenter方法的具體用法?Java Host.getDatacenter怎麽用?Java Host.getDatacenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.Host的用法示例。


在下文中一共展示了Host.getDatacenter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildNetworkTopologyStrategyString

import com.datastax.driver.core.Host; //導入方法依賴的package包/類
static String buildNetworkTopologyStrategyString(Cluster cluster) {
  Map<String, Integer> ntsMap = Maps.newHashMap();
  for (Host host : cluster.getMetadata().getAllHosts()) {
    String dc = host.getDatacenter();
    ntsMap.put(dc, 1 + ntsMap.getOrDefault(dc, 0));
  }
  StringBuilder builder = new StringBuilder("'class':'NetworkTopologyStrategy',");
  for (Map.Entry<String, Integer> e : ntsMap.entrySet()) {
    builder.append("'").append(e.getKey()).append("':").append(e.getValue()).append(",");
  }
  return builder.substring(0, builder.length() - 1);
}
 
開發者ID:thelastpickle,項目名稱:cassandra-reaper,代碼行數:13,代碼來源:BasicSteps.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


注:本文中的com.datastax.driver.core.Host.getDatacenter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。