use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl 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.internal.AsyncEventQueueImpl 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;
}
use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl in project geode by apache.
the class MyGatewayEventSubstitutionFilter method checkAsyncEventQueueUnprocessedStats.
public static void checkAsyncEventQueueUnprocessedStats(String asyncQueueId, int events) {
Set<AsyncEventQueue> asyncQueues = cache.getAsyncEventQueues();
AsyncEventQueue queue = null;
for (AsyncEventQueue q : asyncQueues) {
if (q.getId().equals(asyncQueueId)) {
queue = q;
break;
}
}
final AsyncEventQueueStats statistics = ((AsyncEventQueueImpl) queue).getStatistics();
assertEquals(events, (statistics.getUnprocessedEventsAddedBySecondary() + statistics.getUnprocessedTokensRemovedBySecondary()));
assertEquals(events, (statistics.getUnprocessedEventsRemovedByPrimary() + statistics.getUnprocessedTokensAddedByPrimary()));
}
use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl in project geode by apache.
the class AsyncEventQueueEvictionAndExpirationJUnitTest method getEventsReceived.
public int getEventsReceived(String aeqId) {
AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
AbstractGatewaySender sender = (AbstractGatewaySender) aeq.getSender();
return sender.getStatistics().getEventsReceived();
}
use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueImpl in project geode by apache.
the class LuceneIndexImpl method destroyAsyncEventQueue.
private void destroyAsyncEventQueue(boolean initiator) {
String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath);
// Get the AsyncEventQueue
AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
// The AsyncEventQueue can be null in an accessor member
if (aeq != null) {
aeq.stop();
}
// Remove the id from the dataRegion's AsyncEventQueue ids
// Note: The region may already have been destroyed by a remote member
Region region = getDataRegion();
if (!region.isDestroyed()) {
region.getAttributesMutator().removeAsyncEventQueueId(aeqId);
}
// The AsyncEventQueue can be null in an accessor member
if (aeq != null) {
aeq.destroy(initiator);
}
if (logger.isDebugEnabled()) {
logger.debug("Destroyed aeqId=" + aeqId);
}
}
Aggregations