| /*========================================================================= |
| * Copyright (c) 2002-2014 Pivotal Software, Inc. All Rights Reserved. |
| * This product is protected by U.S. and international copyright |
| * and intellectual property laws. Pivotal products are covered by |
| * more patents listed at http://www.pivotal.io/patents. |
| *========================================================================= |
| */ |
| package com.gemstone.gemfire.internal.cache; |
| |
| import com.gemstone.gemfire.cache.AttributesFactory; |
| import com.gemstone.gemfire.cache.Cache; |
| import com.gemstone.gemfire.cache.DataPolicy; |
| import com.gemstone.gemfire.cache.EvictionAction; |
| import com.gemstone.gemfire.cache.EvictionAttributes; |
| import com.gemstone.gemfire.cache.PartitionAttributes; |
| import com.gemstone.gemfire.cache.PartitionAttributesFactory; |
| import com.gemstone.gemfire.cache.Region; |
| import com.gemstone.gemfire.cache30.CacheTestCase; |
| |
| import dunit.Host; |
| import dunit.SerializableCallable; |
| import dunit.SerializableRunnable; |
| import dunit.VM; |
| |
| /** |
| * Test that the bucket size does not go negative when |
| * we fault out and in a delta object. |
| * @author dsmith |
| * |
| */ |
| public class Bug42055DUnitTest extends CacheTestCase { |
| |
| |
| /** |
| * @param name |
| */ |
| public Bug42055DUnitTest(String name) { |
| super(name); |
| } |
| |
| 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); |
| } |
| } |