use of org.apache.cassandra.locator.AbstractEndpointSnitch in project cassandra by apache.
the class CreateTest method testHyphenDatacenters.
@Test
public // tests CASSANDRA-4278
void testHyphenDatacenters() throws Throwable {
IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
// Register an EndpointSnitch which returns fixed values for test.
DatabaseDescriptor.setEndpointSnitch(new AbstractEndpointSnitch() {
@Override
public String getRack(InetAddress endpoint) {
return RACK1;
}
@Override
public String getDatacenter(InetAddress endpoint) {
return "us-east-1";
}
@Override
public int compareEndpoints(InetAddress target, InetAddress a1, InetAddress a2) {
return 0;
}
});
execute("CREATE KEYSPACE Foo WITH replication = { 'class' : 'NetworkTopologyStrategy', 'us-east-1' : 1 };");
// Restore the previous EndpointSnitch
DatabaseDescriptor.setEndpointSnitch(snitch);
// clean up
execute("DROP KEYSPACE IF EXISTS Foo");
}
Aggregations