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);
}
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());
}
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());
}
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());
}
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);
}
});
}
Aggregations