(cfg *config.Config)
| 158 | } |
| 159 | |
| 160 | func (m *Server) createRaftServer(cfg *config.Config) (err error) { |
| 161 | raftCfg := &raftstore.Config{ |
| 162 | NodeID: m.id, |
| 163 | RaftPath: m.walDir, |
| 164 | NumOfLogsToRetain: m.retainLogs, |
| 165 | HeartbeatPort: m.config.heartbeatPort, |
| 166 | ReplicaPort: m.config.replicaPort, |
| 167 | TickInterval: m.tickInterval, |
| 168 | ElectionTick: m.electionTick, |
| 169 | } |
| 170 | if m.raftStore, err = raftstore.NewRaftStore(raftCfg, cfg); err != nil { |
| 171 | return errors.Trace(err, "NewRaftStore failed! id[%v] walPath[%v]", m.id, m.walDir) |
| 172 | } |
| 173 | m.initFsm() |
| 174 | partitionCfg := &raftstore.PartitionConfig{ |
| 175 | ID: GroupID, |
| 176 | Peers: m.config.peers, |
| 177 | Applied: m.fsm.applied, |
| 178 | SM: m.fsm, |
| 179 | } |
| 180 | if m.partition, err = m.raftStore.CreatePartition(partitionCfg); err != nil { |
| 181 | return errors.Trace(err, "CreatePartition failed") |
| 182 | } |
| 183 | return |
| 184 | } |
| 185 | |
| 186 | // Start starts a server |
| 187 | func (m *Server) Start(cfg *config.Config) (err error) { |
no test coverage detected