Search in sources :

Example 1 with AbstractEndpointSnitch

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");
}
Also used : AbstractEndpointSnitch(org.apache.cassandra.locator.AbstractEndpointSnitch) InetAddress(java.net.InetAddress) IEndpointSnitch(org.apache.cassandra.locator.IEndpointSnitch) Test(org.junit.Test)

Aggregations

InetAddress (java.net.InetAddress)1 AbstractEndpointSnitch (org.apache.cassandra.locator.AbstractEndpointSnitch)1 IEndpointSnitch (org.apache.cassandra.locator.IEndpointSnitch)1 Test (org.junit.Test)1