use of org.apache.geode.cache.SubscriptionAttributes in project geode by apache.
the class Bug41957DUnitTest method createBridgeClient.
private void createBridgeClient(VM client, final String regionName, final String serverHost, final int[] serverPorts) {
client.invoke(new CacheSerializableRunnable("Create client") {
public void run2() throws CacheException {
// Create DS
Properties config = new Properties();
config.setProperty(MCAST_PORT, "0");
config.setProperty(LOCATORS, "");
getSystem(config);
// Create Region
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
{
PoolFactory pf = PoolManager.createFactory();
pf.setSubscriptionEnabled(true);
for (int i = 0; i < serverPorts.length; i++) {
pf.addServer(serverHost, serverPorts[i]);
}
pf.create("myPool");
}
int ENTRIES_ON_CLIENT = 2;
factory.setPoolName("myPool");
factory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(ENTRIES_ON_CLIENT));
createRootRegion(regionName, factory.create());
}
});
}
use of org.apache.geode.cache.SubscriptionAttributes in project geode by apache.
the class P2PDeltaPropagationDUnitTest method createServerCache.
public static void createServerCache(Boolean flag, DataPolicy policy, Scope scope, Boolean listener, Boolean interestPolicyAll, Integer port) throws Exception {
P2PDeltaPropagationDUnitTest test = new P2PDeltaPropagationDUnitTest();
Properties props = new Properties();
if (!flag) {
props.setProperty(DELTA_PROPAGATION, "false");
}
cache = test.createCache(props);
AttributesFactory factory = new AttributesFactory();
factory.setScope(scope);
factory.setDataPolicy(policy);
if (policy == DataPolicy.EMPTY && interestPolicyAll) {
factory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
}
if (listener) {
factory.addCacheListener(new CacheListenerAdapter() {
@SuppressWarnings("synthetic-access")
public void afterUpdate(EntryEvent event) {
numOfUpdates++;
cache.getLoggerI18n().fine("afterUpdate(): numOfUpdates = " + numOfUpdates);
cache.getLoggerI18n().fine("(key, val): " + event.getKey() + ", " + event.getNewValue());
if (event.getOldValue() != null) {
if (event.getOldValue() == event.getNewValue()) {
check = Boolean.TRUE;
}
}
if (((EntryEventImpl) event).getDeltaBytes() != null) {
cache.getLoggerI18n().fine("delta bytes received. " + hasDeltaBytes);
assertTrue("No full value received for event " + event, ((EntryEventImpl) event).getNewValue() != null);
hasDeltaBytes++;
} else {
cache.getLoggerI18n().fine("delta bytes not received.");
}
}
});
}
Region region = cache.createRegion(REGION_NAME, factory.create());
if (!policy.isReplicate()) {
region.create("KEY", "KEY");
}
if (port != null) {
CacheServer server1 = cache.addCacheServer();
server1.setPort(port);
server1.start();
}
}
use of org.apache.geode.cache.SubscriptionAttributes in project geode by apache.
the class ForceInvalidateEvictionDUnitTest method createAccessor.
private void createAccessor(VM vm, final boolean allContent) {
final String name = getUniqueName();
vm.invoke(new SerializableRunnable() {
public void run() {
Cache cache = getCache();
RegionFactory rf = new RegionFactory();
rf.setOffHeap(isOffHeapEnabled());
rf.setDataPolicy(DataPolicy.PARTITION);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setTotalNumBuckets(5);
paf.setLocalMaxMemory(0);
rf.setPartitionAttributes(paf.create());
rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1));
rf.setConcurrencyChecksEnabled(false);
if (allContent) {
// rf.initCacheListeners(new CacheListener [] { new MyListener()});
rf.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL));
}
rf.create(name);
}
});
}
use of org.apache.geode.cache.SubscriptionAttributes in project geode by apache.
the class RemoteTransactionDUnitTest method createRegion.
void createRegion(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.REPLICATE);
af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
getCache().createRegion(D_REFERENCE, af.create());
af = new AttributesFactory();
af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
if (interestPolicy != null) {
af.setSubscriptionAttributes(new SubscriptionAttributes(interestPolicy));
}
af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver1")).setRedundantCopies(redundantCopies).create());
getCache().createRegion(CUSTOMER, af.create());
af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
getCache().createRegion(ORDER, af.create());
}
use of org.apache.geode.cache.SubscriptionAttributes in project geode by apache.
the class RemoteCQTransactionDUnitTest method createRegion.
void createRegion(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.REPLICATE);
af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
getCache().createRegion(D_REFERENCE, af.create());
af = new AttributesFactory();
af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
if (interestPolicy != null) {
af.setSubscriptionAttributes(new SubscriptionAttributes(interestPolicy));
}
af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver1")).setRedundantCopies(redundantCopies).create());
getCache().createRegion(CUSTOMER, af.create());
af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
getCache().createRegion(ORDER, af.create());
}
Aggregations