clustermgr

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: 17 Imported by: 8

Documentation

Index

Constants

View Source
const (
	MemberTypeMin = MemberType(iota)
	MemberTypeLearner
	MemberTypeNormal
	MemberTypeMax
)
View Source
const (
	ConsulRegisterPath         = "ebs/%s/clusters/"
	RaftSnapshotIndexHeaderKey = "Raft-Snapshot-Index"
	RaftSnapshotNameHeaderKey  = "Raft-Snapshot-Name"
)
View Source
const (
	ListServiceUrl = "/service/list"
)

Variables

This section is empty.

Functions

func GetConsulClusterPath

func GetConsulClusterPath(region string) string

Types

type APIAccess

type APIAccess interface {
	GetConfig(ctx context.Context, key string) (string, error)
	GetService(ctx context.Context, args GetServiceArgs) (ServiceInfo, error)
	ListDisk(ctx context.Context, options *ListOptionArgs) (ListDiskRet, error)
}

APIAccess sub of cluster manager api for access

type APIProxy

type APIProxy interface {
	GetConfig(ctx context.Context, key string) (string, error)
	GetVolumeInfo(ctx context.Context, args *GetVolumeArgs) (*VolumeInfo, error)
	DiskInfo(ctx context.Context, id proto.DiskID) (*blobnode.DiskInfo, error)
	AllocVolume(ctx context.Context, args *AllocVolumeArgs) (AllocatedVolumeInfos, error)
	AllocBid(ctx context.Context, args *BidScopeArgs) (*BidScopeRet, error)
	RetainVolume(ctx context.Context, args *RetainVolumeArgs) (RetainVolumes, error)
	RegisterService(ctx context.Context, node ServiceNode, tickInterval, heartbeatTicks, expiresTicks uint32) error
}

APIProxy sub of cluster manager api for allocator

type APIService

type APIService interface {
	GetService(ctx context.Context, args GetServiceArgs) (ServiceInfo, error)
}

APIService sub of cluster manager api for service

type AddMemberArgs

type AddMemberArgs struct {
	PeerID     uint64     `json:"peer_id"`
	Host       string     `json:"host"`
	MemberType MemberType `json:"member_type"`
	NodeHost   string     `json:"node_host"`
}

type AdminUpdateUnitArgs

type AdminUpdateUnitArgs struct {
	Epoch     uint32 `json:"epoch"`
	NextEpoch uint32 `json:"next_epoch"`
	VolumeUnitInfo
}

type AllConfig

type AllConfig struct {
	Configs map[string]string `json:"configs"`
}

type AllocVolumeArgs

type AllocVolumeArgs struct {
	IsInit   bool              `json:"is_init"`
	CodeMode codemode.CodeMode `json:"code_mode"`
	Count    int               `json:"count"`
}

type AllocVolumeInfo

type AllocVolumeInfo struct {
	VolumeInfo
	Token      string `json:"token"`
	ExpireTime int64  `json:"expire_time"`
}

type AllocVolumeUnit

type AllocVolumeUnit struct {
	Vuid   proto.Vuid   `json:"vuid"`
	DiskID proto.DiskID `json:"disk_id"`
}

type AllocVolumeUnitArgs

type AllocVolumeUnitArgs struct {
	Vuid proto.Vuid `json:"vuid"`
}

type AllocatedVolumeInfos

type AllocatedVolumeInfos struct {
	AllocVolumeInfos []AllocVolumeInfo `json:"alloc_volume_infos"`
}

type BidScopeArgs

type BidScopeArgs struct {
	Count uint64 `json:"count"`
}

type BidScopeRet

type BidScopeRet struct {
	StartBid proto.BlobID `json:"start_bid"`
	EndBid   proto.BlobID `json:"end_bid"`
}

type Client

type Client struct {
	rpc.Client
}

func New

func New(cfg *Config) *Client

func (*Client) AddDisk

func (c *Client) AddDisk(ctx context.Context, info *blobnode.DiskInfo) (err error)

AddDisk add/register a new disk into cluster manager

func (*Client) AddMember

func (c *Client) AddMember(ctx context.Context, args *AddMemberArgs) (err error)

AddMember add new member(normal or learner) into raft cluster

func (*Client) AllocBid

func (c *Client) AllocBid(ctx context.Context, args *BidScopeArgs) (ret *BidScopeRet, err error)

BidAlloc return available bid scope

func (*Client) AllocDiskID

func (c *Client) AllocDiskID(ctx context.Context) (proto.DiskID, error)

DiskIDAlloc alloc diskID from cluster manager

func (*Client) AllocVolume

func (c *Client) AllocVolume(ctx context.Context, args *AllocVolumeArgs) (ret AllocatedVolumeInfos, err error)

func (*Client) AllocVolumeUnit

func (c *Client) AllocVolumeUnit(ctx context.Context, args *AllocVolumeUnitArgs) (ret *AllocVolumeUnit, err error)

func (*Client) DeleteConfig

func (c *Client) DeleteConfig(ctx context.Context, key string) (err error)

func (*Client) DeleteKV

func (c *Client) DeleteKV(ctx context.Context, key string) (err error)

func (*Client) DiskInfo

func (c *Client) DiskInfo(ctx context.Context, id proto.DiskID) (ret *blobnode.DiskInfo, err error)

DiskInfo get disk info from cluster manager

func (*Client) DropDisk

func (c *Client) DropDisk(ctx context.Context, id proto.DiskID) (err error)

func (*Client) DroppedDisk

func (c *Client) DroppedDisk(ctx context.Context, id proto.DiskID) (err error)

func (*Client) GetConfig

func (c *Client) GetConfig(ctx context.Context, key string) (ret string, err error)

func (*Client) GetKV

func (c *Client) GetKV(ctx context.Context, key string) (ret GetKvRet, err error)

func (*Client) GetService

func (c *Client) GetService(ctx context.Context, args GetServiceArgs) (info ServiceInfo, err error)

func (*Client) GetVolumeInfo

func (c *Client) GetVolumeInfo(ctx context.Context, args *GetVolumeArgs) (ret *VolumeInfo, err error)

func (*Client) HeartbeatDisk

func (c *Client) HeartbeatDisk(ctx context.Context, infos []*blobnode.DiskHeartBeatInfo) (ret []*DiskHeartbeatRet, err error)

HeartbeatDisk report blobnode disk latest capacity info to cluster manager

func (*Client) ListAllocatedVolumes

func (c *Client) ListAllocatedVolumes(ctx context.Context, args *ListAllocatedVolumeArgs) (ret AllocatedVolumeInfos, err error)

list allocated volume return already allocated allocator's volume

func (*Client) ListDisk

func (c *Client) ListDisk(ctx context.Context, options *ListOptionArgs) (ret ListDiskRet, err error)

ListDisk list disk info from cluster manager when ListOptionArgs is default value, defalut return 10 diskInfos

func (*Client) ListDroppingDisk

func (c *Client) ListDroppingDisk(ctx context.Context) (ret []*blobnode.DiskInfo, err error)

func (*Client) ListHostDisk

func (c *Client) ListHostDisk(ctx context.Context, host string) (ret []*blobnode.DiskInfo, err error)

ListHostDisk list specified host disk info from cluster manager

func (*Client) ListKV

func (c *Client) ListKV(ctx context.Context, args *ListKvOpts) (ret ListKvRet, err error)

func (*Client) ListService

func (c *Client) ListService(ctx context.Context) (info ServiceInfo, err error)

func (*Client) ListVolume

func (c *Client) ListVolume(ctx context.Context, args *ListVolumeArgs) (ret ListVolumes, err error)

func (*Client) ListVolumeUnit

func (c *Client) ListVolumeUnit(ctx context.Context, args *ListVolumeUnitArgs) ([]*VolumeUnitInfo, error)

func (*Client) ListVolumeV2

func (c *Client) ListVolumeV2(ctx context.Context, args *ListVolumeV2Args) (ret ListVolumes, err error)

func (*Client) LockVolume

func (c *Client) LockVolume(ctx context.Context, args *LockVolumeArgs) (err error)

func (*Client) RegisterService

func (c *Client) RegisterService(ctx context.Context, node ServiceNode, tickInterval, heartbeatTicks, expiresTicks uint32) (err error)

Register service node to cm tickInterval: unit of second HeartbeatInterval = heartbeatTicks * tickInterval expires = expiresTicks * tickInterval

func (*Client) ReleaseVolumeUnit

func (c *Client) ReleaseVolumeUnit(ctx context.Context, args *ReleaseVolumeUnitArgs) (err error)

func (*Client) RemoveMember

func (c *Client) RemoveMember(ctx context.Context, peerID uint64) (err error)

RemoveMember remove member from raft cluster

func (*Client) ReportChunk

func (c *Client) ReportChunk(ctx context.Context, args *ReportChunkArgs) (err error)

func (*Client) RetainVolume

func (c *Client) RetainVolume(ctx context.Context, args *RetainVolumeArgs) (ret RetainVolumes, err error)

func (*Client) SetCompactChunk

func (c *Client) SetCompactChunk(ctx context.Context, args *SetCompactChunkArgs) (err error)

func (*Client) SetConfig

func (c *Client) SetConfig(ctx context.Context, args *ConfigSetArgs) (err error)

func (*Client) SetDisk

func (c *Client) SetDisk(ctx context.Context, id proto.DiskID, status proto.DiskStatus) (err error)

SetDisk set disk status

func (*Client) SetKV

func (c *Client) SetKV(ctx context.Context, key string, value []byte) (err error)

func (*Client) SetReadonlyDisk

func (c *Client) SetReadonlyDisk(ctx context.Context, id proto.DiskID, readonly bool) (err error)

func (*Client) Snapshot

func (c *Client) Snapshot(ctx context.Context) (*http.Response, error)

func (*Client) Stat

func (c *Client) Stat(ctx context.Context) (ret *StatInfo, err error)

Stat return cluster's statics info, like space info and raft status and so on

func (*Client) TransferLeadership

func (c *Client) TransferLeadership(ctx context.Context, transfereeID uint64) (err error)

RemoveMember remove member from raft cluster

func (*Client) UnlockVolume

func (c *Client) UnlockVolume(ctx context.Context, args *UnlockVolumeArgs) (err error)

func (*Client) UnregisterService

func (c *Client) UnregisterService(ctx context.Context, args UnregisterArgs) (err error)

func (*Client) UpdateVolume

func (c *Client) UpdateVolume(ctx context.Context, args *UpdateVolumeArgs) (err error)

type ClientAPI

type ClientAPI interface {
	APIAccess
	APIProxy
}

ClientAPI all interface of cluster manager

type ClusterInfo

type ClusterInfo struct {
	Region    string          `json:"region"`
	ClusterID proto.ClusterID `json:"cluster_id"`
	Capacity  int64           `json:"capacity"`
	Available int64           `json:"available"`
	Readonly  bool            `json:"readonly"`
	Nodes     []string        `json:"nodes"`
}

type Config

type Config struct {
	rpc.LbConfig
}

type ConfigArgs

type ConfigArgs struct {
	Key string `json:"key"`
}

type ConfigSetArgs

type ConfigSetArgs struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type DeleteKvArgs

type DeleteKvArgs struct {
	Key string `json:"key"`
}

type DiskAccessArgs

type DiskAccessArgs struct {
	DiskID   proto.DiskID `json:"disk_id"`
	Readonly bool         `json:"readonly"`
}

type DiskHeartbeatRet

type DiskHeartbeatRet struct {
	DiskID   proto.DiskID     `json:"disk_id"`
	Status   proto.DiskStatus `json:"status"`
	ReadOnly bool             `json:"read_only"`
}

type DiskIDAllocRet

type DiskIDAllocRet struct {
	DiskID proto.DiskID `json:"disk_id"`
}

type DiskInfoArgs

type DiskInfoArgs struct {
	DiskID proto.DiskID `json:"disk_id"`
}

type DiskSetArgs

type DiskSetArgs struct {
	DiskID proto.DiskID     `json:"disk_id"`
	Status proto.DiskStatus `json:"status"`
}

type DiskStatInfo

type DiskStatInfo struct {
	IDC            string `json:"idc"`
	Total          int    `json:"total"`
	TotalChunk     int64  `json:"total_chunk"`
	TotalFreeChunk int64  `json:"total_free_chunk"`
	Available      int    `json:"available"`
	Readonly       int    `json:"readonly"`
	Expired        int    `json:"expired"`
	Broken         int    `json:"broken"`
	Repairing      int    `json:"repairing"`
	Repaired       int    `json:"repaired"`
	Dropping       int    `json:"dropping"`
	Dropped        int    `json:"dropped"`
}

type DisksHeartbeatArgs

type DisksHeartbeatArgs struct {
	Disks []*blobnode.DiskHeartBeatInfo `json:"disks"`
}

type DisksHeartbeatRet

type DisksHeartbeatRet struct {
	Disks []*DiskHeartbeatRet `json:"disks"`
}

type GetKvArgs

type GetKvArgs struct {
	Key string `json:"key"`
}

type GetKvRet

type GetKvRet struct {
	Value []byte `json:"value"`
}

type GetServiceArgs

type GetServiceArgs struct {
	Name string `json:"name"`
}

type GetVolumeArgs

type GetVolumeArgs struct {
	Vid proto.Vid `json:"vid"`
}

type HeartbeatArgs

type HeartbeatArgs UnregisterArgs

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value []byte `json:"value"`
}

type ListAllocatedVolumeArgs

type ListAllocatedVolumeArgs struct {
	Host     string            `json:"host"`
	CodeMode codemode.CodeMode `json:"code_mode"`
}

type ListDiskRet

type ListDiskRet struct {
	Disks  []*blobnode.DiskInfo `json:"disks"`
	Marker proto.DiskID         `json:"marker"`
}

type ListKvOpts

type ListKvOpts struct {
	Prefix string `json:"prefix,omitempty"`
	Marker string `json:"marker,omitempty"`
	Count  int    `json:"count,omitempty"`
}

type ListKvRet

type ListKvRet struct {
	Kvs    []*KeyValue `json:"kvs"`
	Marker string      `json:"marker"`
}

type ListOptionArgs

type ListOptionArgs struct {
	Idc    string           `json:"idc,omitempty"`
	Rack   string           `json:"rack,omitempty"`
	Host   string           `json:"host,omitempty"`
	Status proto.DiskStatus `json:"status,omitempty"`
	// list disk info after marker
	Marker proto.DiskID `json:"marker,omitempty"`
	// one page count
	Count int `json:"count,omitempty"`
}

type ListVolumeArgs

type ListVolumeArgs struct {
	// list volume info after Marker marker
	Marker proto.Vid `json:"marker,omitempty"`
	// one page count
	Count int `json:"count"`
}

type ListVolumeUnitArgs

type ListVolumeUnitArgs struct {
	DiskID proto.DiskID `json:"disk_id"`
}

type ListVolumeUnitInfos

type ListVolumeUnitInfos struct {
	VolumeUnitInfos []*VolumeUnitInfo `json:"volume_unit_infos"`
}

type ListVolumeV2Args

type ListVolumeV2Args struct {
	Status proto.VolumeStatus `json:"status"`
}

type ListVolumes

type ListVolumes struct {
	Volumes []*VolumeInfo `json:"volumes"`
	Marker  proto.Vid     `json:"marker"`
}

type LockVolumeArgs

type LockVolumeArgs struct {
	Vid proto.Vid `json:"vid"`
}

type MemberContext

type MemberContext struct {
	NodeHost string `json:"node_host"`
}

func (*MemberContext) Marshal

func (mc *MemberContext) Marshal() ([]byte, error)

func (*MemberContext) Unmarshal

func (mc *MemberContext) Unmarshal(data []byte) error

type MemberType

type MemberType uint8

type RegisterArgs

type RegisterArgs struct {
	ServiceNode
	Timeout int `json:"timeout"`
}

type ReleaseVolumeUnitArgs

type ReleaseVolumeUnitArgs struct {
	Vuid   proto.Vuid   `json:"vuid"`
	DiskID proto.DiskID `json:"disk_id"`
}

type RemoveMemberArgs

type RemoveMemberArgs struct {
	PeerID uint64 `json:"peer_id"`
}

type ReportChunkArgs

type ReportChunkArgs struct {
	ChunkInfos []blobnode.ChunkInfo `json:"chunk_infos"`
}

func (*ReportChunkArgs) Decode

func (r *ReportChunkArgs) Decode(reader io.Reader) error

func (*ReportChunkArgs) Encode

func (r *ReportChunkArgs) Encode() ([]byte, error)

type RetainVolume

type RetainVolume struct {
	Token string `json:"token"`
	// unixTime
	ExpireTime int64 `json:"expire_time"`
}

type RetainVolumeArgs

type RetainVolumeArgs struct {
	Tokens []string `json:"tokens"`
}

type RetainVolumes

type RetainVolumes struct {
	RetainVolTokens []RetainVolume `json:"retain_vol_tokens"`
}

type ServiceInfo

type ServiceInfo struct {
	Nodes []ServiceNode `json:"nodes"`
}

type ServiceNode

type ServiceNode struct {
	ClusterID uint64 `json:"cluster_id"`
	Name      string `json:"name"`
	Host      string `json:"host"`
	Idc       string `json:"idc"`
}

type SetCompactChunkArgs

type SetCompactChunkArgs struct {
	Vuid       proto.Vuid `json:"vuid"`
	Compacting bool       `json:"compact"`
}

type SetKvArgs

type SetKvArgs struct {
	Key   string `json:"key"`
	Value []byte `json:"value"`
}

type SpaceStatInfo

type SpaceStatInfo struct {
	TotalSpace     int64          `json:"total_space"`
	FreeSpace      int64          `json:"free_space"`
	UsedSpace      int64          `json:"used_space"`
	WritableSpace  int64          `json:"writable_space"`
	TotalBlobNode  int64          `json:"total_blob_node"`
	TotalDisk      int64          `json:"total_disk"`
	DisksStatInfos []DiskStatInfo `json:"disk_stat_infos"`
}

type StatInfo

type StatInfo struct {
	LeaderHost string            `json:"leader_host"`
	ReadOnly   bool              `json:"read_only"`
	RaftStatus raftserver.Status `json:"raft_status"`
	SpaceStat  SpaceStatInfo     `json:"space_stat"`
	VolumeStat VolumeStatInfo    `json:"volume_stat"`
}

type Unit

type Unit struct {
	Vuid   proto.Vuid   `json:"vuid"`
	DiskID proto.DiskID `json:"disk_id"`
	Host   string       `json:"host"`
}

type UnlockVolumeArgs

type UnlockVolumeArgs struct {
	Vid proto.Vid `json:"vid"`
}

type UnregisterArgs

type UnregisterArgs struct {
	Name string `json:"name"`
	Host string `json:"host"`
}

type UpdateVolumeArgs

type UpdateVolumeArgs struct {
	NewVuid   proto.Vuid   `json:"new_vuid"`
	NewDiskID proto.DiskID `json:"new_disk_id"`
	OldVuid   proto.Vuid   `json:"old_vuid"`
}

type VolumeInfo

type VolumeInfo struct {
	Units []Unit `json:"units"`
	VolumeInfoBase
}

func (*VolumeInfo) Equal

func (v *VolumeInfo) Equal(expected *VolumeInfo) bool

type VolumeInfoBase

type VolumeInfoBase struct {
	Vid            proto.Vid          `json:"vid"`
	CodeMode       codemode.CodeMode  `json:"code_mode"`
	Status         proto.VolumeStatus `json:"status"`
	HealthScore    int                `json:"health_score"`
	Total          uint64             `json:"total"`
	Free           uint64             `json:"free"`
	Used           uint64             `json:"used"`
	CreateByNodeID uint64             `json:"create_by_node_id"`
}

type VolumeStatInfo

type VolumeStatInfo struct {
	TotalVolume       int `json:"total_volume"`
	IdleVolume        int `json:"idle_volume"`
	AllocatableVolume int `json:"can_alloc_volume"`
	ActiveVolume      int `json:"active_volume"`
	LockVolume        int `json:"lock_volume"`
	UnlockingVolume   int `json:"unlocking_volume"`
}

type VolumeUnitInfo

type VolumeUnitInfo struct {
	Vuid       proto.Vuid   `json:"vuid"`
	DiskID     proto.DiskID `json:"disk_id"`
	Total      uint64       `json:"total"`
	Free       uint64       `json:"free"`
	Used       uint64       `json:"used"`
	Compacting bool         `json:"compact"`
	Host       string       `json:"host"`
}

Jump to

Keyboard shortcuts

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