Search in sources :

Example 1 with GatewayEventFilter

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

the class AbstractGatewaySenderEventProcessor method handleSuccessfulBatchDispatch.

private void handleSuccessfulBatchDispatch(List filteredList, List events) {
    if (filteredList != null) {
        for (GatewayEventFilter filter : sender.getGatewayEventFilters()) {
            for (Iterator i = filteredList.iterator(); i.hasNext(); ) {
                Object o = i.next();
                if (o != null && o instanceof GatewaySenderEventImpl) {
                    try {
                        filter.afterAcknowledgement((GatewaySenderEventImpl) o);
                    } catch (Exception e) {
                        logger.fatal(LocalizedMessage.create(LocalizedStrings.GatewayEventFilter_EXCEPTION_OCCURRED_WHILE_HANDLING_CALL_TO_0_AFTER_ACKNOWLEDGEMENT_FOR_EVENT_1, new Object[] { filter.toString(), o }), e);
                    }
                }
            }
        }
    }
    filteredList.clear();
    eventQueueRemove(events.size());
    final GatewaySenderStats statistics = this.sender.getStatistics();
    int queueSize = eventQueueSize();
    // Log an alert for each event if necessary
    if (this.sender.getAlertThreshold() > 0) {
        Iterator it = events.iterator();
        long currentTime = System.currentTimeMillis();
        while (it.hasNext()) {
            Object o = it.next();
            if (o != null && o instanceof GatewaySenderEventImpl) {
                GatewaySenderEventImpl ge = (GatewaySenderEventImpl) o;
                if (ge.getCreationTime() + this.sender.getAlertThreshold() < currentTime) {
                    logger.warn(LocalizedMessage.create(LocalizedStrings.GatewayImpl_EVENT_QUEUE_ALERT_OPERATION_0_REGION_1_KEY_2_VALUE_3_TIME_4, new Object[] { ge.getOperation(), ge.getRegionPath(), ge.getKey(), ge.getValueAsString(true), currentTime - ge.getCreationTime() }));
                    statistics.incEventsExceedingAlertThreshold();
                }
            }
        }
    }
    if (this.eventQueueSizeWarning && queueSize <= AbstractGatewaySender.QUEUE_SIZE_THRESHOLD) {
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_THE_EVENT_QUEUE_SIZE_HAS_DROPPED_BELOW_THE_THRESHOLD_0, AbstractGatewaySender.QUEUE_SIZE_THRESHOLD));
        this.eventQueueSizeWarning = false;
    }
    incrementBatchId();
}
Also used : Iterator(java.util.Iterator) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException) GemFireException(org.apache.geode.GemFireException) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Example 2 with GatewayEventFilter

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

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

the class CacheXmlGenerator method generateAsyncEventQueue.

private void generateAsyncEventQueue(Cache cache) throws SAXException {
    Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
    for (AsyncEventQueue asyncEventQueue : asyncEventQueues) {
        AttributesImpl atts = new AttributesImpl();
        // id
        atts.addAttribute("", "", ID, "", asyncEventQueue.getId());
        // parallel
        if (generateDefaults() || asyncEventQueue.isParallel() != GatewaySender.DEFAULT_IS_PARALLEL)
            atts.addAttribute("", "", PARALLEL, "", String.valueOf(asyncEventQueue.isParallel()));
        // batch-size
        if (generateDefaults() || asyncEventQueue.getBatchSize() != GatewaySender.DEFAULT_BATCH_SIZE)
            atts.addAttribute("", "", BATCH_SIZE, "", String.valueOf(asyncEventQueue.getBatchSize()));
        // batch-time-interval
        if (generateDefaults() || asyncEventQueue.getBatchTimeInterval() != GatewaySender.DEFAULT_BATCH_TIME_INTERVAL)
            atts.addAttribute("", "", BATCH_TIME_INTERVAL, "", String.valueOf(asyncEventQueue.getBatchTimeInterval()));
        // enable-batch-conflation
        if (generateDefaults() || asyncEventQueue.isBatchConflationEnabled() != GatewaySender.DEFAULT_BATCH_CONFLATION)
            atts.addAttribute("", "", ENABLE_BATCH_CONFLATION, "", String.valueOf(asyncEventQueue.isBatchConflationEnabled()));
        // maximum-queue-memory
        if (generateDefaults() || asyncEventQueue.getMaximumQueueMemory() != GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY)
            atts.addAttribute("", "", MAXIMUM_QUEUE_MEMORY, "", String.valueOf(asyncEventQueue.getMaximumQueueMemory()));
        // enable-persistence
        if (generateDefaults() || asyncEventQueue.isPersistent() != GatewaySender.DEFAULT_PERSISTENCE_ENABLED)
            atts.addAttribute("", "", PERSISTENT, "", String.valueOf(asyncEventQueue.isPersistent()));
        if (asyncEventQueue.isPersistent()) {
            // disk-store-name
            if (generateDefaults() || (asyncEventQueue.getDiskStoreName() != null && !asyncEventQueue.getDiskStoreName().equals("")))
                atts.addAttribute("", "", DISK_STORE_NAME, "", String.valueOf(asyncEventQueue.getDiskStoreName()));
        }
        // dispatcher-threads
        if (generateDefaults() || asyncEventQueue.getDispatcherThreads() != GatewaySender.DEFAULT_DISPATCHER_THREADS)
            atts.addAttribute("", "", DISPATCHER_THREADS, "", String.valueOf(asyncEventQueue.getDispatcherThreads()));
        // order-policy
        if (asyncEventQueue.getOrderPolicy() != null) {
            if (generateDefaults() || !asyncEventQueue.getOrderPolicy().equals(GatewaySender.DEFAULT_ORDER_POLICY))
                atts.addAttribute("", "", ORDER_POLICY, "", String.valueOf(asyncEventQueue.getOrderPolicy()));
        }
        // eviction and expiration events
        if (this.version.compareTo(CacheXmlVersion.GEODE_1_0) >= 0) {
            if (generateDefaults() || asyncEventQueue.isForwardExpirationDestroy() != (GatewaySender.DEFAULT_FORWARD_EXPIRATION_DESTROY))
                atts.addAttribute("", "", FORWARD_EXPIRATION_DESTROY, "", String.valueOf(asyncEventQueue.isForwardExpirationDestroy()));
        }
        // disk-synchronous
        if (generateDefaults() || asyncEventQueue.isDiskSynchronous() != GatewaySender.DEFAULT_DISK_SYNCHRONOUS)
            atts.addAttribute("", "", DISK_SYNCHRONOUS, "", String.valueOf(asyncEventQueue.isDiskSynchronous()));
        // AsyncEventQueue element start
        handler.startElement("", ASYNC_EVENT_QUEUE, ASYNC_EVENT_QUEUE, atts);
        List<GatewayEventFilter> eventFilters = asyncEventQueue.getGatewayEventFilters();
        if (eventFilters != null) {
            for (GatewayEventFilter eventFilter : eventFilters) {
                generateGatewayEventFilter(eventFilter);
            }
        }
        if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) >= 0) {
            if (asyncEventQueue.getGatewayEventSubstitutionFilter() != null) {
                generateGatewayEventSubstitutionFilter(asyncEventQueue.getGatewayEventSubstitutionFilter());
            }
        }
        AsyncEventListener asyncListener = asyncEventQueue.getAsyncEventListener();
        if (asyncListener != null) {
            generate(ASYNC_EVENT_LISTENER, asyncListener);
        }
        handler.endElement("", ASYNC_EVENT_QUEUE, ASYNC_EVENT_QUEUE);
    }
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 4 with GatewayEventFilter

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

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

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