Search in sources :

Example 1 with ObjectStoreException

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();
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober) Probe(org.mule.tck.probe.Probe)

Example 2 with ObjectStoreException

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);
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ProvidedPartitionableObjectStoreWrapper(org.mule.runtime.core.internal.util.store.ProvidedPartitionableObjectStoreWrapper) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Example 3 with ObjectStoreException

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();
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) AggregationException(org.mule.runtime.core.internal.routing.AggregationException) CoreEvent(org.mule.runtime.core.api.event.CoreEvent)

Example 4 with ObjectStoreException

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);
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) FileOutputStream(java.io.FileOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) ObjectStoreNotAvailableException(org.mule.runtime.api.store.ObjectStoreNotAvailableException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) IOException(java.io.IOException) ObjectAlreadyExistsException(org.mule.runtime.api.store.ObjectAlreadyExistsException)

Example 5 with ObjectStoreException

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())));
        }
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) File(java.io.File) FileUtils.newFile(org.mule.runtime.core.api.util.FileUtils.newFile) ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) ObjectDoesNotExistException(org.mule.runtime.api.store.ObjectDoesNotExistException) ObjectStoreNotAvailableException(org.mule.runtime.api.store.ObjectStoreNotAvailableException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) IOException(java.io.IOException) ObjectAlreadyExistsException(org.mule.runtime.api.store.ObjectAlreadyExistsException)

Aggregations

ObjectStoreException (org.mule.runtime.api.store.ObjectStoreException)20 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)10 ObjectAlreadyExistsException (org.mule.runtime.api.store.ObjectAlreadyExistsException)9 ObjectDoesNotExistException (org.mule.runtime.api.store.ObjectDoesNotExistException)9 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)6 MuleException (org.mule.runtime.api.exception.MuleException)5 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)5 File (java.io.File)3 IOException (java.io.IOException)3 Serializable (java.io.Serializable)3 DefaultMuleException (org.mule.runtime.api.exception.DefaultMuleException)3 MessagingException (org.mule.runtime.core.internal.exception.MessagingException)3 EventGroup (org.mule.runtime.core.internal.routing.EventGroup)3 RoutingException (org.mule.runtime.core.privileged.routing.RoutingException)3 PollingProber (org.mule.tck.probe.PollingProber)3 List (java.util.List)2 Message (org.mule.runtime.api.message.Message)2 RoutingNotification (org.mule.runtime.api.notification.RoutingNotification)2 ObjectStoreNotAvailableException (org.mule.runtime.api.store.ObjectStoreNotAvailableException)2 PartitionableObjectStore (org.mule.runtime.api.store.PartitionableObjectStore)2