blob: d16403e2b41aefc9d0bf54ab7487b668158016cf [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 Distributed Ack Region with OffHeap memory.
*
* @author Kirk Lund
* @since 9.0
*/
@SuppressWarnings({ "deprecation", "serial" })
public class DistributedAckRegionOffHeapDUnitTest extends DistributedAckRegionDUnitTest {
public DistributedAckRegionOffHeapDUnitTest(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();
}
}