Search in sources :

Example 1 with LocalWanPublisherStats

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);
    }
}
Also used : LocalWanPublisherStats(com.hazelcast.monitor.LocalWanPublisherStats) JsonObject(com.eclipsesource.json.JsonObject)

Example 2 with LocalWanPublisherStats

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());
}
Also used : LocalWanPublisherStats(com.hazelcast.monitor.LocalWanPublisherStats) HashMap(java.util.HashMap) LocalWanStats(com.hazelcast.monitor.LocalWanStats) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

JsonObject (com.eclipsesource.json.JsonObject)2 LocalWanPublisherStats (com.hazelcast.monitor.LocalWanPublisherStats)2 LocalWanStats (com.hazelcast.monitor.LocalWanStats)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1