Search in sources :

Example 1 with MemberStateImpl

use of com.hazelcast.monitor.impl.MemberStateImpl 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 MemberStateImpl

use of com.hazelcast.monitor.impl.MemberStateImpl in project hazelcast by hazelcast.

the class TimedMemberState method fromJson.

@Override
public void fromJson(JsonObject json) {
    time = getLong(json, "time");
    master = getBoolean(json, "master");
    clusterName = getString(json, "clusterName");
    instanceNames = new HashSet<String>();
    final JsonArray jsonInstanceNames = getArray(json, "instanceNames");
    for (JsonValue instanceName : jsonInstanceNames.values()) {
        instanceNames.add(instanceName.asString());
    }
    memberList = new ArrayList<String>();
    final JsonArray jsonMemberList = getArray(json, "memberList");
    for (JsonValue member : jsonMemberList.values()) {
        memberList.add(member.asString());
    }
    final JsonObject jsonMemberState = getObject(json, "memberState");
    memberState = new MemberStateImpl();
    memberState.fromJson(jsonMemberState);
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) MemberStateImpl(com.hazelcast.monitor.impl.MemberStateImpl) JsonValue(com.eclipsesource.json.JsonValue) JsonObject(com.eclipsesource.json.JsonObject) JsonUtil.getString(com.hazelcast.util.JsonUtil.getString)

Example 3 with MemberStateImpl

use of com.hazelcast.monitor.impl.MemberStateImpl in project hazelcast by hazelcast.

the class PartitionServiceBeanDTOTest method testJMXStatsWithPublicAddressHostName.

/**
     * https://github.com/hazelcast/hazelcast/issues/8463
     */
@Test
public void testJMXStatsWithPublicAddressHostName() {
    String publicAddress = "hazelcast.org";
    instance = createInstanceWithPublicAddress(publicAddress);
    assumeNotNull(instance, "Internet access and/or DNS resolver are not available, " + publicAddress + " cannot be resolved!");
    warmUpPartitions(instance);
    MemberStateImpl memberState = new MemberStateImpl();
    TimedMemberStateFactoryHelper.registerJMXBeans(getNode(instance).hazelcastInstance, memberState);
    PartitionServiceBeanDTO partitionServiceDTO = memberState.getMXBeans().getPartitionServiceBean();
    assertEquals(partitionServiceDTO.getPartitionCount(), partitionServiceDTO.getActivePartitionCount());
}
Also used : MemberStateImpl(com.hazelcast.monitor.impl.MemberStateImpl) PartitionServiceBeanDTO(com.hazelcast.internal.management.dto.PartitionServiceBeanDTO) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MemberStateImpl (com.hazelcast.monitor.impl.MemberStateImpl)3 JsonArray (com.eclipsesource.json.JsonArray)1 JsonObject (com.eclipsesource.json.JsonObject)1 JsonValue (com.eclipsesource.json.JsonValue)1 GroupConfig (com.hazelcast.config.GroupConfig)1 Member (com.hazelcast.core.Member)1 MemberImpl (com.hazelcast.instance.MemberImpl)1 PartitionServiceBeanDTO (com.hazelcast.internal.management.dto.PartitionServiceBeanDTO)1 TimedMemberState (com.hazelcast.monitor.TimedMemberState)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 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)1 Test (org.junit.Test)1