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());
}
}
}
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);
}
}
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);
}
}
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);
}
}
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
}
}
Aggregations