Search in sources :

Example 1 with PartitionableExpirableObjectStore

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;
    }
}
Also used : Scheduler(org.mule.runtime.api.scheduler.Scheduler) PartitionableExpirableObjectStore(org.mule.runtime.api.store.PartitionableExpirableObjectStore) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException)

Aggregations

MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)1 Scheduler (org.mule.runtime.api.scheduler.Scheduler)1 PartitionableExpirableObjectStore (org.mule.runtime.api.store.PartitionableExpirableObjectStore)1