Search in sources :

Example 1 with MemberStateImpl

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

the class TimedMemberStateFactory method createTimedMemberState.

@Nonnull
public TimedMemberState createTimedMemberState() {
    MemberStateImpl memberState = new MemberStateImpl();
    Collection<StatisticsAwareService> services = instance.node.nodeEngine.getServices(StatisticsAwareService.class);
    TimedMemberState timedMemberState = new TimedMemberState();
    createMemberState(memberState, services);
    timedMemberState.setMaster(instance.node.isMaster());
    timedMemberState.setMemberList(new ArrayList<>());
    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);
    timedMemberState.setClusterName(instance.getConfig().getClusterName());
    SSLConfig sslConfig = getActiveMemberNetworkConfig(instance.getConfig()).getSSLConfig();
    timedMemberState.setSslEnabled(sslConfig != null && sslConfig.isEnabled());
    timedMemberState.setLite(instance.node.isLiteMember());
    SocketInterceptorConfig interceptorConfig = getActiveMemberNetworkConfig(instance.getConfig()).getSocketInterceptorConfig();
    timedMemberState.setSocketInterceptorEnabled(interceptorConfig != null && interceptorConfig.isEnabled());
    ManagementCenterConfig managementCenterConfig = instance.node.getConfig().getManagementCenterConfig();
    timedMemberState.setScriptingEnabled(managementCenterConfig.isScriptingEnabled());
    timedMemberState.setConsoleEnabled(managementCenterConfig.isConsoleEnabled());
    timedMemberState.setMcDataAccessEnabled(managementCenterConfig.isDataAccessEnabled());
    return timedMemberState;
}
Also used : SSLConfig(com.hazelcast.config.SSLConfig) StatisticsAwareService(com.hazelcast.internal.services.StatisticsAwareService) Address(com.hazelcast.cluster.Address) SocketInterceptorConfig(com.hazelcast.config.SocketInterceptorConfig) MemberStateImpl(com.hazelcast.internal.monitor.impl.MemberStateImpl) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ManagementCenterConfig(com.hazelcast.config.ManagementCenterConfig) Member(com.hazelcast.cluster.Member) CPMember(com.hazelcast.cp.CPMember) Nonnull(javax.annotation.Nonnull)

Example 2 with MemberStateImpl

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

the class TimedMemberStateTest method testOnlyCachesWithStatsEnabled_areReportedInTimedMemberState.

@Test
public void testOnlyCachesWithStatsEnabled_areReportedInTimedMemberState() {
    // create 100 caches with stats enabled
    for (int i = 0; i < 100; i++) {
        hz.getCacheManager().getCache(CACHE_WITH_STATS_PREFIX + i);
    }
    // create 50 caches with stats disabled
    for (int i = 0; i < 50; i++) {
        ICache cacheWithoutStats = hz.getCacheManager().getCache(CACHE_WITHOUT_STATS_PREFIX + i);
        // explicitly request local stats -> this registers an empty stats object in CacheService
        cacheWithoutStats.getLocalCacheStatistics();
    }
    MemberStateImpl memberState = createState().getMemberState();
    for (int i = 0; i < 100; i++) {
        assertContains(memberState.getCachesWithStats(), getDistributedObjectName(CACHE_WITH_STATS_PREFIX + i));
        assertNotContains(memberState.getCachesWithStats(), getDistributedObjectName(CACHE_WITHOUT_STATS_PREFIX + i));
    }
}
Also used : MemberStateImpl(com.hazelcast.internal.monitor.impl.MemberStateImpl) ICache(com.hazelcast.cache.ICache) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with MemberStateImpl

use of com.hazelcast.internal.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");
    JsonArray jsonMemberList = getArray(json, "memberList");
    memberList = new ArrayList<String>(jsonMemberList.size());
    for (JsonValue member : jsonMemberList.values()) {
        memberList.add(member.asString());
    }
    JsonObject jsonMemberState = getObject(json, "memberState");
    memberState = new MemberStateImpl();
    memberState.fromJson(jsonMemberState);
    sslEnabled = getBoolean(json, "sslEnabled", false);
    lite = getBoolean(json, "lite");
    socketInterceptorEnabled = getBoolean(json, "socketInterceptorEnabled");
    scriptingEnabled = getBoolean(json, "scriptingEnabled");
    consoleEnabled = getBoolean(json, "consoleEnabled");
    mcDataAccessEnabled = getBoolean(json, "mcDataAccessEnabled");
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) MemberStateImpl(com.hazelcast.internal.monitor.impl.MemberStateImpl) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString)

Aggregations

MemberStateImpl (com.hazelcast.internal.monitor.impl.MemberStateImpl)3 ICache (com.hazelcast.cache.ICache)1 Address (com.hazelcast.cluster.Address)1 Member (com.hazelcast.cluster.Member)1 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)1 ManagementCenterConfig (com.hazelcast.config.ManagementCenterConfig)1 SSLConfig (com.hazelcast.config.SSLConfig)1 SocketInterceptorConfig (com.hazelcast.config.SocketInterceptorConfig)1 CPMember (com.hazelcast.cp.CPMember)1 JsonArray (com.hazelcast.internal.json.JsonArray)1 JsonObject (com.hazelcast.internal.json.JsonObject)1 JsonValue (com.hazelcast.internal.json.JsonValue)1 StatisticsAwareService (com.hazelcast.internal.services.StatisticsAwareService)1 JsonUtil.getString (com.hazelcast.internal.util.JsonUtil.getString)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Nonnull (javax.annotation.Nonnull)1 Test (org.junit.Test)1