Open data node for serving
()
| 167 | |
| 168 | // Open data node for serving |
| 169 | func (d *dataNode) Open() error { |
| 170 | d.startedAt = utils.Now() |
| 171 | |
| 172 | //1. start schema watch |
| 173 | d.startSchemaWatch() |
| 174 | |
| 175 | // memstore fetch local disk schema |
| 176 | err := d.memStore.FetchSchema() |
| 177 | if err != nil { |
| 178 | return err |
| 179 | } |
| 180 | |
| 181 | // 2. start debug server |
| 182 | go d.startDebugServer() |
| 183 | |
| 184 | // 3. first shard assignment |
| 185 | d.mapWatch, err = d.topo.Watch() |
| 186 | if err != nil { |
| 187 | return utils.StackError(err, "failed to watch topology") |
| 188 | } |
| 189 | |
| 190 | select { |
| 191 | case <-d.mapWatch.C(): |
| 192 | hostShardSet, ok := d.mapWatch.Get().LookupHostShardSet(d.hostID) |
| 193 | if ok { |
| 194 | d.assignShardSet(hostShardSet.ShardSet()) |
| 195 | } |
| 196 | default: |
| 197 | } |
| 198 | |
| 199 | d.memStore.GetHostMemoryManager().Start() |
| 200 | |
| 201 | // 5. start scheduler |
| 202 | if !d.opts.ServerConfig().SchedulerOff { |
| 203 | d.logger.Info("starting scheduler") |
| 204 | // disable archiving during redolog replay |
| 205 | d.memStore.GetScheduler().EnableJobType(memCom.ArchivingJobType, false) |
| 206 | // this will start scheduler of all jobs except archiving, archiving will be started individually |
| 207 | d.memStore.GetScheduler().Start() |
| 208 | } else { |
| 209 | d.logger.Info("scheduler is turned off") |
| 210 | } |
| 211 | |
| 212 | // 6. start table addition watch |
| 213 | go d.startTableAdditionWatch() |
| 214 | // 7. start active topology watch |
| 215 | go d.startActiveTopologyWatch() |
| 216 | // 8. start analyzing shard availability |
| 217 | go d.startAnalyzingShardAvailability() |
| 218 | // 9. start analyzing server readiness |
| 219 | go d.startAnalyzingServerReadiness() |
| 220 | |
| 221 | return nil |
| 222 | } |
| 223 | |
| 224 | func (d *dataNode) startSchemaWatch() { |
| 225 | if d.opts.ServerConfig().Cluster.Enable { |
nothing calls this directly
no test coverage detected