Search in sources :

Example 86 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testDiskStoreValidation.

@Test
public void testDiskStoreValidation() throws Exception {
    CacheCreation cache = new CacheCreation();
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    DiskStore ds1 = dsf.create(getUniqueName());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setScope(Scope.DISTRIBUTED_ACK);
    attrs.setDataPolicy(DataPolicy.REPLICATE);
    attrs.setDiskStoreName(getUniqueName());
    RegionCreation root;
    try {
        root = (RegionCreation) cache.createRegion("root", attrs);
        fail("Expected IllegalStateException to be thrown");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString()));
    }
    EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1000, EvictionAction.OVERFLOW_TO_DISK);
    attrs.setEvictionAttributes(ea);
    root = (RegionCreation) cache.createRegion("root", attrs);
    File dir = new File("testDiskStoreValidation");
    dir.mkdir();
    dir.deleteOnExit();
    File[] dirs2 = new File[] { dir, new File("").getAbsoluteFile() };
    try {
        AttributesFactory factory = new AttributesFactory();
        factory.setDiskDirs(dirs2);
        factory.setDiskStoreName(getUniqueName());
        RegionAttributes ra = factory.create();
        fail("Expected IllegalStateException to be thrown");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setDiskDirs or setDiskWriteAttributes", getUniqueName())));
    }
    try {
        AttributesFactory factory = new AttributesFactory();
        factory.setDiskStoreName(getUniqueName());
        factory.setDiskDirs(dirs2);
        RegionAttributes ra = factory.create();
        fail("Expected IllegalStateException to be thrown");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setDiskDirs", getUniqueName())));
    }
    testXml(cache);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) EvictionAttributes(org.apache.geode.cache.EvictionAttributes) AttributesFactory(org.apache.geode.cache.AttributesFactory) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test)

Example 87 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testBridgeMaxThreads.

/**
   * Tests the bridge-server attributes ({@code max-threads}
   */
@Test
public void testBridgeMaxThreads() throws Exception {
    CacheCreation cache = new CacheCreation();
    CacheServer bs = cache.addCacheServer();
    bs.setMaxThreads(37);
    bs.setMaxConnections(999);
    bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setDataPolicy(DataPolicy.NORMAL);
    cache.createVMRegion("rootNORMAL", attrs);
    testXml(cache);
}
Also used : CacheServer(org.apache.geode.cache.server.CacheServer) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 88 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testEvictionLRUEntryAttributes.

@Test
public void testEvictionLRUEntryAttributes() throws Exception {
    final String rName = getUniqueName();
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    attrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(80, EvictionAction.LOCAL_DESTROY));
    cache.createRegion(rName, attrs);
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Example 89 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testDefaultRecoveryDelayAttributes.

/**
   * Tests that a region created with a named attributes set programmatically for recovery-delay has
   * the correct attributes.
   */
@Test
public void testDefaultRecoveryDelayAttributes() throws Exception {
    CacheCreation cache = new CacheCreation();
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    PartitionAttributesFactory paf = new PartitionAttributesFactory();
    paf.setRedundantCopies(1);
    paf.setTotalMaxMemory(500);
    paf.setLocalMaxMemory(100);
    attrs.setPartitionAttributes(paf.create());
    cache.createRegion("parRoot", attrs);
    Region r = cache.getRegion("parRoot");
    assertEquals(r.getAttributes().getPartitionAttributes().getRedundantCopies(), 1);
    assertEquals(r.getAttributes().getPartitionAttributes().getLocalMaxMemory(), 100);
    assertEquals(r.getAttributes().getPartitionAttributes().getTotalMaxMemory(), 500);
    assertEquals(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
    assertEquals(0, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Region region = c.getRegion("parRoot");
    assertNotNull(region);
    RegionAttributes regionAttrs = region.getAttributes();
    PartitionAttributes pa = regionAttrs.getPartitionAttributes();
    assertEquals(pa.getRedundantCopies(), 1);
    assertEquals(pa.getLocalMaxMemory(), 100);
    assertEquals(pa.getTotalMaxMemory(), 500);
    assertEquals(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
    assertEquals(0, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
}
Also used : PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Cache(org.apache.geode.cache.Cache) ClientCache(org.apache.geode.cache.client.ClientCache) Test(org.junit.Test)

Example 90 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testDefaultCache.

/**
   * Tests creating a cache with the default lock-timeout, lock-lease, and search-timeout.
   */
@Test
public void testDefaultCache() throws Exception {
    CacheCreation cache = new CacheCreation();
    testXml(cache);
}
Also used : CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) Test(org.junit.Test)

Aggregations

CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)153 Test (org.junit.Test)143 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)114 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)86 Region (org.apache.geode.cache.Region)62 LocalRegion (org.apache.geode.internal.cache.LocalRegion)57 Cache (org.apache.geode.cache.Cache)53 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)53 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)53 ClientCache (org.apache.geode.cache.client.ClientCache)42 RegionAttributes (org.apache.geode.cache.RegionAttributes)35 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)35 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)35 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)25 CacheServer (org.apache.geode.cache.server.CacheServer)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)16 File (java.io.File)15 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)12 AttributesFactory (org.apache.geode.cache.AttributesFactory)9 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9