use of org.apache.geode.cache30.MyGatewayTransportFilter2 in project geode by apache.
the class WanValidationsDUnitTest method testGatewayTransportFiltersOrder.
@Test
public void testGatewayTransportFiltersOrder() {
Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
createCacheInVMs(lnPort, vm1, vm2);
ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
transportFilters.add(new MyGatewayTransportFilter1());
transportFilters.add(new MyGatewayTransportFilter2());
vm1.invoke(() -> WANTestBase.createSenderForValidations("ln", 2, false, 100, false, false, null, transportFilters, true, false));
try {
transportFilters.clear();
transportFilters.add(new MyGatewayTransportFilter2());
transportFilters.add(new MyGatewayTransportFilter1());
vm2.invoke(() -> WANTestBase.createSenderForValidations("ln", 2, false, 100, false, false, null, transportFilters, true, false));
fail("Expected IllegalStateException : GatewayEventFilters Should match");
} catch (Exception e) {
if (!(e.getCause() instanceof IllegalStateException) || !(e.getCause().getMessage().contains("because another cache has the same Gateway Sender defined with GatewayTransportFilters"))) {
Assert.fail("Expected IllegalStateException", e);
}
}
}
use of org.apache.geode.cache30.MyGatewayTransportFilter2 in project geode by apache.
the class WANConfigurationJUnitTest method test_ValidateGatewayReceiverAttributes.
/**
* Test to validate the gateway receiver attributes are correctly set
*/
@Test
public void test_ValidateGatewayReceiverAttributes() {
cache = new CacheFactory().set(MCAST_PORT, "0").create();
int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
int port1 = randomAvailableTCPPorts[0];
int port2 = randomAvailableTCPPorts[1];
GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
if (port1 < port2) {
fact.setStartPort(port1);
fact.setEndPort(port2);
} else {
fact.setStartPort(port2);
fact.setEndPort(port1);
}
fact.setMaximumTimeBetweenPings(2000);
fact.setSocketBufferSize(200);
GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
fact.addGatewayTransportFilter(myStreamFilter2);
fact.addGatewayTransportFilter(myStreamFilter1);
GatewayReceiver receiver1 = fact.create();
Region region = cache.createRegionFactory().create("test_ValidateGatewayReceiverAttributes");
Set<GatewayReceiver> receivers = cache.getGatewayReceivers();
GatewayReceiver rec = receivers.iterator().next();
assertEquals(receiver1.getHost(), rec.getHost());
assertEquals(receiver1.getStartPort(), rec.getStartPort());
assertEquals(receiver1.getEndPort(), rec.getEndPort());
assertEquals(receiver1.getBindAddress(), rec.getBindAddress());
assertEquals(receiver1.getMaximumTimeBetweenPings(), rec.getMaximumTimeBetweenPings());
assertEquals(receiver1.getSocketBufferSize(), rec.getSocketBufferSize());
assertEquals(receiver1.getGatewayTransportFilters().size(), rec.getGatewayTransportFilters().size());
}
use of org.apache.geode.cache30.MyGatewayTransportFilter2 in project geode by apache.
the class ParallelGatewaySenderQueueOverflowDUnitTest method test_ValidateParallelGatewaySenderQueueAttributes_2.
/**
* Test to validate that ParallelGatewaySenderQueue diskSynchronous attribute when persistence of
* sender is not enabled.
*/
@Ignore("TODO: test is disabled")
@Test
public void test_ValidateParallelGatewaySenderQueueAttributes_2() {
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);
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
// set parallel to true
fact.setParallel(true);
fact.setBatchConflationEnabled(true);
fact.setBatchSize(200);
fact.setBatchTimeInterval(300);
// set persistence to false
fact.setPersistenceEnabled(false);
fact.setDiskSynchronous(true);
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 ex = IgnoredException.addIgnoredException("Could not connect");
try {
GatewaySender sender1 = fact.create("TKSender", 2);
AttributesFactory factory = new AttributesFactory();
factory.addGatewaySenderId(sender1.getId());
factory.setDataPolicy(DataPolicy.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(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
} finally {
ex.remove();
}
}
use of org.apache.geode.cache30.MyGatewayTransportFilter2 in project geode by apache.
the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_1.
/**
* Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
* sender is enabled.
*/
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_1() {
Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
WANTestBase test = new WANTestBase(getTestMethodName());
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();
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.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(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
RegionQueue regionQueue = regionQueues.iterator().next();
assertEquals(true, regionQueue.getRegion().getAttributes().isDiskSynchronous());
} finally {
exTKSender.remove();
}
}
use of org.apache.geode.cache30.MyGatewayTransportFilter2 in project geode by apache.
the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_2.
/**
* Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
* sender is not enabled.
*/
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_2() {
Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
WANTestBase test = new WANTestBase(getTestMethodName());
Properties props = test.getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
InternalDistributedSystem ds = test.getSystem(props);
cache = CacheFactory.create(ds);
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
fact.setBatchConflationEnabled(true);
fact.setBatchSize(200);
fact.setBatchTimeInterval(300);
// set persistence to false
fact.setPersistenceEnabled(false);
fact.setDiskSynchronous(true);
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 exp = IgnoredException.addIgnoredException("Could not connect");
try {
GatewaySender sender1 = fact.create("TKSender", 2);
AttributesFactory factory = new AttributesFactory();
factory.addGatewaySenderId(sender1.getId());
factory.setDataPolicy(DataPolicy.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(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
RegionQueue regionQueue = regionQueues.iterator().next();
assertEquals(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
} finally {
exp.remove();
}
}
Aggregations