use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ClientCommandsDUnitTest method waitForMbean.
public void waitForMbean() {
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("waitForMbean Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
try {
ClientHealthStatus stats = bean.showClientStats(bean.getClientIds()[0]);
Map<String, String> poolStats = stats.getPoolStats();
if (poolStats.size() > 0) {
Iterator<Entry<String, String>> it = poolStats.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> entry = it.next();
String poolStatsStr = entry.getValue();
String[] str = poolStatsStr.split(";");
int numCqs = Integer.parseInt(str[3].substring(str[3].indexOf("=") + 1));
if (numCqs == 3) {
return true;
}
}
}
return false;
} catch (Exception e) {
LogWrapper.getInstance().warning("waitForMbean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
}
return false;
}
});
});
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ClientCommandsDUnitTest method waitForListClientMbean3.
public void waitForListClientMbean3() {
final VM manager = Host.getHost(0).getVM(0);
final VM server1 = Host.getHost(0).getVM(1);
final VM server2 = Host.getHost(0).getVM(3);
final DistributedMember serverMember1 = getMember(server1);
final DistributedMember serverMember2 = getMember(server2);
assertNotNull(serverMember1);
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("waitForListClientMbean3 Still probing for service");
return false;
} else {
final ObjectName cacheServerMBeanName1 = service.getCacheServerMBeanName(port0, serverMember1);
final ObjectName cacheServerMBeanName2 = service.getCacheServerMBeanName(port1, serverMember2);
CacheServerMXBean bean1 = service.getMBeanProxy(cacheServerMBeanName1, CacheServerMXBean.class);
CacheServerMXBean bean2 = service.getMBeanProxy(cacheServerMBeanName2, CacheServerMXBean.class);
try {
if (bean1 != null && bean2 != null) {
if (bean1.getClientIds().length > 0 && bean2.getClientIds().length > 0) {
return true;
}
}
return false;
} catch (Exception e) {
LogWrapper.getInstance().warning("waitForListClientMbean3 Exception in waitForListClientMbean ::: " + CliUtil.stackTraceAsString(e));
}
return false;
}
});
});
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ClientCommandsDUnitTest method waitForMixedClients.
public void waitForMixedClients() {
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(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
try {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
getLogWriter().info("waitForMixedClients Still probing for service");
return false;
} else {
getLogWriter().info("waitForMixedClients 1");
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
getLogWriter().info("waitForMixedClients 2 cacheServerMBeanName " + cacheServerMBeanName);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
getLogWriter().info("waitForMixedClients 2 bean " + bean);
if (bean.getClientIds().length > 1) {
return true;
}
}
} catch (Exception e) {
LogWrapper.getInstance().warning("waitForMixedClients Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
}
return false;
});
});
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ClientCommandsDUnitTest method testListClient.
// GEODE-908: random ports, BindException, time sensitive, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testListClient() throws Exception {
setupSystemForListClient();
final VM manager = Host.getHost(0).getVM(0);
String commandString = CliStrings.LIST_CLIENTS;
getLogWriter().info("testListClient commandStr=" + commandString);
waitForListClientMbean();
final VM server1 = Host.getHost(0).getVM(1);
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 serverName = (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testListClient commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testListClient 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);
getLogWriter().info("testListClients serverNames : " + serverNames);
getLogWriter().info("testListClients clientNames : " + clientNames);
assertEquals(2, serverNames.size());
assertEquals(2, clientNames.size());
assertTrue(clientNames.contains(clientIds[0]));
assertTrue(clientNames.contains(clientIds[1]));
serverName = serverName.replace(":", "-");
getLogWriter().info("testListClients serverName : " + serverName);
for (String str : serverNames) {
assertTrue(str.contains(serverName));
}
closeNonDurableClient(Host.getHost(0).getVM(2));
closeCacheServer(Host.getHost(0).getVM(1));
closeCacheServer(Host.getHost(0).getVM(3));
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ClientCommandsDUnitTest method waitForNonSubCliMBean.
public void waitForNonSubCliMBean() {
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(5 * 60, TimeUnit.SECONDS).pollDelay(2, TimeUnit.SECONDS).until(() -> {
try {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
if (service == null) {
getLogWriter().info("waitForNonSubScribedClientMBean Still probing for service");
return false;
} else {
getLogWriter().info("waitForNonSubScribedClientMBean 1");
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
getLogWriter().info("waitForNonSubScribedClientMBean 2 cacheServerMBeanName " + cacheServerMBeanName);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
getLogWriter().info("waitForNonSubScribedClientMBean 2 bean " + bean);
if (bean.getClientIds().length > 0) {
return true;
}
}
} catch (Exception e) {
LogWrapper.getInstance().warning("waitForNonSubScribedClientMBean Exception in waitForMbean ::: " + CliUtil.stackTraceAsString(e));
}
return false;
});
});
}
Aggregations