Search in sources :

Example 26 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory 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 27 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory 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

GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)27 File (java.io.File)12 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)12 DiskStore (org.apache.geode.cache.DiskStore)10 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)9 IgnoredException (org.apache.geode.test.dunit.IgnoredException)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 Test (org.junit.Test)9 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)6 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)6 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)6 Properties (java.util.Properties)5 Region (org.apache.geode.cache.Region)5 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 RegionQueue (org.apache.geode.internal.cache.RegionQueue)4