use of org.mule.runtime.api.store.PartitionableExpirableObjectStore in project mule by mulesoft.
the class MuleObjectStoreManager method getMonitorablePartition.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <T extends ObjectStore<? extends Serializable>> T getMonitorablePartition(String name, ObjectStore baseStore, T store, ObjectStoreSettings settings) {
if (baseStore instanceof PartitionableExpirableObjectStore) {
Scheduler scheduler = schedulerService.customScheduler(muleContext.getSchedulerBaseConfig().withName("ObjectStoreManager-Monitor-" + name).withMaxConcurrentTasks(1));
scheduler.scheduleWithFixedDelay(new Monitor(name, (PartitionableExpirableObjectStore) baseStore, settings.getEntryTTL().orElse(0L), settings.getMaxEntries().orElse(UNBOUNDED)), 0, settings.getExpirationInterval(), MILLISECONDS);
expirationSchedulers.put(name, scheduler);
return store;
} else {
MonitoredObjectStoreWrapper monObjectStore;
// or putting an uninitialised ObjectStore
synchronized (this) {
monObjectStore = new MonitoredObjectStoreWrapper(store, settings);
monObjectStore.setMuleContext(muleContext);
try {
monObjectStore.initialise();
} catch (InitialisationException e) {
throw new MuleRuntimeException(e);
}
}
return (T) monObjectStore;
}
}
Aggregations