use of org.apache.geode.cache.wan.GatewaySenderFactory 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.cache.wan.GatewaySenderFactory in project geode by apache.
the class UpdateVersionDUnitTest method createConcurrentSender.
public static void createConcurrentSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManualStart, int concurrencyLevel) {
File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
persistentDirectory.mkdir();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { persistentDirectory };
if (isParallel) {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setParallel(true);
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManualStart);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
gateway.addGatewayEventFilter(filter);
}
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
gateway.setBatchConflationEnabled(isConflation);
gateway.create(dsName, remoteDsId);
} else {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManualStart);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
gateway.addGatewayEventFilter(filter);
}
gateway.setBatchConflationEnabled(isConflation);
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
gateway.setDispatcherThreads(concurrencyLevel);
gateway.create(dsName, remoteDsId);
}
}
use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class WANTestBase method createSenderWithListener.
public static void createSenderWithListener(String dsName, int remoteDsName, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean attachTwoListeners, boolean isManualStart) {
File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
persistentDirectory.mkdir();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { persistentDirectory };
if (isParallel) {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setParallel(true);
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManualStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
gateway.addGatewayEventFilter(filter);
}
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
gateway.setBatchConflationEnabled(isConflation);
gateway.create(dsName, remoteDsName);
} else {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManualStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
gateway.addGatewayEventFilter(filter);
}
gateway.setBatchConflationEnabled(isConflation);
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
eventListener1 = new MyGatewaySenderEventListener();
((InternalGatewaySenderFactory) gateway).addAsyncEventListener(eventListener1);
if (attachTwoListeners) {
eventListener2 = new MyGatewaySenderEventListener2();
((InternalGatewaySenderFactory) gateway).addAsyncEventListener(eventListener2);
}
((InternalGatewaySenderFactory) gateway).create(dsName);
}
}
use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class WANTestBase method createSenderForValidations.
public static void createSenderForValidations(String dsName, int remoteDsId, boolean isParallel, Integer alertThreshold, boolean isConflation, boolean isPersistent, List<GatewayEventFilter> eventFilters, List<GatewayTransportFilter> transportFilters, boolean isManualStart, boolean isDiskSync) {
IgnoredException exp1 = IgnoredException.addIgnoredException(RegionDestroyedException.class.getName());
try {
File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
persistentDirectory.mkdir();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { persistentDirectory };
if (isParallel) {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setParallel(true);
gateway.setAlertThreshold(alertThreshold);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (eventFilters != null) {
for (GatewayEventFilter filter : eventFilters) {
gateway.addGatewayEventFilter(filter);
}
}
if (transportFilters != null) {
for (GatewayTransportFilter filter : transportFilters) {
gateway.addGatewayTransportFilter(filter);
}
}
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName + "_Parallel").getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName + "_Parallel");
gateway.setDiskStoreName(store.getName());
}
gateway.setDiskSynchronous(isDiskSync);
gateway.setBatchConflationEnabled(isConflation);
gateway.setManualStart(isManualStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
gateway.create(dsName, remoteDsId);
} else {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setAlertThreshold(alertThreshold);
gateway.setManualStart(isManualStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (eventFilters != null) {
for (GatewayEventFilter filter : eventFilters) {
gateway.addGatewayEventFilter(filter);
}
}
if (transportFilters != null) {
for (GatewayTransportFilter filter : transportFilters) {
gateway.addGatewayTransportFilter(filter);
}
}
gateway.setBatchConflationEnabled(isConflation);
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName + "_Serial").getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName + "_Serial");
gateway.setDiskStoreName(store.getName());
}
gateway.setDiskSynchronous(isDiskSync);
gateway.create(dsName, remoteDsId);
}
} finally {
exp1.remove();
}
}
use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class ParallelGatewaySenderQueueOverflowDUnitTest method test_ValidateParallelGatewaySenderQueueAttributes_1.
/**
* Test to validate that ParallelGatewaySenderQueue diskSynchronous attribute when persistence of
* sender is enabled.
*/
@Ignore("TODO: test is disabled")
@Test
public void test_ValidateParallelGatewaySenderQueueAttributes_1() {
Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
WANTestBase test = new WANTestBase();
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
File directory = new File("TKSender" + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
directory.mkdir();
File[] dirs1 = new File[] { directory };
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(dirs1);
DiskStore diskStore = dsf.create("FORNY");
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
// set parallel to true
fact.setParallel(true);
fact.setBatchConflationEnabled(true);
fact.setBatchSize(200);
fact.setBatchTimeInterval(300);
// enable the persistence
fact.setPersistenceEnabled(true);
fact.setDiskSynchronous(true);
fact.setDiskStoreName("FORNY");
fact.setMaximumQueueMemory(200);
fact.setAlertThreshold(1200);
GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
fact.addGatewayEventFilter(myEventFilter1);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
fact.addGatewayTransportFilter(myStreamFilter1);
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
fact.addGatewayTransportFilter(myStreamFilter2);
final IgnoredException exTKSender = IgnoredException.addIgnoredException("Could not connect");
try {
GatewaySender sender1 = fact.create("TKSender", 2);
AttributesFactory factory = new AttributesFactory();
factory.addGatewaySenderId(sender1.getId());
factory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
Set<GatewaySender> senders = cache.getGatewaySenders();
assertEquals(senders.size(), 1);
GatewaySender gatewaySender = senders.iterator().next();
Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
assertEquals(regionQueues.size(), 1);
RegionQueue regionQueue = regionQueues.iterator().next();
assertEquals(true, regionQueue.getRegion().getAttributes().isDiskSynchronous());
} finally {
exTKSender.remove();
}
}
Aggregations