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);
}
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();
}
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();
});
}
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();
}
}
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);
}
Aggregations