Search in sources :

Example 21 with AsyncEventListener

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

the class MyGatewayEventSubstitutionFilter method createAsyncEventQueueWithListener2.

public static void createAsyncEventQueueWithListener2(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) {
    createDiskStore(asyncChannelId, diskStoreName);
    AsyncEventListener asyncEventListener = new MyAsyncEventListener2();
    AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
    // set dispatcher threads
    factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
    AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 22 with AsyncEventListener

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

the class MyGatewayEventSubstitutionFilter method getAsyncEventListenerMapSize.

public static int getAsyncEventListenerMapSize(String asyncEventQueueId) {
    AsyncEventListener theListener = getAsyncEventListener(asyncEventQueueId);
    final Map eventsMap = ((MyAsyncEventListener) theListener).getEventsMap();
    assertNotNull(eventsMap);
    LogWriterUtils.getLogWriter().info("The events map size is " + eventsMap.size());
    return eventsMap.size();
}
Also used : Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 23 with AsyncEventListener

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

the class CreateAlterDestroyRegionCommandsDUnitTest method testAlterRegion.

@Ignore("bug51924")
@Test
public void testAlterRegion() throws IOException {
    setUpJmxManagerOnVm0ThenConnect(null);
    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
    Host.getHost(0).getVM(0).invoke(() -> {
        Cache cache = getCache();
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
    });
    this.alterVm1 = Host.getHost(0).getVM(1);
    this.alterVm1Name = "VM" + this.alterVm1.getPid();
    this.alterVm1.invoke(() -> {
        Properties localProps = new Properties();
        localProps.setProperty(NAME, alterVm1Name);
        localProps.setProperty(GROUPS, "Group1");
        getSystem(localProps);
        Cache cache = getCache();
        // Setup queues and gateway senders to be used by all tests
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
        AsyncEventListener listener = new AsyncEventListener() {

            @Override
            public void close() {
            // Nothing to do
            }

            @Override
            public boolean processEvents(List<AsyncEvent> events) {
                return true;
            }
        };
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId1, listener);
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId2, listener);
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId3, listener);
        GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
        gatewaySenderFactory.setManualStart(true);
        gatewaySenderFactory.create(alterGatewaySenderId1, 2);
        gatewaySenderFactory.create(alterGatewaySenderId2, 3);
        gatewaySenderFactory.create(alterGatewaySenderId3, 4);
    });
    this.alterVm2 = Host.getHost(0).getVM(2);
    this.alterVm2Name = "VM" + this.alterVm2.getPid();
    this.alterVm2.invoke(() -> {
        Properties localProps = new Properties();
        localProps.setProperty(NAME, alterVm2Name);
        localProps.setProperty(GROUPS, "Group1,Group2");
        getSystem(localProps);
        Cache cache = getCache();
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
    });
    deployJarFilesForRegionAlter();
    regionAlterGroupTest();
    regionAlterSetAllTest();
    regionAlterNoChangeTest();
    regionAlterSetDefaultsTest();
    regionAlterManipulatePlugInsTest();
    this.alterVm1.invoke(() -> {
        getCache().getRegion(alterRegionName).destroyRegion();
    });
}
Also used : GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Properties(java.util.Properties) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Cache(org.apache.geode.cache.Cache) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Ignore(org.junit.Ignore) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 24 with AsyncEventListener

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

the class ParallelGatewaySenderImpl method stop.

@Override
public void stop() {
    this.getLifeCycleLock().writeLock().lock();
    try {
        if (!this.isRunning()) {
            return;
        }
        // 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();
        }
        // stop the running threads, open sockets if any
        ((ConcurrentParallelGatewaySenderQueue) this.eventProcessor.getQueue()).cleanUp();
        logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
        InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
        system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
        clearTempEventsAfterSenderStopped();
    // Keep the eventProcessor around so we can ask it for the regionQueues later.
    // Tests expect to be able to do this.
    } finally {
        this.getLifeCycleLock().writeLock().unlock();
    }
}
Also used : InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) AbstractGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.AbstractGatewaySenderEventProcessor) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

Example 25 with AsyncEventListener

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

the class WANTestBase method createAsyncEventQueue.

public static void createAsyncEventQueue(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous) {
    if (diskStoreName != null) {
        File directory = new File(asyncChannelId + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
        directory.mkdir();
        File[] dirs1 = new File[] { directory };
        DiskStoreFactory dsf = cache.createDiskStoreFactory();
        dsf.setDiskDirs(dirs1);
        dsf.create(diskStoreName);
    }
    AsyncEventListener asyncEventListener = new MyAsyncEventListener();
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(batchSize);
    factory.setPersistent(isPersistent);
    factory.setDiskStoreName(diskStoreName);
    factory.setDiskSynchronous(isDiskSynchronous);
    factory.setBatchConflationEnabled(isConflation);
    factory.setMaximumQueueMemory(maxMemory);
    factory.setParallel(isParallel);
    // set dispatcher threads
    factory.setDispatcherThreads(numDispatcherThreadsForTheRun);
    factory.create(asyncChannelId, asyncEventListener);
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) File(java.io.File) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener)

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