Search in sources :

Example 1 with LogSegmentMetadataCache

use of org.apache.distributedlog.logsegment.LogSegmentMetadataCache in project bookkeeper by apache.

the class TestDistributedLogBase method createNewDLM.

public BKDistributedLogManager createNewDLM(DistributedLogConfiguration conf, String name, PermitLimiter writeLimiter) throws Exception {
    URI uri = createDLMURI("/" + name);
    ensureURICreated(uri);
    final Namespace namespace = NamespaceBuilder.newBuilder().uri(uri).conf(conf).build();
    final OrderedScheduler scheduler = OrderedScheduler.newSchedulerBuilder().numThreads(1).name("test-scheduler").build();
    AsyncCloseable resourcesCloseable = new AsyncCloseable() {

        @Override
        public CompletableFuture<Void> asyncClose() {
            LOG.info("Shutting down the scheduler");
            SchedulerUtils.shutdownScheduler(scheduler, 1, TimeUnit.SECONDS);
            LOG.info("Shut down the scheduler");
            LOG.info("Closing the namespace");
            namespace.close();
            LOG.info("Closed the namespace");
            return FutureUtils.Void();
        }
    };
    AsyncFailureInjector failureInjector = AsyncRandomFailureInjector.newBuilder().injectDelays(conf.getEIInjectReadAheadDelay(), conf.getEIInjectReadAheadDelayPercent(), conf.getEIInjectMaxReadAheadDelayMs()).injectErrors(false, 10).injectStops(conf.getEIInjectReadAheadStall(), 10).injectCorruption(conf.getEIInjectReadAheadBrokenEntries()).build();
    return new BKDistributedLogManager(name, conf, ConfUtils.getConstDynConf(conf), uri, namespace.getNamespaceDriver(), new LogSegmentMetadataCache(conf, Ticker.systemTicker()), scheduler, DistributedLogConstants.UNKNOWN_CLIENT_ID, DistributedLogConstants.LOCAL_REGION_ID, writeLimiter, new SettableFeatureProvider("", 0), failureInjector, NullStatsLogger.INSTANCE, NullStatsLogger.INSTANCE, Optional.of(resourcesCloseable));
}
Also used : AsyncCloseable(org.apache.distributedlog.io.AsyncCloseable) AsyncFailureInjector(org.apache.distributedlog.injector.AsyncFailureInjector) LogSegmentMetadataCache(org.apache.distributedlog.logsegment.LogSegmentMetadataCache) URI(java.net.URI) Namespace(org.apache.distributedlog.api.namespace.Namespace) SettableFeatureProvider(org.apache.bookkeeper.feature.SettableFeatureProvider) OrderedScheduler(org.apache.bookkeeper.common.util.OrderedScheduler)

Aggregations

URI (java.net.URI)1 OrderedScheduler (org.apache.bookkeeper.common.util.OrderedScheduler)1 SettableFeatureProvider (org.apache.bookkeeper.feature.SettableFeatureProvider)1 Namespace (org.apache.distributedlog.api.namespace.Namespace)1 AsyncFailureInjector (org.apache.distributedlog.injector.AsyncFailureInjector)1 AsyncCloseable (org.apache.distributedlog.io.AsyncCloseable)1 LogSegmentMetadataCache (org.apache.distributedlog.logsegment.LogSegmentMetadataCache)1