use of com.hazelcast.internal.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.internal.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);
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.internal.monitor.LocalWanPublisherStats in project hazelcast by hazelcast.
the class DelegatingWanScheme method getStats.
/**
* Silently skips publishers not supporting statistics.
*
* @return publisher statistics, grouped by publisher ID
*/
public Map<String, LocalWanPublisherStats> getStats() {
final Map<String, LocalWanPublisherStats> statsMap = createHashMap(publishers.size());
for (Entry<String, WanPublisher> publisherEntry : publishers.entrySet()) {
WanPublisher publisher = publisherEntry.getValue();
if (publisher instanceof InternalWanPublisher) {
String publisherId = publisherEntry.getKey();
LocalWanPublisherStats stats = ((InternalWanPublisher) publisher).getStats();
if (stats != null) {
statsMap.put(publisherId, stats);
}
}
}
return statsMap;
}
use of com.hazelcast.internal.monitor.LocalWanPublisherStats in project hazelcast by hazelcast.
the class InstanceMBean method registerWanPublisherMBeans.
/**
* Registers managed beans for all WAN publishers, if any.
*
* @param wanReplicationService the WAN replication service
*/
private void registerWanPublisherMBeans(WanReplicationService wanReplicationService) {
final Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
if (wanStats == null) {
return;
}
for (Entry<String, LocalWanStats> replicationStatsEntry : wanStats.entrySet()) {
final String wanReplicationName = replicationStatsEntry.getKey();
final LocalWanStats localWanStats = replicationStatsEntry.getValue();
final Map<String, LocalWanPublisherStats> publisherStats = localWanStats.getLocalWanPublisherStats();
for (String wanPublisherId : publisherStats.keySet()) {
register(new WanPublisherMBean(wanReplicationService, wanReplicationName, wanPublisherId, service));
}
}
}
use of com.hazelcast.internal.monitor.LocalWanPublisherStats in project hazelcast by hazelcast.
the class WanPublisherMBean method getState.
@ManagedAnnotation("state")
@ManagedDescription("State of the WAN replication publisher")
public String getState() {
final Map<String, LocalWanStats> wanStats = managedObject.getStats();
if (wanStats == null) {
return "";
}
final LocalWanStats wanReplicationStats = wanStats.get(wanReplicationName);
final Map<String, LocalWanPublisherStats> wanDelegatingPublisherStats = wanReplicationStats.getLocalWanPublisherStats();
final LocalWanPublisherStats wanPublisherStats = wanDelegatingPublisherStats.get(wanPublisherId);
return wanPublisherStats.getPublisherState().name();
}
Aggregations