use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class LuceneIndexXmlParserJUnitTest method setUp.
@Before
public void setUp() {
this.parser = new LuceneXmlParser();
CacheCreation cache = Mockito.mock(CacheCreation.class);
RegionCreation regionCreation = Mockito.mock(RegionCreation.class);
RegionAttributesCreation rac = Mockito.mock(RegionAttributesCreation.class);
Mockito.when(regionCreation.getFullPath()).thenReturn("/region");
Mockito.when(regionCreation.getAttributes()).thenReturn(rac);
Mockito.when(regionCreation.getExtensionPoint()).thenReturn(new SimpleExtensionPoint(this.rc, this.rc));
this.rc = regionCreation;
this.stack = new Stack<Object>();
stack.push(cache);
stack.push(rc);
this.parser.setStack(stack);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml70GatewayDUnitTest method testParallelGatewaySender.
@Test
public void testParallelGatewaySender() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
gatewaySenderFactory.setParallel(true);
gatewaySenderFactory.setDispatcherThreads(13);
gatewaySenderFactory.setManualStart(true);
gatewaySenderFactory.setSocketBufferSize(1234);
gatewaySenderFactory.setSocketReadTimeout(1050);
gatewaySenderFactory.setBatchConflationEnabled(false);
gatewaySenderFactory.setBatchSize(88);
gatewaySenderFactory.setBatchTimeInterval(9);
gatewaySenderFactory.setPersistenceEnabled(true);
gatewaySenderFactory.setDiskStoreName("LNSender");
gatewaySenderFactory.setDiskSynchronous(true);
gatewaySenderFactory.setMaximumQueueMemory(211);
gatewaySenderFactory.setAlertThreshold(35);
GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
gatewaySenderFactory.addGatewayEventFilter(myEventFilter1);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter1);
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter2);
GatewaySender parallelGatewaySender = gatewaySenderFactory.create("LN", 2);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<GatewaySender> sendersOnCache = c.getGatewaySenders();
for (GatewaySender sender : sendersOnCache) {
assertEquals(true, sender.isParallel());
validateGatewaySender(parallelGatewaySender, sender);
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml70GatewayDUnitTest method testSerialGatewaySender.
@Test
public void testSerialGatewaySender() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
gatewaySenderFactory.setParallel(false);
gatewaySenderFactory.setManualStart(true);
gatewaySenderFactory.setSocketBufferSize(124);
gatewaySenderFactory.setSocketReadTimeout(1000);
gatewaySenderFactory.setBatchConflationEnabled(false);
gatewaySenderFactory.setBatchSize(100);
gatewaySenderFactory.setBatchTimeInterval(10);
gatewaySenderFactory.setPersistenceEnabled(true);
gatewaySenderFactory.setDiskStoreName("LNSender");
gatewaySenderFactory.setDiskSynchronous(true);
gatewaySenderFactory.setMaximumQueueMemory(200);
gatewaySenderFactory.setAlertThreshold(30);
GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
gatewaySenderFactory.addGatewayEventFilter(myEventFilter1);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter1);
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
gatewaySenderFactory.addGatewayTransportFilter(myStreamFilter2);
GatewaySender serialGatewaySender = gatewaySenderFactory.create("LN", 2);
RegionAttributesCreation attrs = new RegionAttributesCreation();
attrs.addGatewaySenderId(serialGatewaySender.getId());
cache.createRegion("UserRegion", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<GatewaySender> sendersOnCache = c.getGatewaySenders();
for (GatewaySender sender : sendersOnCache) {
assertEquals(false, sender.isParallel());
validateGatewaySender(serialGatewaySender, sender);
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml70GatewayDUnitTest method testGatewayReceiver.
@Test
public void testGatewayReceiver() 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);
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 GatewayReceiverFactoryImpl method create.
public GatewayReceiver create() {
if (this.startPort > this.endPort) {
throw new IllegalStateException("Please specify either start port a value which is less than end port.");
}
GatewayReceiver recv = null;
if (this.cache instanceof GemFireCacheImpl) {
recv = new GatewayReceiverImpl(this.cache, this.startPort, this.endPort, this.timeBetPings, this.socketBuffSize, this.bindAdd, this.filters, this.hostnameForSenders, this.manualStart);
this.cache.addGatewayReceiver(recv);
InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYRECEIVER_CREATE, recv);
if (!this.manualStart) {
try {
recv.start();
} catch (IOException ioe) {
throw new GatewayReceiverException(LocalizedStrings.GatewayReceiver_EXCEPTION_WHILE_STARTING_GATEWAY_RECEIVER.toLocalizedString(), ioe);
}
}
} else if (this.cache instanceof CacheCreation) {
recv = new GatewayReceiverCreation(this.cache, this.startPort, this.endPort, this.timeBetPings, this.socketBuffSize, this.bindAdd, this.filters, this.hostnameForSenders, this.manualStart);
this.cache.addGatewayReceiver(recv);
}
return recv;
}
Aggregations