Search in sources :

Example 16 with CacheServerMXBean

use of org.apache.geode.management.CacheServerMXBean in project geode by apache.

the class ClientCommandsDUnitTest method setUpNonSubscribedClient.

private void setUpNonSubscribedClient() 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 server2 = Host.getHost(0).getVM(3);
    port0 = startCacheServer(server1, 0, false, regionName);
    startCacheServer(server2, 0, false, regionName);
    startNonSubscribedClient(client1, server1, port0);
    setupCqsOnVM(client1);
    waitForNonSubCliMBean();
    clientId = (String) manager.invoke(new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            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()[0];
        }
    });
}
Also used : VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) DistributedMember(org.apache.geode.distributed.DistributedMember) CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Example 17 with CacheServerMXBean

use of org.apache.geode.management.CacheServerMXBean in project geode by apache.

the class ClientCommandsDUnitTest method testListClientForServers.

@Test
public void testListClientForServers() throws Exception {
    setupSystem3();
    final VM manager = Host.getHost(0).getVM(0);
    String commandString = CliStrings.LIST_CLIENTS;
    System.out.println("testListClientForServers commandStr=" + commandString);
    final VM server1 = Host.getHost(0).getVM(1);
    final VM server2 = Host.getHost(0).getVM(3);
    final DistributedMember serverMember = getMember(server1);
    String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
        final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
        final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
        CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
        return bean.getClientIds();
    });
    String serverName1 = (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
    String serverName2 = (String) server2.invoke("get distributed member Id", () -> getDistributedMemberId());
    CommandResult commandResult = executeCommand(commandString);
    System.out.println("testListClientForServers commandResult=" + commandResult);
    String resultAsString = commandResultToString(commandResult);
    System.out.println("testListClientForServers resultAsString=" + resultAsString);
    assertTrue(Status.OK.equals(commandResult.getStatus()));
    CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
    SectionResultData section = resultData.retrieveSection("section1");
    assertNotNull(section);
    TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
    assertNotNull(tableRsultData);
    List<String> serverNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
    List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
    serverName1 = serverName1.replace(":", "-");
    serverName2 = serverName2.replace(":", "-");
    System.out.println("testListClientForServers serverNames : " + serverNames);
    System.out.println("testListClientForServers serverName1 : " + serverName1);
    System.out.println("testListClientForServers serverName2 : " + serverName2);
    System.out.println("testListClientForServers clientNames : " + clientNames);
    for (String client : clientIds) {
        assertTrue(clientNames.contains(client));
    }
    for (String server : serverNames) {
        assertTrue(server.contains(serverName1) || server.contains(serverName2));
    }
    closeNonDurableClient(Host.getHost(0).getVM(2));
    closeCacheServer(Host.getHost(0).getVM(1));
    closeCacheServer(Host.getHost(0).getVM(3));
}
Also used : CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) VM(org.apache.geode.test.dunit.VM) DistributedMember(org.apache.geode.distributed.DistributedMember) SectionResultData(org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData) 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) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 18 with CacheServerMXBean

use of org.apache.geode.management.CacheServerMXBean 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 19 with CacheServerMXBean

use of org.apache.geode.management.CacheServerMXBean 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)

Aggregations

CacheServerMXBean (org.apache.geode.management.CacheServerMXBean)19 ObjectName (javax.management.ObjectName)18 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)15 DistributedMember (org.apache.geode.distributed.DistributedMember)14 VM (org.apache.geode.test.dunit.VM)13 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)5 SectionResultData (org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData)5 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)4 InternalCache (org.apache.geode.internal.cache.InternalCache)3 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 ClientHealthStatus (org.apache.geode.management.ClientHealthStatus)2 ManagementService (org.apache.geode.management.ManagementService)2 CliMetaData (org.apache.geode.management.cli.CliMetaData)2 Result (org.apache.geode.management.cli.Result)2