use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PartitionedRegionDestroyDUnitTest method createRegionAttrsForPR.
protected RegionAttributes createRegionAttrsForPR(int red, int localMaxMem) {
AttributesFactory attr = new AttributesFactory();
attr.setDataPolicy(DataPolicy.PARTITION);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
PartitionAttributes prAttr = paf.setRedundantCopies(red).setLocalMaxMemory(localMaxMem).setTotalNumBuckets(totalNumBuckets).create();
attr.setPartitionAttributes(prAttr);
return attr.create();
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class Bug39356DUnitTest method testMoveBucketToHostThatHasTheBucketAlready.
/**
* A test to make sure that we cannot move a bucket to a member which already hosts the bucket,
* thereby reducing our redundancy.
*/
@Test
public void testMoveBucketToHostThatHasTheBucketAlready() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
SerializableRunnable createPrRegion = new SerializableRunnable("createRegion") {
public void run() {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setRecoveryDelay(-1);
paf.setStartupRecoveryDelay(-1);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
cache.createRegion("region1", attr.create());
}
};
vm0.invoke(createPrRegion);
vm1.invoke(createPrRegion);
// Create a bucket
vm0.invoke(new SerializableRunnable("createSomeBuckets") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region1");
region.put(Integer.valueOf(0), "A");
}
});
final InternalDistributedMember vm1MemberId = (InternalDistributedMember) vm1.invoke(new SerializableCallable() {
public Object call() throws Exception {
return InternalDistributedSystem.getAnyInstance().getDistributedMember();
}
});
// Move the bucket
vm0.invoke(new SerializableRunnable("moveBucket") {
public void run() {
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.getRegion("region1");
Set<InternalDistributedMember> owners = region.getRegionAdvisor().getBucketOwners(0);
assertEquals(2, owners.size());
PartitionedRegionDataStore ds = region.getDataStore();
assertTrue(ds.isManagingBucket(0));
// try to move the bucket from the other member to this one. This should
// fail because we already have the bucket
assertFalse(ds.moveBucket(0, vm1MemberId, true));
assertEquals(owners, region.getRegionAdvisor().getBucketOwners(0));
}
});
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class Bug42055DUnitTest method testPROverflow.
@Test
public void testPROverflow() throws Exception {
final Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
SerializableCallable createDataRegion = new SerializableCallable("createDataRegion") {
public Object call() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
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();
AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>();
PartitionAttributesFactory<Integer, TestDelta> paf = new PartitionAttributesFactory<Integer, TestDelta>();
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());
}
};
vm1.invoke(createEmptyRegion);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class Bug40632DUnitTest method testLocalInvalidateTimeToLive.
@Test
public void testLocalInvalidateTimeToLive() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setRecoveryDelay(-1);
paf.setStartupRecoveryDelay(-1);
PartitionAttributes prAttr = paf.create();
attr.setStatisticsEnabled(true);
attr.setEntryTimeToLive(new ExpirationAttributes(1000, ExpirationAction.LOCAL_INVALIDATE));
attr.setPartitionAttributes(prAttr);
try {
cache.createRegion("region1", attr.create());
fail("We should not have been able to create the region");
} catch (IllegalStateException expected) {
}
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class Bug40632DUnitTest method testLocalDestroyIdleTimeout.
@Test
public void testLocalDestroyIdleTimeout() throws Exception {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setRecoveryDelay(-1);
paf.setStartupRecoveryDelay(-1);
PartitionAttributes prAttr = paf.create();
attr.setStatisticsEnabled(true);
attr.setEntryIdleTimeout(new ExpirationAttributes(1000, ExpirationAction.LOCAL_DESTROY));
attr.setPartitionAttributes(prAttr);
try {
cache.createRegion("region1", attr.create());
fail("We should not have been able to create the region");
} catch (IllegalStateException expected) {
}
}
Aggregations