Search in sources :

Example 6 with GatewayEventFilter

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

the class ParallelGatewaySenderQueueOverflowDUnitTest method test_ValidateParallelGatewaySenderQueueAttributes_1.

/**
   * Test to validate that ParallelGatewaySenderQueue diskSynchronous attribute when persistence of
   * sender is enabled.
   */
@Ignore("TODO: test is disabled")
@Test
public void test_ValidateParallelGatewaySenderQueueAttributes_1() {
    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);
    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();
    // set parallel to true
    fact.setParallel(true);
    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.PERSISTENT_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(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) Ignore(org.junit.Ignore) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 7 with GatewayEventFilter

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

the class WanValidationsDUnitTest method testGatewayEventFilters.

@Test
public void testGatewayEventFilters() {
    Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    createCacheInVMs(lnPort, vm1, vm2);
    ArrayList<GatewayEventFilter> eventFilters = new ArrayList<GatewayEventFilter>();
    eventFilters.add(new MyGatewayEventFilter());
    vm1.invoke(() -> WANTestBase.createSenderForValidations("ln", 2, false, 100, false, false, eventFilters, null, true, false));
    try {
        eventFilters.clear();
        eventFilters.add(new Filter70());
        vm2.invoke(() -> WANTestBase.createSenderForValidations("ln", 2, false, 100, false, false, eventFilters, null, true, false));
        fail("Expected IllegalStateException : GatewayEventFilters Should match");
    } catch (Exception e) {
        if (!(e.getCause() instanceof IllegalStateException) || !(e.getCause().getMessage().contains("because another cache has the same Gateway Sender defined with GatewayEventFilters"))) {
            Assert.fail("Expected IllegalStateException", e);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Filter70(org.apache.geode.internal.cache.wan.Filter70) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 8 with GatewayEventFilter

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

the class CacheXmlParser method endAsyncEventQueue.

private void endAsyncEventQueue() {
    AsyncEventQueueCreation asyncEventChannelCreation = (AsyncEventQueueCreation) stack.peek();
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setParallel(asyncEventChannelCreation.isParallel());
    factory.setBatchSize(asyncEventChannelCreation.getBatchSize());
    factory.setBatchTimeInterval(asyncEventChannelCreation.getBatchTimeInterval());
    factory.setBatchConflationEnabled(asyncEventChannelCreation.isBatchConflationEnabled());
    factory.setPersistent(asyncEventChannelCreation.isPersistent());
    factory.setDiskStoreName(asyncEventChannelCreation.getDiskStoreName());
    factory.setDiskSynchronous(asyncEventChannelCreation.isDiskSynchronous());
    factory.setMaximumQueueMemory(asyncEventChannelCreation.getMaximumQueueMemory());
    factory.setDispatcherThreads(asyncEventChannelCreation.getDispatcherThreads());
    factory.setOrderPolicy(asyncEventChannelCreation.getOrderPolicy());
    factory.setForwardExpirationDestroy(asyncEventChannelCreation.isForwardExpirationDestroy());
    List<GatewayEventFilter> gatewayEventFilters = asyncEventChannelCreation.getGatewayEventFilters();
    for (GatewayEventFilter gatewayEventFilter : gatewayEventFilters) {
        factory.addGatewayEventFilter(gatewayEventFilter);
    }
    factory.setGatewayEventSubstitutionListener(asyncEventChannelCreation.getGatewayEventSubstitutionFilter());
    AsyncEventQueue asyncEventChannel = factory.create(asyncEventChannelCreation.getId(), asyncEventChannelCreation.getAsyncEventListener());
    stack.pop();
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Example 9 with GatewayEventFilter

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

the class CacheXmlParser method endGatewayEventFilter.

private void endGatewayEventFilter() {
    Declarable d = createDeclarable();
    if (!(d instanceof GatewayEventFilter)) {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "GatewayEventFilter" }));
    }
    Object obj = stack.peek();
    if (obj instanceof GatewaySenderFactory) {
        GatewaySenderFactory senderFactory = (GatewaySenderFactory) obj;
        senderFactory.addGatewayEventFilter((GatewayEventFilter) d);
    } else if (obj instanceof AsyncEventQueueCreation) {
        AsyncEventQueueCreation asyncEventQueueCreation = (AsyncEventQueueCreation) obj;
        asyncEventQueueCreation.addGatewayEventFilter((GatewayEventFilter) d);
    } else {
        throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAY_SENDER_OR_ASYNC_EVENT_QUEUE.toLocalizedString("GatewayEventFilter"));
    }
}
Also used : Declarable(org.apache.geode.cache.Declarable) CacheXmlException(org.apache.geode.cache.CacheXmlException) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Example 10 with GatewayEventFilter

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

the class GatewaySenderMBeanBridge method getGatewayEventFilters.

public String[] getGatewayEventFilters() {
    List<GatewayEventFilter> filters = sender.getGatewayEventFilters();
    String[] filtersStr = null;
    if (filters != null && filters.size() > 0) {
        filtersStr = new String[filters.size()];
    } else {
        return filtersStr;
    }
    int j = 0;
    for (GatewayEventFilter filter : filters) {
        filtersStr[j] = filter.toString();
        j++;
    }
    return filtersStr;
}
Also used : GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Aggregations

GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)20 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)10 Test (org.junit.Test)9 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)8 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)8 IgnoredException (org.apache.geode.test.dunit.IgnoredException)7 GatewaySender (org.apache.geode.cache.wan.GatewaySender)6 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)6 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)6 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)6 Region (org.apache.geode.cache.Region)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 AttributesFactory (org.apache.geode.cache.AttributesFactory)4 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)4 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 RegionQueue (org.apache.geode.internal.cache.RegionQueue)4 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)4 WANTestBase (org.apache.geode.internal.cache.wan.WANTestBase)4