1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| func (bs *Raftstore) start( meta *metapb.Store, cfg *config.Config, engines *engine_util.Engines, trans Transport, schedulerClient scheduler_client.Client, snapMgr *snap.SnapManager) error {
y.Assert(bs.workers == nil) if err := cfg.Validate(); err != nil { return err } err := snapMgr.Init() if err != nil { return err } wg := new(sync.WaitGroup) bs.workers = &workers{ splitCheckWorker: worker.NewWorker("split-check", wg), regionWorker: worker.NewWorker("snapshot-worker", wg), raftLogGCWorker: worker.NewWorker("raft-gc-worker", wg), schedulerWorker: worker.NewWorker("scheduler-worker", wg), wg: wg, } bs.ctx = &GlobalContext{ cfg: cfg, engine: engines, store: meta, storeMeta: newStoreMeta(), snapMgr: snapMgr, router: bs.router, trans: trans, schedulerTaskSender: bs.workers.schedulerWorker.Sender(), regionTaskSender: bs.workers.regionWorker.Sender(), splitCheckTaskSender: bs.workers.splitCheckWorker.Sender(), raftLogGCTaskSender: bs.workers.raftLogGCWorker.Sender(), schedulerClient: schedulerClient, tickDriverSender: bs.tickDriver.newRegionCh, } regionPeers, err := bs.loadPeers() if err != nil { return err }
for _, peer := range regionPeers { bs.router.register(peer) } bs.startWorkers(regionPeers) return nil }
|