blob: c854b64e68dcd4f403ee17f4f001dd43b81a93e8 [file] [log] [blame]
package com.gemstone.gemfire.cache30;
import java.util.Properties;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.internal.cache.OffHeapTestUtil;
import dunit.SerializableRunnable;
/**
* Tests Partitioned Region with OffHeap memory.
*
* @author Kirk Lund
* @since 9.0
*/
public class PartitionedRegionOffHeapDUnitTest extends PartitionedRegionDUnitTest {
public PartitionedRegionOffHeapDUnitTest(String name) {
super(name);
}
@Override
public void tearDown2() throws Exception {
SerializableRunnable checkOrphans = new SerializableRunnable() {
@Override
public void run() {
if(hasCache()) {
OffHeapTestUtil.checkOrphans();
}
}
};
invokeInEveryVM(checkOrphans);
try {
checkOrphans.run();
} finally {
super.tearDown2();
}
}
@Override
public Properties getDistributedSystemProperties() {
Properties props = super.getDistributedSystemProperties();
props.setProperty(DistributionConfig.OFF_HEAP_MEMORY_SIZE_NAME, "10m");
return props;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected RegionAttributes getRegionAttributes() {
RegionAttributes attrs = super.getRegionAttributes();
AttributesFactory factory = new AttributesFactory(attrs);
factory.setOffHeap(true);
return factory.create();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected RegionAttributes getRegionAttributes(String type) {
RegionAttributes ra = super.getRegionAttributes(type);
AttributesFactory factory = new AttributesFactory(ra);
if(!ra.getDataPolicy().isEmpty()) {
factory.setOffHeap(true);
}
return factory.create();
}
}