use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class CliUtilDUnitTest method getRegionAssociatedMembers.
public void getRegionAssociatedMembers() {
String region_group1 = "/region_group1";
String region1 = "/region1";
String region_member2_group1 = "/region_member2_group1";
InternalCache cache = getCache();
Set<DistributedMember> set = CliUtil.getRegionAssociatedMembers(region1, cache, true);
assertNotNull(set);
assertEquals(4, set.size());
assertEquals(true, containsMember(set, MEMBER_1_GROUP1));
assertEquals(true, containsMember(set, MEMBER_2_GROUP1));
assertEquals(true, containsMember(set, MEMBER_1_GROUP2));
assertEquals(true, containsMember(set, MEMBER_2_GROUP2));
/*
* TODO: This is failing because last param is not considered in method set =
* CliUtil.getRegionAssociatedMembers(region1, cache, false); assertNotNull(set);
* assertIndexDetailsEquals(1, set.size());
*/
set = CliUtil.getRegionAssociatedMembers(region_group1, cache, true);
assertNotNull(set);
assertEquals(2, set.size());
assertEquals(true, containsMember(set, MEMBER_1_GROUP1));
assertEquals(true, containsMember(set, MEMBER_2_GROUP1));
set = CliUtil.getRegionAssociatedMembers(region_member2_group1, cache, true);
assertNotNull(set);
assertEquals(1, set.size());
assertEquals(true, containsMember(set, MEMBER_2_GROUP1));
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class CliUtilDUnitTest method getDistributedMemberByNameOrId.
public void getDistributedMemberByNameOrId(String name, String id) {
DistributedMember member = CliUtil.getDistributedMemberByNameOrId(name);
assertNotNull(member);
member = CliUtil.getDistributedMemberByNameOrId(id);
assertNotNull(member);
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ShowMetricsDUnitTest method testShowMetricsRegionFromMember.
@Test
public void testShowMetricsRegionFromMember() throws ClassNotFoundException, IOException, InterruptedException {
systemSetUp();
Cache cache = getCache();
final DistributedMember distributedMember = cache.getDistributedSystem().getDistributedMember();
final String exportFileName = "regionOnAMemberReport.csv";
final String regionName = "REGION1";
SerializableCallable showMetricCmd = new SerializableCallable() {
@Override
public Object call() throws Exception {
WaitCriterion wc = createMBeanWaitCriterion(4, regionName, distributedMember, 0);
waitForCriterion(wc, 5000, 500, true);
CommandProcessor commandProcessor = new CommandProcessor();
Result result = commandProcessor.createCommandStatement("show metrics --region=" + regionName + " --member=" + distributedMember.getName() + " --file=" + exportFileName, Collections.EMPTY_MAP).process();
String resultAsString = commandResultToString((CommandResult) result);
assertEquals(resultAsString, true, result.getStatus().equals(Status.OK));
assertTrue(result.hasIncomingFiles());
result.saveIncomingFiles(null);
File file = new File(exportFileName);
file.deleteOnExit();
assertTrue(file.exists());
file.delete();
return resultAsString;
}
};
// Invoke the command in the Manager VM
final VM managerVm = Host.getHost(0).getVM(0);
Object managerResultObj = managerVm.invoke(showMetricCmd);
String managerResult = (String) managerResultObj;
getLogWriter().info("#SB Manager");
getLogWriter().info(managerResult);
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ListIndexFunctionJUnitTest method testExecuteThrowsException.
@Test(expected = RuntimeException.class)
public void testExecuteThrowsException() throws Throwable {
final Cache mockCache = mockContext.mock(Cache.class, "Cache");
final DistributedSystem mockDistributedSystem = mockContext.mock(DistributedSystem.class, "DistributedSystem");
final DistributedMember mockDistributedMember = mockContext.mock(DistributedMember.class, "DistributedMember");
final QueryService mockQueryService = mockContext.mock(QueryService.class, "QueryService");
final FunctionContext mockFunctionContext = mockContext.mock(FunctionContext.class, "FunctionContext");
final TestResultSender testResultSender = new TestResultSender();
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getDistributedSystem();
will(returnValue(mockDistributedSystem));
oneOf(mockCache).getQueryService();
will(returnValue(mockQueryService));
oneOf(mockDistributedSystem).getDistributedMember();
will(returnValue(mockDistributedMember));
oneOf(mockQueryService).getIndexes();
will(throwException(new RuntimeException("expected")));
oneOf(mockFunctionContext).getResultSender();
will(returnValue(testResultSender));
}
});
final ListIndexFunction function = createListIndexFunction(mockCache);
function.execute(mockFunctionContext);
try {
testResultSender.getResults();
} catch (Throwable t) {
assertTrue(t instanceof RuntimeException);
assertEquals("expected", t.getMessage());
throw t;
}
}
use of org.apache.geode.distributed.DistributedMember in project geode by apache.
the class ShowMetricsDUnitTest method testShowMetricsMember.
// GEODE-1764
@Category(FlakyTest.class)
@Test
public void testShowMetricsMember() throws ClassNotFoundException, IOException, InterruptedException {
systemSetUp();
Cache cache = getCache();
final DistributedMember distributedMember = cache.getDistributedSystem().getDistributedMember();
final String exportFileName = "memberMetricReport.csv";
int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(1);
CacheServer cs = getCache().addCacheServer();
cs.setPort(ports[0]);
cs.start();
final int cacheServerPort = cs.getPort();
SerializableCallable showMetricCmd = new SerializableCallable() {
@Override
public Object call() throws Exception {
WaitCriterion wc = createMBeanWaitCriterion(3, "", distributedMember, 0);
waitForCriterion(wc, 5000, 500, true);
wc = createMBeanWaitCriterion(5, "", distributedMember, cacheServerPort);
waitForCriterion(wc, 10000, 500, true);
final String command = CliStrings.SHOW_METRICS + " --" + CliStrings.SHOW_METRICS__MEMBER + "=" + distributedMember.getId() + " --" + CliStrings.SHOW_METRICS__CACHESERVER__PORT + "=" + cacheServerPort + " --" + CliStrings.SHOW_METRICS__FILE + "=" + exportFileName;
CommandProcessor commandProcessor = new CommandProcessor();
Result result = commandProcessor.createCommandStatement(command, Collections.EMPTY_MAP).process();
String resultAsString = commandResultToString((CommandResult) result);
assertEquals(resultAsString, true, result.getStatus().equals(Status.OK));
assertTrue(result.hasIncomingFiles());
result.saveIncomingFiles(null);
File file = new File(exportFileName);
file.deleteOnExit();
assertTrue(file.exists());
file.delete();
return resultAsString;
}
};
// Invoke the command in the Manager VM
final VM managerVm = Host.getHost(0).getVM(0);
Object managerResultObj = managerVm.invoke(showMetricCmd);
String managerResult = (String) managerResultObj;
getLogWriter().info("#SB Manager");
getLogWriter().info(managerResult);
cs.stop();
}
Aggregations