Search in sources :

Example 21 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.

the class CacheXml70GatewayDUnitTest method testParallelGatewaySender.

@Test
public void testParallelGatewaySender() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
    gatewaySenderFactory.setParallel(true);
    gatewaySenderFactory.setDispatcherThreads(13);
    gatewaySenderFactory.setManualStart(true);
    gatewaySenderFactory.setSocketBufferSize(1234);
    gatewaySenderFactory.setSocketReadTimeout(1050);
    gatewaySenderFactory.setBatchConflationEnabled(false);
    gatewaySenderFactory.setBatchSize(88);
    gatewaySenderFactory.setBatchTimeInterval(9);
    gatewaySenderFactory.setPersistenceEnabled(true);
    gatewaySenderFactory.setDiskStoreName("LNSender");
    gatewaySenderFactory.setDiskSynchronous(true);
    gatewaySenderFactory.setMaximumQueueMemory(211);
    gatewaySenderFactory.setAlertThreshold(35);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    gatewaySenderFactory.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter2);
    GatewaySender parallelGatewaySender = gatewaySenderFactory.create("LN", 2);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<GatewaySender> sendersOnCache = c.getGatewaySenders();
    for (GatewaySender sender : sendersOnCache) {
        assertEquals(true, sender.isParallel());
        validateGatewaySender(parallelGatewaySender, sender);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 22 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.

the class CacheXml70GatewayDUnitTest method testSerialGatewaySender.

@Test
public void testSerialGatewaySender() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
    gatewaySenderFactory.setParallel(false);
    gatewaySenderFactory.setManualStart(true);
    gatewaySenderFactory.setSocketBufferSize(124);
    gatewaySenderFactory.setSocketReadTimeout(1000);
    gatewaySenderFactory.setBatchConflationEnabled(false);
    gatewaySenderFactory.setBatchSize(100);
    gatewaySenderFactory.setBatchTimeInterval(10);
    gatewaySenderFactory.setPersistenceEnabled(true);
    gatewaySenderFactory.setDiskStoreName("LNSender");
    gatewaySenderFactory.setDiskSynchronous(true);
    gatewaySenderFactory.setMaximumQueueMemory(200);
    gatewaySenderFactory.setAlertThreshold(30);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    gatewaySenderFactory.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter2);
    GatewaySender serialGatewaySender = gatewaySenderFactory.create("LN", 2);
    RegionAttributesCreation attrs = new RegionAttributesCreation();
    attrs.addGatewaySenderId(serialGatewaySender.getId());
    cache.createRegion("UserRegion", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<GatewaySender> sendersOnCache = c.getGatewaySenders();
    for (GatewaySender sender : sendersOnCache) {
        assertEquals(false, sender.isParallel());
        validateGatewaySender(serialGatewaySender, sender);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 23 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.

the class UpdateVersionDUnitTest method createSender.

public static void createSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, 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);
        gateway.setManualStart(isManualStart);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        if (filter != null) {
            gateway.addGatewayEventFilter(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());
        if (filter != null) {
            gateway.addGatewayEventFilter(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) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) File(java.io.File) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Example 24 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.

the class WANTestBase method createSenderWithDiskStore.

public static String createSenderWithDiskStore(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, String dsStore, boolean isManualStart) {
    File persistentDirectory = null;
    if (dsStore == null) {
        persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
    } else {
        persistentDirectory = new File(dsStore);
    }
    LogWriterUtils.getLogWriter().info("The ds is : " + persistentDirectory.getName());
    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);
        gateway.setManualStart(isManualStart);
        // set dispatcher threads
        gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        if (filter != null) {
            gateway.addGatewayEventFilter(filter);
        }
        if (isPersistent) {
            gateway.setPersistenceEnabled(true);
            String dsname = dsf.setDiskDirs(dirs1).create(dsName).getName();
            gateway.setDiskStoreName(dsname);
            LogWriterUtils.getLogWriter().info("The DiskStoreName is : " + dsname);
        } else {
            DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
            gateway.setDiskStoreName(store.getName());
            LogWriterUtils.getLogWriter().info("The ds is : " + store.getName());
        }
        gateway.setBatchConflationEnabled(isConflation);
        gateway.create(dsName, remoteDsId);
    } else {
        GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
        gateway.setMaximumQueueMemory(maxMemory);
        gateway.setBatchSize(batchSize);
        gateway.setManualStart(isManualStart);
        // set dispatcher threads
        gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        if (filter != null) {
            gateway.addGatewayEventFilter(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);
    }
    return persistentDirectory.getName();
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Example 25 with GatewaySenderFactory

use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.

the class WANTestBase method createSenderWithMultipleDispatchers.

public static void createSenderWithMultipleDispatchers(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManualStart, int numDispatchers, OrderPolicy orderPolicy) {
    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, numDispatchers, orderPolicy);
        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