use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class ClientHealthStatsDUnitTest method createClientCache.
/**
* Invoked in client1VM and client2VM
*/
private void createClientCache(final String hostName, final Integer port, final int clientNum, final boolean subscriptionEnabled) {
Properties props = new Properties();
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
ClientCacheFactory cacheFactory = new ClientCacheFactory(props);
if (subscriptionEnabled) {
cacheFactory.setPoolSubscriptionEnabled(true);
cacheFactory.setPoolSubscriptionAckInterval(50);
cacheFactory.setPoolSubscriptionRedundancy(0);
}
cacheFactory.set(DURABLE_CLIENT_ID, "DurableClientId_" + clientNum);
cacheFactory.set(DURABLE_CLIENT_TIMEOUT, "" + 30000);
cacheFactory.addPoolServer(hostName, port);
clientCache = cacheFactory.create();
ClientRegionFactory<String, String> regionFactory = clientCache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
regionFactory.setConcurrencyChecksEnabled(false);
regionFactory.addCacheListener(new CacheListenerAdapter<String, String>() {
@Override
public void afterCreate(final EntryEvent<String, String> event) {
if ("last_key".equals(event.getKey())) {
lastKeyReceived = true;
}
}
});
Region<String, String> region = regionFactory.create(REGION_NAME);
if (subscriptionEnabled) {
region.registerInterest("ALL_KEYS", true);
clientCache.readyForEvents();
}
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class Bug49856JUnitTest method testNoGFThreadsRunningPostCacheClose.
@Test
public void testNoGFThreadsRunningPostCacheClose() throws Exception {
ClientCacheFactory ccf = new ClientCacheFactory();
GemFireCacheImpl cache = (GemFireCacheImpl) ccf.create();
SystemFailure.getFailure();
Thread.sleep(5000);
// Assert the threads have been started.
checkThreads(true);
cache.close();
Thread.sleep(5000);
// Assert the threads have been terminated.
checkThreads(false);
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class Bug47667DUnitTest method testbug47667.
@Test
public void testbug47667() {
Host host = Host.getHost(0);
VM locator = host.getVM(0);
VM server1 = host.getVM(1);
VM server2 = host.getVM(2);
VM client = host.getVM(3);
final int locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
final String locatorHost = NetworkUtils.getServerHostName(host);
locator.invoke("Start Locator", () -> startLocator(locatorHost, locatorPort, ""));
String locString = getLocatorString(host, locatorPort);
server1.invoke("Start BridgeServer", () -> startBridgeServer(new String[] { "R1" }, locString, new String[] { "R1" }));
server2.invoke("Start BridgeServer", () -> startBridgeServer(new String[] { "R2" }, locString, new String[] { "R2" }));
client.invoke("create region and insert data in transaction", () -> {
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.addPoolLocator(locatorHost, locatorPort);
ClientCache cache = ccf.create();
PoolManager.createFactory().addLocator(locatorHost, locatorPort).setServerGroup("R1").create("R1");
PoolManager.createFactory().addLocator(locatorHost, locatorPort).setServerGroup("R2").create("R2");
Region region1 = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).setPoolName("R1").create("R1");
Region region2 = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).setPoolName("R2").create("R2");
CacheTransactionManager transactionManager = cache.getCacheTransactionManager();
transactionManager.begin();
region1.put(1, "value1");
transactionManager.commit();
transactionManager.begin();
region2.put(2, "value2");
transactionManager.commit();
return null;
});
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class Bug48571DUnitTest method createClientCache.
public static void createClientCache(Host host, Integer port) throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
props.setProperty(DURABLE_CLIENT_ID, "durable-48571");
props.setProperty(DURABLE_CLIENT_TIMEOUT, "300000");
props.setProperty(LOG_FILE, "client_" + OSProcess.getId() + ".log");
props.setProperty(LOG_LEVEL, "info");
props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
ClientCacheFactory ccf = new ClientCacheFactory(props);
ccf.setPoolSubscriptionEnabled(true);
ccf.setPoolSubscriptionAckInterval(50);
ccf.setPoolSubscriptionRedundancy(0);
ccf.addPoolServer(host.getHostName(), port);
DistributedSystem ds = new Bug48571DUnitTest().getSystem(props);
ds.disconnect();
cache = (GemFireCacheImpl) ccf.create();
ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
crf.setConcurrencyChecksEnabled(false);
crf.addCacheListener(new CacheListenerAdapter<String, String>() {
public void afterInvalidate(EntryEvent<String, String> event) {
cache.getLoggerI18n().fine("Invalidate Event: " + event.getKey() + ", " + event.getNewValue());
numOfInvalidates++;
}
public void afterCreate(EntryEvent<String, String> event) {
if (((String) event.getKey()).equals("last_key")) {
lastKeyReceived = true;
}
cache.getLoggerI18n().fine("Create Event: " + event.getKey() + ", " + event.getNewValue());
numOfCreates++;
}
public void afterUpdate(EntryEvent<String, String> event) {
cache.getLoggerI18n().fine("Update Event: " + event.getKey() + ", " + event.getNewValue());
numOfUpdates++;
}
});
Region<String, String> r = crf.create(region);
r.registerInterest("ALL_KEYS", true);
cache.readyForEvents();
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class Bug48879DUnitTest method createClientCache.
@SuppressWarnings("deprecation")
public static void createClientCache(Host host, Integer[] ports, Boolean doRI) throws Exception {
Properties props = new Properties();
props.setProperty(STATISTIC_ARCHIVE_FILE, "client_" + OSProcess.getId() + ".gfs");
props.setProperty(STATISTIC_SAMPLING_ENABLED, "true");
DistributedSystem ds = new Bug48879DUnitTest().getSystem(props);
ds.disconnect();
ClientCacheFactory ccf = new ClientCacheFactory(props);
ccf.setPoolSubscriptionEnabled(doRI);
ccf.setPoolSubscriptionAckInterval(50);
ccf.setPoolSubscriptionRedundancy(1);
for (int port : ports) {
ccf.addPoolServer(host.getHostName(), port);
}
cache = (GemFireCacheImpl) ccf.create();
ClientRegionFactory<String, String> crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
Region<String, String> region = crf.create(REGION_NAME);
if (doRI) {
region.registerInterest("ALL_KEYS");
}
}
Aggregations