codemode

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeMode

type CodeMode uint8

CodeMode EC encode and decode mode

const (
	EC15P12       CodeMode = 1
	EC6P6         CodeMode = 2
	EC16P20L2     CodeMode = 3
	EC6P10L2      CodeMode = 4
	EC6P3L3       CodeMode = 5
	EC6P6Align0   CodeMode = 6
	EC6P6Align512 CodeMode = 7
	EC4P4L2       CodeMode = 8
	EC12P4        CodeMode = 9
	EC16P4        CodeMode = 10
	EC3P3         CodeMode = 11
	EC10P4        CodeMode = 12
	EC6P3         CodeMode = 13
	EC12P9        CodeMode = 14
	// for test
	EC6P6L9  CodeMode = 200
	EC6P8L10 CodeMode = 201
)

pre-defined mode

func GetAllCodeModes

func GetAllCodeModes() []CodeMode

GetAllCodeModes get all the available CodeModes

func (CodeMode) GetShardNum

func (c CodeMode) GetShardNum() int

GetShardNum returns all shards number.

func (CodeMode) IsValid

func (c CodeMode) IsValid() bool

IsValid check the CodeMode is valid

func (CodeMode) Name

func (c CodeMode) Name() CodeModeName

Name turn the CodeMode to CodeModeName

func (CodeMode) String

func (c CodeMode) String() string

String turn the CodeMode to string

func (CodeMode) T

func (c CodeMode) T() *Tactic

T returns pointer of Tactic, used like: EC6P6.T().AllLocalStripe()

func (CodeMode) Tactic

func (c CodeMode) Tactic() Tactic

Tactic returns its constant tactic

type CodeModeName

type CodeModeName string

func (CodeModeName) GetCodeMode

func (cn CodeModeName) GetCodeMode() CodeMode

GetCodeMode get the code mode by name

func (CodeModeName) IsValid

func (cn CodeModeName) IsValid() bool

IsValid check the CodeMode is valid by Name

func (CodeModeName) Tactic

func (cn CodeModeName) Tactic() Tactic

Tactic get tactic by code mode name

type Policy

type Policy struct {
	ModeName CodeModeName `json:"mode_name"`
	// min size of object, access use this to put object
	MinSize int64 `json:"min_size"`
	// max size of object. access use this to put object
	MaxSize int64 `json:"max_size"`
	// code mode's cluster space size ratio, clusterMgr should use this to create specified num of volume
	SizeRatio float64 `json:"size_ratio"`
	// enable means this kind of code mode enable or not
	// access/allocator will ignore this kind of code mode's allocation when enable is false
	// clustermgr will ignore this kind of code mode's creation when enable is false
	Enable bool `json:"enable"`
}

Policy will be used to adjust code mode's upload range or code mode's volume ratio and so on

type Tactic

type Tactic struct {
	N int
	M int
	// local parity count
	L int
	// the count of AZ, access use this for split data shards and parity shards
	AZCount int

	// PutQuorum write quorum,
	// MUST make sure that ec data is recoverable if one AZ was down
	// We SHOULD ignore the local shards
	// (N + M) / AZCount + N <= PutQuorum <= M + N
	PutQuorum int

	// get quorum config
	GetQuorum int

	// MinShardSize min size per shard, fill data into shards 0-N continuously,
	// align with zero bytes if data size less than MinShardSize*N
	//
	// length of data less than MinShardSize*N, size of per shard = MinShardSize
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//  |  data  |                 align zero bytes                     |
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//  |    0    |    1    |    2    |   ....                |    N    |
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//
	// length of data more than MinShardSize*N, size of per shard = ceil(len(data)/N)
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//  |                           data                        |padding|
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	//  |    0    |    1    |    2    |   ....                |    N    |
	//  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	MinShardSize int
}

Tactic constant strategy of one CodeMode

func (*Tactic) AllLocalStripe

func (c *Tactic) AllLocalStripe() (stripes [][]int, n, m int)

AllLocalStripe returns all local stripes

func (*Tactic) GetECLayoutByAZ

func (c *Tactic) GetECLayoutByAZ() (azStripes [][]int)

GetECLayoutByAZ ec layout by AZ

func (*Tactic) GlobalStripe

func (c *Tactic) GlobalStripe() (indexes []int, n, m int)

GlobalStripe returns initial stripe return name.GetCodeMode().Tactic()

func (*Tactic) IsValid

func (c *Tactic) IsValid() bool

IsValid ec tactic valid or not

func (*Tactic) LocalStripe

func (c *Tactic) LocalStripe(index int) (localStripe []int, n, m int)

LocalStripe get local stripe by index

func (*Tactic) LocalStripeInAZ

func (c *Tactic) LocalStripeInAZ(azIndex int) (localStripe []int, n, m int)

LocalStripeInAZ get local stripe in az index

Jump to

Keyboard shortcuts

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