Merge pull request #18 from filecoin-project/feat/no-ffi-workerinfo
Move WorkerInfo to not require importing ffi
This commit is contained in:
commit
9404c859cb
@ -15,6 +15,7 @@ import (
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/sector-storage/sealtasks"
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
"github.com/filecoin-project/sector-storage/storiface"
|
||||
)
|
||||
|
||||
var pathTypes = []stores.SectorFileType{stores.FTUnsealed, stores.FTSealed, stores.FTCache}
|
||||
@ -167,7 +168,7 @@ func (l *LocalWorker) Paths(ctx context.Context) ([]stores.StoragePath, error) {
|
||||
return l.localStore.Local(ctx)
|
||||
}
|
||||
|
||||
func (l *LocalWorker) Info(context.Context) (WorkerInfo, error) {
|
||||
func (l *LocalWorker) Info(context.Context) (storiface.WorkerInfo, error) {
|
||||
hostname, err := os.Hostname() // TODO: allow overriding from config
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -180,17 +181,17 @@ func (l *LocalWorker) Info(context.Context) (WorkerInfo, error) {
|
||||
|
||||
h, err := sysinfo.Host()
|
||||
if err != nil {
|
||||
return WorkerInfo{}, xerrors.Errorf("getting host info: %w", err)
|
||||
return storiface.WorkerInfo{}, xerrors.Errorf("getting host info: %w", err)
|
||||
}
|
||||
|
||||
mem, err := h.Memory()
|
||||
if err != nil {
|
||||
return WorkerInfo{}, xerrors.Errorf("getting memory info: %w", err)
|
||||
return storiface.WorkerInfo{}, xerrors.Errorf("getting memory info: %w", err)
|
||||
}
|
||||
|
||||
return WorkerInfo{
|
||||
return storiface.WorkerInfo{
|
||||
Hostname: hostname,
|
||||
Resources: WorkerResources{
|
||||
Resources: storiface.WorkerResources{
|
||||
MemPhysical: mem.Total,
|
||||
MemSwap: mem.VirtualTotal,
|
||||
MemReserved: mem.VirtualUsed + mem.Total - mem.Available, // TODO: sub this process
|
||||
|
18
manager.go
18
manager.go
@ -19,6 +19,7 @@ import (
|
||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||
"github.com/filecoin-project/sector-storage/sealtasks"
|
||||
"github.com/filecoin-project/sector-storage/stores"
|
||||
"github.com/filecoin-project/sector-storage/storiface"
|
||||
)
|
||||
|
||||
var log = logging.Logger("advmgr")
|
||||
@ -35,26 +36,11 @@ type Worker interface {
|
||||
// Returns paths accessible to the worker
|
||||
Paths(context.Context) ([]stores.StoragePath, error)
|
||||
|
||||
Info(context.Context) (WorkerInfo, error)
|
||||
Info(context.Context) (storiface.WorkerInfo, error)
|
||||
|
||||
Close() error
|
||||
}
|
||||
|
||||
type WorkerInfo struct {
|
||||
Hostname string
|
||||
|
||||
Resources WorkerResources
|
||||
}
|
||||
|
||||
type WorkerResources struct {
|
||||
MemPhysical uint64
|
||||
MemSwap uint64
|
||||
|
||||
MemReserved uint64 // Used by system / other processes
|
||||
|
||||
GPUs []string
|
||||
}
|
||||
|
||||
type SectorManager interface {
|
||||
SectorSize() abi.SectorSize
|
||||
|
||||
|
3
sched.go
3
sched.go
@ -6,6 +6,7 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
|
||||
"github.com/filecoin-project/sector-storage/sealtasks"
|
||||
"github.com/filecoin-project/sector-storage/storiface"
|
||||
)
|
||||
|
||||
const mib = 1 << 20
|
||||
@ -39,7 +40,7 @@ func (r *workerRequest) respond(resp workerResponse) {
|
||||
type workerHandle struct {
|
||||
w Worker
|
||||
|
||||
info WorkerInfo
|
||||
info storiface.WorkerInfo
|
||||
|
||||
memUsedMin uint64
|
||||
memUsedMax uint64
|
||||
|
15
stats.go
15
stats.go
@ -1,22 +1,15 @@
|
||||
package sectorstorage
|
||||
|
||||
type WorkerStats struct {
|
||||
Info WorkerInfo
|
||||
import "github.com/filecoin-project/sector-storage/storiface"
|
||||
|
||||
MemUsedMin uint64
|
||||
MemUsedMax uint64
|
||||
GpuUsed bool
|
||||
CpuUse int
|
||||
}
|
||||
|
||||
func (m *Manager) WorkerStats() map[uint64]WorkerStats {
|
||||
func (m *Manager) WorkerStats() map[uint64]storiface.WorkerStats {
|
||||
m.workersLk.Lock()
|
||||
defer m.workersLk.Unlock()
|
||||
|
||||
out := map[uint64]WorkerStats{}
|
||||
out := map[uint64]storiface.WorkerStats{}
|
||||
|
||||
for id, handle := range m.workers {
|
||||
out[uint64(id)] = WorkerStats{
|
||||
out[uint64(id)] = storiface.WorkerStats{
|
||||
Info: handle.info,
|
||||
MemUsedMin: handle.memUsedMin,
|
||||
MemUsedMax: handle.memUsedMax,
|
||||
|
25
storiface/worker.go
Normal file
25
storiface/worker.go
Normal file
@ -0,0 +1,25 @@
|
||||
package storiface
|
||||
|
||||
type WorkerInfo struct {
|
||||
Hostname string
|
||||
|
||||
Resources WorkerResources
|
||||
}
|
||||
|
||||
type WorkerResources struct {
|
||||
MemPhysical uint64
|
||||
MemSwap uint64
|
||||
|
||||
MemReserved uint64 // Used by system / other processes
|
||||
|
||||
GPUs []string
|
||||
}
|
||||
|
||||
type WorkerStats struct {
|
||||
Info WorkerInfo
|
||||
|
||||
MemUsedMin uint64
|
||||
MemUsedMax uint64
|
||||
GpuUsed bool
|
||||
CpuUse int
|
||||
}
|
Loading…
Reference in New Issue
Block a user