Stats for remote workers
This commit is contained in:
parent
88bbcd80ea
commit
98b1de33b6
@ -66,7 +66,7 @@ type StorageMiner interface {
|
||||
|
||||
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
||||
|
||||
WorkerStats(context.Context) (WorkerStats, error)
|
||||
WorkerStats(context.Context) (sectorbuilder.WorkerStats, error)
|
||||
|
||||
// WorkerQueue registers a remote worker
|
||||
WorkerQueue(context.Context) (<-chan sectorbuilder.WorkerTask, error)
|
||||
@ -74,12 +74,6 @@ type StorageMiner interface {
|
||||
WorkerDone(ctx context.Context, task uint64, res sectorbuilder.SealRes) error
|
||||
}
|
||||
|
||||
type WorkerStats struct {
|
||||
Free int
|
||||
Reserved int // for PoSt
|
||||
Total int
|
||||
}
|
||||
|
||||
type SectorInfo struct {
|
||||
SectorID uint64
|
||||
State SectorState
|
||||
|
@ -142,7 +142,7 @@ type StorageMinerStruct struct {
|
||||
SectorsList func(context.Context) ([]uint64, error) `perm:"read"`
|
||||
SectorsRefs func(context.Context) (map[string][]SealedRef, error) `perm:"read"`
|
||||
|
||||
WorkerStats func(context.Context) (WorkerStats, error) `perm:"read"`
|
||||
WorkerStats func(context.Context) (sectorbuilder.WorkerStats, error) `perm:"read"`
|
||||
|
||||
WorkerQueue func(context.Context) (<-chan sectorbuilder.WorkerTask, error) `perm:"admin"` // TODO: worker perm
|
||||
WorkerDone func(ctx context.Context, task uint64, res sectorbuilder.SealRes) error `perm:"admin"`
|
||||
@ -527,7 +527,7 @@ func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]Seal
|
||||
return c.Internal.SectorsRefs(ctx)
|
||||
}
|
||||
|
||||
func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (WorkerStats, error) {
|
||||
func (c *StorageMinerStruct) WorkerStats(ctx context.Context) (sectorbuilder.WorkerStats, error) {
|
||||
return c.Internal.WorkerStats(ctx)
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,10 @@ var infoCmd = &cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Worker use: %d / %d (+%d)\n", wstat.Total-wstat.Reserved-wstat.Free, wstat.Total, wstat.Reserved)
|
||||
|
||||
fmt.Printf("Worker use:\n")
|
||||
fmt.Printf("\tLocal: %d / %d (+%d reserved)\n",wstat.LocalTotal-wstat.LocalReserved-wstat.LocalFree, wstat.LocalTotal-wstat.LocalReserved, wstat.LocalReserved )
|
||||
fmt.Printf("\tRemote: %d / %d\n", wstat.RemotesTotal - wstat.RemotesFree, wstat.RemotesTotal)
|
||||
|
||||
ppe, err := api.StateMinerProvingPeriodEnd(ctx, maddr, nil)
|
||||
if err != nil {
|
||||
|
@ -209,8 +209,33 @@ func (sb *SectorBuilder) RateLimit() func() {
|
||||
}
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) WorkerStats() (free, reserved, total int) {
|
||||
return cap(sb.rateLimit) - len(sb.rateLimit), PoStReservedWorkers, cap(sb.rateLimit) + PoStReservedWorkers
|
||||
type WorkerStats struct {
|
||||
LocalFree int
|
||||
LocalReserved int
|
||||
LocalTotal int
|
||||
// todo: post in progress
|
||||
RemotesTotal int
|
||||
RemotesFree int
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) WorkerStats() WorkerStats {
|
||||
sb.remoteLk.Lock()
|
||||
defer sb.remoteLk.Unlock()
|
||||
|
||||
remoteFree := len(sb.remotes)
|
||||
for _, r := range sb.remotes {
|
||||
if r.busy > 0 {
|
||||
remoteFree--
|
||||
}
|
||||
}
|
||||
|
||||
return WorkerStats{
|
||||
LocalFree: cap(sb.rateLimit) - len(sb.rateLimit),
|
||||
LocalReserved: PoStReservedWorkers,
|
||||
LocalTotal: cap(sb.rateLimit) + PoStReservedWorkers,
|
||||
RemotesTotal: len(sb.remotes),
|
||||
RemotesFree: remoteFree,
|
||||
}
|
||||
}
|
||||
|
||||
func addressToProverID(a address.Address) [32]byte {
|
||||
|
@ -76,13 +76,9 @@ func (sm *StorageMinerAPI) remotePutSector(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) WorkerStats(context.Context) (api.WorkerStats, error) {
|
||||
free, reserved, total := sm.SectorBuilder.WorkerStats()
|
||||
return api.WorkerStats{
|
||||
Free: free,
|
||||
Reserved: reserved,
|
||||
Total: total,
|
||||
}, nil
|
||||
func (sm *StorageMinerAPI) WorkerStats(context.Context) (sectorbuilder.WorkerStats, error) {
|
||||
stat := sm.SectorBuilder.WorkerStats()
|
||||
return stat, nil
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) ActorAddress(context.Context) (address.Address, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user