Search in sources :

Example 1 with ObjectStoreManager

use of org.mule.runtime.api.store.ObjectStoreManager in project mule by mulesoft.

the class ManagedStoresTestCase method testPartitionableInMemoryStore.

@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());
}
Also used : ObjectStoreManager(org.mule.runtime.api.store.ObjectStoreManager) PartitionedInMemoryObjectStore(org.mule.runtime.core.internal.store.PartitionedInMemoryObjectStore) Test(org.junit.Test)

Example 2 with ObjectStoreManager

use of org.mule.runtime.api.store.ObjectStoreManager in project mule by mulesoft.

the class ManagedStoresTestCase method testInMemoryStore.

@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());
}
Also used : ObjectStoreManager(org.mule.runtime.api.store.ObjectStoreManager) Test(org.junit.Test)

Example 3 with ObjectStoreManager

use of org.mule.runtime.api.store.ObjectStoreManager in project mule by mulesoft.

the class ManagedStoresTestCase method testClearPartition.

@Test
public void testClearPartition() throws ObjectStoreException, InterruptedException, RegistrationException {
    getRegistry().registerObject(BASE_IN_MEMORY_OBJECT_STORE_KEY, new SimpleMemoryObjectStore<String>());
    ObjectStoreManager manager = getRegistry().lookupObject(OBJECT_STORE_MANAGER);
    ObjectStore<String> partition1 = manager.createObjectStore("inMemoryPart1", unmanagedTransient());
    ObjectStore<String> partition2 = manager.createObjectStore("inMemoryPart2", unmanagedTransient());
    partition1.store("key1", "value1");
    partition2.store("key2", "value2");
    assertEquals("value1", partition1.retrieve("key1"));
    assertEquals("value2", partition2.retrieve("key2"));
    partition1.clear();
    assertEquals("value2", partition2.retrieve("key2"));
}
Also used : ObjectStoreManager(org.mule.runtime.api.store.ObjectStoreManager) Test(org.junit.Test)

Example 4 with ObjectStoreManager

use of org.mule.runtime.api.store.ObjectStoreManager in project mule by mulesoft.

the class ManagedStoresTestCase method testPartitionablePersistenceStore.

@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());
}
Also used : ObjectStoreManager(org.mule.runtime.api.store.ObjectStoreManager) PartitionedPersistentObjectStore(org.mule.runtime.core.internal.store.PartitionedPersistentObjectStore) Ignore(org.junit.Ignore) Issue(io.qameta.allure.Issue) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ObjectStoreManager (org.mule.runtime.api.store.ObjectStoreManager)4 Issue (io.qameta.allure.Issue)1 Ignore (org.junit.Ignore)1 PartitionedInMemoryObjectStore (org.mule.runtime.core.internal.store.PartitionedInMemoryObjectStore)1 PartitionedPersistentObjectStore (org.mule.runtime.core.internal.store.PartitionedPersistentObjectStore)1