Search in sources :

Example 11 with MemberMXBean

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

the class DistributedSystemStatsDUnitTest method awaitMemberMXBeanProxy.

private MemberMXBean awaitMemberMXBeanProxy(final DistributedMember member) {
    SystemManagementService service = this.managementTestRule.getSystemManagementService();
    ObjectName objectName = service.getMemberMBeanName(member);
    String alias = "Awaiting MemberMXBean proxy for " + member;
    await(alias).until(() -> assertThat(service.getMBeanProxy(objectName, MemberMXBean.class)).isNotNull());
    return service.getMBeanProxy(objectName, MemberMXBean.class);
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) ObjectName(javax.management.ObjectName) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 12 with MemberMXBean

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

the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBeanWithProcessId.

@Test
public void testQueryForMemberMXBeanWithProcessId() throws Exception {
    final Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    props.setProperty("name", getUniqueName());
    new CacheFactory(props).create();
    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
    final QueryExp constraint = Query.eq(Query.attr("ProcessId"), Query.value(ProcessUtils.identifyPid()));
    waitForMemberMXBean(mbeanServer, pattern);
    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
    assertFalse(mbeanNames.isEmpty());
    assertEquals(1, mbeanNames.size());
    final ObjectName objectName = mbeanNames.iterator().next();
    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
    assertNotNull(mbean);
    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
    assertEquals(getUniqueName(), mbean.getName());
    assertEquals(getUniqueName(), mbean.getMember());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 13 with MemberMXBean

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

the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBean.

@Test
public void testQueryForMemberMXBean() throws Exception {
    final Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    props.setProperty("name", getUniqueName());
    new CacheFactory(props).create();
    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
    waitForMemberMXBean(mbeanServer, pattern);
    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, null);
    assertFalse(mbeanNames.isEmpty());
    assertEquals("mbeanNames=" + mbeanNames, 1, mbeanNames.size());
    final ObjectName objectName = mbeanNames.iterator().next();
    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
    assertNotNull(mbean);
    assertEquals(ProcessUtils.identifyPid(), mbean.getProcessId());
    assertEquals(getUniqueName(), mbean.getName());
    assertEquals(getUniqueName(), mbean.getMember());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 14 with MemberMXBean

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

the class LauncherMemberMXBeanIntegrationTest method testQueryForMemberMXBeanWithMemberName.

@Test
public void testQueryForMemberMXBeanWithMemberName() throws Exception {
    final Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "");
    props.setProperty("name", getUniqueName());
    new CacheFactory(props).create();
    final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
    final ObjectName pattern = ObjectName.getInstance("GemFire:type=Member,*");
    final QueryExp constraint = Query.eq(Query.attr("Name"), Query.value(getUniqueName()));
    waitForMemberMXBean(mbeanServer, pattern);
    final Set<ObjectName> mbeanNames = mbeanServer.queryNames(pattern, constraint);
    assertFalse(mbeanNames.isEmpty());
    assertEquals(1, mbeanNames.size());
    final ObjectName objectName = mbeanNames.iterator().next();
    final MemberMXBean mbean = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, objectName, MemberMXBean.class, false);
    assertNotNull(mbean);
    assertEquals(getUniqueName(), mbean.getMember());
}
Also used : Properties(java.util.Properties) CacheFactory(org.apache.geode.cache.CacheFactory) MemberMXBean(org.apache.geode.management.MemberMXBean) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 15 with MemberMXBean

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

the class GemfireDataCommandsDUnitTest method doTestSelectProjectionProcessCommand.

public void doTestSelectProjectionProcessCommand() {
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            Random random = new Random(System.nanoTime());
            int randomInteger = random.nextInt(COUNT);
            String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from " + DATA_PAR_REGION_NAME_PATH + " where ID <= " + randomInteger + "\" --interactive=false";
            ManagementService service = ManagementService.getExistingManagementService(getCache());
            MemberMXBean member = service.getMemberMXBean();
            String cmdResult = member.processCommand(query);
            assertNotNull(cmdResult);
            getLogWriter().info("Text Command Output : " + cmdResult);
        }
    });
}
Also used : ManagementService(org.apache.geode.management.ManagementService) Random(java.util.Random) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) MemberMXBean(org.apache.geode.management.MemberMXBean)

Aggregations

MemberMXBean (org.apache.geode.management.MemberMXBean)25 ObjectName (javax.management.ObjectName)9 Test (org.junit.Test)6 CliMetaData (org.apache.geode.management.cli.CliMetaData)5 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 CliCommand (org.springframework.shell.core.annotation.CliCommand)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)4 CacheFactory (org.apache.geode.cache.CacheFactory)4 ManagementException (org.apache.geode.management.ManagementException)4 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)4 MXBeanProvider.getMemberMXBean (org.apache.geode.management.internal.cli.shell.MXBeanProvider.getMemberMXBean)4 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 ManagementService (org.apache.geode.management.ManagementService)3 Type (java.lang.reflect.Type)2 ListenerNotFoundException (javax.management.ListenerNotFoundException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectInstance (javax.management.ObjectInstance)2 DistributedMember (org.apache.geode.distributed.DistributedMember)2 LocatorLauncher (org.apache.geode.distributed.LocatorLauncher)2