use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class GFSnapshotDUnitTest method createAndStartClient.
private void createAndStartClient(final int locatorPort, final String serverHostName) {
ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
clientCacheFactory.set("log-level", "config").addPoolLocator(serverHostName, locatorPort);
ClientCache clientCache = clientCacheFactory.create();
clientCache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("TestRegion");
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class GFSnapshotDUnitTest method testDataExportAndIterate.
@Test
public void testDataExportAndIterate() throws IOException, ClassNotFoundException {
int locatorPort = AvailablePortHelper.getRandomAvailableTCPPort();
String serverHostName = NetworkUtils.getServerHostName(host);
Properties properties = configureCommonProperties(new Properties());
locator.invoke("Start Locator", () -> configureAndStartLocator(locatorPort, serverHostName, properties));
server.invoke("Start Server", () -> configureAndStartServer(locatorPort, serverHostName, properties));
client.invoke("Start client", () -> {
createAndStartClient(locatorPort, serverHostName);
return null;
});
client.invoke("Populate data", () -> populateDataOnClient());
String snapshotFilePath = server.invoke("Export data snapshot", () -> createSnapshot());
client.invoke("Iterate over snapshot", () -> {
ClientCache clientCache = ClientCacheFactory.getAnyInstance();
clientCache.close();
createAndStartClient(locatorPort, serverHostName);
iterateOverSnapshot(snapshotFilePath);
});
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class CompressionRegionConfigDUnitTest method putUsingClientVM.
/**
* Performs a put operation on a client virtual machine.
*
* @param vm a client.
* @param key the key to put.
* @param value the value to put.
* @return the old value.
*/
private String putUsingClientVM(final VM vm, final String key, final String value) {
return (String) vm.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
ClientCache cache = getClientCache(getClientCacheFactory(getLocatorPort()));
Region<String, String> region = cache.getRegion(REGION_NAME);
assertNotNull(region);
return region.put(key, value);
}
});
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class CompressionRegionConfigDUnitTest method getUsingClientVM.
/**
* Performs a get operation on a client.
*
* @param vm a client.
* @param key a region entry key.
* @return the value.
*/
private String getUsingClientVM(final VM vm, final String key) {
return (String) vm.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
ClientCache cache = getClientCache(getClientCacheFactory(getLocatorPort()));
Region<String, String> region = cache.getRegion(REGION_NAME);
assertNotNull(region);
return region.get(key);
}
});
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class RegionCreateDestroyDUnitTest method testCreateInvalidRegion.
@Test
public void testCreateInvalidRegion() throws InterruptedException {
Cache serverCache = getCache();
try {
serverCache.createRegionFactory(RegionShortcut.REPLICATE).create(BAD_REGION_NAME);
} catch (IllegalArgumentException iae) {
assertEquals("Region names may only be alphanumeric and may contain hyphens or underscores: Bad@Region", iae.getMessage());
}
try {
startServer(serverCache);
} catch (IOException e) {
fail(e.getMessage());
}
client1.invoke(() -> {
ClientCache cache = new ClientCacheFactory(createClientProperties()).setPoolSubscriptionEnabled(true).addPoolServer("localhost", serverPort).create();
try {
cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(BAD_REGION_NAME);
fail("Should have thrown an IllegalArgumentException");
} catch (IllegalArgumentException iae) {
assertEquals("Region names may only be alphanumeric and may contain hyphens or underscores: Bad@Region", iae.getMessage());
}
});
}
Aggregations