Search in sources :

Example 41 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class ClientCommandsDUnitTest method setupSystemWithSubAndNonSubClient.

private String[] setupSystemWithSubAndNonSubClient() throws Exception {
    disconnectAllFromDS();
    setUpJmxManagerOnVm0ThenConnect(getServerProperties());
    final VM manager = Host.getHost(0).getVM(0);
    final VM server1 = Host.getHost(0).getVM(1);
    final VM client1 = Host.getHost(0).getVM(2);
    final VM client2 = Host.getHost(0).getVM(3);
    port0 = startCacheServer(server1, 0, false, regionName);
    startNonDurableClient(client1, server1, port0);
    startNonSubscribedClient(client2, server1, port0);
    waitForMixedClients();
    String[] cliendIds = (String[]) manager.invoke("get client Ids", () -> {
        Cache cache = GemFireCacheImpl.getInstance();
        SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
        DistributedMember serverMember = getMember(server1);
        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
        return bean.getClientIds();
    });
    return cliendIds;
}
Also used : VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Example 42 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class ClientCommandsDUnitTest method waitForListClientMbean.

public void waitForListClientMbean() {
    final VM manager = Host.getHost(0).getVM(0);
    final VM server1 = Host.getHost(0).getVM(1);
    final DistributedMember serverMember = getMember(server1);
    assertNotNull(serverMember);
    manager.invoke(() -> {
        Awaitility.waitAtMost(2 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
            final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
            if (service == null) {
                getLogWriter().info("waitForListClientMbean Still probing for service");
                return false;
            } else {
                final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
                CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
                try {
                    if (bean != null) {
                        if (bean.getClientIds().length > 1) {
                            return true;
                        }
                    }
                    return false;
                } catch (Exception e) {
                    LogWrapper.getInstance().warning("waitForListClientMbean Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
                }
                return false;
            }
        });
    });
}
Also used : VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Example 43 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class DistributedSystemStatsDUnitTest method testDistributedSystemStats.

@Test
public void testDistributedSystemStats() throws Exception {
    this.managerVM.invoke("verifyMBeans", () -> {
        DistributedSystemMXBean distributedSystemMXBean = awaitDistributedSystemMXBean();
        // next block awaits all memberMXBeanName to refresh (getLastUpdateTime)
        SystemManagementService service = this.managementTestRule.getSystemManagementService();
        Set<DistributedMember> otherMemberSet = this.managementTestRule.getOtherNormalMembers();
        assertEquals(3, otherMemberSet.size());
        for (DistributedMember member : otherMemberSet) {
            MemberMXBean memberMXBean = awaitMemberMXBeanProxy(member);
            ObjectName memberMXBeanName = service.getMemberMBeanName(member);
            long lastRefreshTime = service.getLastUpdateTime(memberMXBeanName);
            await().until(() -> assertTrue(service.getLastUpdateTime(memberMXBeanName) > lastRefreshTime));
        }
    // TODO: add assertions for distributedSystemMXBean stats?
    });
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) DistributedMember(org.apache.geode.distributed.DistributedMember) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) MemberMXBean(org.apache.geode.management.MemberMXBean) ObjectName(javax.management.ObjectName) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 44 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class ClientCommandsDUnitTest method testDescribeClientWithServers3.

@Ignore("disabled for unknown reason")
@Test
public void testDescribeClientWithServers3() throws Exception {
    setupSystem3();
    String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
    final VM server1 = Host.getHost(0).getVM(1);
    final VM server2 = Host.getHost(0).getVM(3);
    final VM manager = Host.getHost(0).getVM(0);
    String serverName1 = (String) server1.invoke("get DistributedMemberID ", () -> getDistributedMemberId());
    String serverName2 = (String) server2.invoke("get DistributedMemberID ", () -> getDistributedMemberId());
    final DistributedMember serverMember1 = getMember(server1);
    String[] clientIds = (String[]) manager.invoke("get Client Ids", () -> {
        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember1);
        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
        return bean.getClientIds();
    });
    String clientId1 = "";
    for (String str : clientIds) {
        clientId1 = str;
        getLogWriter().info("testDescribeClientWithServers clientIds for server1 =" + str);
    }
    final DistributedMember serverMember2 = getMember(server2);
    String[] clientIds2 = (String[]) manager.invoke("get Client Ids", () -> {
        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port1, serverMember2);
        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
        return bean.getClientIds();
    });
    String clientId2 = "";
    for (String str : clientIds2) {
        clientId2 = str;
        getLogWriter().info("testDescribeClientWithServers clientIds for server2 =" + str);
    }
    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId1 + "\"";
    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 =" + commandString);
    CommandResult commandResultForClient1 = executeCommand(commandString);
    getLogWriter().info("testDescribeClientWithServers commandStr clientId1=" + commandResultForClient1);
    String resultAsString = commandResultToString(commandResultForClient1);
    getLogWriter().info("testDescribeClientWithServers commandStr clientId1 =" + resultAsString);
    assertTrue(Status.OK.equals(commandResultForClient1.getStatus()));
    verifyClientStats(commandResultForClient1, serverName1);
    commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId2 + "\"";
    getLogWriter().info("testDescribeClientWithServers commandStr1=" + commandString);
    CommandResult commandResultForClient2 = executeCommand(commandString);
    getLogWriter().info("testDescribeClientWithServers commandResult1=" + commandResultForClient2);
    resultAsString = commandResultToString(commandResultForClient2);
    getLogWriter().info("testDescribeClientWithServers resultAsString1=" + resultAsString);
    assertTrue(Status.OK.equals(commandResultForClient2.getStatus()));
    verifyClientStats(commandResultForClient2, serverName2);
    closeNonDurableClient(Host.getHost(0).getVM(2));
    closeCacheServer(Host.getHost(0).getVM(3));
    closeCacheServer(Host.getHost(0).getVM(1));
}
Also used : VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Ignore(org.junit.Ignore) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 45 with SystemManagementService

use of org.apache.geode.management.internal.SystemManagementService in project geode by apache.

the class LuceneManagementDUnitTest method getMBeanProxy.

private static LuceneServiceMXBean getMBeanProxy(DistributedMember member) {
    SystemManagementService service = (SystemManagementService) getManagementService();
    ObjectName objectName = MBeanJMXAdapter.getCacheServiceMBeanName(member, "LuceneService");
    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> assertNotNull(service.getMBeanProxy(objectName, LuceneServiceMXBean.class)));
    return service.getMBeanProxy(objectName, LuceneServiceMXBean.class);
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Aggregations

SystemManagementService (org.apache.geode.management.internal.SystemManagementService)83 ObjectName (javax.management.ObjectName)56 DistributedMember (org.apache.geode.distributed.DistributedMember)31 CacheServerMXBean (org.apache.geode.management.CacheServerMXBean)15 InternalCache (org.apache.geode.internal.cache.InternalCache)14 VM (org.apache.geode.test.dunit.VM)14 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)13 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)12 ExecutionException (java.util.concurrent.ExecutionException)11 CliMetaData (org.apache.geode.management.cli.CliMetaData)11 Result (org.apache.geode.management.cli.Result)11 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)11 ResourceOperation (org.apache.geode.management.internal.security.ResourceOperation)11 CliCommand (org.springframework.shell.core.annotation.CliCommand)11 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)10 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)8 Test (org.junit.Test)8 GatewaySenderMXBean (org.apache.geode.management.GatewaySenderMXBean)7 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)7 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)7