Search in sources :

Example 66 with GatewaySender

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

the class ParallelGatewaySenderQueueOverflowDUnitTest method test_ValidateParallelGatewaySenderQueueAttributes_2.

/**
   * Test to validate that ParallelGatewaySenderQueue diskSynchronous attribute when persistence of
   * sender is not enabled.
   */
@Ignore("TODO: test is disabled")
@Test
public void test_ValidateParallelGatewaySenderQueueAttributes_2() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase();
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    // set parallel to true
    fact.setParallel(true);
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // set persistence to false
    fact.setPersistenceEnabled(false);
    fact.setDiskSynchronous(true);
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException ex = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), 1);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        ex.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Ignore(org.junit.Ignore) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 67 with GatewaySender

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

the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_1.

/**
   * Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
   * sender is enabled.
   */
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_1() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase(getTestMethodName());
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    File directory = new File("TKSender" + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
    directory.mkdir();
    File[] dirs1 = new File[] { directory };
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    dsf.setDiskDirs(dirs1);
    DiskStore diskStore = dsf.create("FORNY");
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // enable the persistence
    fact.setPersistenceEnabled(true);
    fact.setDiskSynchronous(true);
    fact.setDiskStoreName("FORNY");
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException exTKSender = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(true, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        exTKSender.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) RegionQueue(org.apache.geode.internal.cache.RegionQueue) DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) File(java.io.File) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 68 with GatewaySender

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

the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_2.

/**
   * Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
   * sender is not enabled.
   */
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_2() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase(getTestMethodName());
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // set persistence to false
    fact.setPersistenceEnabled(false);
    fact.setDiskSynchronous(true);
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException exp = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        exp.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 69 with GatewaySender

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

the class SerialGatewaySenderEventListenerDUnitTest method validateReceivedEventsMapSizeListener2.

public static void validateReceivedEventsMapSizeListener2(final String senderId, final Map map) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    final List<AsyncEventListener> listeners = ((AbstractGatewaySender) sender).getAsyncEventListeners();
    if (listeners.size() == 2) {
        final AsyncEventListener l1 = listeners.get(0);
        final AsyncEventListener l2 = listeners.get(1);
        Awaitility.await().atMost(60000, TimeUnit.MILLISECONDS).until(() -> {
            Map listenerMap1 = ((MyGatewaySenderEventListener) l1).getEventsMap();
            Map listenerMap2 = ((MyGatewaySenderEventListener2) l2).getEventsMap();
            int listener1MapSize = listenerMap1.size();
            int listener2MapSize = listenerMap1.size();
            int expectedMapSize = map.size();
            boolean sizeCorrect = expectedMapSize == listener1MapSize;
            boolean keySetCorrect = listenerMap1.keySet().containsAll(map.keySet());
            boolean valuesCorrect = listenerMap1.values().containsAll(map.values());
            boolean sizeCorrect2 = expectedMapSize == listener2MapSize;
            boolean keySetCorrect2 = listenerMap2.keySet().containsAll(map.keySet());
            boolean valuesCorrect2 = listenerMap2.values().containsAll(map.values());
            assertEquals("Failed while waiting for all sites to get updated with the correct events. \nThe " + "size of listener 1's map = " + listener1MapSize + "\n The size of listener 2's map = " + "" + listener2MapSize + "\n The expected map size =" + expectedMapSize, true, sizeCorrect && keySetCorrect && valuesCorrect && sizeCorrect2 && keySetCorrect2 && valuesCorrect2);
        });
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) MyGatewaySenderEventListener(org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener) MyGatewaySenderEventListener2(org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener2) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) HashMap(java.util.HashMap) Map(java.util.Map) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 70 with GatewaySender

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

the class SerialGatewaySenderEventListenerDUnitTest method validateNoPoolCreation.

public static void validateNoPoolCreation(final String siteId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    for (GatewaySender sender : senders) {
        if (sender.getId().equals(siteId)) {
            AbstractGatewaySender sImpl = (AbstractGatewaySender) sender;
            assertNull(sImpl.getProxy());
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Aggregations

GatewaySender (org.apache.geode.cache.wan.GatewaySender)116 RegionQueue (org.apache.geode.internal.cache.RegionQueue)28 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)28 Test (org.junit.Test)17 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 Region (org.apache.geode.cache.Region)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)9 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)9 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)9 DiskStore (org.apache.geode.cache.DiskStore)8 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)8 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)8 Expectations (org.jmock.Expectations)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5