private void setReturnsAndExceptions() throws Exception { when(muleContext.getConfiguration()).thenReturn(muleConfiguration); when(partitionableObjectStore.retrieve(any(String.class), any(String.class))) .thenThrow(ObjectDoesNotExistException.class); when(eventCorrelatorCallback.createEventGroup(any(CoreEvent.class), any(Object.class))).thenReturn(eventGroup); when(eventCorrelatorCallback.aggregateEvents(any(EventGroup.class))).thenThrow(RoutingException.class); when(eventCorrelatorCallback.shouldAggregateEvents(any(EventGroup.class))).thenReturn(true); }
@Override protected T doRetrieve(String key) throws ObjectStoreException { return partitionedObjectStore.retrieve(key, partitionName); }
@Override protected T doRetrieve(String key, String partitionName) throws ObjectStoreException { return wrapped.retrieve(key, partitionName); }
/** * Returns a snapshot of collected events in this group, optionally sorted by their arrival time. * * @return an array of collected {@link CoreEvent}s. * @throws ObjectStoreException */ public PrivilegedEvent[] toArray(boolean sortByArrival) throws ObjectStoreException { synchronized (this) { if (eventsObjectStore.allKeys(eventsPartitionKey).isEmpty()) { return EMPTY_EVENTS_ARRAY; } List<String> keys = eventsObjectStore.allKeys(eventsPartitionKey); PrivilegedEvent[] eventArray = new PrivilegedEvent[keys.size()]; for (int i = 0; i < keys.size(); i++) { eventArray[i] = (PrivilegedEvent) eventsObjectStore.retrieve(keys.get(i), eventsPartitionKey); } if (sortByArrival) { Arrays.sort(eventArray, new ArrivalOrderEventComparator()); } return eventArray; } }
while (i.hasNext()) { String id = i.next(); buf.append(eventsObjectStore.retrieve(id, eventsPartitionKey).getCorrelationId()); if (i.hasNext()) { buf.append(", ");
/** * Removes the elements in expiredAndDispatchedGroups when groupLife is reached */ @Override public void expired() { try { for (String o : (List<String>) correlatorStore.allKeys(getExpiredAndDispatchedPartitionKey())) { Long time = (Long) correlatorStore.retrieve(o, getExpiredAndDispatchedPartitionKey()); if (time + DAYS.toMillis(1) < currentTimeMillis()) { correlatorStore.remove(o, getExpiredAndDispatchedPartitionKey()); logger.warn(MessageFormat.format("Discarding group {0}", o)); } } } catch (ObjectStoreException e) { logger.warn("Expiration of objects failed due to ObjectStoreException " + e + "."); } }
private void setReturnsAndExceptions() throws Exception { when(muleContext.getConfiguration()).thenReturn(muleConfiguration); when(partitionableObjectStore.retrieve(any(String.class), any(String.class))) .thenThrow(ObjectDoesNotExistException.class); when(eventCorrelatorCallback.createEventGroup(any(CoreEvent.class), any(Object.class))).thenReturn(eventGroup); when(eventCorrelatorCallback.aggregateEvents(any(EventGroup.class))).thenThrow(RoutingException.class); when(eventCorrelatorCallback.shouldAggregateEvents(any(EventGroup.class))).thenReturn(true); }
public void forceGroupExpiry(String groupId) throws MuleException { try { if (correlatorStore.retrieve(groupId, getEventGroupsPartitionKey()) != null) { handleGroupExpiry(getEventGroup(groupId)); } else { addProcessedGroup(groupId); } } catch (ObjectStoreException e) { // TODO improve this throw new MessagingException(null, e); } }
protected EventGroup getEventGroup(String groupId) throws ObjectStoreException { try { EventGroup eventGroup = (EventGroup) correlatorStore.retrieve(groupId, getEventGroupsPartitionKey()); if (!eventGroup.isInitialised()) { try { DeserializationPostInitialisable.Implementation.init(eventGroup, muleContext); } catch (Exception e) { throw new ObjectStoreException(e); } } eventGroup.initEventsStore(correlatorStore); return eventGroup; } catch (ObjectDoesNotExistException e) { return null; } }