use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method waitForAsyncQueueToGetEmpty.
public static void waitForAsyncQueueToGetEmpty(String asyncQueueId) {
AsyncEventQueue theAsyncEventQueue = null;
Set<AsyncEventQueue> asyncEventChannels = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncChannel : asyncEventChannels) {
if (asyncQueueId.equals(asyncChannel.getId())) {
theAsyncEventQueue = asyncChannel;
}
}
final GatewaySender sender = ((AsyncEventQueueImpl) theAsyncEventQueue).getSender();
if (sender.isParallel()) {
final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
if (size == 0) {
return true;
}
return false;
}
public String description() {
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
return "Expected queue size to be : " + 0 + " but actual entries: " + size;
}
};
Wait.waitForCriterion(wc, 60000, 500, true);
} else {
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
if (size == 0) {
return true;
}
return false;
}
public String description() {
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
int size = 0;
for (RegionQueue q : queues) {
size += q.size();
}
return "Expected queue size to be : " + 0 + " but actual entries: " + size;
}
};
Wait.waitForCriterion(wc, 60000, 500, true);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method validateAsyncEventForOperationDetail.
public static void validateAsyncEventForOperationDetail(String asyncQueueId, final int expectedSize, boolean isLoad, boolean isPutAll) {
AsyncEventListener theListener = null;
Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncQueue : asyncEventQueues) {
if (asyncQueueId.equals(asyncQueue.getId())) {
theListener = asyncQueue.getAsyncEventListener();
}
}
final Map eventsMap = ((MyAsyncEventListener_CacheLoader) theListener).getEventsMap();
assertNotNull(eventsMap);
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
if (eventsMap.size() == expectedSize) {
return true;
}
return false;
}
public String description() {
return "Expected map entries: " + expectedSize + " but actual entries: " + eventsMap.size();
}
};
// TODO:Yogs
Wait.waitForCriterion(wc, 60000, 500, true);
Collection values = eventsMap.values();
Iterator itr = values.iterator();
while (itr.hasNext()) {
AsyncEvent asyncEvent = (AsyncEvent) itr.next();
if (isLoad)
assertTrue(asyncEvent.getOperation().isLoad());
if (isPutAll)
assertTrue(asyncEvent.getOperation().isPutAll());
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method verifySubstitutionFilterToDataInvocations.
public static void verifySubstitutionFilterToDataInvocations(String asyncEventQueueId, int expectedToDataInvoations) {
AsyncEventQueue queue = cache.getAsyncEventQueue(asyncEventQueueId);
assertNotNull(queue);
// Verify the GatewayEventSubstitutionFilter has been invoked the appropriate number of times
SizeableGatewayEventSubstitutionFilter filter = (SizeableGatewayEventSubstitutionFilter) queue.getGatewayEventSubstitutionFilter();
assertNotNull(filter);
assertEquals(expectedToDataInvoations, filter.getNumToDataInvocations());
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createConcurrentAsyncEventQueue.
public static void createConcurrentAsyncEventQueue(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, String diskStoreName, boolean isDiskSynchronous, int dispatcherThreads, OrderPolicy policy) {
createDiskStore(asyncChannelId, diskStoreName);
AsyncEventListener asyncEventListener = new MyAsyncEventListener();
AsyncEventQueueFactory factory = getInitialAsyncEventQueueFactory(isParallel, maxMemory, batchSize, isPersistent, diskStoreName);
factory.setDiskSynchronous(isDiskSynchronous);
factory.setBatchConflationEnabled(isConflation);
factory.setOrderPolicy(policy);
AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener);
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class MyGatewayEventSubstitutionFilter method killAsyncEventQueue.
public static Boolean killAsyncEventQueue(String asyncQueueId) {
Set<AsyncEventQueue> queues = cache.getAsyncEventQueues();
AsyncEventQueueImpl queue = null;
for (AsyncEventQueue q : queues) {
if (q.getId().equals(asyncQueueId)) {
queue = (AsyncEventQueueImpl) q;
break;
}
}
if (queue.isPrimary()) {
LogWriterUtils.getLogWriter().info("AsyncEventQueue is killed by a test");
cache.getDistributedSystem().disconnect();
return Boolean.TRUE;
}
return Boolean.FALSE;
}
Aggregations