use of org.apache.cassandra.distributed.api.IInstance in project cassandra by apache.
the class Instance method registerOutboundFilter.
private void registerOutboundFilter(ICluster cluster) {
MessagingService.instance().outboundSink.add((message, to) -> {
if (isShutdown())
return false;
IMessage serialzied = serializeMessage(message.from(), to, message);
// since this instance is sending the message, from will always be this instance
int fromNum = config.num();
IInstance toInstance = cluster.get(fromCassandraInetAddressAndPort(to));
if (toInstance == null)
return false;
int toNum = toInstance.config().num();
return cluster.filters().permitOutbound(fromNum, toNum, serialzied);
});
}
use of org.apache.cassandra.distributed.api.IInstance in project cassandra by apache.
the class Instance method registerInboundFilter.
private void registerInboundFilter(ICluster<?> cluster) {
MessagingService.instance().inboundSink.add(message -> {
if (!cluster.filters().hasInbound())
return true;
if (isShutdown())
return false;
IMessage serialized = serializeMessage(message.from(), toCassandraInetAddressAndPort(broadcastAddress()), message);
IInstance from = cluster.get(serialized.from());
if (from == null)
return false;
int fromNum = from.config().num();
// since this instance is reciving the message, to will always be this instance
int toNum = config.num();
return cluster.filters().permitInbound(fromNum, toNum, serialized);
});
}
use of org.apache.cassandra.distributed.api.IInstance in project cassandra by apache.
the class TableEstimatesTest method refreshSizeEstimatesClearsInvalidEntries.
/**
* Replaces Python Dtest: nodetool_test.py#test_refresh_size_estimates_clears_invalid_entries
*/
@Test
public void refreshSizeEstimatesClearsInvalidEntries() {
String size_estimatesInsert = "INSERT INTO system.size_estimates (keyspace_name, table_name, range_start, range_end, mean_partition_size, partitions_count) VALUES (?, ?, ?, ?, ?, ?)";
IInstance node = CLUSTER.get(1);
node.executeInternal(size_estimatesInsert, "system_auth", "bad_table", "-5", "5", 0L, 0L);
node.executeInternal(size_estimatesInsert, "bad_keyspace", "bad_table", "-5", "5", 0L, 0L);
node.nodetoolResult("refreshsizeestimates").asserts().success();
QueryResult qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.size_estimates WHERE keyspace_name=? AND table_name=?", ConsistencyLevel.ONE, "system_auth", "bad_table");
Assertions.assertThat(qr).isExhausted();
qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.size_estimates WHERE keyspace_name=?", ConsistencyLevel.ONE, "bad_keyspace");
Assertions.assertThat(qr).isExhausted();
}
use of org.apache.cassandra.distributed.api.IInstance in project cassandra by apache.
the class TableEstimatesTest method refreshTableEstimatesClearsInvalidEntries.
/**
* Replaces Python Dtest: nodetool_test.py#test_refresh_size_estimates_clears_invalid_entries
*/
@Test
public void refreshTableEstimatesClearsInvalidEntries() {
String table_estimatesInsert = "INSERT INTO system.table_estimates (keyspace_name, table_name, range_type, range_start, range_end, mean_partition_size, partitions_count) VALUES (?, ?, ?, ?, ?, ?, ?)";
IInstance node = CLUSTER.get(1);
try {
node.executeInternal(table_estimatesInsert, "system_auth", "bad_table", "local_primary", "-5", "5", 0L, 0L);
node.executeInternal(table_estimatesInsert, "bad_keyspace", "bad_table", "local_primary", "-5", "5", 0L, 0L);
} catch (Exception e) {
// to make this test portable (with the intent to extract out), handle the case where the table_estimates isn't defined
Assertions.assertThat(e.getClass().getCanonicalName()).isEqualTo("org.apache.cassandra.exceptions.InvalidRequestException");
Assertions.assertThat(e).hasMessageContaining("does not exist");
Assume.assumeTrue("system.table_estimates not present", false);
}
node.nodetoolResult("refreshsizeestimates").asserts().success();
QueryResult qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.table_estimates WHERE keyspace_name=? AND table_name=?", ConsistencyLevel.ONE, "system_auth", "bad_table");
Assertions.assertThat(qr).isExhausted();
qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.table_estimates WHERE keyspace_name=?", ConsistencyLevel.ONE, "bad_keyspace");
Assertions.assertThat(qr).isExhausted();
}
use of org.apache.cassandra.distributed.api.IInstance in project cassandra by apache.
the class AbstractCluster method updateMessagingVersions.
private void updateMessagingVersions() {
for (IInstance reportTo : instances) {
if (reportTo.isShutdown())
continue;
for (IInstance reportFrom : instances) {
if (reportFrom == reportTo || reportFrom.isShutdown())
continue;
int minVersion = Math.min(reportFrom.getMessagingVersion(), reportTo.getMessagingVersion());
reportTo.setMessagingVersion(reportFrom.broadcastAddress(), minVersion);
}
}
}
Aggregations