本文整理了Java中com.datastax.driver.core.Metadata.getHost()
方法的一些代码示例,展示了Metadata.getHost()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.getHost()
方法的具体详情如下:
包路径:com.datastax.driver.core.Metadata
类名称:Metadata
方法名:getHost
暂无
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
Host connectedHost() {
Connection current = connectionRef.get();
return (current == null) ? null : cluster.metadata.getHost(current.address);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
<E extends Throwable> E defunct(E e) {
if (isDefunct.compareAndSet(false, true)) {
if (Host.statesLogger.isTraceEnabled()) Host.statesLogger.trace("Defuncting " + this, e);
else if (Host.statesLogger.isDebugEnabled())
Host.statesLogger.debug("Defuncting {} because: {}", this, e.getMessage());
Host host = factory.manager.metadata.getHost(address);
if (host != null) {
// Sometimes close() can be called before defunct(); avoid decrementing the connection count
// twice, but
// we still want to signal the error to the conviction policy.
boolean decrement = signaled.compareAndSet(false, true);
boolean hostDown = host.convictionPolicy.signalConnectionFailure(this, decrement);
if (hostDown) {
factory.manager.signalHostDown(host, host.wasJustAdded());
} else {
notifyOwnerWhenDefunct();
}
}
// Force the connection to close to make sure the future completes. Otherwise force() might
// never get called and
// threads will wait on the future forever.
// (this also errors out pending handlers)
closeAsync().force();
}
return e;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
Host host = factory.manager.metadata.getHost(address);
if (host != null) {
host.convictionPolicy.signalConnectionClosed(this);
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
protected Host retrieveSingleHost(Cluster cluster) {
Host host = cluster.getMetadata().getHost(hostAddress);
if (host == null) {
fail("Unable to retrieve host");
}
return host;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
switch (eventType) {
case UP:
Host upHost = metadata.getHost(address);
if (upHost == null) {
upHost = metadata.newHost(address);
Host downHost = metadata.getHost(address);
if (downHost != null) {
Host removedHost = metadata.getHost(address);
if (removedHost != null) futures.add(execute(hostRemoved(removedHost)));
break;
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
Host host = cluster.metadata.getHost(connection.address);
Host host = cluster.metadata.getHost(foundHosts.get(i));
boolean isNew = false;
if (host == null) {
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private static boolean checkSchemaAgreement(Connection connection, Cluster.Manager cluster)
throws InterruptedException, ExecutionException {
DefaultResultSetFuture peersFuture =
new DefaultResultSetFuture(
null, cluster.protocolVersion(), new Requests.Query(SELECT_SCHEMA_PEERS));
DefaultResultSetFuture localFuture =
new DefaultResultSetFuture(
null, cluster.protocolVersion(), new Requests.Query(SELECT_SCHEMA_LOCAL));
connection.write(peersFuture);
connection.write(localFuture);
Set<UUID> versions = new HashSet<UUID>();
Row localRow = localFuture.get().one();
if (localRow != null && !localRow.isNull("schema_version"))
versions.add(localRow.getUUID("schema_version"));
for (Row row : peersFuture.get()) {
InetSocketAddress addr = nativeAddressForPeerHost(row, connection.address, cluster);
if (addr == null || row.isNull("schema_version")) continue;
Host peer = cluster.metadata.getHost(addr);
if (peer != null && peer.isUp()) versions.add(row.getUUID("schema_version"));
}
logger.debug("Checking for schema agreement: versions are {}", versions);
return versions.size() <= 1;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void testMissingRpcAddressAtStartup() throws Exception {
deleteNode2RpcAddressFromNode1();
// Use only one contact point to make sure that the control connection is on node1
Cluster cluster =
register(
Cluster.builder()
.addContactPoints(getContactPoints().get(0))
.withPort(ccm().getBinaryPort())
.build());
cluster.connect();
// Since node2's RPC address is unknown on our control host, it should have been ignored
assertEquals(cluster.getMetrics().getConnectedToHosts().getValue().intValue(), 1);
assertNull(cluster.getMetadata().getHost(getContactPointsWithPorts().get(1)));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
final Host host = cluster().getMetadata().getHost(ccm().addressOfNode(1));
ScheduledExecutorService openConnectionsWatcherExecutor = Executors.newScheduledThreadPool(1);
final Runnable openConnectionsWatcher =
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
throws ConnectionException, BusyConnectionException, ExecutionException,
InterruptedException {
Host host = cluster.metadata.getHost(connection.address);
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
Host connectedHost() {
Connection current = connectionRef.get();
return (current == null)
? null
: cluster.metadata.getHost(current.address);
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
Host connectedHost() {
Connection current = connectionRef.get();
return (current == null)
? null
: cluster.metadata.getHost(current.address);
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
Host connectedHost() {
Connection current = connectionRef.get();
return (current == null)
? null
: cluster.metadata.getHost(current.address);
}
代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core
Host connectedHost() {
Connection current = connectionRef.get();
return cluster.metadata.getHost(current.address);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
Host host2 = cluster.getMetadata().getHost(node2RpcAddress);
assertThat(host2).isNotNull();
host2 = cluster.getMetadata().getHost(node2RpcAddress);
代码示例来源:origin: com.stratio.cassandra/cassandra-driver-core
ConnectionException defunct(ConnectionException e) {
if (logger.isDebugEnabled())
logger.debug("Defuncting connection to " + address, e);
exception = e;
isDefunct = true;
dispatcher.errorOutAllHandler(e);
Host host = factory.manager.metadata.getHost(address);
if (host != null) {
boolean isDown = factory.manager.signalConnectionFailure(host, e, host.wasJustAdded());
notifyOwnerWhenDefunct(isDown);
}
closeAsync();
return e;
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
protected Host retrieveSingleHost(Cluster cluster) {
Host host = cluster.getMetadata().getHost(hostAddress);
if (host == null) {
fail("Unable to retrieve host");
}
return host;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
static void refreshSchema(Connection connection, SchemaElement targetType, String targetKeyspace, String targetName, List<String> targetSignature, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
Host host = cluster.metadata.getHost(connection.address);
// Neither host, nor it's version should be null. But instead of dying if there is a race or something, we can kind of try to infer
// a Cassandra version from the protocol version (this is not full proof, we can have the protocol 1 against C* 2.0+, but it's worth
// a shot, and since we log in this case, it should be relatively easy to debug when if this ever fail).
VersionNumber cassandraVersion;
if (host == null || host.getCassandraVersion() == null) {
cassandraVersion = cluster.protocolVersion().minCassandraVersion();
logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. "
+ "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion);
} else {
cassandraVersion = host.getCassandraVersion();
}
SchemaParser.forVersion(cassandraVersion)
.refresh(cluster.getCluster(),
targetType, targetKeyspace, targetName, targetSignature,
connection, cassandraVersion);
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
static void refreshSchema(Connection connection, SchemaElement targetType, String targetKeyspace, String targetName, List<String> targetSignature, Cluster.Manager cluster) throws ConnectionException, BusyConnectionException, ExecutionException, InterruptedException {
Host host = cluster.metadata.getHost(connection.address);
// Neither host, nor it's version should be null. But instead of dying if there is a race or something, we can kind of try to infer
// a Cassandra version from the protocol version (this is not full proof, we can have the protocol 1 against C* 2.0+, but it's worth
// a shot, and since we log in this case, it should be relatively easy to debug when if this ever fail).
VersionNumber cassandraVersion;
if (host == null || host.getCassandraVersion() == null) {
cassandraVersion = cluster.protocolVersion().minCassandraVersion();
logger.warn("Cannot find Cassandra version for host {} to parse the schema, using {} based on protocol version in use. "
+ "If parsing the schema fails, this could be the cause", connection.address, cassandraVersion);
} else {
cassandraVersion = host.getCassandraVersion();
}
SchemaParser.forVersion(cassandraVersion)
.refresh(cluster.getCluster(),
targetType, targetKeyspace, targetName, targetSignature,
connection, cassandraVersion);
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@Test(groups = "short")
public void testMissingRpcAddressAtStartup() throws Exception {
deleteNode2RpcAddressFromNode1();
// Use only one contact point to make sure that the control connection is on node1
Cluster cluster =
register(
Cluster.builder()
.addContactPoints(getContactPoints().get(0))
.withPort(ccm().getBinaryPort())
.build());
cluster.connect();
// Since node2's RPC address is unknown on our control host, it should have been ignored
assertEquals(cluster.getMetrics().getConnectedToHosts().getValue().intValue(), 1);
assertNull(cluster.getMetadata().getHost(getContactPointsWithPorts().get(1)));
}
内容来源于网络,如有侵权,请联系作者删除!