Help us shape the future of Go! Take the 2026 Go Developer Survey

types

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OP_SET       = 0
	OP_GET       = 1
	OP_DEL       = 2
	OP_RECOVER   = 3
	OP_WARMUP    = 90
	OP_MIGRATION = 91
	OP_RECOVERY  = 92 // Recover repository
	OP_COMMIT    = 93 // Commit lineage

	CHUNK_AVAILABLE  = 0
	CHUNK_DELETED    = 1
	CHUNK_RECOVERING = 2
	CHUNK_INCOMPLETE = 3

	CHUNK_TOBEBUFFERED = -1
)

Variables

View Source
var (
	// Provided by amazon.
	AWSRegion           = os.Getenv("AWS_REGION")
	UploadConcurrency   = 5
	DownloadConcurrency = 10
	// AWSDummyTimeout     = 10 * time.Millisecond
	AWSServiceTimeout = 10000 * time.Millisecond
)
View Source
var (
	ErrProxyClosing = errors.New("proxy closed")
	ErrNotFound     = errors.New("key not found")
	ErrDeleted      = errors.New("key deleted")
	ErrIncomplete   = errors.New("key incomplete")
)

Functions

func AWSSession

func AWSSession() *awsSession.Session

Types

type CalibratePriority

type CalibratePriority int

type Chunk

type Chunk struct {
	Key  string
	Id   string // Obsoleted, chunk id of the object
	Body []byte
	Size uint64
	Term uint64 // Lineage term of last write operation.
	// Status of the chunk, can be one of CHUNK_AVAILABLE, CHUNK_DELETED, or CHUNK_RECOVERING
	// CHUNK_RECOVERING is only used for ensure atomicity, check Available to ensure recovery status.
	Status    uint32
	Available uint64         // Bytes available now. Used for recovering
	Notifier  sync.WaitGroup // See benchmarks in github.com/ds2-lab/infinistore/common/sync
	Accessed  time.Time
	Bucket    string
	Backup    bool
	BuffIdx   int    // Index in buffer queue
	Note      string // Reason for the status.
}

For storage

func NewChunk

func NewChunk(key string, id string, body []byte) *Chunk

func (*Chunk) Access

func (c *Chunk) Access() []byte

func (*Chunk) AddRecovered

func (c *Chunk) AddRecovered(bytes uint64) bool

AddRecovered tracks recovery progress.

func (*Chunk) Delete

func (c *Chunk) Delete(reason string)

func (*Chunk) EndRecover

func (c *Chunk) EndRecover(status uint32)

NotifyRecovered notified concurrent requests that recovery has ended, success or not.

func (*Chunk) IsAvailable

func (c *Chunk) IsAvailable() bool

func (*Chunk) IsBuffered

func (c *Chunk) IsBuffered(includeTBD bool) bool

func (*Chunk) IsDeleted

func (c *Chunk) IsDeleted() bool

func (*Chunk) IsIncomplete

func (c *Chunk) IsIncomplete() bool

func (*Chunk) IsRecovering

func (c *Chunk) IsRecovering() bool

func (*Chunk) NotifyRecovered

func (c *Chunk) NotifyRecovered()

NotifyRecovered notified concurrent requests that recovery has ended, success or not.

func (*Chunk) Op

func (c *Chunk) Op() uint32

func (*Chunk) PrepareRecover

func (c *Chunk) PrepareRecover() bool

PrepareRecover initiate chunk for recovery. Return true if chunk is ready for wait.

func (*Chunk) StartRecover

func (c *Chunk) StartRecover()

StartRecover reset states of the winning chunk, so it is ready to start recovery

func (*Chunk) WaitRecovered

func (c *Chunk) WaitRecovered()

type CommitOption

type CommitOption struct {
	Full               bool
	Snapshotted        bool
	BytesUploaded      uint64
	Checked            bool
	StorageSignalFlags uint32
}

func (*CommitOption) Flags

func (opts *CommitOption) Flags() uint32

type Lineage

type Lineage interface {
	// Validate validates the lineage, it will call the IsConsistent to check if the lineage is consistent.
	Validate(*LineageMeta) (LineageValidationResult, error)

	// IsConsistent checks if the lineage is consistent.
	IsConsistent(*LineageMeta) (bool, error)

	// ClearBackup clears the backup data.
	ClearBackup()

	// Commit commits the lineage to the COS.
	Commit() (*CommitOption, error)

	// Recover recovers data from the COS by the given lineage.
	Recover(*LineageMeta) (bool, <-chan error)

	// Status returns the status of the lineage.
	// Parameter short: returns simplified status if passes true.
	Status(bool) (confirmed uint64, status LineageStatus)
}

type LineageMeta

type LineageMeta struct {
	*protocol.Meta
	Consistent   bool
	Type         LineageMetaType
	BackupId     int
	BackupTotal  int
	MaxChunkSize uint64
	Tips         url.Values
}

func LineageMetaFromProtocol

func LineageMetaFromProtocol(meta *protocol.Meta) (lm *LineageMeta, err error)

func (*LineageMeta) ServingKey

func (meta *LineageMeta) ServingKey() string

type LineageMetaType

type LineageMetaType int
const (
	LineageMetaTypeMain LineageMetaType = iota
	LineageMetaTypeBackup
	LineageMetaTypeDelegate
)

func (LineageMetaType) String

func (t LineageMetaType) String() string

type LineageOp

type LineageOp struct {
	Op       uint32 // Operation, can be "OP_SET" or "OP_DEL"
	Key      string // Key of the object
	Id       string // Chunk id of the object
	Size     uint64 // Size of the object
	Accessed time.Time
	Bucket   string
	BIdx     int // Index in bufferQueue
}

type LineageStatus

type LineageStatus []*protocol.Meta

func (LineageStatus) ProtocolStatus

func (s LineageStatus) ProtocolStatus() protocol.Status

func (LineageStatus) ShortStatus

func (s LineageStatus) ShortStatus() *protocol.ShortMeta

type LineageTerm

type LineageTerm struct {
	Size uint64      // Storage footprint of storing current term.
	Ops  []LineageOp // Operations of the term.

	// Fields below will be serialized.
	Term     uint64  // Term id, increase on write operation.
	Updates  uint64  // Storage footprint of storing all terms of lineage so far.
	RawOps   []byte  // Serialized "Ops"
	Hash     string  // Hash value for the term.
	DiffRank float64 // For snapshot only, this is supposed to be a moving value.
	Buffered int     // For snapshot only, number of buffered objects.
}

func LineageTermFromMeta

func LineageTermFromMeta(meta *LineageMeta) *LineageTerm

type LineageValidationResult

type LineageValidationResult int
const (
	LineageValidationInconsistent LineageValidationResult = iota
	LineageValidationConsistent
	LineageValidationConsistentWithHistoryTerm
)

func LineageValidationResultFromConsistent

func LineageValidationResultFromConsistent(consistent bool) LineageValidationResult

func (LineageValidationResult) IsConsistent

func (ret LineageValidationResult) IsConsistent() bool

type Loggable

type Loggable interface {
	ConfigLogger(int, bool)
}

type OpRet

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

func OpDelayedSuccess

func OpDelayedSuccess() *OpRet

func OpError

func OpError(err error) *OpRet

func OpErrorWithMessage

func OpErrorWithMessage(err error, msg string) *OpRet

func OpSuccess

func OpSuccess() *OpRet

func (*OpRet) Done

func (ret *OpRet) Done(err ...error)

Conclude OpRet. Noted error is evaluated before notifing "delayed" channel, so no lock is required for IsDone or Wait.

func (*OpRet) Error

func (ret *OpRet) Error() error

func (*OpRet) IsDelayed

func (ret *OpRet) IsDelayed() bool

func (*OpRet) IsDone

func (ret *OpRet) IsDone() bool

func (*OpRet) Message

func (ret *OpRet) Message() string

func (*OpRet) Wait

func (ret *OpRet) Wait() error

Behavior like the Promise in javascript. Allow blocking wait or return last result if delayed is closed.

type OpWrapper

type OpWrapper struct {
	LineageOp
	*OpRet
	Body      []byte // For safety of persistence of the SET operation in the case like DEL after SET.
	Chunk     *Chunk
	OpIdx     int
	Persisted bool // Indicate the operation has been persisted.
	Accessed  bool // Indicate the access time should not be changed.
	Sized     bool // Indicate the size of storage has been updated.
}

type PersistentStorage

type PersistentStorage interface {
	Storage

	ConfigS3(string, string)
	SetRecovery(string, string, uint64, int) *OpRet
	StartTracker()
	StopTracker() error
}

type ServerStats

type ServerStats interface {
	RTT() time.Duration
}

type Storage

type Storage interface {
	Id() uint64
	Get(string) (string, []byte, *OpRet)
	GetStream(string) (string, resp.AllReadCloser, *OpRet)
	Set(string, string, []byte) *OpRet
	SetStream(string, string, resp.AllReadCloser) *OpRet
	Del(string, string) *OpRet
	Len() int
	Keys() <-chan string
	Meta() StorageMeta
}

type StorageMeta

type StorageMeta interface {
	// Capacity is physical memory allowed.
	Capacity() uint64

	// System is real memory used.
	System() uint64

	// Waterline is max memory used.
	Waterline() uint64

	// Effectetive is dynamic capacity calculated.
	Effective() uint64

	// Reserved is reserved capacity configured.
	Reserved() uint64

	// Size is the size stored.
	Size() uint64

	// Calibrate adjusts capacity after each invocation.
	Calibrate()
}

Jump to

Keyboard shortcuts

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