use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method setupCacheServersForTestExecute.
private Set<DiskStoreDetails.CacheServerDetails> setupCacheServersForTestExecute(final InternalCache mockCache, final String diskStoreName) {
final CacheServer mockCacheServer1 = mockContext.mock(CacheServer.class, "CacheServer1");
final CacheServer mockCacheServer2 = mockContext.mock(CacheServer.class, "CacheServer2");
final CacheServer mockCacheServer3 = mockContext.mock(CacheServer.class, "CacheServer3");
final ClientSubscriptionConfig cacheServer1ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer1ClientSubscriptionConfig");
final ClientSubscriptionConfig cacheServer3ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer3ClientSubscriptionConfig");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getCacheServers();
will(returnValue(Arrays.asList(mockCacheServer1, mockCacheServer2, mockCacheServer3)));
exactly(2).of(mockCacheServer1).getClientSubscriptionConfig();
will(returnValue(cacheServer1ClientSubscriptionConfig));
oneOf(cacheServer1ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(diskStoreName));
oneOf(mockCacheServer2).getClientSubscriptionConfig();
will(returnValue(null));
exactly(2).of(mockCacheServer3).getClientSubscriptionConfig();
will(returnValue(cacheServer3ClientSubscriptionConfig));
oneOf(cacheServer3ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(""));
oneOf(mockCacheServer1).getBindAddress();
will(returnValue("10.127.0.1"));
oneOf(mockCacheServer1).getPort();
will(returnValue(10123));
oneOf(mockCacheServer1).getHostnameForClients();
will(returnValue("rodan"));
}
});
return CollectionUtils.asSet(createCacheServerDetails("10.127.0.1", 10123, "rodan"));
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testSetCacheServerDetails.
@Test
public void testSetCacheServerDetails() {
final String diskStoreName = "testDiskStore";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final CacheServer mockCacheServer1 = mockContext.mock(CacheServer.class, "CacheServer1");
final CacheServer mockCacheServer2 = mockContext.mock(CacheServer.class, "CacheServer2");
final CacheServer mockCacheServer3 = mockContext.mock(CacheServer.class, "CacheServer3");
final ClientSubscriptionConfig mockCacheServer1ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer1ClientSubscriptionConfig");
final ClientSubscriptionConfig mockCacheServer2ClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "cacheServer2ClientSubscriptionConfig");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getCacheServers();
will(returnValue(Arrays.asList(mockCacheServer1, mockCacheServer2, mockCacheServer3)));
exactly(2).of(mockCacheServer1).getClientSubscriptionConfig();
will(returnValue(mockCacheServer1ClientSubscriptionConfig));
oneOf(mockCacheServer1ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(diskStoreName));
oneOf(mockCacheServer1).getBindAddress();
will(returnValue("10.127.255.1"));
oneOf(mockCacheServer1).getPort();
will(returnValue(65536));
oneOf(mockCacheServer1).getHostnameForClients();
will(returnValue("gemini"));
exactly(2).of(mockCacheServer2).getClientSubscriptionConfig();
will(returnValue(mockCacheServer2ClientSubscriptionConfig));
oneOf(mockCacheServer2ClientSubscriptionConfig).getDiskStoreName();
will(returnValue(" "));
oneOf(mockCacheServer3).getClientSubscriptionConfig();
will(returnValue(null));
exactly(3).of(mockDiskStore).getName();
will(returnValue(diskStoreName));
}
});
final Set<DiskStoreDetails.CacheServerDetails> expectedCacheServerDetails = CollectionUtils.asSet(createCacheServerDetails("10.127.255.1", 65536, "gemini"));
final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
function.setCacheServerDetails(mockCache, mockDiskStore, diskStoreDetails);
assertCacheServerDetails(expectedCacheServerDetails, diskStoreDetails);
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testIsCacheServerUsingDiskStoreWhenUsingDefaultDiskStore.
@Test
public void testIsCacheServerUsingDiskStoreWhenUsingDefaultDiskStore() {
final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
final ClientSubscriptionConfig mockClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "ClientSubscriptionConfig");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
exactly(2).of(mockCacheServer).getClientSubscriptionConfig();
will(returnValue(mockClientSubscriptionConfig));
oneOf(mockClientSubscriptionConfig).getDiskStoreName();
will(returnValue(""));
oneOf(mockDiskStore).getName();
will(returnValue(DiskStoreDetails.DEFAULT_DISK_STORE_NAME));
}
});
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
assertTrue(function.isUsingDiskStore(mockCacheServer, mockDiskStore));
}
use of org.apache.geode.cache.server.CacheServer in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testIsCacheServerUsingDiskStore.
@Test
public void testIsCacheServerUsingDiskStore() {
final String diskStoreName = "testDiskStore";
final CacheServer mockCacheServer = mockContext.mock(CacheServer.class, "CacheServer");
final ClientSubscriptionConfig mockClientSubscriptionConfig = mockContext.mock(ClientSubscriptionConfig.class, "ClientSubscriptionConfig");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
exactly(2).of(mockCacheServer).getClientSubscriptionConfig();
will(returnValue(mockClientSubscriptionConfig));
oneOf(mockClientSubscriptionConfig).getDiskStoreName();
will(returnValue(diskStoreName));
oneOf(mockDiskStore).getName();
will(returnValue(diskStoreName));
}
});
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(null);
assertTrue(function.isUsingDiskStore(mockCacheServer, mockDiskStore));
}
use of org.apache.geode.cache.server.CacheServer 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