use of org.apache.geode.cache.client.ClientCache 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.ClientCache 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.ClientCache 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.ClientCache 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);
}
use of org.apache.geode.cache.client.ClientCache in project geode by apache.
the class JSONPdxClientServerDUnitTest method createClientRegion.
private void createClientRegion(final VM vm, final int port, final boolean threadLocalConnections) {
SerializableCallable createRegion = new SerializableCallable() {
public Object call() throws Exception {
ClientCacheFactory cf = new ClientCacheFactory();
cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port);
cf.setPoolThreadLocalConnections(threadLocalConnections);
ClientCache cache = getClientCache(cf);
cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create("testSimplePdx");
return null;
}
};
vm.invoke(createRegion);
}
Aggregations