stores

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2020 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const FSOverheadDen = 10
View Source
const MetaFile = "sectorstore.json"

Variables

View Source
var FetchTempSubdir = "fetching"
View Source
var HeartbeatInterval = 10 * time.Second
View Source
var SkippedHeartbeatThresh = HeartbeatInterval * 5

Functions

func ParseSectorID

func ParseSectorID(baseName string) (abi.SectorID, error)

func PathByType

func PathByType(sps SectorPaths, fileType SectorFileType) string

func SectorName

func SectorName(sid abi.SectorID) string

func SetPathByType

func SetPathByType(sps *SectorPaths, fileType SectorFileType, p string)

Types

type AcquireMode

type AcquireMode string
const (
	AcquireMove AcquireMode = "move"
	AcquireCopy AcquireMode = "copy"
)

type Decl

type Decl struct {
	abi.SectorID
	SectorFileType
}

type FetchHandler

type FetchHandler struct {
	*Local
}

func (*FetchHandler) ServeHTTP

func (handler *FetchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HealthReport

type HealthReport struct {
	Stat fsutil.FsStat
	Err  error
}

type ID

type ID string

ID identifies sector storage by UUID. One sector storage should map to one

filesystem, local or networked / shared by multiple machines

type Index

type Index struct {
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex() *Index

func (*Index) FindSector

func (i *Index) FindSector(id abi.SectorID, typ SectorFileType) ([]ID, error)

func (*Index) StorageAttach

func (i *Index) StorageAttach(ctx context.Context, si StorageInfo, st fsutil.FsStat) error

func (*Index) StorageBestAlloc

func (i *Index) StorageBestAlloc(ctx context.Context, allocate SectorFileType, spt abi.RegisteredSealProof, pathType PathType) ([]StorageInfo, error)

func (*Index) StorageDeclareSector

func (i *Index) StorageDeclareSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType, primary bool) error

func (*Index) StorageDropSector

func (i *Index) StorageDropSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType) error

func (*Index) StorageFindSector

func (i *Index) StorageFindSector(ctx context.Context, s abi.SectorID, ft SectorFileType, spt abi.RegisteredSealProof, allowFetch bool) ([]SectorStorageInfo, error)

func (*Index) StorageInfo

func (i *Index) StorageInfo(ctx context.Context, id ID) (StorageInfo, error)

func (*Index) StorageList

func (i *Index) StorageList(ctx context.Context) (map[ID][]Decl, error)

func (Index) StorageLock

func (i Index) StorageLock(ctx context.Context, sector abi.SectorID, read SectorFileType, write SectorFileType) error

func (*Index) StorageReportHealth

func (i *Index) StorageReportHealth(ctx context.Context, id ID, report HealthReport) error

func (Index) StorageTryLock

func (i Index) StorageTryLock(ctx context.Context, sector abi.SectorID, read SectorFileType, write SectorFileType) (bool, error)

type Local

type Local struct {
	// contains filtered or unexported fields
}

func NewLocal

func NewLocal(ctx context.Context, ls LocalStorage, index SectorIndex, urls []string) (*Local, error)

func (*Local) AcquireSector

func (st *Local) AcquireSector(ctx context.Context, sid abi.SectorID, spt abi.RegisteredSealProof, existing SectorFileType, allocate SectorFileType, pathType PathType, op AcquireMode) (SectorPaths, SectorPaths, error)

func (*Local) FsStat

func (st *Local) FsStat(ctx context.Context, id ID) (fsutil.FsStat, error)

func (*Local) Local

func (st *Local) Local(ctx context.Context) ([]StoragePath, error)

func (*Local) MoveStorage

func (st *Local) MoveStorage(ctx context.Context, s abi.SectorID, spt abi.RegisteredSealProof, types SectorFileType) error

func (*Local) OpenPath

func (st *Local) OpenPath(ctx context.Context, p string) error

func (*Local) Remove

func (st *Local) Remove(ctx context.Context, sid abi.SectorID, typ SectorFileType, force bool) error

func (*Local) RemoveCopies

func (st *Local) RemoveCopies(ctx context.Context, sid abi.SectorID, typ SectorFileType) error

func (*Local) Reserve

func (st *Local) Reserve(ctx context.Context, sid abi.SectorID, spt abi.RegisteredSealProof, ft SectorFileType, storageIDs SectorPaths, overheadTab map[SectorFileType]int) (func(), error)

type LocalPath

type LocalPath struct {
	Path string
}

type LocalStorage

type LocalStorage interface {
	GetStorage() (StorageConfig, error)
	SetStorage(func(*StorageConfig)) error

	Stat(path string) (fsutil.FsStat, error)

	// returns real disk usage for a file/directory
	// os.ErrNotExit when file doesn't exist
	DiskUsage(path string) (int64, error)
}

type LocalStorageMeta

type LocalStorageMeta struct {
	ID     ID
	Weight uint64 // 0 = readonly

	CanSeal  bool
	CanStore bool
}

LocalStorageMeta path/sectorstore.json

type PathType

type PathType string
const (
	PathStorage PathType = "storage"
	PathSealing PathType = "sealing"
)

type Remote

type Remote struct {
	// contains filtered or unexported fields
}

func NewRemote

func NewRemote(local *Local, index SectorIndex, auth http.Header, fetchLimit int) *Remote

func (*Remote) AcquireSector

func (r *Remote) AcquireSector(ctx context.Context, s abi.SectorID, spt abi.RegisteredSealProof, existing SectorFileType, allocate SectorFileType, pathType PathType, op AcquireMode) (SectorPaths, SectorPaths, error)

func (*Remote) FsStat

func (r *Remote) FsStat(ctx context.Context, id ID) (fsutil.FsStat, error)

func (*Remote) MoveStorage

func (r *Remote) MoveStorage(ctx context.Context, s abi.SectorID, spt abi.RegisteredSealProof, types SectorFileType) error

func (*Remote) Remove

func (r *Remote) Remove(ctx context.Context, sid abi.SectorID, typ SectorFileType, force bool) error

func (*Remote) RemoveCopies

func (r *Remote) RemoveCopies(ctx context.Context, s abi.SectorID, types SectorFileType) error

type SectorFileType

type SectorFileType int
const (
	FTUnsealed SectorFileType = 1 << iota
	FTSealed
	FTCache

	FileTypes = iota
)
const (
	FTNone SectorFileType = 0
)

func (SectorFileType) All

func (t SectorFileType) All() [FileTypes]bool

func (SectorFileType) Has

func (t SectorFileType) Has(singleType SectorFileType) bool

func (SectorFileType) SealSpaceUse

func (t SectorFileType) SealSpaceUse(spt abi.RegisteredSealProof) (uint64, error)

func (SectorFileType) String

func (t SectorFileType) String() string

type SectorIndex

type SectorIndex interface {
	StorageAttach(context.Context, StorageInfo, fsutil.FsStat) error
	StorageInfo(context.Context, ID) (StorageInfo, error)
	StorageReportHealth(context.Context, ID, HealthReport) error

	StorageDeclareSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType, primary bool) error
	StorageDropSector(ctx context.Context, storageID ID, s abi.SectorID, ft SectorFileType) error
	StorageFindSector(ctx context.Context, sector abi.SectorID, ft SectorFileType, spt abi.RegisteredSealProof, allowFetch bool) ([]SectorStorageInfo, error)

	StorageBestAlloc(ctx context.Context, allocate SectorFileType, spt abi.RegisteredSealProof, pathType PathType) ([]StorageInfo, error)

	// atomically acquire locks on all sector file types. close ctx to unlock
	StorageLock(ctx context.Context, sector abi.SectorID, read SectorFileType, write SectorFileType) error
	StorageTryLock(ctx context.Context, sector abi.SectorID, read SectorFileType, write SectorFileType) (bool, error)
}

type SectorPaths

type SectorPaths struct {
	ID abi.SectorID

	Unsealed string
	Sealed   string
	Cache    string
}

type SectorStorageInfo

type SectorStorageInfo struct {
	ID     ID
	URLs   []string // TODO: Support non-http transports
	Weight uint64

	CanSeal  bool
	CanStore bool

	Primary bool
}

type StorageConfig

type StorageConfig struct {
	StoragePaths []LocalPath
}

StorageConfig .lotusstorage/storage.json

type StorageInfo

type StorageInfo struct {
	ID     ID
	URLs   []string // TODO: Support non-http transports
	Weight uint64

	CanSeal  bool
	CanStore bool
}

type StoragePath

type StoragePath struct {
	ID     ID
	Weight uint64

	LocalPath string

	CanSeal  bool
	CanStore bool
}

type Store

type Store interface {
	AcquireSector(ctx context.Context, s abi.SectorID, spt abi.RegisteredSealProof, existing SectorFileType, allocate SectorFileType, sealing PathType, op AcquireMode) (paths SectorPaths, stores SectorPaths, err error)
	Remove(ctx context.Context, s abi.SectorID, types SectorFileType, force bool) error

	// like remove, but doesn't remove the primary sector copy, nor the last
	// non-primary copy if there no primary copies
	RemoveCopies(ctx context.Context, s abi.SectorID, types SectorFileType) error

	// move sectors into storage
	MoveStorage(ctx context.Context, s abi.SectorID, spt abi.RegisteredSealProof, types SectorFileType) error

	FsStat(ctx context.Context, id ID) (fsutil.FsStat, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL