Search in sources :

Example 76 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class PartitionedRegionEvictionDUnitTest method testEntryLRUWithLocalDestroy.

@Test
public void testEntryLRUWithLocalDestroy() {
    final Host host = Host.getHost(0);
    final VM vm2 = host.getVM(2);
    final VM vm3 = host.getVM(3);
    final String uniqName = getUniqueName();
    final int redundantCopies = 1;
    final int maxBuckets = 8;
    final int maxEntries = 16;
    final String name = uniqName + "-PR";
    final int extraEntries = 4;
    // final int heapPercentage = 66;
    // final int evictorInterval = 100;
    final SerializableRunnable create = new CacheSerializableRunnable("Create Entry LRU with local destroy on a partitioned Region") {

        public void run2() {
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).setTotalNumBuckets(maxBuckets).create());
            factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.LOCAL_DESTROY));
            factory.addCacheListener(new VerifiableCacheListener() {

                private long evictionDestroyEvents = 0;

                public void afterDestroy(EntryEvent e) {
                    System.out.println("EEEEEEEEEEEEEE key:" + e.getKey());
                    EntryEventImpl eei = (EntryEventImpl) e;
                    if (Operation.EVICT_DESTROY.equals(eei.getOperation())) {
                        evictionDestroyEvents++;
                    }
                }

                public boolean verify(long expectedEntries) {
                    return expectedEntries == evictionDestroyEvents;
                }
            });
            final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
            assertNotNull(pr);
        }
    };
    vm3.invoke(create);
    final SerializableRunnable create2 = new SerializableRunnable("Create Entry LRU with local destroy on a partitioned Region") {

        public void run() {
            try {
                final AttributesFactory factory = new AttributesFactory();
                factory.setOffHeap(isOffHeap());
                factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).setTotalNumBuckets(8).create());
                factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries));
                final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
                assertNotNull(pr);
            } catch (final CacheException ex) {
                Assert.fail("While creating Partitioned region", ex);
            }
        }
    };
    vm2.invoke(create2);
    final SerializableRunnable createBuckets = new SerializableRunnable("Create Buckets") {

        public void run() {
            final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
            assertNotNull(pr);
            for (int counter = 1; counter <= maxEntries + extraEntries; counter++) {
                pr.put(new Integer(counter), new byte[1 * 1024 * 1024]);
            }
        }
    };
    vm3.invoke(createBuckets);
    final SerializableCallable assertBucketAttributesAndEviction = new SerializableCallable("Assert bucket attributes and eviction") {

        public Object call() throws Exception {
            try {
                final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
                assertNotNull(pr);
                long entriesEvicted = 0;
                for (final Iterator i = pr.getDataStore().getAllLocalBuckets().iterator(); i.hasNext(); ) {
                    final Map.Entry entry = (Map.Entry) i.next();
                    final BucketRegion bucketRegion = (BucketRegion) entry.getValue();
                    if (bucketRegion == null) {
                        continue;
                    }
                    assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAlgorithm().isLRUEntry());
                    assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAction().isLocalDestroy());
                }
                entriesEvicted = ((AbstractLRURegionMap) pr.entries)._getLruList().stats().getEvictions();
                return new Long(entriesEvicted);
            } finally {
            }
        }
    };
    final Long v2i = (Long) vm2.invoke(assertBucketAttributesAndEviction);
    final Long v3i = (Long) vm3.invoke(assertBucketAttributesAndEviction);
    final int totalEvicted = v2i.intValue() + v3i.intValue();
    assertEquals(2 * extraEntries, totalEvicted);
    final SerializableCallable assertListenerCount = new SerializableCallable("Assert that the number of listener invocations matches the expected total") {

        public Object call() throws Exception {
            final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
            assertNotNull(pr);
            RegionAttributes attrs = pr.getAttributes();
            assertNotNull(attrs);
            long entriesEvicted = ((AbstractLRURegionMap) pr.entries)._getLruList().stats().getEvictions();
            VerifiableCacheListener verifyMe = null;
            for (CacheListener listener : attrs.getCacheListeners()) {
                if (listener instanceof VerifiableCacheListener) {
                    verifyMe = ((VerifiableCacheListener) listener);
                }
            }
            // assert if unable to find the expected listener
            assertNotNull(verifyMe);
            return verifyMe.verify(entriesEvicted);
        }
    };
    assertTrue((Boolean) vm3.invoke(assertListenerCount));
}
Also used : CacheException(org.apache.geode.cache.CacheException) RegionAttributes(org.apache.geode.cache.RegionAttributes) CacheListener(org.apache.geode.cache.CacheListener) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) EntryEvent(org.apache.geode.cache.EntryEvent) Iterator(java.util.Iterator) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Host(org.apache.geode.test.dunit.Host) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Map(java.util.Map) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 77 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class PartitionedRegionEvictionDUnitTest method testMemoryLRUWithLocalDestroy.

@Test
public void testMemoryLRUWithLocalDestroy() {
    final Host host = Host.getHost(0);
    final VM vm2 = host.getVM(2);
    final VM vm3 = host.getVM(3);
    final String uniqName = getUniqueName();
    final int redundantCopies = 1;
    final int maxBuckets = 8;
    final int localMaxMem = 16;
    final int halfKb = 512;
    final int justShyOfTwoMb = (2 * 1024 * 1024) - halfKb;
    final String name = uniqName + "-PR";
    final SerializableRunnable create = new CacheSerializableRunnable("Create Memory LRU with local destroy on a partitioned Region") {

        public void run2() {
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).setLocalMaxMemory(16).setTotalNumBuckets(maxBuckets).create());
            factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(ObjectSizer.DEFAULT, EvictionAction.LOCAL_DESTROY));
            final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
            assertNotNull(pr);
        }
    };
    vm3.invoke(create);
    vm2.invoke(create);
    final int extraEntries = 4;
    final SerializableRunnable createBuckets = new SerializableRunnable("Create Buckets") {

        public void run() {
            final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
            assertNotNull(pr);
            for (int counter = 1; counter <= localMaxMem + extraEntries; counter++) {
                pr.put(new Integer(counter), new byte[1 * 1024 * 1024]);
            }
        }
    };
    vm3.invoke(createBuckets);
    final SerializableCallable assertBucketAttributesAndEviction = new SerializableCallable("Assert bucket attributes and eviction") {

        public Object call() throws Exception {
            try {
                final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
                assertNotNull(pr);
                long entriesEvicted = 0;
                for (final Iterator i = pr.getDataStore().getAllLocalBuckets().iterator(); i.hasNext(); ) {
                    final Map.Entry entry = (Map.Entry) i.next();
                    final BucketRegion bucketRegion = (BucketRegion) entry.getValue();
                    if (bucketRegion == null) {
                        continue;
                    }
                    assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAlgorithm().isLRUMemory());
                    assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAction().isLocalDestroy());
                }
                entriesEvicted = ((AbstractLRURegionMap) pr.entries)._getLruList().stats().getEvictions();
                return new Long(entriesEvicted);
            } finally {
            }
        }
    };
    final Long v2i = (Long) vm2.invoke(assertBucketAttributesAndEviction);
    final Long v3i = (Long) vm3.invoke(assertBucketAttributesAndEviction);
    final int totalEvicted = v2i.intValue() + v3i.intValue();
    assertTrue(2 * extraEntries <= totalEvicted);
}
Also used : SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Host(org.apache.geode.test.dunit.Host) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Iterator(java.util.Iterator) Map(java.util.Map) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 78 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class PartitionedRegionEvictionDUnitTest method testEvictionValidationForLRUEntry.

// Test to validate the Eviction Attribute : LRU Check
@Test
public void testEvictionValidationForLRUEntry() {
    final Host host = Host.getHost(0);
    final VM testAccessor = host.getVM(1);
    final VM testDatastore = host.getVM(2);
    final VM firstDatastore = host.getVM(3);
    final String uniqName = getUniqueName();
    final int redundantCopies = 1;
    final int maxEntries = 226;
    final String name = uniqName + "-PR";
    // final int evictionSizeInMB = 200;
    final EvictionAttributes firstEvictionAttrs = EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.LOCAL_DESTROY);
    // Creating LRU Entry Count Eviction Attribute
    final SerializableRunnable create = new CacheSerializableRunnable("Create Entry LRU with local destroy on a partitioned Region") {

        public void run2() {
            // Assert that LRUEntry maximum can be less than 1 entry per
            // bucket
            // DUnit not required for this test, but its a convenient place
            // to put it.
            {
                final int buks = 11;
                final AttributesFactory factory = new AttributesFactory();
                factory.setOffHeap(isOffHeap());
                factory.setPartitionAttributes(new PartitionAttributesFactory().setTotalNumBuckets(buks).setRedundantCopies(0).create());
                factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes((buks / 2)));
                final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
                final Integer key = new Integer(1);
                pr.put(key, "testval");
                final BucketRegion b;
                try {
                    b = pr.getDataStore().getInitializedBucketForId(key, new Integer(PartitionedRegionHelper.getHashKey(pr, null, key, null, null)));
                } catch (final ForceReattemptException e) {
                    fail();
                }
                pr.destroyRegion();
            }
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
            factory.setEvictionAttributes(firstEvictionAttrs);
            final Region pr = createRootRegion(name, factory.create());
            assertNotNull(pr);
        }
    };
    firstDatastore.invoke(create);
    final SerializableRunnable create2 = new SerializableRunnable("Create Entry LRU with Overflow to disk partitioned Region") {

        public void run() {
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
            // Assert a different algo is invalid
            try {
                getCache().getLogger().info("<ExpectedException action=add>" + "IllegalStateException</ExpectedException>");
                assertTrue(!firstEvictionAttrs.getAlgorithm().isLRUHeap());
                final EvictionAttributes illegalEa = EvictionAttributes.createLRUHeapAttributes(null, firstEvictionAttrs.getAction());
                assertTrue(!firstEvictionAttrs.equals(illegalEa));
                factory.setEvictionAttributes(illegalEa);
                setEvictionPercentage(50);
                createRootRegion(name, factory.create());
                fail("Creating LRU Entry Count Eviction Attribute");
            } catch (final IllegalStateException expected) {
                assertTrue(expected.getMessage().contains(PartitionRegionConfigValidator.EVICTION_ATTRIBUTES_ARE_INCOMPATIBLE_MESSAGE));
            } finally {
                getCache().getLogger().info("<ExpectedException action=remove>" + "IllegalStateException</ExpectedException>");
            }
            // Assert a different action is invalid
            try {
                getCache().getLogger().info("<ExpectedException action=add>" + "IllegalStateException</ExpectedException>");
                assertTrue(firstEvictionAttrs.getAlgorithm().isLRUEntry());
                assertTrue(!firstEvictionAttrs.getAction().isOverflowToDisk());
                final EvictionAttributes illegalEa = EvictionAttributes.createLRUEntryAttributes(firstEvictionAttrs.getMaximum(), EvictionAction.OVERFLOW_TO_DISK);
                assertTrue(!firstEvictionAttrs.equals(illegalEa));
                factory.setEvictionAttributes(illegalEa);
                createRootRegion(name, factory.create());
                fail("Creating LRU Entry Count Eviction Attribute");
            } catch (final IllegalStateException expected) {
                assertTrue(expected.getMessage().contains(PartitionRegionConfigValidator.EVICTION_ATTRIBUTES_ARE_INCOMPATIBLE_MESSAGE));
            } finally {
                getCache().getLogger().info("<ExpectedException action=remove>" + "IllegalStateException</ExpectedException>");
            }
            assertTrue(firstEvictionAttrs.getAlgorithm().isLRUEntry());
            final EvictionAttributes brokenEa = EvictionAttributes.createLRUEntryAttributes(firstEvictionAttrs.getMaximum() + 1, firstEvictionAttrs.getAction());
            assertTrue(!firstEvictionAttrs.equals(brokenEa));
            factory.setEvictionAttributes(brokenEa);
            createRootRegion(name, factory.create());
        }
    };
    testDatastore.invoke(create2);
    testAccessor.invoke(new CacheSerializableRunnable("Create an Accessor with and without eviction attributes") {

        public void run2() throws CacheException {
            final PartitionAttributes pra = new PartitionAttributesFactory().setRedundantCopies(redundantCopies).setLocalMaxMemory(0).create();
            AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(pra);
            factory.setEvictionAttributes(firstEvictionAttrs);
            setEvictionPercentage(50);
            Region r1 = createRootRegion(name, factory.create());
            assertNotNull(r1);
            assertEquals(firstEvictionAttrs, r1.getAttributes().getEvictionAttributes());
        }
    });
}
Also used : EvictionAttributes(org.apache.geode.cache.EvictionAttributes) CacheException(org.apache.geode.cache.CacheException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) Host(org.apache.geode.test.dunit.Host) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) VM(org.apache.geode.test.dunit.VM) Region(org.apache.geode.cache.Region) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 79 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class PartitionedRegionEvictionDUnitTest method testEntryLRUWithOverflowToDisk.

@Test
public void testEntryLRUWithOverflowToDisk() {
    final Host host = Host.getHost(0);
    final VM vm2 = host.getVM(2);
    final VM vm3 = host.getVM(3);
    final String uniqName = getUniqueName();
    final int redundantCopies = 1;
    final int maxBuckets = 8;
    final int maxEntries = 16;
    final String name = uniqName + "-PR";
    final SerializableRunnable create = new SerializableRunnable("Create Entry LRU with Overflow to disk partitioned Region") {

        public void run() {
            try {
                final AttributesFactory factory = new AttributesFactory();
                factory.setOffHeap(isOffHeap());
                factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).setTotalNumBuckets(maxBuckets).create());
                factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.OVERFLOW_TO_DISK));
                factory.setDiskSynchronous(true);
                DiskStoreFactory dsf = getCache().createDiskStoreFactory();
                final File[] diskDirs = new File[1];
                diskDirs[0] = new File("overflowDir/" + uniqName + "_" + OSProcess.getId());
                diskDirs[0].mkdirs();
                dsf.setDiskDirs(diskDirs);
                DiskStore ds = dsf.create(name);
                factory.setDiskStoreName(ds.getName());
                final PartitionedRegion pr = (PartitionedRegion) createRootRegion(name, factory.create());
                assertNotNull(pr);
            } catch (final CacheException ex) {
                Assert.fail("While creating Partitioned region", ex);
            }
        }
    };
    vm3.invoke(create);
    vm2.invoke(create);
    final int extraEntries = 4;
    final SerializableRunnable createBuckets = new SerializableRunnable("Create Buckets") {

        public void run() {
            final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
            assertNotNull(pr);
            for (int counter = 1; counter <= maxEntries + extraEntries; counter++) {
                pr.put(new Integer(counter), new byte[1 * 1024 * 1024]);
            }
        }
    };
    vm3.invoke(createBuckets);
    final SerializableCallable assertBucketAttributesAndEviction = new SerializableCallable("Assert bucket attributes and eviction") {

        public Object call() throws Exception {
            final PartitionedRegion pr = (PartitionedRegion) getRootRegion(name);
            assertNotNull(pr);
            // assert over-flow behavior in local buckets and number of
            // entries
            // overflowed
            int entriesEvicted = 0;
            for (final Iterator i = pr.getDataStore().getAllLocalBuckets().iterator(); i.hasNext(); ) {
                final Map.Entry entry = (Map.Entry) i.next();
                final BucketRegion bucketRegion = (BucketRegion) entry.getValue();
                if (bucketRegion == null) {
                    continue;
                }
                assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAlgorithm().isLRUEntry());
                assertTrue(bucketRegion.getAttributes().getEvictionAttributes().getAction().isOverflowToDisk());
            }
            entriesEvicted += pr.getDiskRegionStats().getNumOverflowOnDisk();
            return new Integer(entriesEvicted);
        }
    };
    final Integer vm2i = (Integer) vm2.invoke(assertBucketAttributesAndEviction);
    final Integer vm3i = (Integer) vm3.invoke(assertBucketAttributesAndEviction);
    final int totalEvicted = vm2i.intValue() + vm3i.intValue();
    assertEquals(extraEntries * 2, totalEvicted);
}
Also used : CacheException(org.apache.geode.cache.CacheException) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Host(org.apache.geode.test.dunit.Host) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Iterator(java.util.Iterator) File(java.io.File) Map(java.util.Map) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 80 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class PartitionedRegionEvictionDUnitTest method testEvictionValidationForLRUAction.

// Test to validate the Eviction Attribute : LRU Action
@Test
public void testEvictionValidationForLRUAction() {
    final Host host = Host.getHost(0);
    final VM testDatastore = host.getVM(2);
    final VM firstDatastore = host.getVM(3);
    final String uniqName = getUniqueName();
    final int redundantCopies = 1;
    final int maxEntries = 226;
    final String name = uniqName + "-PR";
    final EvictionAttributes firstEa = EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.LOCAL_DESTROY);
    // Creating LRU Entry Count Eviction Attribute : Algorithm :
    // LOCAL_DESTROY
    final SerializableRunnable create = new CacheSerializableRunnable("Create Entry LRU with local destroy on a partitioned Region") {

        public void run2() {
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
            factory.setEvictionAttributes(firstEa);
            final Region pr = createRootRegion(name, factory.create());
            assertNotNull(pr);
            assertEquals(firstEa, pr.getAttributes().getEvictionAttributes());
        }
    };
    firstDatastore.invoke(create);
    final SerializableRunnable create2 = new SerializableRunnable("Create Entry LRU with Overflow to disk partitioned Region") {

        public void run() {
            final AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeap());
            factory.setPartitionAttributes(new PartitionAttributesFactory().setRedundantCopies(redundantCopies).create());
            // OVERFLOW_TO_DISK // Exception should occur
            try {
                getCache().getLogger().info("<ExpectedException action=add>" + "IllegalStateException</ExpectedException>");
                assertTrue(firstEa.getAlgorithm().isLRUEntry());
                assertTrue(!firstEa.getAction().isOverflowToDisk());
                factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.OVERFLOW_TO_DISK));
                createRootRegion(name, factory.create());
                fail("Test to validate the Eviction Attribute : LRU Action");
            } catch (final IllegalStateException expected) {
                assertTrue(expected.getMessage().contains(PartitionRegionConfigValidator.EVICTION_ATTRIBUTES_ARE_INCOMPATIBLE_MESSAGE));
            } finally {
                getCache().getLogger().info("<ExpectedException action=remove>" + "IllegalStateException</ExpectedException>");
            }
            // // Exception should occur
            try {
                getCache().getLogger().info("<ExpectedException action=add>" + "IllegalStateException</ExpectedException>");
                assertTrue(firstEa.getAlgorithm().isLRUEntry());
                assertTrue(!firstEa.getAction().isNone());
                factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries, EvictionAction.NONE));
                createRootRegion(name, factory.create());
                fail("Test to validate the Eviction Attribute : LRU Action");
            } catch (final IllegalStateException expected) {
                assertTrue(expected.getMessage().contains(PartitionRegionConfigValidator.EVICTION_ATTRIBUTES_ARE_INCOMPATIBLE_MESSAGE));
            } finally {
                getCache().getLogger().info("<ExpectedException action=remove>" + "IllegalStateException</ExpectedException>");
            }
            // Creating LRU Entry Count Eviction Attribute : Action :
            // LOCAL_DESTROY // Exception should not occur
            factory.setEvictionAttributes(firstEa);
            final Region pr = createRootRegion(name, factory.create());
            assertNotNull(pr);
            assertEquals(firstEa, pr.getAttributes().getEvictionAttributes());
        }
    };
    testDatastore.invoke(create2);
}
Also used : EvictionAttributes(org.apache.geode.cache.EvictionAttributes) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) Region(org.apache.geode.cache.Region) Host(org.apache.geode.test.dunit.Host) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)741 VM (org.apache.geode.test.dunit.VM)405 Test (org.junit.Test)403 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)353 Region (org.apache.geode.cache.Region)347 Host (org.apache.geode.test.dunit.Host)344 Cache (org.apache.geode.cache.Cache)274 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)259 CacheException (org.apache.geode.cache.CacheException)207 AttributesFactory (org.apache.geode.cache.AttributesFactory)204 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)198 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)166 LocalRegion (org.apache.geode.internal.cache.LocalRegion)160 IOException (java.io.IOException)145 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)120 Properties (java.util.Properties)66 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)66 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)65 IgnoredException (org.apache.geode.test.dunit.IgnoredException)61 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)53