use of org.apache.geode.cache.asyncqueue.AsyncEvent in project geode by apache.
the class PDXAsyncEventQueueDUnitTest method createSerialAsyncEventQueue.
protected void createSerialAsyncEventQueue(VM vm, final boolean persistent) {
SerializableCallable createSystem = new SerializableCallable() {
public Object call() throws Exception {
Cache cache = getCache();
AsyncEventQueue sender = cache.createAsyncEventQueueFactory().setBatchSize(2).setBatchTimeInterval(1000).setBatchConflationEnabled(false).setPersistent(persistent).create("queue", new AsyncEventListener() {
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean processEvents(List<AsyncEvent> events) {
// do nothing
return true;
}
});
return null;
}
};
vm.invoke(createSystem);
}
use of org.apache.geode.cache.asyncqueue.AsyncEvent in project geode by apache.
the class LuceneEventListenerJUnitTest method shouldHandleBucketNotFoundExceptionWithoutLoggingError.
@Test
public void shouldHandleBucketNotFoundExceptionWithoutLoggingError() throws BucketNotFoundException {
RepositoryManager manager = Mockito.mock(RepositoryManager.class);
Logger log = Mockito.mock(Logger.class);
Mockito.when(manager.getRepository(any(), any(), any())).thenThrow(BucketNotFoundException.class);
LuceneEventListener listener = new LuceneEventListener(manager);
listener.logger = log;
AsyncEvent event = Mockito.mock(AsyncEvent.class);
boolean result = listener.processEvents(Arrays.asList(new AsyncEvent[] { event }));
assertFalse(result);
verify(log, never()).error(anyString(), any(Exception.class));
}
use of org.apache.geode.cache.asyncqueue.AsyncEvent 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.AsyncEvent in project geode by apache.
the class CustomAsyncEventListener method processEvents.
public boolean processEvents(List<AsyncEvent> events) {
int i = 0;
for (AsyncEvent event : events) {
i++;
if (!exceptionThrown && i == 40) {
i = 0;
exceptionThrown = true;
throw new Error("TestError");
}
if (exceptionThrown) {
eventsMap.put((Long) event.getKey(), event);
}
}
return true;
}
use of org.apache.geode.cache.asyncqueue.AsyncEvent in project geode by apache.
the class MyAsyncEventListener2 method processEvents.
public boolean processEvents(List<AsyncEvent> events) {
for (AsyncEvent event : events) {
GatewaySenderEventImpl gatewayEvent = (GatewaySenderEventImpl) event;
int bucketId = gatewayEvent.getBucketId();
List<GatewaySenderEventImpl> bucketEvents = this.bucketToEventsMap.get(bucketId);
if (bucketEvents == null) {
bucketEvents = new ArrayList<GatewaySenderEventImpl>();
bucketEvents.add(gatewayEvent);
this.bucketToEventsMap.put(bucketId, bucketEvents);
} else {
bucketEvents.add(gatewayEvent);
}
}
return true;
}
Aggregations