Search in sources :

Example 1 with DumpConfigHandler

use of com.alibaba.nacos.config.server.service.dump.DumpConfigHandler in project nacos by alibaba.

the class DistributedDatabaseOperateImpl method init.

protected void init() throws Exception {
    this.dataSourceService = (LocalDataSourceServiceImpl) DynamicDataSource.getInstance().getDataSource();
    // Because in Raft + Derby mode, ensuring data consistency depends on the Raft's
    // log playback and snapshot recovery capabilities, and the last data must be cleared
    this.dataSourceService.cleanAndReopenDerby();
    this.jdbcTemplate = dataSourceService.getJdbcTemplate();
    this.transactionTemplate = dataSourceService.getTransactionTemplate();
    // Registers a Derby Raft state machine failure event for node degradation processing
    NotifyCenter.registerToSharePublisher(RaftDbErrorEvent.class);
    // Register the snapshot load event
    NotifyCenter.registerToSharePublisher(DerbyLoadEvent.class);
    NotifyCenter.registerSubscriber(new Subscriber<RaftDbErrorEvent>() {

        @Override
        public void onEvent(RaftDbErrorEvent event) {
            dataSourceService.setHealthStatus("DOWN");
        }

        @Override
        public Class<? extends Event> subscribeType() {
            return RaftDbErrorEvent.class;
        }
    });
    NotifyCenter.registerToPublisher(ConfigDumpEvent.class, NotifyCenter.ringBufferSize);
    NotifyCenter.registerSubscriber(new DumpConfigHandler());
    this.protocol.addRequestProcessors(Collections.singletonList(this));
    LogUtil.DEFAULT_LOG.info("use DistributedTransactionServicesImpl");
}
Also used : DumpConfigHandler(com.alibaba.nacos.config.server.service.dump.DumpConfigHandler) RaftDbErrorEvent(com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent) Event(com.alibaba.nacos.common.notify.Event) DerbyLoadEvent(com.alibaba.nacos.config.server.model.event.DerbyLoadEvent) ConfigDumpEvent(com.alibaba.nacos.config.server.model.event.ConfigDumpEvent) RaftDbErrorEvent(com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent)

Aggregations

Event (com.alibaba.nacos.common.notify.Event)1 ConfigDumpEvent (com.alibaba.nacos.config.server.model.event.ConfigDumpEvent)1 DerbyLoadEvent (com.alibaba.nacos.config.server.model.event.DerbyLoadEvent)1 RaftDbErrorEvent (com.alibaba.nacos.config.server.model.event.RaftDbErrorEvent)1 DumpConfigHandler (com.alibaba.nacos.config.server.service.dump.DumpConfigHandler)1