Search in sources :

Example 71 with DiskStoreFactory

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

the class DiskRegionIllegalArguementsJUnitTest method testMaxOplogSize.

/**
   * test Illegal max oplog size
   */
@Test
public void testMaxOplogSize() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    try {
        dsf.setMaxOplogSize(-1);
        fail("expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {
    }
    dsf.setMaxOplogSize(1);
    assertEquals(1, dsf.create("test").getMaxOplogSize());
}
Also used : DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 72 with DiskStoreFactory

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

the class DiskRegionIllegalArguementsJUnitTest method testAllowForceCompaction.

@Test
public void testAllowForceCompaction() {
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    dsf.setAllowForceCompaction(true);
    assertEquals(true, dsf.create("test").getAllowForceCompaction());
    dsf.setAllowForceCompaction(false);
    assertEquals(false, dsf.create("test2").getAllowForceCompaction());
}
Also used : DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 73 with DiskStoreFactory

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

the class IndexCommandsDUnitTest method createParRegWithPersistence.

private Region<?, ?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) {
    Cache cache = getCache();
    File diskStoreDirFile = new File(diskDirName);
    diskStoreDirFile.deleteOnExit();
    if (!diskStoreDirFile.exists()) {
        diskStoreDirFile.mkdirs();
    }
    DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory();
    diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile });
    diskStoreFactory.setMaxOplogSize(1);
    diskStoreFactory.setAllowForceCompaction(true);
    diskStoreFactory.setAutoCompact(false);
    diskStoreFactory.create(diskStoreName);
    /****
     * Eviction Attributes
     */
    EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
    RegionFactory regionFactory = cache.createRegionFactory();
    regionFactory.setDiskStoreName(diskStoreName);
    regionFactory.setDiskSynchronous(true);
    regionFactory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
    regionFactory.setEvictionAttributes(ea);
    return regionFactory.create(regionName);
}
Also used : EvictionAttributes(org.apache.geode.cache.EvictionAttributes) RegionFactory(org.apache.geode.cache.RegionFactory) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) Cache(org.apache.geode.cache.Cache)

Example 74 with DiskStoreFactory

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

the class SenderWithTransportFilterDUnitTest method createSenderWithTransportFilter.

public static void createSenderWithTransportFilter(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, boolean isManualStart) {
    File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
    persistentDirectory.mkdir();
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    File[] dirs1 = new File[] { persistentDirectory };
    if (isParallel) {
        GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
        gateway.setParallel(true);
        gateway.setMaximumQueueMemory(maxMemory);
        gateway.setBatchSize(batchSize);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
        transportFilters.add(new CheckSumTransportFilter("CheckSumTransportFilter"));
        if (!transportFilters.isEmpty()) {
            for (GatewayTransportFilter filter : transportFilters) {
                gateway.addGatewayTransportFilter(filter);
            }
        }
        if (isPersistent) {
            gateway.setPersistenceEnabled(true);
            gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
        } else {
            DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
            gateway.setDiskStoreName(store.getName());
        }
        gateway.setBatchConflationEnabled(isConflation);
        gateway.create(dsName, remoteDsId);
    } else {
        GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
        gateway.setMaximumQueueMemory(maxMemory);
        gateway.setBatchSize(batchSize);
        gateway.setManualStart(isManualStart);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
        transportFilters.add(new CheckSumTransportFilter("CheckSumTransportFilter"));
        if (!transportFilters.isEmpty()) {
            for (GatewayTransportFilter filter : transportFilters) {
                gateway.addGatewayTransportFilter(filter);
            }
        }
        gateway.setBatchConflationEnabled(isConflation);
        if (isPersistent) {
            gateway.setPersistenceEnabled(true);
            gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
        } else {
            DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
            gateway.setDiskStoreName(store.getName());
        }
        gateway.create(dsName, remoteDsId);
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) ArrayList(java.util.ArrayList) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) File(java.io.File) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Example 75 with DiskStoreFactory

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

the class WANTestBase method createSender.

public static void createSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManualStart) {
    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
    try {
        File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
        persistentDirectory.mkdir();
        DiskStoreFactory dsf = cache.createDiskStoreFactory();
        File[] dirs1 = new File[] { persistentDirectory };
        GatewaySenderFactory gateway = configureGateway(dsf, dirs1, dsName, isParallel, maxMemory, batchSize, isConflation, isPersistent, filter, isManualStart, numDispatcherThreadsForTheRun, GatewaySender.DEFAULT_ORDER_POLICY);
        gateway.create(dsName, remoteDsId);
    } finally {
        exln.remove();
    }
}
Also used : GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Aggregations

DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)132 File (java.io.File)95 DiskStore (org.apache.geode.cache.DiskStore)91 Test (org.junit.Test)86 AttributesFactory (org.apache.geode.cache.AttributesFactory)56 Region (org.apache.geode.cache.Region)46 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)46 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)35 Cache (org.apache.geode.cache.Cache)32 LocalRegion (org.apache.geode.internal.cache.LocalRegion)24 RegionFactory (org.apache.geode.cache.RegionFactory)22 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)21 DiskRegion (org.apache.geode.internal.cache.DiskRegion)19 Properties (java.util.Properties)18 VM (org.apache.geode.test.dunit.VM)18 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)16 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)12 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)11 IOException (java.io.IOException)10 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)10