use of com.hazelcast.monitor.LocalWanPublisherStats in project hazelcast by hazelcast.
the class LocalWanStatsImpl method fromJson.
@Override
public void fromJson(JsonObject json) {
for (JsonObject.Member next : json) {
LocalWanPublisherStats localPublisherStats = new LocalWanPublisherStatsImpl();
localPublisherStats.fromJson(next.getValue().asObject());
localPublisherStatsMap.put(next.getName(), localPublisherStats);
}
}
use of com.hazelcast.monitor.LocalWanPublisherStats in project hazelcast by hazelcast.
the class LocalWanStatsImplTest method testSerialization.
@Test
public void testSerialization() {
LocalWanPublisherStatsImpl tokyo = new LocalWanPublisherStatsImpl();
tokyo.setConnected(true);
tokyo.incrementPublishedEventCount(10);
tokyo.setOutboundQueueSize(100);
LocalWanPublisherStatsImpl singapore = new LocalWanPublisherStatsImpl();
singapore.setConnected(true);
singapore.setOutboundQueueSize(200);
singapore.incrementPublishedEventCount(20);
LocalWanStatsImpl localWanStats = new LocalWanStatsImpl();
Map<String, LocalWanPublisherStats> localWanPublisherStatsMap = new HashMap<String, LocalWanPublisherStats>();
localWanPublisherStatsMap.put("tokyo", tokyo);
localWanPublisherStatsMap.put("singapore", singapore);
localWanStats.setLocalPublisherStatsMap(localWanPublisherStatsMap);
JsonObject serialized = localWanStats.toJson();
LocalWanStats deserialized = new LocalWanStatsImpl();
deserialized.fromJson(serialized);
LocalWanPublisherStats deserializedTokyo = deserialized.getLocalWanPublisherStats().get("tokyo");
LocalWanPublisherStats deserializedSingapore = deserialized.getLocalWanPublisherStats().get("singapore");
assertEquals(tokyo.isConnected(), deserializedTokyo.isConnected());
assertEquals(tokyo.getTotalPublishedEventCount(), deserializedTokyo.getTotalPublishedEventCount());
assertEquals(tokyo.getOutboundQueueSize(), deserializedTokyo.getOutboundQueueSize());
assertEquals(tokyo.getTotalPublishLatency(), deserializedTokyo.getTotalPublishLatency());
assertEquals(singapore.isConnected(), deserializedSingapore.isConnected());
assertEquals(singapore.getTotalPublishedEventCount(), deserializedSingapore.getTotalPublishedEventCount());
assertEquals(singapore.getOutboundQueueSize(), deserializedSingapore.getOutboundQueueSize());
assertEquals(singapore.getTotalPublishLatency(), deserializedSingapore.getTotalPublishLatency());
}
Aggregations