storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandCreate = iota + 1
	CommandRemove
	CommandUpdate
	CommandAddSlots
	CommandRemoveSlots
	CommandMigrateSlots
)
View Source
const MetadataPrefix = "/kvrocks/metadata"

Variables

View Source
var (
	ErrNoLeaderOrNotReady = errors.New("the current node role isn't leader or the state is NOT ready")
)

Functions

This section is empty.

Types

type Command

type Command int

type Event

type Event struct {
	Namespace string
	Cluster   string
	Shard     int
	NodeID    string
	Type      EventType
	Command   Command
	Data      interface{}
}

type EventType

type EventType int
const (
	EventNamespace EventType = iota + 1
	EventCluster
	EventShard
	EventNode
)

type FailoverTask added in v0.2.0

type FailoverTask struct {
	Namespace  string            `json:"namespace"`
	Cluster    string            `json:"cluster"`
	ShardIdx   int               `json:"shard_idx"`
	Node       metadata.NodeInfo `json:"node"`
	Type       int               `json:"type"`
	ProbeCount int               `json:"probe_count"`

	QueuedTime int64 `json:"pending_time"`
	StartTime  int64 `json:"start_time"`
	FinishTime int64 `json:"finish_time"`

	Status int    `json:"status"`
	Err    string `json:"error"`
}

type MigrationTask

type MigrationTask struct {
	Namespace  string             `json:"namespace"`
	Cluster    string             `json:"cluster"`
	TaskID     string             `json:"task_id"`
	Source     int                `json:"source"`
	SourceNode *metadata.NodeInfo `json:"source_node"`
	Target     int                `json:"target"`
	TargetNode *metadata.NodeInfo `json:"target_node"`
	Slot       int                `json:"slot"`

	StartTime  int64 `json:"start_time"`
	FinishTime int64 `json:"finish_time"`

	Status      int    `json:"status"`
	ErrorDetail string `json:"error_detail"`
}

type Storage

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

func NewStorage

func NewStorage(persist persistence.Persistence) (*Storage, error)

func (*Storage) AddFailOverHistory

func (s *Storage) AddFailOverHistory(ctx context.Context, task *FailoverTask) error

func (*Storage) AddMigrateHistory

func (s *Storage) AddMigrateHistory(ctx context.Context, task *MigrationTask) error

func (*Storage) AddMigratingTask added in v0.2.0

func (s *Storage) AddMigratingTask(ctx context.Context, task *MigrationTask) error

func (*Storage) AddShardSlots

func (s *Storage) AddShardSlots(ctx context.Context, ns, cluster string, shardIdx int, slotRanges []metadata.SlotRange) error

AddShardSlots add slotRanges to the specified shard under the specified cluster

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) ClusterNodesCounts

func (s *Storage) ClusterNodesCounts(ctx context.Context, ns, cluster string) (int, error)

func (*Storage) CreateCluster

func (s *Storage) CreateCluster(ctx context.Context, ns string, clusterInfo *metadata.Cluster) error

func (*Storage) CreateNamespace

func (s *Storage) CreateNamespace(ctx context.Context, ns string) error

CreateNamespace will create a namespace for clusters

func (*Storage) CreateNode

func (s *Storage) CreateNode(ctx context.Context, ns, cluster string, shardIdx int, node *metadata.NodeInfo) error

CreateNode add a node under the specified shard

func (*Storage) CreateShard

func (s *Storage) CreateShard(ctx context.Context, ns, cluster string, shard *metadata.Shard) error

CreateShard add a shard under the specified cluster

func (*Storage) EmitEvent

func (s *Storage) EmitEvent(event Event)

func (*Storage) GetClusterInfo

func (s *Storage) GetClusterInfo(ctx context.Context, ns, cluster string) (*metadata.Cluster, error)

func (*Storage) GetFailOverHistory

func (s *Storage) GetFailOverHistory(ctx context.Context, ns, cluster string) ([]*FailoverTask, error)

func (*Storage) GetFailOverTask

func (s *Storage) GetFailOverTask(ctx context.Context, ns, cluster string) (*FailoverTask, error)

func (*Storage) GetMasterNode

func (s *Storage) GetMasterNode(ctx context.Context, ns, cluster string, shardIdx int) (metadata.NodeInfo, error)

GetMasterNode return the master of node under the specified shard

func (*Storage) GetMigrateHistory

func (s *Storage) GetMigrateHistory(ctx context.Context, ns, cluster string) ([]*MigrationTask, error)

func (*Storage) GetMigratingTask added in v0.2.0

func (s *Storage) GetMigratingTask(ctx context.Context, ns, cluster string) (*MigrationTask, error)

func (*Storage) GetShard

func (s *Storage) GetShard(ctx context.Context, ns, cluster string, shardIdx int) (*metadata.Shard, error)

func (*Storage) HasSlot

func (s *Storage) HasSlot(ctx context.Context, ns, cluster string, shardIdx, slot int) (bool, error)

HasSlot return an indicator whether the slot under the specified Shard

func (*Storage) IsClusterExists

func (s *Storage) IsClusterExists(ctx context.Context, ns, cluster string) (bool, error)

func (*Storage) IsLeader

func (s *Storage) IsLeader() bool

func (*Storage) IsMigrateHistoryExists

func (s *Storage) IsMigrateHistoryExists(ctx context.Context, task *MigrationTask) (bool, error)

func (*Storage) IsNamespaceExists

func (s *Storage) IsNamespaceExists(ctx context.Context, ns string) (bool, error)

IsNamespaceExists return an indicator whether the specified namespace exists

func (*Storage) IsReady

func (s *Storage) IsReady() bool

func (*Storage) Leader

func (s *Storage) Leader() string

func (*Storage) LeaderChange

func (s *Storage) LeaderChange() <-chan bool

func (*Storage) ListCluster

func (s *Storage) ListCluster(ctx context.Context, ns string) ([]string, error)

ListCluster return the list of name of cluster under the specified namespace

func (*Storage) ListNamespace

func (s *Storage) ListNamespace(ctx context.Context) ([]string, error)

ListNamespace return the list of name of all namespaces

func (*Storage) ListNodes

func (s *Storage) ListNodes(ctx context.Context, ns, cluster string, shardIdx int) ([]metadata.NodeInfo, error)

ListNodes return the list of nodes under the specified shard

func (*Storage) ListShard

func (s *Storage) ListShard(ctx context.Context, ns, cluster string) ([]metadata.Shard, error)

func (*Storage) Load

func (s *Storage) Load(ctx context.Context) error

func (*Storage) Notify

func (s *Storage) Notify() <-chan Event

func (*Storage) PromoteNewMaster

func (s *Storage) PromoteNewMaster(ctx context.Context, ns, cluster string, shardIdx int, oldMasterNodeID string) error

PromoteNewMaster delete the master node from the specified shard

func (*Storage) RemoveCluster

func (s *Storage) RemoveCluster(ctx context.Context, ns, cluster string) error

func (*Storage) RemoveMigratingTask added in v0.2.0

func (s *Storage) RemoveMigratingTask(ctx context.Context, ns, cluster string) error

func (*Storage) RemoveNamespace

func (s *Storage) RemoveNamespace(ctx context.Context, ns string) error

RemoveNamespace delete the specified namespace from storage

func (*Storage) RemoveNode

func (s *Storage) RemoveNode(ctx context.Context, ns, cluster string, shardIdx int, nodeID string) error

RemoveNode delete the node from the specified shard

func (*Storage) RemoveShard

func (s *Storage) RemoveShard(ctx context.Context, ns, cluster string, shardIdx int) error

RemoveShard delete the shard under the specified cluster

func (*Storage) RemoveShardSlots

func (s *Storage) RemoveShardSlots(ctx context.Context, ns, cluster string, shardIdx int, slotRanges []metadata.SlotRange) error

func (*Storage) Stop

func (s *Storage) Stop() error

func (*Storage) UpdateCluster

func (s *Storage) UpdateCluster(ctx context.Context, ns string, clusterInfo *metadata.Cluster) error

UpdateCluster update the Name to storage under the specified namespace

func (*Storage) UpdateFailOverTask

func (s *Storage) UpdateFailOverTask(ctx context.Context, task *FailoverTask) error

func (*Storage) UpdateMigrateSlotInfo

func (s *Storage) UpdateMigrateSlotInfo(ctx context.Context, ns,
	cluster string, sourceIdx, targetIdx int, slotRanges []metadata.SlotRange) error

func (*Storage) UpdateNode

func (s *Storage) UpdateNode(ctx context.Context, ns, cluster string, shardIdx int, node *metadata.NodeInfo) error

UpdateNode update exists node under the specified shard

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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