use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class MyGatewayEventSubstitutionFilter method killSender.
public static Boolean killSender(String senderId) {
final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
IgnoredException exp = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
IgnoredException exp1 = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
try {
Set<GatewaySender> senders = cache.getGatewaySenders();
AbstractGatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = (AbstractGatewaySender) s;
break;
}
}
if (sender.isPrimary()) {
LogWriterUtils.getLogWriter().info("Gateway sender is killed by a test");
cache.getDistributedSystem().disconnect();
return Boolean.TRUE;
}
return Boolean.FALSE;
} finally {
exp.remove();
exp1.remove();
exln.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createReplicatedRegionWithSenderAndAsyncEventQueue.
public static void createReplicatedRegionWithSenderAndAsyncEventQueue(String regionName, String senderIds, String asyncChannelId, Boolean offHeap) {
IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
try {
AttributesFactory fact = new AttributesFactory();
if (senderIds != null) {
StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
while (tokenizer.hasMoreTokens()) {
String senderId = tokenizer.nextToken();
fact.addGatewaySenderId(senderId);
}
}
fact.setDataPolicy(DataPolicy.REPLICATE);
fact.setOffHeap(offHeap);
fact.setScope(Scope.DISTRIBUTED_ACK);
RegionFactory regionFactory = cache.createRegionFactory(fact.create());
regionFactory.addAsyncEventQueueId(asyncChannelId);
Region r = regionFactory.create(regionName);
assertNotNull(r);
} finally {
exp.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createSender.
public static void createSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManulaStart) {
final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
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.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManulaStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
eventFilter = filter;
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(isManulaStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
eventFilter = filter;
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.create(dsName, remoteDsId);
}
} finally {
exln.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class MyGatewayEventSubstitutionFilter method validateRegionSize.
public static void validateRegionSize(String regionName, final int regionSize) {
IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
IgnoredException exp1 = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
try {
final Region r = cache.getRegion(Region.SEPARATOR + regionName);
assertNotNull(r);
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
if (r.keySet().size() == regionSize) {
return true;
}
return false;
}
public String description() {
return "Expected region entries: " + regionSize + " but actual entries: " + r.keySet().size() + " present region keyset " + r.keySet();
}
};
Wait.waitForCriterion(wc, 240000, 500, true);
} finally {
exp.remove();
exp1.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class MyGatewayEventSubstitutionFilter method doNextPuts.
public static void doNextPuts(String regionName, int start, int numPuts) {
// waitForSitesToUpdate();
IgnoredException exp = IgnoredException.addIgnoredException(CacheClosedException.class.getName());
try {
Region r = cache.getRegion(Region.SEPARATOR + regionName);
assertNotNull(r);
for (long i = start; i < numPuts; i++) {
r.put(i, i);
}
} finally {
exp.remove();
}
}
Aggregations