use of org.apache.geode.cache.client.ClientCacheFactory 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());
}
});
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class ClientsWithVersioningRetryDUnitTest method createClientRegion.
private void createClientRegion(final VM vm, final int port1, final int port2, final boolean threadLocalConnections) {
SerializableCallable createRegion = new SerializableCallable("create client region in " + vm) {
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port1);
cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port2);
cf.setPoolPRSingleHopEnabled(false);
cf.setPoolThreadLocalConnections(threadLocalConnections);
cf.setPoolReadTimeout(10 * 60 * 1000);
ClientCache cache = getClientCache(cf);
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("region");
return null;
}
};
vm.invoke(createRegion);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class PdxClientServerDUnitTest method createClientRegion.
private void createClientRegion(final VM vm, final int port, final boolean threadLocalConnections, final boolean setPdxTypeClearProp, final String... autoSerializerPatterns) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
if (setPdxTypeClearProp) {
System.setProperty(PoolImpl.ON_DISCONNECT_CLEAR_PDXTYPEIDS, "true");
}
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port);
cf.setPoolThreadLocalConnections(threadLocalConnections);
if (autoSerializerPatterns != null && autoSerializerPatterns.length != 0) {
cf.setPdxSerializer(new ReflectionBasedAutoSerializer(autoSerializerPatterns));
}
ClientCache cache = getClientCache(cf);
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("testSimplePdx");
return null;
}
};
vm.invoke(createRegion);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class PdxTypeExportDUnitTest method loadCache.
@SuppressWarnings("serial")
public void loadCache() throws Exception {
SerializableCallable peer = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
Cache cache = getCache(cf);
Region r = cache.createRegionFactory(RegionShortcut.REPLICATE).create("pdxtest");
r.put(1, new MyObjectPdx(1, "test", MyEnumPdx.const1));
return null;
}
};
final Host host = Host.getHost(0);
host.getVM(1).invoke(peer);
SerializableCallable server = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheFactory cf = new CacheFactory().setPdxSerializer(new MyPdxSerializer());
CacheServer server = getCache().addCacheServer();
int port = AvailablePortHelper.getRandomAvailableTCPPort();
server.setPort(port);
server.start();
Region r = getCache().createRegionFactory(RegionShortcut.REPLICATE).create("pdxtest");
return port;
}
};
final int port = (Integer) host.getVM(2).invoke(server);
SerializableCallable client = new SerializableCallable() {
@Override
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory().setPdxSerializer(new MyPdxSerializer()).addPoolServer(NetworkUtils.getServerHostName(host), port);
ClientCache cache = getClientCache(cf);
Region r = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("pdxtest");
return null;
}
};
host.getVM(3).invoke(client);
peer.call();
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class PdxDeserializationDUnitTest method createClient.
private void createClient(final int port0) {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer("localhost", port0);
cf.setPoolSubscriptionEnabled(true);
ClientCache cache = getClientCache(cf);
Region replicate = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("replicate");
Region pr = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("pr");
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("overflow_replicate");
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("overflow_pr");
// Register interest in a key
replicate.registerInterest("A", InterestResultPolicy.KEYS_VALUES);
pr.registerInterest("A", InterestResultPolicy.KEYS_VALUES);
}
Aggregations