Search in sources :

Example 6 with GatewayTransportFilter

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

the class CacheXmlGenerator method generateGatewaySender.

private void generateGatewaySender(GatewaySender sender) throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    // id
    atts.addAttribute("", "", ID, "", sender.getId());
    // remote-distributed-system
    atts.addAttribute("", "", REMOTE_DISTRIBUTED_SYSTEM_ID, "", String.valueOf(sender.getRemoteDSId()));
    // parallel
    if (generateDefaults() || sender.isParallel() != GatewaySender.DEFAULT_IS_PARALLEL)
        atts.addAttribute("", "", PARALLEL, "", String.valueOf(sender.isParallel()));
    // manual-start
    if (generateDefaults() || sender.isManualStart() != GatewaySender.DEFAULT_MANUAL_START)
        atts.addAttribute("", "", MANUAL_START, "", String.valueOf(sender.isManualStart()));
    // socket-buffer-size
    if (generateDefaults() || sender.getSocketBufferSize() != GatewaySender.DEFAULT_SOCKET_BUFFER_SIZE)
        atts.addAttribute("", "", SOCKET_BUFFER_SIZE, "", String.valueOf(sender.getSocketBufferSize()));
    // socket-read-timeout
    if (generateDefaults() || sender.getSocketReadTimeout() != GatewaySender.DEFAULT_SOCKET_READ_TIMEOUT)
        atts.addAttribute("", "", SOCKET_READ_TIMEOUT, "", String.valueOf(sender.getSocketReadTimeout()));
    // enable-batch-conflation
    if (generateDefaults() || sender.isBatchConflationEnabled() != GatewaySender.DEFAULT_BATCH_CONFLATION)
        atts.addAttribute("", "", ENABLE_BATCH_CONFLATION, "", // Should we use ENABLE-CONFLATION
        String.valueOf(sender.isBatchConflationEnabled()));
    // batch-size
    if (generateDefaults() || sender.getBatchSize() != GatewaySender.DEFAULT_BATCH_SIZE)
        atts.addAttribute("", "", BATCH_SIZE, "", String.valueOf(sender.getBatchSize()));
    // batch-time-interval
    if (generateDefaults() || sender.getBatchTimeInterval() != GatewaySender.DEFAULT_BATCH_TIME_INTERVAL)
        atts.addAttribute("", "", BATCH_TIME_INTERVAL, "", String.valueOf(sender.getBatchTimeInterval()));
    // enable-persistence
    if (generateDefaults() || sender.isPersistenceEnabled() != GatewaySender.DEFAULT_PERSISTENCE_ENABLED)
        atts.addAttribute("", "", ENABLE_PERSISTENCE, "", String.valueOf(sender.isPersistenceEnabled()));
    // disk-store-name
    if (generateDefaults() || sender.getDiskStoreName() != null && !sender.getDiskStoreName().equals(""))
        atts.addAttribute("", "", DISK_STORE_NAME, "", String.valueOf(sender.getDiskStoreName()));
    // disk-synchronous
    if (generateDefaults() || sender.isDiskSynchronous() != GatewaySender.DEFAULT_DISK_SYNCHRONOUS)
        atts.addAttribute("", "", DISK_SYNCHRONOUS, "", String.valueOf(sender.isDiskSynchronous()));
    // maximum-queue-memory
    if (generateDefaults() || sender.getMaximumQueueMemory() != GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY)
        atts.addAttribute("", "", MAXIMUM_QUEUE_MEMORY, "", String.valueOf(sender.getMaximumQueueMemory()));
    // alert-threshold
    if (generateDefaults() || sender.getAlertThreshold() != GatewaySender.DEFAULT_ALERT_THRESHOLD)
        atts.addAttribute("", "", ALERT_THRESHOLD, "", String.valueOf(sender.getAlertThreshold()));
    // dispatcher-threads
    if (generateDefaults() || sender.getDispatcherThreads() != GatewaySender.DEFAULT_DISPATCHER_THREADS)
        atts.addAttribute("", "", DISPATCHER_THREADS, "", String.valueOf(sender.getDispatcherThreads()));
    // order-policy
    if (sender.getOrderPolicy() != null) {
        if (generateDefaults() || !sender.getOrderPolicy().equals(GatewaySender.DEFAULT_ORDER_POLICY))
            atts.addAttribute("", "", ORDER_POLICY, "", String.valueOf(sender.getOrderPolicy()));
    }
    handler.startElement("", GATEWAY_SENDER, GATEWAY_SENDER, atts);
    for (GatewayEventFilter gef : sender.getGatewayEventFilters()) {
        generateGatewayEventFilter(gef);
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) >= 0) {
        if (sender.getGatewayEventSubstitutionFilter() != null) {
            generateGatewayEventSubstitutionFilter(sender.getGatewayEventSubstitutionFilter());
        }
    }
    for (GatewayTransportFilter gsf : sender.getGatewayTransportFilters()) {
        generateGatewayTransportFilter(gsf);
    }
    handler.endElement("", GATEWAY_SENDER, GATEWAY_SENDER);
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Example 7 with GatewayTransportFilter

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

the class SerialGatewaySenderImpl method fillInProfile.

@Override
public void fillInProfile(Profile profile) {
    assert profile instanceof GatewaySenderProfile;
    GatewaySenderProfile pf = (GatewaySenderProfile) profile;
    pf.Id = getId();
    pf.startTime = getStartTime();
    pf.remoteDSId = getRemoteDSId();
    pf.isRunning = isRunning();
    pf.isPrimary = isPrimary();
    pf.isParallel = false;
    pf.isBatchConflationEnabled = isBatchConflationEnabled();
    pf.isPersistenceEnabled = isPersistenceEnabled();
    pf.alertThreshold = getAlertThreshold();
    pf.manualStart = isManualStart();
    for (org.apache.geode.cache.wan.GatewayEventFilter filter : getGatewayEventFilters()) {
        pf.eventFiltersClassNames.add(filter.getClass().getName());
    }
    for (GatewayTransportFilter filter : getGatewayTransportFilters()) {
        pf.transFiltersClassNames.add(filter.getClass().getName());
    }
    for (AsyncEventListener listener : getAsyncEventListeners()) {
        pf.senderEventListenerClassNames.add(listener.getClass().getName());
    }
    pf.isDiskSynchronous = isDiskSynchronous();
    pf.dispatcherThreads = getDispatcherThreads();
    pf.orderPolicy = getOrderPolicy();
    pf.serverLocation = this.getServerLocation();
}
Also used : GatewaySenderProfile(org.apache.geode.internal.cache.wan.GatewaySenderAdvisor.GatewaySenderProfile) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 8 with GatewayTransportFilter

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

the class CacheXml80GatewayDUnitTest method testGatewayReceiverWithManualStartTRUE.

@Test
public void testGatewayReceiverWithManualStartTRUE() throws Exception {
    // getSystem();
    CacheCreation cache = new CacheCreation();
    GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
    gatewayReceiverFactory.setBindAddress("");
    gatewayReceiverFactory.setStartPort(20000);
    gatewayReceiverFactory.setEndPort(29999);
    gatewayReceiverFactory.setMaximumTimeBetweenPings(2000);
    gatewayReceiverFactory.setSocketBufferSize(1500);
    gatewayReceiverFactory.setManualStart(true);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
    GatewayReceiver receiver1 = gatewayReceiverFactory.create();
    receiver1.start();
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<GatewayReceiver> receivers = c.getGatewayReceivers();
    for (GatewayReceiver receiver : receivers) {
        validateGatewayReceiver(receiver1, receiver);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) 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) Test(org.junit.Test) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 9 with GatewayTransportFilter

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

the class ParallelGatewaySenderImpl method fillInProfile.

public void fillInProfile(Profile profile) {
    assert profile instanceof GatewaySenderProfile;
    GatewaySenderProfile pf = (GatewaySenderProfile) profile;
    pf.Id = getId();
    pf.remoteDSId = getRemoteDSId();
    pf.isRunning = isRunning();
    pf.isPrimary = isPrimary();
    pf.isParallel = true;
    pf.isBatchConflationEnabled = isBatchConflationEnabled();
    pf.isPersistenceEnabled = isPersistenceEnabled();
    pf.alertThreshold = getAlertThreshold();
    pf.manualStart = isManualStart();
    pf.dispatcherThreads = getDispatcherThreads();
    pf.orderPolicy = getOrderPolicy();
    for (GatewayEventFilter filter : getGatewayEventFilters()) {
        pf.eventFiltersClassNames.add(filter.getClass().getName());
    }
    for (GatewayTransportFilter filter : getGatewayTransportFilters()) {
        pf.transFiltersClassNames.add(filter.getClass().getName());
    }
    for (AsyncEventListener listener : getAsyncEventListeners()) {
        pf.senderEventListenerClassNames.add(listener.getClass().getName());
    }
    pf.isDiskSynchronous = isDiskSynchronous();
}
Also used : GatewaySenderProfile(org.apache.geode.internal.cache.wan.GatewaySenderAdvisor.GatewaySenderProfile) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 10 with GatewayTransportFilter

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

the class WANTestBase method createSenderForValidations.

public static void createSenderForValidations(String dsName, int remoteDsId, boolean isParallel, Integer alertThreshold, boolean isConflation, boolean isPersistent, List<GatewayEventFilter> eventFilters, List<GatewayTransportFilter> transportFilters, boolean isManualStart, boolean isDiskSync) {
    IgnoredException exp1 = IgnoredException.addIgnoredException(RegionDestroyedException.class.getName());
    try {
        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.setAlertThreshold(alertThreshold);
            ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
            if (eventFilters != null) {
                for (GatewayEventFilter filter : eventFilters) {
                    gateway.addGatewayEventFilter(filter);
                }
            }
            if (transportFilters != null) {
                for (GatewayTransportFilter filter : transportFilters) {
                    gateway.addGatewayTransportFilter(filter);
                }
            }
            if (isPersistent) {
                gateway.setPersistenceEnabled(true);
                gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName + "_Parallel").getName());
            } else {
                DiskStore store = dsf.setDiskDirs(dirs1).create(dsName + "_Parallel");
                gateway.setDiskStoreName(store.getName());
            }
            gateway.setDiskSynchronous(isDiskSync);
            gateway.setBatchConflationEnabled(isConflation);
            gateway.setManualStart(isManualStart);
            // set dispatcher threads
            gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
            gateway.create(dsName, remoteDsId);
        } else {
            GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
            gateway.setAlertThreshold(alertThreshold);
            gateway.setManualStart(isManualStart);
            // set dispatcher threads
            gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
            ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
            if (eventFilters != null) {
                for (GatewayEventFilter filter : eventFilters) {
                    gateway.addGatewayEventFilter(filter);
                }
            }
            if (transportFilters != null) {
                for (GatewayTransportFilter filter : transportFilters) {
                    gateway.addGatewayTransportFilter(filter);
                }
            }
            gateway.setBatchConflationEnabled(isConflation);
            if (isPersistent) {
                gateway.setPersistenceEnabled(true);
                gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName + "_Serial").getName());
            } else {
                DiskStore store = dsf.setDiskDirs(dirs1).create(dsName + "_Serial");
                gateway.setDiskStoreName(store.getName());
            }
            gateway.setDiskSynchronous(isDiskSync);
            gateway.create(dsName, remoteDsId);
        }
    } finally {
        exp1.remove();
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Aggregations

GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)25 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)10 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)10 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)10 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 Test (org.junit.Test)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)7 IgnoredException (org.apache.geode.test.dunit.IgnoredException)7 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)6 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 AttributesFactory (org.apache.geode.cache.AttributesFactory)5 DiskStore (org.apache.geode.cache.DiskStore)5 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)5 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)5 GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)5 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)5 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)5