@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 serialization() throws Exception { final String key = "key"; ObjectStore<DateTime> os = muleContext.getObjectStoreManager().createObjectStore("DateTimeTestCase", unmanagedPersistent()); try { os.store(key, now); DateTime recovered = os.retrieve(key); assertEquals(now, recovered); } finally { os.clear(); } }
@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()); }
@Test public void serialization() throws Exception { final String key = "key"; ObjectStore<DateTime> os = muleContext.getObjectStoreManager().createObjectStore("DateTimeTestCase", unmanagedPersistent()); try { os.store(key, now); DateTime recovered = os.retrieve(key); assertEquals(now, recovered); } finally { os.clear(); } }
@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"), ObjectStoreSettings.builder() .persistent(true) .maxEntries(1000) .entryTtl(60000L) .expirationInterval(20000L) .build()); 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)); }
@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()); }