MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / Upload

Method Upload

internal/metrics/task_sqlite.go:318–441  ·  view source on GitHub ↗

Upload 上传数据

(pauseDuration time.Duration)

Source from the content-addressed store, hash-verified

316
317// Upload 上传数据
318func (this *SQLiteTask) Upload(pauseDuration time.Duration) error {
319 var uploadTr = trackers.Begin("METRIC:UPLOAD_STATS")
320 defer uploadTr.End()
321
322 if this.isStopped {
323 return nil
324 }
325
326 this.serverIdMapLocker.Lock()
327
328 // 服务IDs
329 var serverIds []int64
330 for serverId := range this.serverIdMap {
331 serverIds = append(serverIds, serverId)
332 }
333 this.serverIdMap = map[int64]zero.Zero{} // 清空数据
334
335 // 时间
336 var times = []string{}
337 for t := range this.timeMap {
338 times = append(times, t)
339 }
340 this.timeMap = map[string]zero.Zero{} // 清空数据
341
342 this.serverIdMapLocker.Unlock()
343
344 rpcClient, err := rpc.SharedRPC()
345 if err != nil {
346 return err
347 }
348
349 for _, serverId := range serverIds {
350 for _, currentTime := range times {
351 idStrings, err := func(serverId int64, currentTime string) (ids []string, err error) {
352 var t = trackers.Begin("METRIC:SELECT_TOP_STMT")
353 rows, err := this.selectTopStmt.Query(serverId, this.itemConfig.Version, currentTime)
354 t.End()
355 if err != nil {
356 return nil, err
357 }
358 var isClosed bool
359 defer func() {
360 if isClosed {
361 return
362 }
363 _ = rows.Close()
364 }()
365
366 var pbStats []*pb.UploadingMetricStat
367 for rows.Next() {
368 var pbStat = &pb.UploadingMetricStat{}
369 // "id", "hash", "keys", "value", "isUploaded"
370 var isUploaded int
371 var keysData []byte
372 err = rows.Scan(&pbStat.Id, &pbStat.Hash, &keysData, &pbStat.Value, &isUploaded)
373 if err != nil {
374 return nil, err
375 }

Callers 1

StartMethod · 0.95

Calls 11

sumMethod · 0.95
BeginFunction · 0.92
SharedRPCFunction · 0.92
NextMethod · 0.80
ContextMethod · 0.80
CloseMethod · 0.65
AddMethod · 0.65
EndMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected