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