Search in sources :

Example 1 with LocalWanPublisherStats

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

Example 2 with LocalWanPublisherStats

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

Example 3 with LocalWanPublisherStats

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;
}
Also used : LocalWanPublisherStats(com.hazelcast.internal.monitor.LocalWanPublisherStats) WanPublisher(com.hazelcast.wan.WanPublisher)

Example 4 with LocalWanPublisherStats

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

Example 5 with LocalWanPublisherStats

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

Aggregations

LocalWanPublisherStats (com.hazelcast.internal.monitor.LocalWanPublisherStats)5 LocalWanStats (com.hazelcast.internal.monitor.LocalWanStats)3 JsonObject (com.hazelcast.internal.json.JsonObject)2 JsonSerializable (com.hazelcast.json.internal.JsonSerializable)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 WanPublisher (com.hazelcast.wan.WanPublisher)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1