Search in sources :

Example 1 with ApplicationState

use of org.apache.cassandra.gms.ApplicationState in project cassandra by apache.

the class CloudstackSnitchTest method testRacks.

@Test
public void testRacks() throws IOException, ConfigurationException {
    az = "ch-gva-1";
    CloudstackSnitch snitch = new TestCloudstackSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");
    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("ch-zrh"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.rack("2"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);
    assertEquals("ch-zrh", snitch.getDatacenter(nonlocal));
    assertEquals("2", snitch.getRack(nonlocal));
    assertEquals("ch-gva", snitch.getDatacenter(local));
    assertEquals("1", snitch.getRack(local));
}
Also used : VersionedValue(org.apache.cassandra.gms.VersionedValue) ApplicationState(org.apache.cassandra.gms.ApplicationState) InetAddress(java.net.InetAddress) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 2 with ApplicationState

use of org.apache.cassandra.gms.ApplicationState in project cassandra by apache.

the class EC2SnitchTest method testRac.

@Test
public void testRac() throws IOException, ConfigurationException {
    az = "us-east-1d";
    Ec2Snitch snitch = new TestEC2Snitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");
    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("us-west"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("1a"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);
    assertEquals("us-west", snitch.getDatacenter(nonlocal));
    assertEquals("1a", snitch.getRack(nonlocal));
    assertEquals("us-east", snitch.getDatacenter(local));
    assertEquals("1d", snitch.getRack(local));
}
Also used : VersionedValue(org.apache.cassandra.gms.VersionedValue) ApplicationState(org.apache.cassandra.gms.ApplicationState) InetAddress(java.net.InetAddress) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 3 with ApplicationState

use of org.apache.cassandra.gms.ApplicationState in project cassandra by apache.

the class GoogleCloudSnitchTest method testRac.

@Test
public void testRac() throws IOException, ConfigurationException {
    az = "us-central1-a";
    GoogleCloudSnitch snitch = new TestGoogleCloudSnitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");
    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = new EnumMap<>(ApplicationState.class);
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("europe-west1"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("a"));
    Gossiper.instance.getEndpointStateForEndpoint(nonlocal).addApplicationStates(stateMap);
    assertEquals("europe-west1", snitch.getDatacenter(nonlocal));
    assertEquals("a", snitch.getRack(nonlocal));
    assertEquals("us-central1", snitch.getDatacenter(local));
    assertEquals("a", snitch.getRack(local));
}
Also used : VersionedValue(org.apache.cassandra.gms.VersionedValue) ApplicationState(org.apache.cassandra.gms.ApplicationState) InetAddress(java.net.InetAddress) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 4 with ApplicationState

use of org.apache.cassandra.gms.ApplicationState in project eiger by wlloyd.

the class EC2SnitchTest method testRac.

@Test
public void testRac() throws IOException, ConfigurationException {
    Ec2Snitch snitch = new TestEC2Snitch();
    InetAddress local = InetAddress.getByName("127.0.0.1");
    InetAddress nonlocal = InetAddress.getByName("127.0.0.7");
    Gossiper.instance.addSavedEndpoint(nonlocal);
    Map<ApplicationState, VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap();
    stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("us-west"));
    stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("1a"));
    assertEquals("us-west", snitch.getDatacenter(nonlocal));
    assertEquals("1a", snitch.getRack(nonlocal));
    assertEquals("us-east", snitch.getDatacenter(local));
    assertEquals("1d", snitch.getRack(local));
}
Also used : VersionedValue(org.apache.cassandra.gms.VersionedValue) ApplicationState(org.apache.cassandra.gms.ApplicationState) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Aggregations

InetAddress (java.net.InetAddress)4 ApplicationState (org.apache.cassandra.gms.ApplicationState)4 VersionedValue (org.apache.cassandra.gms.VersionedValue)4 Test (org.junit.Test)4 EnumMap (java.util.EnumMap)3