use of org.apache.cassandra.gms.VersionedValue in project cassandra by apache.
the class DynamicEndpointSnitch method getSeverity.
private double getSeverity(InetAddressAndPort 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 Utils method currentToken.
static Token currentToken() {
EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(getBroadcastAddressAndPort());
VersionedValue value = epState.getApplicationState(ApplicationState.TOKENS);
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(value.toBytes()))) {
return TokenSerializer.deserialize(getPartitioner(), in).iterator().next();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.cassandra.gms.VersionedValue 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));
}
Aggregations