public DefaultStorage(final BrokerRole role, final StorageConfig config, final CheckpointLoader loader) {
this.config = config;
this.consumerLogManager = new ConsumerLogManager(config);
this.messageLog = new MessageLog(config, consumerLogManager);
this.pullLogManager = new PullLogManager(config);
this.actionLog = new ActionLog(config);
this.checkpointManager = new CheckpointManager(role, config, loader);
this.checkpointManager.fixOldVersionCheckpointIfShould(consumerLogManager, pullLogManager);
this.consumeQueueManager = new ConsumeQueueManager(this);
this.pullLogFlusher = new PullLogFlusher(config, checkpointManager, pullLogManager);
this.actionEventBus = new FixedExecOrderEventBus();
this.actionEventBus.subscribe(ActionEvent.class, new PullLogBuilder(this));
this.actionEventBus.subscribe(ActionEvent.class, new MaxSequencesUpdater(checkpointManager));
this.actionEventBus.subscribe(ActionEvent.class, pullLogFlusher);
this.actionLogIterateService = new ActionLogIterateService(actionLog, checkpointManager, actionEventBus);
this.consumerLogFlusher = new ConsumerLogFlusher(config, checkpointManager, consumerLogManager);
this.messageEventBus = new FixedExecOrderEventBus();
this.messageEventBus.subscribe(MessageLogMeta.class, new BuildConsumerLogEventListener(consumerLogManager));
this.messageEventBus.subscribe(MessageLogMeta.class, consumerLogFlusher);
this.messageLogIterateService = new MessageLogIterateService(messageLog, checkpointManager, messageEventBus);
this.logCleanerExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("log-cleaner-%d").build());
this.messageLogFlushService = new PeriodicFlushService(new MessageLogFlushProvider());
this.actionLogFlushService = new PeriodicFlushService(new ActionLogFlushProvider());
}