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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FLAG_ENABLE_WARMUP Enable warmup.
	FLAG_ENABLE_WARMUP = 0x0001

	// FLAG_ENABLE_REPLICA Enable replication.
	FLAG_ENABLE_REPLICA = 0x0010
	// FLAG_WARMUP_REPLICA Replication will be triggered on warming up.
	FLAG_WARMUP_REPLICA = 0x0020

	// FLAG_ENABLE_PERSISTENT Enable persist.
	FLAG_ENABLE_PERSISTENT = 0x0100
	// FLAG_DISABLE_RECOVERY Disable recovery on reclaimation.
	FLAG_DISABLE_RECOVERY = 0x0200

	// FLAG_BACKING_ONLY Disable recovery for main repository
	FLAG_BACKING_ONLY = 0x1000
	// FLAG_DISABLE_WAIT_FOR_COS Disable waiting for COS on PUT chunks.
	FLAG_DISABLE_WAIT_FOR_COS = 0x2000

	// PONG_FOR_DATA Pong for data link
	PONG_FOR_DATA = int64(0x0000)
	// PONG_FOR_CTRL Pong for ctrl link
	PONG_FOR_CTRL = int64(0x0001)

	// PONG_ON_INVOKING Pong issued on invoking
	PONG_ON_INVOKING = int64(0x0010)
	// PONG_RECOVERY Pong with parallel recovery requested
	PONG_RECOVERY = int64(0x0020)
	// PONG_RECLAIMED Pong with claiming the node has experienced reclaimation (backing mode only).
	PONG_RECLAIMED = int64(0x0040)
	// PONG_WITH_PAYLOAD Pong with piggyback payload.
	PONG_WITH_PAYLOAD = int64(0x0080)

	// PONG_RECONCILE Pong with reconcile meta included.
	PONG_RECONCILE = int64(0x0100)

	CMD_TEST           = "test"
	CMD_ACK            = "ack"            // Control command
	CMD_GET            = "get"            // Redis and Lambda command
	CMD_GET_CHUNK      = "get chunk"      // Client command
	CMD_SET            = "set"            // Redis and Lambda command
	CMD_SET_CHUNK      = "set chunk"      // Client command
	CMD_PERSISTED      = "persisted"      // Control command
	CMD_PERSIST_FAILED = "persist failed" // Control command
	CMD_RECOVER        = "recover"        // Control command
	CMD_DEL            = "del"            // Control command
	CMD_WARMUP         = "warmup"         // Control command
	CMD_PING           = "ping"           // Control command
	CMD_PONG           = "pong"           // Control command
	CMD_RECOVERED      = "recovered"      // Control command
	CMD_INITMIGRATE    = "initMigrate"    // Control command
	CMD_MIGRATE        = "migrate"        // Control command
	CMD_MHELLO         = "mhello"         // Control command
	CMD_DATA           = "data"           // Control command
	CMD_BYE            = "bye"            // Control command

	REQUEST_GET_OPTIONAL      = 0x0001 // Flag response is optional. There is a compete fallback will eventually fulfill the request.
	REQUEST_GET_OPTION_BUFFER = 0x0002 // Flag the chunk should be put in buffer area.

	// TIP_BACKUP_KEY Backup ID.
	TIP_BACKUP_KEY = "bak"
	// TIP_BACKUP_TOTAL Total backups available.
	TIP_BACKUP_TOTAL = "baks"
	// TIP_DELEGATE_KEY Delegate ID.
	TIP_DELEGATE_KEY = "dele"
	// TIP_DELEGATE_TOTAL Total delegates available.
	TIP_DELEGATE_TOTAL = "deles"
	// TIP_SERVING_KEY Key should be recovered as the first one.
	TIP_SERVING_KEY = "key"
	// TIP_MAX_CHUNK Max chunk size can be backed up.
	TIP_MAX_CHUNK = "max"
)

Variables

View Source
var (
	HeaderTimeout     = 1 * time.Second
	MinBodyTimeout    = 1 * time.Second
	BandwidthFactor   = int64(100) // ns/B. 1/bandwidth, while bandwidth = 10MB/s = 100ns/B for single connection.
	BodyTimeoutFactor = int64(10)
	PersistTimeout    = 10 * time.Second
)

Functions

func GetBodyDeadline

func GetBodyDeadline(size int64) time.Time

func GetBodyTimeout

func GetBodyTimeout(size int64) time.Duration

func GetDeadline

func GetDeadline(d time.Duration) time.Time

func GetHeaderDeadline

func GetHeaderDeadline() time.Time

func GetHeaderTimeout

func GetHeaderTimeout() time.Duration

Types

type BackupLocator

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

Backups for a instace. If not specified, all operation are not thread safe.

func (*BackupLocator) Locate

func (b *BackupLocator) Locate(key string) (int, int, bool)

func (*BackupLocator) LocateByHash

func (b *BackupLocator) LocateByHash(hash uint64) (int, int, bool)

func (*BackupLocator) Reset

func (b *BackupLocator) Reset(num int)

type Contextable

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

func (*Contextable) Context

func (r *Contextable) Context() context.Context

Context returns the context

func (*Contextable) SetContext

func (r *Contextable) SetContext(ctx context.Context)

SetContext sets the context

type InputEvent

type InputEvent struct {
	Sid       string   `json:"sid"`   // Session id to ensure invoking once only.
	Cmd       string   `json:"cmd"`   // Invocation type, can be "ping", "warmup".
	Id        uint64   `json:"id"`    // Node id
	Proxy     string   `json:"proxy"` // Address of proxy .
	ProxyAddr net.Addr // Address of proxy, for simulation.
	Addr      string   `json:"addr"`   // Address of P2P relay.
	Prefix    string   `json:"prefix"` // Experiment id reserved for evaluation.
	Log       int      `json:"log"`    // Log level - debug or not.
	Flags     uint64   `json:"flags"`  // Feature flags
	Backups   int      `json:"baks"`   // Number of configured recovery nodes
	Status    Status   `json:"status"` // Lineage info
}

InputEvent Input for the Lambda

func (*InputEvent) IsBackingOnly

func (i *InputEvent) IsBackingOnly() bool

func (*InputEvent) IsPersistencyEnabled

func (i *InputEvent) IsPersistencyEnabled() bool

func (*InputEvent) IsRecoveryEnabled

func (i *InputEvent) IsRecoveryEnabled() bool

func (*InputEvent) IsReplicaEnabled

func (i *InputEvent) IsReplicaEnabled() bool

func (*InputEvent) IsWaitForCOSDisabled

func (i *InputEvent) IsWaitForCOSDisabled() bool

type Meta

type Meta struct {
	// Lambda ID
	Id uint64 `json:"id"`

	// Sequence of the last confirmed log. Logs store by sequence.
	Term uint64 `json:"term"`

	// Total transmission size for restoring all confirmed logs.
	Updates uint64 `json:"updates"`

	// Rank for lambda to decide if a fast recovery is required.
	DiffRank float64 `json:"diffrank"`

	// Hash of the last confirmed log.
	Hash string `json:"hash"`

	// Sequence of snapshot.
	SnapshotTerm uint64 `json:"snapshot"`

	// Total transmission size for restoring all confirmed logs from start to SnapShotSeq.
	SnapshotUpdates uint64 `json:"snapshotupdates"`

	// Total size of snapshot for transmission.
	SnapshotSize uint64 `json:"snapshotsize"`

	// Tips offer the lambda clues of how to recovery data. It is in http query format.
	Tip string `json:"tip"`
}

type OutputError

type OutputError struct {
	Message string `json:"errorMessage"`
	Type    string `json:"errorType"`
}

func (*OutputError) String

func (e *OutputError) String() string

type ShortMeta

type ShortMeta struct {
	// Lambda ID
	Id uint64 `json:"id"`

	// Sequence of the last confirmed log. Logs store by sequence.
	Term uint64 `json:"term"`

	// Total transmission size for restoring all confirmed logs.
	Updates uint64 `json:"updates"`

	// Rank for lambda to decide if a fast recovery is required.
	DiffRank float64 `json:"diffrank"`

	// Hash of the last confirmed log.
	Hash string `json:"hash"`
}

type Status

type Status struct {
	Capacity  uint64 `json:"cap"`
	Mem       uint64 `json:"mem"`
	Effective uint64 `json:"effe"`
	Modified  uint64 `json:"modi"`
	Metas     []Meta `json:"metas"`
}

Jump to

Keyboard shortcuts

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