本文整理了Java中com.datastax.driver.core.Metadata.allHosts()
方法的一些代码示例,展示了Metadata.allHosts()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.allHosts()
方法的具体详情如下:
包路径:com.datastax.driver.core.Metadata
类名称:Metadata
方法名:allHosts
暂无
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Override
public Integer getValue() {
return manager.metadata.allHosts().size();
}
});
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Returns the known hosts of this cluster.
*
* @return A set will all the know host of this cluster.
*/
public Set<Host> getAllHosts() {
return new HashSet<Host>(allHosts());
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
void connect() throws UnsupportedProtocolVersionException {
if (isShutdown) return;
// NB: at this stage, allHosts() only contains the initial contact points
List<Host> hosts = new ArrayList<Host>(cluster.metadata.allHosts());
// shuffle so that multiple clients with the same contact points don't all pick the same control
// host
Collections.shuffle(hosts);
setNewConnection(reconnectInternal(hosts.iterator(), true));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
if (!initFuture.compareAndSet(null, myInitFuture)) return initFuture.get();
Collection<Host> hosts = cluster.getMetadata().allHosts();
ListenableFuture<?> allPoolsCreatedFuture = createPools(hosts);
ListenableFuture<?> allPoolsUpdatedFuture =
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
List<ListenableFuture<Boolean>> poolCreatedFutures = Lists.newArrayList();
for (Host h : cluster.getMetadata().allHosts()) {
HostDistance dist = loadBalancingPolicy().distance(h);
HostConnectionPool pool = pools.get(h);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public static Host findHost(Cluster cluster, String address) {
// Note: we can't rely on ProtocolOptions.getPort() to build an InetSocketAddress and call
// metadata.getHost,
// because the port doesn't have the correct value if addContactPointsWithPorts was used to
// create the Cluster
// (JAVA-860 will solve that)
for (Host host : cluster.getMetadata().allHosts()) {
if (host.getAddress().getHostAddress().equals(address)) return host;
}
return null;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
for (Host host : cluster.metadata.allHosts())
if (!host.getSocketAddress().equals(connection.address)
&& !foundHostsSet.contains(host.getSocketAddress()))
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
@Override
public Integer getValue() {
return manager.metadata.allHosts().size();
}
});
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Returns the known hosts of this cluster.
*
* @return A set will all the know host of this cluster.
*/
public Set<Host> getAllHosts() {
return new HashSet<Host>(allHosts());
}
代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core
@Override
public Integer getValue() {
return manager.metadata.allHosts().size();
}
});
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Returns the known hosts of this cluster.
*
* @return A set will all the know host of this cluster.
*/
public Set<Host> getAllHosts() {
return new HashSet<Host>(allHosts());
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
@Override
public Integer getValue() {
return manager.metadata.allHosts().size();
}
});
代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core
/**
* Returns the known hosts of this cluster.
*
* @return A set will all the know host of this cluster.
*/
public Set<Host> getAllHosts() {
return new HashSet<Host>(allHosts());
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_init_cluster_and_session_if_needed() throws Exception {
// For this test we need an uninitialized cluster, so we can't reuse the one provided by the
// parent class. Rebuild a new one with the same (unique) host.
Host host = cluster().getMetadata().allHosts().iterator().next();
Cluster cluster2 =
register(
Cluster.builder()
.addContactPointsWithPorts(Lists.newArrayList(host.getSocketAddress()))
.build());
try {
Session session2 = cluster2.newSession();
// Neither cluster2 nor session2 are initialized at this point
assertThat(cluster2.manager.metadata).isNull();
ResultSetFuture future = session2.executeAsync("select release_version from system.local");
Row row = Uninterruptibles.getUninterruptibly(future).one();
assertThat(row.getString(0)).isNotEmpty();
} finally {
cluster2.close();
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
for (Host host : cluster().getMetadata().allHosts()) {
assertThat(host.getTokens()).hasSize(numTokens);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
Collection<Host> allHosts = metadata.allHosts();
代码示例来源:origin: com.yugabyte/cassandra-driver-core
void connect() throws UnsupportedProtocolVersionException {
if (isShutdown)
return;
// NB: at this stage, allHosts() only contains the initial contact points
List<Host> hosts = new ArrayList<Host>(cluster.metadata.allHosts());
// shuffle so that multiple clients with the same contact points don't all pick the same control host
Collections.shuffle(hosts);
setNewConnection(reconnectInternal(hosts.iterator(), true));
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
void connect() throws UnsupportedProtocolVersionException {
if (isShutdown)
return;
// NB: at this stage, allHosts() only contains the initial contact points
List<Host> hosts = new ArrayList<Host>(cluster.metadata.allHosts());
// shuffle so that multiple clients with the same contact points don't all pick the same control host
Collections.shuffle(hosts);
setNewConnection(reconnectInternal(hosts.iterator(), true));
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
void connect() throws UnsupportedProtocolVersionException {
if (isShutdown)
return;
// NB: at this stage, allHosts() only contains the initial contact points
List<Host> hosts = new ArrayList<Host>(cluster.metadata.allHosts());
// shuffle so that multiple clients with the same contact points don't all pick the same control host
Collections.shuffle(hosts);
setNewConnection(reconnectInternal(hosts.iterator(), true));
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
public static Host findHost(Cluster cluster, String address) {
// Note: we can't rely on ProtocolOptions.getPort() to build an InetSocketAddress and call
// metadata.getHost,
// because the port doesn't have the correct value if addContactPointsWithPorts was used to
// create the Cluster
// (JAVA-860 will solve that)
for (Host host : cluster.getMetadata().allHosts()) {
if (host.getAddress().getHostAddress().equals(address)) return host;
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!