2020-08-17 13:26:18 +00:00
|
|
|
package sectorstorage
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-08-27 21:14:33 +00:00
|
|
|
import (
|
|
|
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
|
|
|
)
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-04-23 22:16:21 +00:00
|
|
|
func (m *Manager) WorkerStats() map[uint64]storiface.WorkerStats {
|
2020-08-13 09:31:18 +00:00
|
|
|
m.sched.workersLk.RLock()
|
|
|
|
defer m.sched.workersLk.RUnlock()
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-04-23 22:16:21 +00:00
|
|
|
out := map[uint64]storiface.WorkerStats{}
|
2020-03-23 14:56:22 +00:00
|
|
|
|
2020-04-27 18:37:31 +00:00
|
|
|
for id, handle := range m.sched.workers {
|
2020-04-23 22:16:21 +00:00
|
|
|
out[uint64(id)] = storiface.WorkerStats{
|
2020-03-23 14:56:22 +00:00
|
|
|
Info: handle.info,
|
2020-04-27 20:43:42 +00:00
|
|
|
MemUsedMin: handle.active.memUsedMin,
|
|
|
|
MemUsedMax: handle.active.memUsedMax,
|
|
|
|
GpuUsed: handle.active.gpuUsed,
|
|
|
|
CpuUse: handle.active.cpuUse,
|
2020-03-23 14:56:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return out
|
|
|
|
}
|
2020-07-21 18:01:25 +00:00
|
|
|
|
|
|
|
func (m *Manager) WorkerJobs() map[uint64][]storiface.WorkerJob {
|
2020-08-13 09:31:18 +00:00
|
|
|
m.sched.workersLk.RLock()
|
|
|
|
defer m.sched.workersLk.RUnlock()
|
2020-07-21 18:01:25 +00:00
|
|
|
|
|
|
|
out := map[uint64][]storiface.WorkerJob{}
|
|
|
|
|
|
|
|
for id, handle := range m.sched.workers {
|
|
|
|
out[uint64(id)] = handle.wt.Running()
|
2020-08-27 21:14:33 +00:00
|
|
|
|
|
|
|
handle.wndLk.Lock()
|
2020-08-28 16:26:17 +00:00
|
|
|
for wi, window := range handle.activeWindows {
|
2020-08-27 21:14:33 +00:00
|
|
|
for _, request := range window.todo {
|
|
|
|
out[uint64(id)] = append(out[uint64(id)], storiface.WorkerJob{
|
|
|
|
ID: 0,
|
|
|
|
Sector: request.sector,
|
|
|
|
Task: request.taskType,
|
2020-08-28 16:26:17 +00:00
|
|
|
RunWait: wi + 1,
|
2020-08-27 21:14:33 +00:00
|
|
|
Start: request.start,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle.wndLk.Unlock()
|
2020-07-21 18:01:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return out
|
|
|
|
}
|