use of org.apache.bookkeeper.stream.storage.impl.store.MVCCStoreFactory in project bookkeeper by apache.
the class TestRangeStoreImpl method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
storageResources = StorageResources.create();
Endpoint endpoint = createEndpoint("127.0.0.1", 0);
// create the client manager
MVCCStoreFactory storeFactory = mock(MVCCStoreFactory.class);
MVCCAsyncStore<byte[], byte[]> store = mock(MVCCAsyncStore.class);
when(storeFactory.openStore(anyLong(), anyLong(), anyLong())).thenReturn(FutureUtils.value(store));
when(storeFactory.closeStores(anyLong())).thenReturn(FutureUtils.Void());
rangeStore = (RangeStoreImpl) RangeStoreBuilder.newBuilder().withStorageConfiguration(storageConf).withStorageResources(storageResources).withStorageContainerManagerFactory((numScs, storeConf, rgRegistry) -> new LocalStorageContainerManager(endpoint, storeConf, rgRegistry, 2)).withRangeStoreFactory(storeFactory).withDefaultBackendUri(URI.create("distributedlog://127.0.0.1/stream/storage")).build();
rangeStore.start();
}
use of org.apache.bookkeeper.stream.storage.impl.store.MVCCStoreFactory in project bookkeeper by apache.
the class TestDefaultStorageContainerFactory method testCreate.
@Test
public void testCreate() throws Exception {
OrderedScheduler scheduler = mock(OrderedScheduler.class);
OrderedScheduler snapshotScheduler = mock(OrderedScheduler.class);
MVCCStoreFactory storeFactory = mock(MVCCStoreFactory.class);
ListeningScheduledExecutorService snapshotExecutor = mock(ListeningScheduledExecutorService.class);
when(snapshotScheduler.chooseThread(anyLong())).thenReturn(snapshotExecutor);
Mockito.doReturn(mock(ListenableScheduledFuture.class)).when(snapshotExecutor).scheduleWithFixedDelay(any(Runnable.class), anyInt(), anyInt(), any(TimeUnit.class));
DefaultStorageContainerFactory factory = new DefaultStorageContainerFactory(new StorageConfiguration(new CompositeConfiguration()), (streamId, rangeId) -> streamId, scheduler, storeFactory, URI.create("distributedlog://127.0.0.1/stream/storage"));
StorageContainer sc = factory.createStorageContainer(1234L);
assertTrue(sc instanceof StorageContainerImpl);
assertEquals(1234L, sc.getId());
}
Aggregations