MCPcopy
hub / github.com/uber/aresdb / Run

Method Run

controller/tasks/etcd/ingestion_assignment.go:124–154  ·  view source on GitHub ↗

Run starts the ingestionAssignmentTask

()

Source from the content-addressed store, hash-verified

122
123// Run starts the ingestionAssignmentTask
124func (ia *ingestionAssignmentTask) Run() {
125 hostName, _ := os.Hostname()
126
127 // wait random interval to avoid herd effect electing for leader on cluster reboot
128 waitSeconds := rand.Intn(5)
129 time.Sleep(time.Duration(waitSeconds) * time.Second)
130
131 ia.logger.With(
132 "host", hostName,
133 "waitedSeconds", waitSeconds,
134 ).Info("start ingestion assignment task after waiting")
135
136 if err := ia.leaderElection.Start(); err != nil {
137 ia.logger.With("host", hostName, "error", err.Error()).Error("failed to start leader election")
138 ia.scope.Counter("task_failed").Inc(1)
139 return
140 }
141
142 defer func() {
143 err := ia.leaderElection.Close()
144 if err != nil {
145 ia.logger.Error(err)
146 } else {
147 ia.logger.With("host", hostName).Infof("stopped leader election")
148 }
149 }()
150
151 ia.logger.With("host", hostName).Infof("entering ingestion assignment calculation loop")
152 ia.startIngestionAssignment(hostName)
153 ia.logger.With("host", hostName).Infof("exited ingestion assignment calculation loop")
154}
155
156// Done stops the task
157func (ia *ingestionAssignmentTask) Done() {

Callers

nothing calls this directly

Calls 7

InfoMethod · 0.65
WithMethod · 0.65
StartMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65
InfofMethod · 0.65

Tested by

no test coverage detected