client

package
v3.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ShardStatusNotExist shard not exist code
	ShardStatusNotExist = 100
)

Variables

View Source
var (
	LeaderOutdatedErr       = errors.New("leader outdated")
	SuidNotMemberOfShardErr = errors.New("suid not member of shard")
)

Functions

func NopdataSize

func NopdataSize(size int)

Types

type BlobNodeClient

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

BlobNodeClient blobnode client

func (*BlobNodeClient) GetShard

func (c *BlobNodeClient) GetShard(ctx context.Context, location proto.VunitLocation, bid proto.BlobID, ioType api.IOType) (body io.ReadCloser, crc32 uint32, err error)

GetShard returns shard data

func (*BlobNodeClient) GetShards

func (c *BlobNodeClient) GetShards(ctx context.Context, location proto.VunitLocation, bids []api.BidInfo, ioType api.IOType) (getter api.ShardGetter, err error)

GetShards get batch shards

func (*BlobNodeClient) ListShards

func (c *BlobNodeClient) ListShards(ctx context.Context, location proto.VunitLocation) (sis []*ShardInfo, err error)

ListShards return shards info

func (*BlobNodeClient) PutShard

func (c *BlobNodeClient) PutShard(ctx context.Context,
	location proto.VunitLocation, bid proto.BlobID, size int64, data []byte, ioType api.IOType,
) (err error)

PutShard put data to shard

func (*BlobNodeClient) StatChunk

func (c *BlobNodeClient) StatChunk(ctx context.Context, location proto.VunitLocation) (ci *ChunkInfo, err error)

StatChunk returns chunk stat

func (*BlobNodeClient) StatShard

func (c *BlobNodeClient) StatShard(ctx context.Context, location proto.VunitLocation, bid proto.BlobID, ioType api.IOType) (si *ShardInfo, err error)

StatShard return shard stat

type ChunkInfo

type ChunkInfo struct {
	clustermgr.ChunkInfo
}

ChunkInfo chunk info

func (*ChunkInfo) Locked

func (c *ChunkInfo) Locked() bool

Locked return true if chunk is locked

type Config

type Config struct {
	api.Config
	BatchReadTimeoutMs int64 `json:"batch_read_timeout_ms"`
}

type IBlobNode

type IBlobNode interface {
	StatChunk(ctx context.Context, location proto.VunitLocation) (ci *ChunkInfo, err error)
	StatShard(ctx context.Context, location proto.VunitLocation, bid proto.BlobID, ioType api.IOType) (si *ShardInfo, err error)
	ListShards(ctx context.Context, location proto.VunitLocation) (shards []*ShardInfo, err error)
	GetShard(ctx context.Context, location proto.VunitLocation, bid proto.BlobID, ioType api.IOType) (body io.ReadCloser, crc32 uint32, err error)
	GetShards(ctx context.Context, location proto.VunitLocation, bids []api.BidInfo, ioType api.IOType) (getter api.ShardGetter, err error)
	PutShard(ctx context.Context, location proto.VunitLocation, bid proto.BlobID, size int64, data []byte, ioType api.IOType) (err error)
}

IBlobNode define the interface of blobnode used for worker

func NewBlobNodeClient

func NewBlobNodeClient(conf *Config) IBlobNode

NewBlobNodeClient returns blobnode client

type IShardNode

type IShardNode interface {
	UpdateShard(ctx context.Context, args *UpdateShardArgs) error
	GetShardStatus(ctx context.Context, suid proto.Suid, leader proto.ShardUnitInfoSimple) (*ShardStatusRet, error)
	LeaderTransfer(ctx context.Context, args *LeaderTransferArgs) error
	GetShardLeader(ctx context.Context, leader proto.ShardUnitInfoSimple) (*proto.ShardUnitInfoSimple, error)
}

IShardNode ShardNode client

func NewShardNodeClient

func NewShardNodeClient(cfg shardnode.Config) IShardNode

type LeaderTransferArgs

type LeaderTransferArgs struct {
	DiskID proto.DiskID              `json:"disk_id"`
	Leader proto.ShardUnitInfoSimple `json:"leader"`
}

type ShardInfo

type ShardInfo struct {
	api.ShardInfo
}

ShardInfo shard info

func (*ShardInfo) MarkDeleted

func (si *ShardInfo) MarkDeleted() bool

MarkDeleted return true if shard is mark delete

func (*ShardInfo) Normal

func (si *ShardInfo) Normal() bool

Normal return true if shard is normal

func (*ShardInfo) NotExist

func (si *ShardInfo) NotExist() bool

NotExist returns true if shard is not exist

type ShardNodeClient

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

func (*ShardNodeClient) GetShardLeader

func (*ShardNodeClient) GetShardStatus

func (c *ShardNodeClient) GetShardStatus(ctx context.Context, suid proto.Suid, leader proto.ShardUnitInfoSimple) (*ShardStatusRet, error)

func (*ShardNodeClient) LeaderTransfer

func (c *ShardNodeClient) LeaderTransfer(ctx context.Context, args *LeaderTransferArgs) error

func (*ShardNodeClient) UpdateShard

func (c *ShardNodeClient) UpdateShard(ctx context.Context, args *UpdateShardArgs) error

type ShardStatusRet

type ShardStatusRet struct {
	Suid               proto.Suid                `json:"suid"`
	DiskID             proto.DiskID              `json:"disk_id"`
	Leader             proto.ShardUnitInfoSimple `json:"leader"`        // leader
	AppliedIndex       uint64                    `json:"applied_index"` // applied index of new add node
	LeaderAppliedIndex uint64                    `json:"leader_index"`  // applied index of leader
}

type UpdateShardArgs

type UpdateShardArgs struct {
	Unit    proto.ShardUnitInfoSimple `json:"unit"`
	Type    proto.ShardUpdateType     `json:"type"`
	Leader  proto.ShardUnitInfoSimple `json:"leader"`
	Learner bool                      `json:"learner"`
}

Jump to

Keyboard shortcuts

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