use of org.apache.geode.internal.cache.xmlcache.CacheCreation 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.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml80GatewayDUnitTest method testGatewaySenderWithSubstitutionFilter.
@Test
public void testGatewaySenderWithSubstitutionFilter() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
// Create a GatewaySender with GatewayEventSubstitutionFilter.
// Don't start the sender to avoid 'Locators must be configured before starting gateway-sender'
// exception.
String id = getName();
GatewaySenderFactory factory = cache.createGatewaySenderFactory();
factory.setManualStart(true);
factory.setGatewayEventSubstitutionFilter(new MyGatewayEventSubstitutionFilter());
GatewaySender sender = factory.create(id, 2);
// Verify the GatewayEventSubstitutionFilter is set on the GatewaySender.
assertNotNull(sender.getGatewayEventSubstitutionFilter());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
// Get the GatewaySender. Verify the GatewayEventSubstitutionFilter is not null.
GatewaySender senderOnCache = c.getGatewaySender(id);
assertNotNull(senderOnCache);
assertNotNull(senderOnCache.getGatewayEventSubstitutionFilter());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml80GatewayDUnitTest method testAsyncEventQueueWithSubstitutionFilter.
@Test
public void testAsyncEventQueueWithSubstitutionFilter() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
// Create an AsyncEventQueue with GatewayEventSubstitutionFilter.
String id = getName();
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setGatewayEventSubstitutionListener(new MyGatewayEventSubstitutionFilter());
AsyncEventQueue queue = factory.create(id, new CacheXml70DUnitTest.MyAsyncEventListener());
// Verify the GatewayEventSubstitutionFilter is set on the AsyncEventQueue.
assertNotNull(queue.getGatewayEventSubstitutionFilter());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
// Get the AsyncEventQueue. Verify the GatewayEventSubstitutionFilter is not null.
AsyncEventQueue queueOnCache = c.getAsyncEventQueue(id);
assertNotNull(queueOnCache);
assertNotNull(queueOnCache.getGatewayEventSubstitutionFilter());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml80GatewayDUnitTest method testGatewayReceiverWithManualStartTRUE.
@Test
public void testGatewayReceiverWithManualStartTRUE() throws Exception {
// getSystem();
CacheCreation cache = new CacheCreation();
GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
gatewayReceiverFactory.setBindAddress("");
gatewayReceiverFactory.setStartPort(20000);
gatewayReceiverFactory.setEndPort(29999);
gatewayReceiverFactory.setMaximumTimeBetweenPings(2000);
gatewayReceiverFactory.setSocketBufferSize(1500);
gatewayReceiverFactory.setManualStart(true);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter1);
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
GatewayReceiver receiver1 = gatewayReceiverFactory.create();
receiver1.start();
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<GatewayReceiver> receivers = c.getGatewayReceivers();
for (GatewayReceiver receiver : receivers) {
validateGatewayReceiver(receiver1, receiver);
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class GatewaySenderFactoryImpl method create.
public GatewaySender create(String id) {
this.attrs.id = id;
GatewaySender sender = null;
if (this.attrs.getDispatcherThreads() <= 0) {
throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
}
if (this.attrs.isParallel()) {
if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
}
if (this.cache instanceof GemFireCacheImpl) {
sender = new ParallelGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new ParallelGatewaySenderCreation(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
}
} else {
if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
}
if (this.cache instanceof GemFireCacheImpl) {
sender = new SerialGatewaySenderImpl(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
if (!this.attrs.isManualStart()) {
sender.start();
}
} else if (this.cache instanceof CacheCreation) {
sender = new SerialGatewaySenderCreation(this.cache, this.attrs);
this.cache.addGatewaySender(sender);
}
}
return sender;
}
Aggregations