use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method verifyRegionQueueNotEmpty.
public static void verifyRegionQueueNotEmpty(String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
if (!sender.isParallel()) {
final Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
int queueSize = 0;
for (RegionQueue q : queues) {
queueSize += q.size();
}
assertTrue(queues.size() > 0);
assertTrue(queueSize > 0);
} else if (sender.isParallel()) {
RegionQueue regionQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
assertTrue(regionQueue.size() > 0);
}
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method addSecondCacheQueueListener.
private void addSecondCacheQueueListener(String senderId, boolean isParallel) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
listener2 = new QueueListener();
if (!isParallel) {
Set<RegionQueue> queues = ((AbstractGatewaySender) sender).getQueues();
for (RegionQueue q : queues) {
q.addCacheListener(listener2);
}
} else {
RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
parallelQueue.addCacheListener(listener2);
}
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method addCacheListenerOnQueueBucketRegion.
private void addCacheListenerOnQueueBucketRegion(String senderId, int numBuckets) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
PartitionedRegion region = (PartitionedRegion) parallelQueue.getRegion();
for (int i = 0; i < numBuckets; i++) {
BucketRegion br = region.getBucketRegion(i);
if (br != null) {
AttributesMutator mutator = br.getAttributesMutator();
CacheListener listener = new QueueListener();
mutator.addCacheListener(listener);
}
}
}
use of org.apache.geode.internal.cache.RegionQueue in project geode by apache.
the class WANTestBase method checkQueue_BR.
public static HashMap checkQueue_BR(String senderId, int numBuckets) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
RegionQueue parallelQueue = ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
PartitionedRegion region = (PartitionedRegion) parallelQueue.getRegion();
HashMap listenerAttrs = new HashMap();
for (int i = 0; i < numBuckets; i++) {
BucketRegion br = region.getBucketRegion(i);
if (br != null) {
QueueListener listener = (QueueListener) br.getCacheListener();
if (listener != null) {
listenerAttrs.put("Create" + i, listener.createList);
listenerAttrs.put("Update" + i, listener.updateList);
listenerAttrs.put("Destroy" + i, listener.destroyList);
}
}
}
return listenerAttrs;
}
use of org.apache.geode.internal.cache.RegionQueue 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);
}
}
Aggregations