Search in sources :

Example 1 with TimedMemberState

use of com.hazelcast.monitor.TimedMemberState in project hazelcast by hazelcast.

the class TimedMemberStateFactory method createTimedMemberState.

public TimedMemberState createTimedMemberState() {
    MemberStateImpl memberState = new MemberStateImpl();
    Collection<StatisticsAwareService> services = instance.node.nodeEngine.getServices(StatisticsAwareService.class);
    TimedMemberState timedMemberState = new TimedMemberState();
    createMemberState(timedMemberState, memberState, services);
    timedMemberState.setMaster(instance.node.isMaster());
    timedMemberState.setMemberList(new ArrayList<String>());
    if (timedMemberState.getMaster()) {
        Set<Member> memberSet = instance.getCluster().getMembers();
        for (Member member : memberSet) {
            MemberImpl memberImpl = (MemberImpl) member;
            Address address = memberImpl.getAddress();
            timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort());
        }
    }
    timedMemberState.setMemberState(memberState);
    GroupConfig groupConfig = instance.getConfig().getGroupConfig();
    timedMemberState.setClusterName(groupConfig.getName());
    return timedMemberState;
}
Also used : StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) Address(com.hazelcast.nio.Address) GroupConfig(com.hazelcast.config.GroupConfig) MemberStateImpl(com.hazelcast.monitor.impl.MemberStateImpl) MemberImpl(com.hazelcast.instance.MemberImpl) Member(com.hazelcast.core.Member) TimedMemberState(com.hazelcast.monitor.TimedMemberState)

Example 2 with TimedMemberState

use of com.hazelcast.monitor.TimedMemberState in project hazelcast by hazelcast.

the class MemberStateImplTest method testSerialization.

@Test
public void testSerialization() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    LocalReplicatedMapStatsImpl replicatedMapStats = new LocalReplicatedMapStatsImpl();
    replicatedMapStats.incrementPuts(30);
    CacheStatisticsImpl cacheStatistics = new CacheStatisticsImpl(Clock.currentTimeMillis());
    cacheStatistics.increaseCacheHits(5);
    Collection<ClientEndPointDTO> clients = new ArrayList<ClientEndPointDTO>();
    ClientEndPointDTO client = new ClientEndPointDTO();
    client.uuid = "abc123456";
    client.address = "localhost";
    client.clientType = "undefined";
    clients.add(client);
    Map<String, Long> runtimeProps = new HashMap<String, Long>();
    runtimeProps.put("prop1", 598123L);
    ClusterState clusterState = ClusterState.ACTIVE;
    com.hazelcast.instance.NodeState nodeState = com.hazelcast.instance.NodeState.PASSIVE;
    Version clusterVersion = Version.of("3.8.0");
    MemberVersion memberVersion = MemberVersion.of("3.9.0");
    NodeState state = new NodeStateImpl(clusterState, nodeState, clusterVersion, memberVersion);
    final BackupTaskStatus backupTaskStatus = new BackupTaskStatus(BackupTaskState.IN_PROGRESS, 5, 10);
    final HotRestartStateImpl hotRestartState = new HotRestartStateImpl(backupTaskStatus, false);
    final WanSyncState wanSyncState = new WanSyncStateImpl(WanSyncStatus.IN_PROGRESS, 86, "atob", "B");
    TimedMemberStateFactory factory = new TimedMemberStateFactory(getHazelcastInstanceImpl(hazelcastInstance));
    TimedMemberState timedMemberState = factory.createTimedMemberState();
    MemberStateImpl memberState = timedMemberState.getMemberState();
    memberState.setAddress("memberStateAddress:Port");
    memberState.putLocalMapStats("mapStats", new LocalMapStatsImpl());
    memberState.putLocalMultiMapStats("multiMapStats", new LocalMultiMapStatsImpl());
    memberState.putLocalQueueStats("queueStats", new LocalQueueStatsImpl());
    memberState.putLocalTopicStats("topicStats", new LocalTopicStatsImpl());
    memberState.putLocalExecutorStats("executorStats", new LocalExecutorStatsImpl());
    memberState.putLocalReplicatedMapStats("replicatedMapStats", replicatedMapStats);
    memberState.putLocalCacheStats("cacheStats", new LocalCacheStatsImpl(cacheStatistics));
    memberState.setRuntimeProps(runtimeProps);
    memberState.setLocalMemoryStats(new LocalMemoryStatsImpl());
    memberState.setOperationStats(new LocalOperationStatsImpl());
    memberState.setClients(clients);
    memberState.setNodeState(state);
    memberState.setHotRestartState(hotRestartState);
    memberState.setWanSyncState(wanSyncState);
    MemberStateImpl deserialized = new MemberStateImpl();
    deserialized.fromJson(memberState.toJson());
    assertEquals("memberStateAddress:Port", deserialized.getAddress());
    assertNotNull(deserialized.getLocalMapStats("mapStats").toString());
    assertNotNull(deserialized.getLocalMultiMapStats("multiMapStats").toString());
    assertNotNull(deserialized.getLocalQueueStats("queueStats").toString());
    assertNotNull(deserialized.getLocalTopicStats("topicStats").toString());
    assertNotNull(deserialized.getLocalExecutorStats("executorStats").toString());
    assertNotNull(deserialized.getLocalReplicatedMapStats("replicatedMapStats").toString());
    assertEquals(1, deserialized.getLocalReplicatedMapStats("replicatedMapStats").getPutOperationCount());
    assertNotNull(deserialized.getLocalCacheStats("cacheStats").toString());
    assertEquals(5, deserialized.getLocalCacheStats("cacheStats").getCacheHits());
    assertNotNull(deserialized.getRuntimeProps());
    assertEquals(Long.valueOf(598123L), deserialized.getRuntimeProps().get("prop1"));
    assertNotNull(deserialized.getLocalMemoryStats());
    assertNotNull(deserialized.getOperationStats());
    assertNotNull(deserialized.getMXBeans());
    client = deserialized.getClients().iterator().next();
    assertEquals("abc123456", client.uuid);
    assertEquals("localhost", client.address);
    assertEquals("undefined", client.clientType);
    NodeState deserializedState = deserialized.getNodeState();
    assertEquals(clusterState, deserializedState.getClusterState());
    assertEquals(nodeState, deserializedState.getNodeState());
    assertEquals(clusterVersion, deserializedState.getClusterVersion());
    assertEquals(memberVersion, deserializedState.getMemberVersion());
    final HotRestartState deserializedHotRestartState = deserialized.getHotRestartState();
    assertEquals(backupTaskStatus, deserializedHotRestartState.getBackupTaskStatus());
    final WanSyncState deserializedWanSyncState = deserialized.getWanSyncState();
    assertEquals(WanSyncStatus.IN_PROGRESS, deserializedWanSyncState.getStatus());
    assertEquals(86, deserializedWanSyncState.getSyncedPartitionCount());
    assertEquals("atob", deserializedWanSyncState.getActiveWanConfigName());
    assertEquals("B", deserializedWanSyncState.getActivePublisherName());
    ClusterHotRestartStatusDTO clusterHotRestartStatus = deserialized.getClusterHotRestartStatus();
    assertEquals(FULL_RECOVERY_ONLY, clusterHotRestartStatus.getDataRecoveryPolicy());
    assertEquals(ClusterHotRestartStatusDTO.ClusterHotRestartStatus.UNKNOWN, clusterHotRestartStatus.getHotRestartStatus());
    assertEquals(-1, clusterHotRestartStatus.getRemainingValidationTimeMillis());
    assertEquals(-1, clusterHotRestartStatus.getRemainingDataLoadTimeMillis());
    assertTrue(clusterHotRestartStatus.getMemberHotRestartStatusMap().isEmpty());
}
Also used : NodeState(com.hazelcast.monitor.NodeState) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WanSyncState(com.hazelcast.monitor.WanSyncState) MemberVersion(com.hazelcast.version.MemberVersion) Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) ClusterHotRestartStatusDTO(com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO) TimedMemberState(com.hazelcast.monitor.TimedMemberState) ClusterState(com.hazelcast.cluster.ClusterState) TimedMemberStateFactory(com.hazelcast.internal.management.TimedMemberStateFactory) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) CacheStatisticsImpl(com.hazelcast.cache.impl.CacheStatisticsImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) BackupTaskStatus(com.hazelcast.hotrestart.BackupTaskStatus) HotRestartState(com.hazelcast.monitor.HotRestartState) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with TimedMemberState

use of com.hazelcast.monitor.TimedMemberState in project hazelcast by hazelcast.

the class MancenterServlet method process.

public void process(JsonObject json) {
    ManagementCenterIdentifier identifier = new ManagementCenterIdentifier();
    identifier.fromJson(json.get("identifier").asObject());
    memberState = new TimedMemberState();
    memberState.fromJson(json.get("timedMemberState").asObject());
}
Also used : TimedMemberState(com.hazelcast.monitor.TimedMemberState)

Aggregations

TimedMemberState (com.hazelcast.monitor.TimedMemberState)3 CacheStatisticsImpl (com.hazelcast.cache.impl.CacheStatisticsImpl)1 ClusterState (com.hazelcast.cluster.ClusterState)1 GroupConfig (com.hazelcast.config.GroupConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Member (com.hazelcast.core.Member)1 BackupTaskStatus (com.hazelcast.hotrestart.BackupTaskStatus)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 TimedMemberStateFactory (com.hazelcast.internal.management.TimedMemberStateFactory)1 ClientEndPointDTO (com.hazelcast.internal.management.dto.ClientEndPointDTO)1 ClusterHotRestartStatusDTO (com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO)1 HotRestartState (com.hazelcast.monitor.HotRestartState)1 NodeState (com.hazelcast.monitor.NodeState)1 WanSyncState (com.hazelcast.monitor.WanSyncState)1 MemberStateImpl (com.hazelcast.monitor.impl.MemberStateImpl)1 Address (com.hazelcast.nio.Address)1 StatisticsAwareService (com.hazelcast.spi.StatisticsAwareService)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 MemberVersion (com.hazelcast.version.MemberVersion)1