@Test public void expireTwoStoresInParallel() throws ObjectStoreException, InitialisationException, InterruptedException { when(muleContext.isPrimaryPollingInstance()).thenReturn(true); expireDelayLatch = new CountDownLatch(1); addJavaSerializerToMockMuleContext(muleContext); storeManager.initialise(); storeManager.createObjectStore(TEST_PARTITION_NAME + "_1", ObjectStoreSettings.builder() .persistent(false) .entryTtl(10L) .expirationInterval(10L) .build()); storeManager.createObjectStore(TEST_PARTITION_NAME + "_2", ObjectStoreSettings.builder() .persistent(false) .entryTtl(10L) .expirationInterval(10L) .build()); new PollingProber(POLLING_TIMEOUT, POLLING_DELAY).check(new JUnitLambdaProbe(() -> { assertThat(expires.get(), is(2)); return true; })); expireDelayLatch.countDown(); }
@Test public void disposeMonitoredObjectStores() throws Exception { ObjectStore<?> managedObjectStore = osm.createObjectStore(TEST_OS_NAME, ObjectStoreSettings.builder() .persistent(false) .maxEntries(MAX_ENTRIES) .entryTtl(TIMEOUT) .expirationInterval(TIMEOUT) .build()); assertNotNull(managedObjectStore); assertTrue(managedObjectStore instanceof Disposable); doDispose(); verify((Disposable) disposableStore).dispose(); }
private ObjectStorePartition<Serializable> createStorePartition(String partitionName, boolean isPersistent) throws InitialisationException { addJavaSerializerToMockMuleContext(muleContext); storeManager.initialise(); ObjectStorePartition<Serializable> store = storeManager.createObjectStore(partitionName, ObjectStoreSettings.builder() .persistent(isPersistent) .entryTtl(10000L) .expirationInterval(50L) .build()); assertThat(storeManager.getObjectStore(partitionName), is(sameInstance(store))); return store; }
@Override public void initialise() throws InitialisationException { name = format(NAME_TEMPLATE, storePrefix, muleContext.getConfiguration().getId(), getLocation().getRootContainerName()); MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry(); store = ((ObjectStoreManager) registry.get(OBJECT_STORE_MANAGER)) .createObjectStore(name, ObjectStoreSettings.builder() .persistent(false) .maxEntries(MAX_PROCESSED_GROUPS) .entryTtl(UNCLAIMED_TIME_TO_LIVE) .expirationInterval(UNCLAIMED_INTERVAL) .build()); try { notificationFirer = registry.lookupObject(NotificationDispatcher.class); } catch (RegistrationException e) { throw new InitialisationException(e, this); } }
private static <T extends Exception> ObjectStore<T> getObjectStore(MuleContext muleContext) { return muleContext.getObjectStoreManager().createObjectStore("SerializationTestUtils", ObjectStoreSettings.builder().persistent(true).build()); }
private Supplier<ObjectStore> internalProcessedGroupsObjectStoreFactory() { return () -> { ObjectStoreManager objectStoreManager = ((MuleContextWithRegistries) muleContext).getRegistry().get(OBJECT_STORE_MANAGER); return objectStoreManager.createObjectStore(storePrefix + ".processedGroups", ObjectStoreSettings.builder() .persistent(persistentStores) .maxEntries(MAX_PROCESSED_GROUPS) .expirationInterval(1000L) .build()); }; }
protected ObjectStore<String> createMessageIdStore() throws InitialisationException { ObjectStoreManager objectStoreManager = ((MuleContextWithRegistries) muleContext).getRegistry().get(OBJECT_STORE_MANAGER); return objectStoreManager.createObjectStore(storePrefix, ObjectStoreSettings.builder() .persistent(false) .entryTtl(MINUTES.toMillis(5)) .expirationInterval(SECONDS.toMillis(6)) .build()); }
public <T extends ObjectStore<? extends Serializable>> T createObjectStore( String name, int maxEntries, long entryTTL, long expirationInterval) throws ObjectStoreNotAvailableException { return (T) muleObjectStoreManager.createObjectStore(name, ObjectStoreSettings.builder() .persistent(isPersistent) .maxEntries(maxEntries) .entryTtl(entryTTL) .expirationInterval(expirationInterval) .build()); } }
private ObjectStorePartition<Serializable> createStorePartition(String partitionName, boolean isPersistent) throws InitialisationException { addJavaSerializerToMockMuleContext(muleContext); storeManager.initialise(); ObjectStorePartition<Serializable> store = storeManager.createObjectStore(partitionName, ObjectStoreSettings.builder() .persistent(isPersistent) .entryTtl(10000L) .expirationInterval(50L) .build()); assertThat(storeManager.getObjectStore(partitionName), is(sameInstance(store))); return store; }
@Test public void disposeMonitoredObjectStores() throws Exception { ObjectStore<?> managedObjectStore = osm.createObjectStore(TEST_OS_NAME, ObjectStoreSettings.builder() .persistent(false) .maxEntries(MAX_ENTRIES) .entryTtl(TIMEOUT) .expirationInterval(TIMEOUT) .build()); assertNotNull(managedObjectStore); assertTrue(managedObjectStore instanceof Disposable); doDispose(); verify((Disposable) disposableStore).dispose(); }
public <T extends ObjectStore<? extends Serializable>> T createObjectStore(String name) throws ObjectStoreNotAvailableException { return (T) muleObjectStoreManager.createObjectStore(name, ObjectStoreSettings.builder().persistent(isPersistent).build()); }
private Supplier<ObjectStore> internalObjectStoreSupplier() { return () -> { return objectStoreManager.createObjectStore(getLocation().getRootContainerName() + "." + getClass().getName(), ObjectStoreSettings.builder() .persistent(false) .entryTtl((long) 60 * 5 * 1000) .expirationInterval(6000L).build()); }; }
@Ignore("MULE-6926") @Issue("MULE-6926") @Test public void testPartitionablePersistenceStore() throws ObjectStoreException, RegistrationException, InterruptedException { PartitionedPersistentObjectStore<String> partitionedStore = new PartitionedPersistentObjectStore<>(muleContext); partitionedStore.open(); getRegistry().registerObject(BASE_PERSISTENT_OBJECT_STORE_KEY, partitionedStore); ObjectStoreManager manager = getRegistry().lookupObject(OBJECT_STORE_MANAGER); ObjectStore<String> store = manager.createObjectStore("persistencePart2", unmanagedPersistent()); assertTrue(store instanceof ObjectStorePartition); ObjectStore<String> baseStore = ((ObjectStorePartition<String>) store).getBaseStore(); assertTrue(baseStore instanceof PartitionedPersistentObjectStore); assertSame(baseStore, getRegistry().lookupObject(BASE_PERSISTENT_OBJECT_STORE_KEY)); testObjectStore(store); testObjectStoreExpiry(manager, "persistenceExpPart2", ObjectStoreSettings.builder() .persistent(true) .entryTtl(1000L) .expirationInterval(200L) .build()); testObjectStoreMaxEntries(manager, "persistenceMaxPart2", ObjectStoreSettings.builder() .persistent(true) .maxEntries(10) .entryTtl(10000L) .expirationInterval(200L) .build()); }
@Override public void onStart(SourceCallback<T, A> sourceCallback) throws MuleException { delegate.onStart(sourceCallback); flowName = componentLocation.getRootContainerName(); keyPrefix = "_pollingSource_" + flowName + "/"; inflightIdsObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("inflight-ids"), ObjectStoreSettings.builder() .persistent(false) .maxEntries(1000) .entryTtl(60000L) .expirationInterval(20000L) .build()); recentlyProcessedIds = objectStoreManager.getOrCreateObjectStore(formatKey("recently-processed-ids"), unmanagedPersistent()); idsOnUpdatedWatermark = objectStoreManager.getOrCreateObjectStore(formatKey("ids-on-updated-watermark"), unmanagedPersistent()); watermarkObjectStore = objectStoreManager.getOrCreateObjectStore(formatKey("watermark"), unmanagedPersistent()); executor = schedulerService.customScheduler(SchedulerConfig.config() .withMaxConcurrentTasks(1) .withWaitAllowed(true) .withName(formatKey("executor"))); stopRequested.set(false); scheduler.schedule(executor, () -> poll(sourceCallback)); }
@Test public void testPartitionableInMemoryStore() throws ObjectStoreException, RegistrationException, InterruptedException { getRegistry().registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, new PartitionedInMemoryObjectStore<String>()); ObjectStoreManager manager = getRegistry().lookupObject(OBJECT_STORE_MANAGER); ObjectStore<String> store = manager.createObjectStore("inMemoryPart2", unmanagedTransient()); assertTrue(store instanceof ObjectStorePartition); ObjectStore<String> baseStore = ((ObjectStorePartition<String>) store).getBaseStore(); assertTrue(baseStore instanceof PartitionedInMemoryObjectStore); testObjectStore(store); testObjectStoreExpiry(manager, "inMemoryExpPart2", ObjectStoreSettings.builder() .persistent(false) .entryTtl(500L) .expirationInterval(200L) .build()); testObjectStoreMaxEntries(manager, "inMemoryMaxPart2", ObjectStoreSettings.builder() .persistent(false) .maxEntries(10) .entryTtl(10000L) .expirationInterval(200L) .build()); }
@Test public void testInMemoryStore() throws ObjectStoreException, InterruptedException, RegistrationException { getRegistry().registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, new SimpleMemoryObjectStore<String>()); ObjectStoreManager manager = getRegistry().lookupObject(OBJECT_STORE_MANAGER); ObjectStore<String> store = manager.createObjectStore("inMemoryPart1", unmanagedTransient()); testObjectStore(store); testObjectStoreExpiry(manager, "inMemoryExpPart1", ObjectStoreSettings.builder() .persistent(false) .entryTtl(500L) .expirationInterval(200L) .build()); testObjectStoreMaxEntries(manager, "inMemoryMaxPart1", ObjectStoreSettings.builder() .persistent(false) .maxEntries(10) .entryTtl(10000L) .expirationInterval(200L) .build()); }
public <T extends ObjectStore<? extends Serializable>> T createObjectStore( String name, int maxEntries, long entryTTL, long expirationInterval) throws ObjectStoreNotAvailableException { return (T) muleObjectStoreManager.createObjectStore(name, ObjectStoreSettings.builder() .persistent(isPersistent) .maxEntries(maxEntries) .entryTtl(entryTTL) .expirationInterval(expirationInterval) .build()); } }
private static <T extends Exception> ObjectStore<T> getObjectStore(MuleContext muleContext) { return muleContext.getObjectStoreManager().createObjectStore("SerializationTestUtils", ObjectStoreSettings.builder().persistent(true).build()); }
@Override public CoreEvent process(CoreEvent event) throws MuleException { ObjectStore<String> myPartition = objectStoreManager.getOrCreateObjectStore("myPartition", ObjectStoreSettings.builder().persistent(true).build()); String key = "value"; if (myPartition.contains(key)) { myPartition.remove(key); } myPartition.store(key, key); return event; } }
public <T extends ObjectStore<? extends Serializable>> T createObjectStore(String name) throws ObjectStoreNotAvailableException { return (T) muleObjectStoreManager.createObjectStore(name, ObjectStoreSettings.builder().persistent(isPersistent).build()); }