public static NodeStoreFixture create(Options options) throws Exception { return create(options, !options.getOptionBean(CommonOptions.class).isReadWrite()); }
private static StatisticsProvider createStatsProvider(Options options, Whiteboard wb, Closer closer) { if (options.getCommonOpts().isMetricsEnabled()) { ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1)); MetricStatisticsProvider statsProvider = new MetricStatisticsProvider(getPlatformMBeanServer(), executorService); closer.register(statsProvider); closer.register(() -> reportMetrics(statsProvider)); wb.register(MetricRegistry.class, statsProvider.getRegistry(), emptyMap()); return statsProvider; } return StatisticsProvider.NOOP; }
StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer); wb.register(StatisticsProvider.class, statisticsProvider, emptyMap()); store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly); } catch (InvalidFileStoreVersionException e) { if (oldSegmentStore(options)) { store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly); } else {
StatisticsProvider statisticsProvider = createStatsProvider(options, wb, closer); wb.register(StatisticsProvider.class, statisticsProvider, emptyMap()); store = SegmentTarFixtureProvider.configureSegment(options, blobStore, wb, closer, readOnly); } catch (InvalidFileStoreVersionException e) { if (oldSegmentStore(options)) { store = SegmentFixtureProvider.create(options, blobStore, wb, closer, readOnly); } else {
public static NodeStoreFixture create(Options options) throws Exception { return create(options, !options.getOptionBean(CommonOptions.class).isReadWrite()); }
private static StatisticsProvider createStatsProvider(Options options, Whiteboard wb, Closer closer) { if (options.getCommonOpts().isMetricsEnabled()) { ScheduledExecutorService executorService = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(1)); MetricStatisticsProvider statsProvider = new MetricStatisticsProvider(getPlatformMBeanServer(), executorService); closer.register(statsProvider); closer.register(() -> reportMetrics(statsProvider)); wb.register(MetricRegistry.class, statsProvider.getRegistry(), emptyMap()); return statsProvider; } return StatisticsProvider.NOOP; }
@Test public void customizer() throws Exception{ Options o = createMongoOptions(); DocumentBuilderCustomizer customizer = mock(DocumentBuilderCustomizer.class); o.getWhiteboard().register(DocumentBuilderCustomizer.class, customizer, emptyMap()); try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(o, false)) { } verify(customizer, times(1)).customize(any(DocumentNodeStoreBuilder.class)); }
@Test public void customizerCalled() throws Exception{ Options o = createSegmentOptions(folder.getRoot()); FileStoreTarBuilderCustomizer customizer = mock(FileStoreTarBuilderCustomizer.class); o.getWhiteboard().register(FileStoreTarBuilderCustomizer.class, customizer, emptyMap()); try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(o, false)) { } verify(customizer, times(1)).customize(any(FileStoreBuilder.class)); }
@Test public void testReadWrite() throws Exception { try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(createSegmentOptions(folder.getRoot()), false)) { NodeStore store = fixture.getStore(); NodeBuilder builder = store.getRoot().builder(); builder.setChildNode("foo"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); } }
@Test public void documentNodeStore() throws Exception{ try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(createMongoOptions(), false)) { NodeStore store = fixture.getStore(); NodeBuilder builder = store.getRoot().builder(); builder.setChildNode("foo"); store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); assertNotNull(fixture.getBlobStore()); } }
@Test(expected = UnsupportedOperationException.class) public void testReadOnly() throws Exception { File directory = folder.getRoot(); createStoreAt(directory); try (NodeStoreFixture fixture = NodeStoreFixtureProvider.create(createSegmentOptions(folder.getRoot()), true)) { NodeStore s = fixture.getStore(); NodeBuilder builder = s.getRoot().builder(); builder.setChildNode("foo"); s.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); } }