use of com.hazelcast.json.internal.JsonSerializable 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);
tokyo.setState(WanPublisherState.REPLICATING);
LocalWanPublisherStatsImpl singapore = new LocalWanPublisherStatsImpl();
singapore.setConnected(true);
singapore.setOutboundQueueSize(200);
singapore.incrementPublishedEventCount(20);
singapore.setState(WanPublisherState.REPLICATING);
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();
((JsonSerializable) deserialized).fromJson(serialized);
LocalWanPublisherStats deserializedTokyo = deserialized.getLocalWanPublisherStats().get("tokyo");
LocalWanPublisherStats deserializedSingapore = deserialized.getLocalWanPublisherStats().get("singapore");
assertEquals(tokyo.isConnected(), deserializedTokyo.isConnected());
assertEquals(tokyo.getPublisherState(), deserializedTokyo.getPublisherState());
assertEquals(singapore.isConnected(), deserializedSingapore.isConnected());
assertEquals(singapore.getPublisherState(), deserializedSingapore.getPublisherState());
}
use of com.hazelcast.json.internal.JsonSerializable in project hazelcast by hazelcast.
the class SlowOperationDetectorAbstractTest method getOperationStats.
static JsonObject getOperationStats(HazelcastInstance instance) {
TimedMemberStateFactory timedMemberStateFactory = new TimedMemberStateFactory(getHazelcastInstanceImpl(instance));
LocalOperationStats operationStats = timedMemberStateFactory.createTimedMemberState().getMemberState().getOperationStats();
return ((JsonSerializable) operationStats).toJson();
}
Aggregations