use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ClientConflationDUnitTest method createClientCacheFeeder.
public static void createClientCacheFeeder(String host, Integer port) throws Exception {
ClientConflationDUnitTest test = new ClientConflationDUnitTest();
cacheFeeder = test.createCache(createProperties1(DistributionConfig.CLIENT_CONFLATION_PROP_VALUE_DEFAULT));
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
createPool2(host, factory, port);
RegionAttributes attrs = factory.create();
cacheFeeder.createRegion(REGION_NAME1, attrs);
attrs = factory.create();
cacheFeeder.createRegion(REGION_NAME2, attrs);
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ClientServerMiscDUnitTest method testProxyCreationBeforeCacheCreation.
/**
* Create proxy before cache creation, create cache, create two regions, attach same bridge writer
* to both of the regions Region interests AL_KEYS on both the regions,
* notify-by-subscription=true . The CCP should have both the regions in interest list.
*
* @throws Exception
*/
@Test
public void testProxyCreationBeforeCacheCreation() throws Exception {
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "");
DistributedSystem ds = getSystem(props);
assertNotNull(ds);
ds.disconnect();
ds = getSystem(props);
PORT1 = initServerCache(true);
String host = NetworkUtils.getServerHostName(server1.getHost());
Pool p = PoolManager.createFactory().addServer(host, PORT1).setSubscriptionEnabled(true).setSubscriptionRedundancy(-1).create("testProxyCreationBeforeCacheCreationPool");
Cache cache = getCache();
assertNotNull(cache);
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setPoolName(p.getName());
RegionAttributes myAttrs = factory.create();
Region region1 = cache.createRegion(REGION_NAME1, myAttrs);
Region region2 = cache.createRegion(REGION_NAME2, myAttrs);
assertNotNull(region1);
assertNotNull(region2);
// region1.registerInterest(CacheClientProxy.ALL_KEYS);
region2.registerInterest("ALL_KEYS");
Wait.pause(6000);
server1.invoke(() -> ClientServerMiscDUnitTest.verifyInterestListOnServer());
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ConflationDUnitTest method createServerCache.
/**
* create a server cache and start the server
*
* @throws Exception
*/
public static Integer createServerCache() throws Exception {
ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableConflation(true);
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME1, attrs);
cache.createRegion(REGION_NAME2, attrs);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
server.setPort(port);
server.setNotifyBySubscription(true);
server.setSocketBufferSize(32768);
server.start();
return new Integer(server.getPort());
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ClientServerMiscDUnitTest method createServerCache.
public static Integer createServerCache(Boolean notifyBySubscription, Integer maxThreads, boolean isHA) throws Exception {
Cache cache = new ClientServerMiscDUnitTest().createCacheV(new Properties());
unsetSlowDispatcherFlag();
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setEnableConflation(true);
factory.setDataPolicy(DataPolicy.REPLICATE);
RegionAttributes myAttrs = factory.create();
Region r1 = cache.createRegion(REGION_NAME1, myAttrs);
Region r2 = cache.createRegion(REGION_NAME2, myAttrs);
factory = new AttributesFactory();
factory.setDataPolicy(DataPolicy.PARTITION);
if (isHA) {
PartitionAttributesFactory paf = new PartitionAttributesFactory().setRedundantCopies(1);
factory.setPartitionAttributes(paf.create());
}
RegionAttributes prAttrs = factory.create();
Region pr = cache.createRegion(PR_REGION_NAME, prAttrs);
assertNotNull(r1);
assertNotNull(r2);
assertNotNull(pr);
CacheServer server = cache.addCacheServer();
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
r1.getCache().getDistributedSystem().getLogWriter().info("Starting server on port " + port);
server.setPort(port);
server.setMaxThreads(maxThreads.intValue());
server.setNotifyBySubscription(notifyBySubscription.booleanValue());
server.start();
r1.getCache().getDistributedSystem().getLogWriter().info("Started server on port " + server.getPort());
return new Integer(server.getPort());
}
use of org.apache.geode.cache.RegionAttributes in project geode by apache.
the class ConflationDUnitTest method createClientCache2CommonWriter.
/**
* create client 2 with 2 regions with sharing a common writer and having a common listener
*
* @throws Exception
*/
public static void createClientCache2CommonWriter(String host, Integer port) throws Exception {
ConflationDUnitTest test = new ConflationDUnitTest();
cache = test.createCache(createProperties1());
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setPoolName(createPool(host, "p1", port, true).getName());
factory.addCacheListener(new CacheListenerAdapter() {
public void afterCreate(EntryEvent event) {
LogWriterUtils.getLogWriter().info("Listener received event " + event);
String val = (String) event.getNewValue();
synchronized (ConflationDUnitTest.class) {
if (val.equals(MARKER)) {
count++;
} else {
counterCreate++;
}
if (2 == count) {
ConflationDUnitTest.class.notify();
}
}
}
public void afterUpdate(EntryEvent event) {
LogWriterUtils.getLogWriter().info("Listener received event " + event);
synchronized (this) {
counterUpdate++;
}
}
public void afterDestroy(EntryEvent event) {
LogWriterUtils.getLogWriter().info("Listener received event " + event);
synchronized (this) {
if (!event.getKey().equals(MARKER)) {
counterDestroy++;
}
}
}
});
RegionAttributes attrs = factory.create();
cache.createRegion(REGION_NAME1, attrs);
cache.createRegion(REGION_NAME2, attrs);
}
Aggregations