use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.
the class EventCorrelatorTestCase method doExpiredGroupMonitoringTest.
private void doExpiredGroupMonitoringTest(boolean primaryNode) throws Exception {
when(mockMuleContext.isPrimaryPollingInstance()).thenReturn(primaryNode);
EventCorrelator eventCorrelator = createEventCorrelator();
when(mockEventCorrelatorCallback.createEventGroup(mockMuleEvent, TEST_GROUP_ID)).thenReturn(mockEventGroup);
eventCorrelator.start();
try {
Prober prober = new PollingProber(1000, 50);
prober.check(new Probe() {
@Override
public boolean isSatisfied() {
try {
return !memoryObjectStore.contains(TEST_GROUP_ID, "prefix.eventGroups");
} catch (ObjectStoreException e) {
LOGGER.debug("Could not access object store.");
return false;
}
}
@Override
public String describeFailure() {
return "Event group not expired.";
}
});
} finally {
eventCorrelator.stop();
}
}
use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.
the class AbstractAggregator method initEventGroupsObjectStore.
protected void initEventGroupsObjectStore() throws InitialisationException {
try {
if (eventGroupsObjectStore == null) {
// TODO: Delete ProvidedObjectStoreWrapper if not needed when moving this to compatibility
eventGroupsObjectStore = new ProvidedPartitionableObjectStoreWrapper(null, internalEventsGroupsObjectStoreSupplier());
}
eventGroupsObjectStore.open(storePrefix + ".expiredAndDispatchedGroups");
eventGroupsObjectStore.open(storePrefix + ".eventGroups");
} catch (MuleRuntimeException | ObjectStoreException e) {
throw new InitialisationException(e, this);
}
}
use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.
the class ResequenceCorrelatorCallback method aggregateEvents.
/**
* This method is invoked if the shouldAggregate method is called and returns true. Once this method returns an aggregated
* message, the event group is removed from the router.
*
* @param events the event group for this request
* @return an aggregated message
* @throws AggregationException if the aggregation fails. in this scenario the whole event group is removed and passed to the
* exception handler for this componenet
*/
@Override
public CoreEvent aggregateEvents(EventGroup events) throws AggregationException {
CoreEvent[] results;
try {
results = events.toArray(false);
} catch (ObjectStoreException e) {
throw new AggregationException(events, null, e);
}
Arrays.sort(results, eventComparator);
// Mule Message to pass back
return CoreEvent.builder(results[0]).message(of(results)).build();
}
use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.
the class PersistentObjectStorePartition method serialize.
protected void serialize(File outputFile, StoreValue<T> storeValue) throws ObjectStoreException {
try (FileOutputStream fileOutputStream = new FileOutputStream(outputFile);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
ObjectOutputStream objectOutputStream = new ObjectOutputStream(bufferedOutputStream)) {
serializer.getInternalProtocol().serialize(storeValue, objectOutputStream);
objectOutputStream.flush();
} catch (Exception se) {
throw new ObjectStoreException(se);
}
}
use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.
the class PersistentObjectStorePartition method loadStoredKeysAndFileNames.
private void loadStoredKeysAndFileNames() throws ObjectStoreException {
synchronized (realKeyToUUIDIndex) {
/*
* by re-checking this condition here we can avoid contention in {@link #assureLoaded}. The amount of times that this
* condition should evaluate to {@code true} is really limited, which provides better performance in the long run
*/
if (loaded) {
return;
}
try {
File[] files = listValuesFiles();
for (File file : files) {
try {
StoreValue<T> storeValue = deserialize(file);
realKeyToUUIDIndex.put(storeValue.getKey(), file.getName());
} catch (ObjectStoreException e) {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn(format("Could not deserialize the ObjectStore file: %s. The file will be skipped and moved to the Garbage folder", file.getName()));
}
moveToCorruptedFilesFolder(file);
}
}
loaded = true;
} catch (Exception e) {
throw new ObjectStoreException(createStaticMessage(format("Could not restore object store data from %1s", partitionDirectory.getAbsolutePath())));
}
}
}
Aggregations