use of com.facebook.presto.failureDetector.HeartbeatFailureDetector.Stats in project presto by prestodb.
the class TestHeartbeatFailureDetector method testHeartbeatStatsSerialization.
@Test
public void testHeartbeatStatsSerialization() throws Exception {
ObjectMapper objectMapper = new JsonObjectMapperProvider().get();
Stats stats = new Stats(new URI("http://example.com"), 60);
String serialized = objectMapper.writeValueAsString(stats);
JsonNode deserialized = objectMapper.readTree(serialized);
assertFalse(deserialized.has("lastFailureInfo"));
stats.recordFailure(new SocketTimeoutException("timeout"));
serialized = objectMapper.writeValueAsString(stats);
deserialized = objectMapper.readTree(serialized);
assertFalse(deserialized.get("lastFailureInfo").isNull());
assertEquals(deserialized.get("lastFailureInfo").get("type").asText(), SocketTimeoutException.class.getName());
}
Aggregations