Search in sources :

Example 11 with CacheServerMXBean

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

the class DistributedSystemBridge method fetchCacheServerObjectName.

public ObjectName fetchCacheServerObjectName(String member, int port) throws Exception {
    validateMember(member);
    ObjectName serverName = MBeanJMXAdapter.getClientServiceMBeanName(port, member);
    CacheServerMXBean bean = service.getMBeanInstance(serverName, CacheServerMXBean.class);
    if (bean != null) {
        return serverName;
    } else {
        bean = service.getLocalCacheServerMXBean(port);
        if (bean != null) {
            return serverName;
        } else {
            throw new Exception(ManagementStrings.CACHE_SERVER_MBEAN_NOT_FOUND_IN_DS.toString());
        }
    }
}
Also used : CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) ManagementException(org.apache.geode.management.ManagementException) ListenerNotFoundException(javax.management.ListenerNotFoundException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectName(javax.management.ObjectName)

Example 12 with CacheServerMXBean

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

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

the class TestClientIdsDUnitTest method verifyClientIds.

private void verifyClientIds(final DistributedMember serverMember, final int serverPort) throws Exception {
    CacheServerMXBean cacheServerMXBean = awaitCacheServerMXBean(serverMember, serverPort);
    await().until(() -> {
        try {
            assertThat(cacheServerMXBean.getClientIds()).hasSize(2);
        } catch (Exception e) {
            throw new Error(e);
        }
    });
    // TODO: write better assertions
    assertThat(cacheServerMXBean.getClientIds()).hasSize(2);
}
Also used : CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) IOException(java.io.IOException)

Example 14 with CacheServerMXBean

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

the class TestClientIdsDUnitTest method awaitCacheServerMXBean.

private CacheServerMXBean awaitCacheServerMXBean(final DistributedMember serverMember, final int port) {
    SystemManagementService service = this.managementTestRule.getSystemManagementService();
    ObjectName objectName = service.getCacheServerMBeanName(port, serverMember);
    await().until(() -> assertThat(service.getMBeanProxy(objectName, CacheServerMXBean.class)).isNotNull());
    return service.getMBeanProxy(objectName, CacheServerMXBean.class);
}
Also used : CacheServerMXBean(org.apache.geode.management.CacheServerMXBean) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName)

Example 15 with CacheServerMXBean

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

the class ClientCommandsDUnitTest method setupSystem2.

private void setupSystem2() 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);
    startNonDurableClient(client2, server1, port0);
    setupCqsOnVM(client1);
    setupCqsOnVM(client2);
    waitForMbean();
    clientId = (String) manager.invoke("get client Id", () -> {
        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) 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