Search in sources :

Example 16 with ObjectStoreException

use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.

the class PartitionedPersistentObjectStore method loadPreviousStoredPartitions.

private void loadPreviousStoredPartitions() throws ObjectStoreException {
    File[] directories = storeDirectory.listFiles(File::isDirectory);
    if (directories == null) {
        return;
    }
    for (File partitionDirectory : directories) {
        try {
            PersistentObjectStorePartition persistentObjectStorePartition = new PersistentObjectStorePartition(muleContext, partitionDirectory);
            persistentObjectStorePartition.open();
            partitionsByName.put(persistentObjectStorePartition.getPartitionName(), persistentObjectStorePartition);
        } catch (Exception e) {
            LOGGER.error("Could not restore partition under directory " + partitionDirectory.getAbsolutePath());
        }
    }
}
Also used : File(java.io.File) PersistentObjectStorePartition(org.mule.runtime.core.internal.util.store.PersistentObjectStorePartition) ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 17 with ObjectStoreException

use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.

the class MuleObjectStoreManager method initialise.

@Override
public void initialise() throws InitialisationException {
    basePersistentStore = lookupBaseStore(basePersistentStoreKey, "Persistent");
    baseTransientStore = lookupBaseStore(baseTransientStoreKey, "Transient");
    try {
        baseTransientPartition = getPartitionFromBaseObjectStore(baseTransientStore, baseTransientStoreKey);
        basePersistentPartition = getPartitionFromBaseObjectStore(basePersistentStore, basePersistentStoreKey);
    } catch (ObjectStoreException e) {
        throw new InitialisationException(e, this);
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Example 18 with ObjectStoreException

use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.

the class PersistentObjectStorePartition method createOrRetrievePartitionDescriptorFile.

protected File createOrRetrievePartitionDescriptorFile() throws ObjectStoreException {
    try {
        File partitionDescriptorFile = new File(partitionDirectory, PARTITION_DESCRIPTOR_FILE);
        if (partitionDescriptorFile.exists()) {
            this.partitionName = readPartitionFileName(partitionDirectory);
            return partitionDescriptorFile;
        }
        try (FileWriter fileWriter = new FileWriter(partitionDescriptorFile.getAbsolutePath(), false)) {
            fileWriter.write(partitionName);
            fileWriter.flush();
        }
        return partitionDescriptorFile;
    } catch (Exception e) {
        throw new ObjectStoreException(e);
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) FileWriter(java.io.FileWriter) 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)

Example 19 with ObjectStoreException

use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.

the class PollingSourceWrapper method updateWatermark.

private void updateWatermark(Serializable value, Comparator comparator) {
    try {
        if (watermarkObjectStore.contains(WATERMARK_OS_KEY)) {
            Serializable currentValue = watermarkObjectStore.retrieve(WATERMARK_OS_KEY);
            if (compareWatermarks(currentValue, value, comparator) >= 0) {
                return;
            }
            watermarkObjectStore.remove(WATERMARK_OS_KEY);
            recentlyProcessedIds.clear();
        }
        watermarkObjectStore.store(WATERMARK_OS_KEY, value);
    } catch (ObjectStoreException e) {
        throw new MuleRuntimeException(createStaticMessage(format("Failed to update watermark value for message source at location '%s'. %s", flowName, e.getMessage())), e);
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) Serializable(java.io.Serializable) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException)

Example 20 with ObjectStoreException

use of org.mule.runtime.api.store.ObjectStoreException in project mule by mulesoft.

the class TemplateObjectStoreContractTestCase method testStoreWithNullKey.

@Test
public void testStoreWithNullKey() {
    try {
        Serializable value = getStorableValue();
        getObjectStore().store(null, value);
        fail("store() called with null key must throw ObjectStoreException");
    } catch (ObjectStoreException ose) {
    // this one was expected
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) Serializable(java.io.Serializable) Test(org.junit.Test)

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