Documentation ¶
Index ¶
- Constants
- Variables
- type Command
- type Event
- type EventType
- type FailoverTask
- type MigrationTask
- type Storage
- func (s *Storage) AddFailOverHistory(ctx context.Context, task *FailoverTask) error
- func (s *Storage) AddMigrateHistory(ctx context.Context, task *MigrationTask) error
- func (s *Storage) AddMigratingTask(ctx context.Context, task *MigrationTask) error
- func (s *Storage) AddShardSlots(ctx context.Context, ns, cluster string, shardIdx int, ...) error
- func (s *Storage) Close() error
- func (s *Storage) ClusterNodesCounts(ctx context.Context, ns, cluster string) (int, error)
- func (s *Storage) CreateCluster(ctx context.Context, ns string, clusterInfo *metadata.Cluster) error
- func (s *Storage) CreateNamespace(ctx context.Context, ns string) error
- func (s *Storage) CreateNode(ctx context.Context, ns, cluster string, shardIdx int, node *metadata.NodeInfo) error
- func (s *Storage) CreateShard(ctx context.Context, ns, cluster string, shard *metadata.Shard) error
- func (s *Storage) EmitEvent(event Event)
- func (s *Storage) GetClusterInfo(ctx context.Context, ns, cluster string) (*metadata.Cluster, error)
- func (s *Storage) GetFailOverHistory(ctx context.Context, ns, cluster string) ([]*FailoverTask, error)
- func (s *Storage) GetFailOverTask(ctx context.Context, ns, cluster string) (*FailoverTask, error)
- func (s *Storage) GetMasterNode(ctx context.Context, ns, cluster string, shardIdx int) (metadata.NodeInfo, error)
- func (s *Storage) GetMigrateHistory(ctx context.Context, ns, cluster string) ([]*MigrationTask, error)
- func (s *Storage) GetMigratingTask(ctx context.Context, ns, cluster string) (*MigrationTask, error)
- func (s *Storage) GetShard(ctx context.Context, ns, cluster string, shardIdx int) (*metadata.Shard, error)
- func (s *Storage) HasSlot(ctx context.Context, ns, cluster string, shardIdx, slot int) (bool, error)
- func (s *Storage) IsClusterExists(ctx context.Context, ns, cluster string) (bool, error)
- func (s *Storage) IsLeader() bool
- func (s *Storage) IsMigrateHistoryExists(ctx context.Context, task *MigrationTask) (bool, error)
- func (s *Storage) IsNamespaceExists(ctx context.Context, ns string) (bool, error)
- func (s *Storage) IsReady() bool
- func (s *Storage) Leader() string
- func (s *Storage) LeaderChange() <-chan bool
- func (s *Storage) ListCluster(ctx context.Context, ns string) ([]string, error)
- func (s *Storage) ListNamespace(ctx context.Context) ([]string, error)
- func (s *Storage) ListNodes(ctx context.Context, ns, cluster string, shardIdx int) ([]metadata.NodeInfo, error)
- func (s *Storage) ListShard(ctx context.Context, ns, cluster string) ([]metadata.Shard, error)
- func (s *Storage) Load(ctx context.Context) error
- func (s *Storage) Notify() <-chan Event
- func (s *Storage) PromoteNewMaster(ctx context.Context, ns, cluster string, shardIdx int, oldMasterNodeID string) error
- func (s *Storage) RemoveCluster(ctx context.Context, ns, cluster string) error
- func (s *Storage) RemoveMigratingTask(ctx context.Context, ns, cluster string) error
- func (s *Storage) RemoveNamespace(ctx context.Context, ns string) error
- func (s *Storage) RemoveNode(ctx context.Context, ns, cluster string, shardIdx int, nodeID string) error
- func (s *Storage) RemoveShard(ctx context.Context, ns, cluster string, shardIdx int) error
- func (s *Storage) RemoveShardSlots(ctx context.Context, ns, cluster string, shardIdx int, ...) error
- func (s *Storage) Stop() error
- func (s *Storage) UpdateCluster(ctx context.Context, ns string, clusterInfo *metadata.Cluster) error
- func (s *Storage) UpdateFailOverTask(ctx context.Context, task *FailoverTask) error
- func (s *Storage) UpdateMigrateSlotInfo(ctx context.Context, ns, cluster string, sourceIdx, targetIdx int, ...) error
- func (s *Storage) UpdateNode(ctx context.Context, ns, cluster string, shardIdx int, node *metadata.NodeInfo) error
Constants ¶
const ( CommandCreate = iota + 1 CommandRemove CommandUpdate CommandAddSlots CommandRemoveSlots CommandMigrateSlots )
const MetadataPrefix = "/kvrocks/metadata"
Variables ¶
var (
ErrNoLeaderOrNotReady = errors.New("the current node role isn't leader or the state is NOT ready")
)
Functions ¶
This section is empty.
Types ¶
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) ClusterNodesCounts ¶
func (*Storage) CreateCluster ¶
func (*Storage) CreateNamespace ¶
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 ¶
CreateShard add a shard under the specified cluster
func (*Storage) GetClusterInfo ¶
func (*Storage) GetFailOverHistory ¶
func (*Storage) GetFailOverTask ¶
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 (*Storage) GetMigratingTask ¶ added in v0.2.0
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 (*Storage) IsMigrateHistoryExists ¶
func (*Storage) IsNamespaceExists ¶
IsNamespaceExists return an indicator whether the specified namespace exists
func (*Storage) LeaderChange ¶
func (*Storage) ListCluster ¶
ListCluster return the list of name of cluster under the specified namespace
func (*Storage) ListNamespace ¶
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) 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 (*Storage) RemoveMigratingTask ¶ added in v0.2.0
func (*Storage) RemoveNamespace ¶
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 ¶
RemoveShard delete the shard under the specified cluster
func (*Storage) RemoveShardSlots ¶
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