MCPcopy Create free account
hub / github.com/actiontech/dtle / RegularlyUpdateJobStatus

Function RegularlyUpdateJobStatus

driver/common/common.go:162–190  ·  view source on GitHub ↗

regularly update the task status value by the memory usage

(store *StoreManager, shutdownCh chan struct{}, jobId string)

Source from the content-addressed store, hash-verified

160
161// regularly update the task status value by the memory usage
162func RegularlyUpdateJobStatus(store *StoreManager, shutdownCh chan struct{}, jobId string) {
163 ticker := time.NewTicker(time.Second * 3)
164 defer ticker.Stop()
165 for {
166 select {
167 case <-shutdownCh:
168 return
169 case <-ticker.C:
170 lowMemoryStatus := g.GetLowMemoryStatus()
171 jobInfo, err := store.GetJobInfo(jobId)
172 if err != nil {
173 store.logger.Error("get job info err", "jobId", jobId, "err", err)
174 continue
175 }
176 if jobInfo.JobStatus == DtleJobStatusNonPaused && lowMemoryStatus {
177 jobInfo.JobStatus = DtleJobStatusStop
178 } else if jobInfo.JobStatus == DtleJobStatusStop && !lowMemoryStatus {
179 jobInfo.JobStatus = DtleJobStatusNonPaused
180 } else {
181 continue
182 }
183 store.logger.Info("update job status", "jobId", jobId, "jobStatus", jobInfo.JobStatus)
184 if err = store.SaveJobInfo(*jobInfo); err != nil {
185 store.logger.Error("get job info err", "jobId", jobId, "err", err)
186 continue
187 }
188 }
189 }
190}

Callers 1

initiateStreamingMethod · 0.92

Calls 3

GetLowMemoryStatusFunction · 0.92
GetJobInfoMethod · 0.80
SaveJobInfoMethod · 0.80

Tested by

no test coverage detected