use of org.apache.cassandra.gms.VersionedValue 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));
}
use of org.apache.cassandra.gms.VersionedValue 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));
}
use of org.apache.cassandra.gms.VersionedValue 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));
}
use of org.apache.cassandra.gms.VersionedValue in project cassandra by apache.
the class DynamicEndpointSnitch method getSeverity.
private double getSeverity(InetAddress endpoint) {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null)
return 0.0;
VersionedValue event = state.getApplicationState(ApplicationState.SEVERITY);
if (event == null)
return 0.0;
return Double.parseDouble(event.value);
}
use of org.apache.cassandra.gms.VersionedValue in project cassandra by apache.
the class GossipHelper method changeGossipState.
/**
* Changes gossip state of the `peer` on `target`
*/
public static void changeGossipState(IInvokableInstance target, IInstance peer, List<VersionedApplicationState> newState) {
InetSocketAddress addr = peer.broadcastAddress();
UUID hostId = peer.config().hostId();
int netVersion = peer.getMessagingVersion();
target.runOnInstance(() -> {
InetAddressAndPort endpoint = toCassandraInetAddressAndPort(addr);
StorageService storageService = StorageService.instance;
Gossiper.runInGossipStageBlocking(() -> {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null) {
Gossiper.instance.initializeNodeUnsafe(endpoint, hostId, netVersion, 1);
state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state.isAlive() && !Gossiper.instance.isDeadState(state))
Gossiper.instance.realMarkAlive(endpoint, state);
}
for (VersionedApplicationState value : newState) {
ApplicationState as = toApplicationState(value);
VersionedValue vv = toVersionedValue(value);
state.addApplicationState(as, vv);
storageService.onChange(endpoint, as, vv);
}
});
});
}
Aggregations