use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DistTXExpiryJUnitTest method createCache.
@Override
protected void createCache() throws CacheException {
Properties p = new Properties();
// loner
p.setProperty(MCAST_PORT, "0");
p.setProperty(ConfigurationProperties.DISTRIBUTED_TRANSACTIONS, "true");
this.cache = (GemFireCacheImpl) CacheFactory.create(DistributedSystem.connect(p));
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_NO_ACK);
this.txMgr = this.cache.getCacheTransactionManager();
assert (this.txMgr.isDistributed());
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DeltaPropagationDUnitTest method createDurableCacheClient.
public static void createDurableCacheClient(Pool poolAttr, String regionName, Properties dsProperties, Integer listenerCode, Boolean close) throws Exception {
new DeltaPropagationDUnitTest().createCache(dsProperties);
PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
pf.init(poolAttr);
PoolImpl p = (PoolImpl) pf.create("DeltaPropagationDUnitTest");
AttributesFactory factory = new AttributesFactory();
factory.setScope(Scope.LOCAL);
factory.setConcurrencyChecksEnabled(false);
factory.setPoolName(p.getName());
if (listenerCode.intValue() != 0) {
factory.addCacheListener(getCacheListener(listenerCode));
}
RegionAttributes attrs = factory.create();
Region r = cache.createRegion(regionName, attrs);
r.registerInterest("ALL_KEYS");
pool = p;
cache.readyForEvents();
logger = cache.getLogger();
closeCache = close.booleanValue();
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DeltaPropagationDUnitTest method createServerCache.
public static Integer createServerCache(String ePolicy, Integer cap, Integer listenerCode, Boolean conflate, Compressor compressor) throws Exception {
ConnectionTable.threadWantsSharedResources();
new DeltaPropagationDUnitTest().createCache(new Properties());
AttributesFactory factory = new AttributesFactory();
factory.setEnableSubscriptionConflation(conflate);
if (listenerCode.intValue() != 0) {
factory.addCacheListener(getCacheListener(listenerCode));
}
if (compressor != null) {
factory.setCompressor(compressor);
}
if (listenerCode.intValue() == C2S2S_SERVER_LISTENER) {
factory.setScope(Scope.DISTRIBUTED_NO_ACK);
factory.setDataPolicy(DataPolicy.NORMAL);
factory.setConcurrencyChecksEnabled(false);
RegionAttributes attrs = factory.create();
Region r = cache.createRegion(regionName, attrs);
logger = cache.getLogger();
r.create(DELTA_KEY, deltaPut[0]);
} else {
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.REPLICATE);
factory.setConcurrencyChecksEnabled(false);
RegionAttributes attrs = factory.create();
cache.createRegion(regionName, attrs);
logger = cache.getLogger();
}
int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
CacheServer server1 = cache.addCacheServer();
server1.setPort(port);
server1.setNotifyBySubscription(true);
if (ePolicy != null) {
File overflowDirectory = new File("bsi_overflow_" + port);
overflowDirectory.mkdir();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { overflowDirectory };
server1.getClientSubscriptionConfig().setEvictionPolicy(ePolicy);
server1.getClientSubscriptionConfig().setCapacity(cap.intValue());
// specify diskstore for this server
server1.getClientSubscriptionConfig().setDiskStoreName(dsf.setDiskDirs(dirs1).create("bsi").getName());
}
server1.start();
return new Integer(server1.getPort());
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class DeltaFaultInDUnitTest method test.
@Test
public void test() throws Exception {
final Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final boolean copyOnRead = false;
final boolean clone = true;
SerializableCallable createDataRegion = new SerializableCallable("createDataRegion") {
public Object call() throws Exception {
Cache cache = getCache();
cache.setCopyOnRead(copyOnRead);
cache.createDiskStoreFactory().create("DeltaFaultInDUnitTestData");
AttributesFactory attr = new AttributesFactory();
attr.setDiskStoreName("DeltaFaultInDUnitTestData");
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
attr.setCloningEnabled(clone);
attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
Region region = cache.createRegion("region1", attr.create());
return null;
}
};
vm0.invoke(createDataRegion);
SerializableRunnable createEmptyRegion = new SerializableRunnable("createEmptyRegion") {
public void run() {
Cache cache = getCache();
cache.setCopyOnRead(copyOnRead);
AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>();
attr.setCloningEnabled(clone);
PartitionAttributesFactory<Integer, TestDelta> paf = new PartitionAttributesFactory<Integer, TestDelta>();
paf.setRedundantCopies(1);
paf.setLocalMaxMemory(0);
PartitionAttributes<Integer, TestDelta> prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
attr.setDataPolicy(DataPolicy.PARTITION);
attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK));
Region<Integer, TestDelta> region = cache.createRegion("region1", attr.create());
// Put an entry
region.put(new Integer(0), new TestDelta(false, "initial"));
// Put a delta object that is larger
region.put(new Integer(0), new TestDelta(true, "initial_plus_some_more_data"));
}
};
vm1.invoke(createEmptyRegion);
vm0.invoke(new SerializableRunnable("doPut") {
public void run() {
Cache cache = getCache();
Region<Integer, TestDelta> region = cache.getRegion("region1");
// Evict the other object
region.put(new Integer(113), new TestDelta(false, "bogus"));
// Something was going weird with the LRU list. It was evicting this object.
// I want to make sure the other object is the one evicted.
region.get(new Integer(113));
long entriesEvicted = ((AbstractLRURegionMap) ((PartitionedRegion) region).entries)._getLruList().stats().getEvictions();
// assertIndexDetailsEquals(1, entriesEvicted);
TestDelta result = region.get(new Integer(0));
assertEquals("initial_plus_some_more_data", result.info);
}
});
}
use of org.apache.geode.cache.AttributesFactory in project geode by apache.
the class EvictionTestBase method createDistRegion.
public void createDistRegion() {
final AttributesFactory factory = new AttributesFactory();
factory.setOffHeap(getOffHeapEnabled());
factory.setDataPolicy(DataPolicy.NORMAL);
factory.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.LOCAL_DESTROY));
DistributedRegion distRegion = (DistributedRegion) cache.createRegion("DR1", factory.create());
assertNotNull(distRegion);
}
Aggregations