Search in sources :

Example 1 with AsyncEventListener

use of org.apache.geode.cache.asyncqueue.AsyncEventListener 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 2 with AsyncEventListener

use of org.apache.geode.cache.asyncqueue.AsyncEventListener in project geode by apache.

the class SerialGatewaySenderImpl method stop.

@Override
public void stop() {
    if (logger.isDebugEnabled()) {
        logger.debug("Stopping Gateway Sender : {}", this);
    }
    this.getLifeCycleLock().writeLock().lock();
    try {
        // Stop the dispatcher
        AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
        if (ev != null && !ev.isStopped()) {
            ev.stopProcessing();
        }
        // Stop the proxy (after the dispatcher, so the socket is still
        // alive until after the dispatcher has stopped)
        stompProxyDead();
        // Close the listeners
        for (AsyncEventListener listener : this.listeners) {
            listener.close();
        }
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
        clearTempEventsAfterSenderStopped();
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
    if (this.isPrimary()) {
        try {
            DistributedLockService.destroy(getSenderAdvisor().getDLockServiceName());
        } catch (IllegalArgumentException e) {
        // service not found... ignore
        }
    }
    Set<RegionQueue> queues = getQueues();
    if (queues != null && !queues.isEmpty()) {
        for (RegionQueue q : queues) {
            ((SerialGatewaySenderQueue) q).cleanUp();
        }
    }
    this.setIsPrimary(false);
    new UpdateAttributesProcessor(this).distribute(false);
    Thread lockObtainingThread = getSenderAdvisor().getLockObtainingThread();
    if (lockObtainingThread != null && lockObtainingThread.isAlive()) {
        // wait a while for thread to terminate
        try {
            lockObtainingThread.join(3000);
        } catch (InterruptedException ex) {
            // we allowed our join to be canceled
            // reset interrupt bit so this thread knows it has been interrupted
            Thread.currentThread().interrupt();
        }
        if (lockObtainingThread.isAlive()) {
            logger.info(LocalizedMessage.create(LocalizedStrings.GatewaySender_COULD_NOT_STOP_LOCK_OBTAINING_THREAD_DURING_GATEWAY_SENDER_STOP));
        }
    }
    InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
    system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
    this.eventProcessor = null;
}
Also used : UpdateAttributesProcessor(org.apache.geode.internal.cache.UpdateAttributesProcessor) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 3 with AsyncEventListener

use of org.apache.geode.cache.asyncqueue.AsyncEventListener in project geode by apache.

the class CacheXml70GatewayDUnitTest method testAsyncEventQueueWithGatewayEventFilter.

/**
   * Added to test the scenario of defect #50600.
   */
@Test
public void testAsyncEventQueueWithGatewayEventFilter() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    String id = "WBCLChannel";
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(100);
    factory.setBatchTimeInterval(500);
    factory.setBatchConflationEnabled(true);
    factory.setMaximumQueueMemory(200);
    factory.setDiskSynchronous(true);
    factory.setParallel(false);
    factory.setDispatcherThreads(33);
    factory.addGatewayEventFilter(new MyGatewayEventFilter());
    AsyncEventListener eventListener = new CacheXml70DUnitTest.MyAsyncEventListener();
    AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
    RegionAttributesCreation attrs = new RegionAttributesCreation();
    attrs.addAsyncEventQueueId(asyncEventQueue.getId());
    cache.createRegion("UserRegion", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
    assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
    for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
        CacheXml70DUnitTest.validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 4 with AsyncEventListener

use of org.apache.geode.cache.asyncqueue.AsyncEventListener 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 AsyncEventListener

use of org.apache.geode.cache.asyncqueue.AsyncEventListener in project geode by apache.

the class WANConfigurationJUnitTest method test_GatewaySenderWithGatewaySenderEventListener2.

@Test
public void test_GatewaySenderWithGatewaySenderEventListener2() {
    cache = new CacheFactory().set(MCAST_PORT, "0").create();
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    AsyncEventListener listener = new MyGatewaySenderEventListener();
    ((InternalGatewaySenderFactory) fact).addAsyncEventListener(listener);
    try {
        ((InternalGatewaySenderFactory) fact).create("ln");
    } catch (Exception e) {
        fail("Received Exception :" + e);
    }
}
Also used : MyGatewaySenderEventListener(org.apache.geode.internal.cache.wan.MyGatewaySenderEventListener) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) IOException(java.io.IOException) GatewayReceiverException(org.apache.geode.internal.cache.wan.GatewayReceiverException) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)38 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)19 AsyncEventQueueFactory (org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 Cache (org.apache.geode.cache.Cache)8 Test (org.junit.Test)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)5 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)5 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 AsyncEvent (org.apache.geode.cache.asyncqueue.AsyncEvent)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 AbstractGatewaySenderEventProcessor (org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor)4 GatewaySenderProfile (org.apache.geode.internal.cache.wan.GatewaySenderAdvisor.GatewaySenderProfile)4 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2