Search in sources :

Example 11 with DiskWriteAttributesFactory

use of org.apache.geode.cache.DiskWriteAttributesFactory in project geode by apache.

the class CacheXml66DUnitTest method testDiskWriteAttributes.

/**
   * Tests {@code DiskWriteAttributes}
   */
@Test
public void testDiskWriteAttributes() throws Exception {
    CacheCreation cache = new CacheCreation();
    // Set properties for Asynch writes
    RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
    RegionCreation root = (RegionCreation) cache.createRegion("root", attrs);
    {
        attrs = new RegionAttributesCreation(cache);
        DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
        dwaf.setSynchronous(true);
        attrs.setDiskWriteAttributes(dwaf.create());
        root.createSubregion("sync", attrs);
    }
    {
        attrs = new RegionAttributesCreation(cache);
        DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
        dwaf.setTimeInterval(123L);
        dwaf.setBytesThreshold(456L);
        attrs.setDiskWriteAttributes(dwaf.create());
        root.createSubregion("async", attrs);
    }
    testXml(cache);
}
Also used : RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 12 with DiskWriteAttributesFactory

use of org.apache.geode.cache.DiskWriteAttributesFactory in project geode by apache.

the class PersistentRecoveryOrderOldConfigDUnitTest method createPersistentRegionAsync.

@Override
protected AsyncInvocation createPersistentRegionAsync(final VM vm) {
    SerializableRunnable createRegion = new SerializableRunnable("Create persistent region") {

        public void run() {
            Cache cache = getCache();
            File dir = getDiskDirForVM(vm);
            dir.mkdirs();
            RegionFactory rf = new RegionFactory();
            // rf.setDiskSynchronous(true);
            rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
            rf.setScope(Scope.DISTRIBUTED_ACK);
            rf.setDiskDirs(new File[] { dir });
            DiskWriteAttributesFactory dwf = new DiskWriteAttributesFactory();
            dwf.setMaxOplogSize(1);
            dwf.setSynchronous(true);
            rf.setDiskWriteAttributes(dwf.create());
            rf.create(REGION_NAME);
        }
    };
    return vm.invokeAsync(createRegion);
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) File(java.io.File) Cache(org.apache.geode.cache.Cache)

Example 13 with DiskWriteAttributesFactory

use of org.apache.geode.cache.DiskWriteAttributesFactory in project geode by apache.

the class DiskWriteAttributesJUnitTest method testGetDefaultInstance.

/**
   * Test method for 'org.apache.geode.cache.DiskWriteAttributes.getDefaultInstance()'
   */
@Test
public void testGetDefaultInstance() {
    DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
    DiskWriteAttributes dwa = dwaf.create();
    assertTrue(!dwa.isSynchronous());
    assertTrue(dwa.isRollOplogs());
}
Also used : DiskWriteAttributes(org.apache.geode.cache.DiskWriteAttributes) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 14 with DiskWriteAttributesFactory

use of org.apache.geode.cache.DiskWriteAttributesFactory in project geode by apache.

the class DiskWriteAttributesJUnitTest method testDiskWriteAttributesCreation.

/**
   * Tests the behaviour of DiskWriteAttributesFactory & DiskWritesAttrbutes with various
   * combinations of time interval & buffer size.
   */
@Test
public void testDiskWriteAttributesCreation() {
    DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
    dwaf.setSynchronous(true);
    DiskWriteAttributes dwa = dwaf.create();
    assertEquals(dwa.getBytesThreshold(), 0);
    assertEquals(dwa.getTimeInterval(), 0);
    dwaf.setSynchronous(false);
    dwa = dwaf.create();
    assertEquals(dwa.getBytesThreshold(), 0);
    assertEquals(dwa.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    dwaf.setBytesThreshold(0);
    dwa = dwaf.create();
    assertEquals(dwa.getBytesThreshold(), 0);
    assertEquals(dwa.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    dwaf.setBytesThreshold(1);
    dwa = dwaf.create();
    assertEquals(dwa.getBytesThreshold(), 1);
    assertEquals(dwa.getTimeInterval(), 0);
    dwaf.setBytesThreshold(0);
    dwaf.setTimeInterval(0);
    dwa = dwaf.create();
    assertEquals(dwa.getBytesThreshold(), 0);
    assertEquals(dwa.getTimeInterval(), 0);
    DiskWriteAttributesFactory dwaf1 = new DiskWriteAttributesFactory();
    DiskWriteAttributes dwa1 = dwaf1.create();
    assertEquals(dwa1.getBytesThreshold(), 0);
    assertEquals(dwa1.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    DiskWriteAttributesFactory dwaf2 = new DiskWriteAttributesFactory(dwa1);
    DiskWriteAttributes dwa2 = dwaf2.create();
    assertEquals(dwa2.getBytesThreshold(), 0);
    assertEquals(dwa2.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    dwaf1 = new DiskWriteAttributesFactory();
    dwaf1.setBytesThreshold(100);
    dwaf2 = new DiskWriteAttributesFactory(dwaf1.create());
    dwa2 = dwaf2.create();
    assertEquals(dwa2.getBytesThreshold(), 100);
    assertEquals(dwa2.getTimeInterval(), 0);
    dwaf1 = new DiskWriteAttributesFactory();
    dwaf1.setBytesThreshold(0);
    dwaf1.setTimeInterval(0);
    dwaf2 = new DiskWriteAttributesFactory(dwaf1.create());
    dwa2 = dwaf2.create();
    assertEquals(dwa2.getBytesThreshold(), 0);
    assertEquals(dwa2.getTimeInterval(), 0);
    dwaf1 = new DiskWriteAttributesFactory();
    dwa1 = dwaf1.create();
    dwaf2 = new DiskWriteAttributesFactory(dwa1);
    dwa2 = dwaf2.create();
    assertEquals(dwa2.getBytesThreshold(), 0);
    assertEquals(dwa2.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    assertEquals(dwa1.getBytesThreshold(), 0);
    assertEquals(dwa1.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    // Important :Notice the behaviour difference in the time nterval setting
    dwaf1.setBytesThreshold(1);
    dwaf2.setBytesThreshold(1);
    dwa1 = dwaf1.create();
    dwa2 = dwaf2.create();
    assertEquals(dwa2.getBytesThreshold(), 1);
    assertEquals(dwa2.getTimeInterval(), DiskWriteAttributesImpl.DEFAULT_TIME_INTERVAL);
    assertEquals(dwa1.getBytesThreshold(), 1);
    assertEquals(dwa1.getTimeInterval(), 0);
}
Also used : DiskWriteAttributes(org.apache.geode.cache.DiskWriteAttributes) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 15 with DiskWriteAttributesFactory

use of org.apache.geode.cache.DiskWriteAttributesFactory in project geode by apache.

the class DiskWriteAttributesJUnitTest method testGetDefaultAsync.

/**
   * Test method for 'org.apache.geode.cache.DiskWriteAttributes.getDefaultAsync()'
   */
@Test
public void testGetDefaultAsync() {
    DiskWriteAttributesFactory dwaf = new DiskWriteAttributesFactory();
    DiskWriteAttributes dwa = dwaf.create();
    assertTrue(!dwa.isSynchronous());
    assertTrue(dwa.isRollOplogs());
}
Also used : DiskWriteAttributes(org.apache.geode.cache.DiskWriteAttributes) DiskWriteAttributesFactory(org.apache.geode.cache.DiskWriteAttributesFactory) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)17 Test (org.junit.Test)14 DiskWriteAttributes (org.apache.geode.cache.DiskWriteAttributes)8 UnitTest (org.apache.geode.test.junit.categories.UnitTest)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)4 Region (org.apache.geode.cache.Region)4 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)4 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)4 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)4 Set (java.util.Set)3 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)3 Cache (org.apache.geode.cache.Cache)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 File (java.io.File)1 Properties (java.util.Properties)1 EvictionAttributes (org.apache.geode.cache.EvictionAttributes)1 ExpirationAttributes (org.apache.geode.cache.ExpirationAttributes)1 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)1 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1