storage

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterStateEmpty ClusterState = iota + 1
	ClusterStateStable
	ClusterStatePrepare

	TopologyTypeUnknown = "unknown"
	TopologyTypeStatic  = "static"
	TopologyTypeDynamic = "dynamic"
)

Variables

View Source
var (
	ErrEncode = coderr.NewCodeError(coderr.Internal, "storage encode")
	ErrDecode = coderr.NewCodeError(coderr.Internal, "storage decode")

	ErrCreateSchemaAgain         = coderr.NewCodeError(coderr.Internal, "storage create schemas")
	ErrCreateClusterAgain        = coderr.NewCodeError(coderr.Internal, "storage create cluster")
	ErrUpdateCluster             = coderr.NewCodeError(coderr.Internal, "storage update cluster")
	ErrCreateClusterViewAgain    = coderr.NewCodeError(coderr.Internal, "storage create cluster view")
	ErrUpdateClusterViewConflict = coderr.NewCodeError(coderr.Internal, "storage update cluster view")
	ErrCreateTableAgain          = coderr.NewCodeError(coderr.Internal, "storage create tables")
	ErrDeleteTableAgain          = coderr.NewCodeError(coderr.Internal, "storage delete table")
	ErrCreateShardViewAgain      = coderr.NewCodeError(coderr.Internal, "storage create shard view")
	ErrUpdateShardViewConflict   = coderr.NewCodeError(coderr.Internal, "storage update shard view")
)

Functions

func ConvertShardRoleToPB added in v1.0.0

func ConvertShardRoleToPB(role ShardRole) clusterpb.ShardRole

func ConvertShardStatusToPB added in v1.2.5

func ConvertShardStatusToPB(status ShardStatus) metaservicepb.ShardInfo_Status

func ConvertShardStatusToString added in v1.2.7

func ConvertShardStatusToString(status ShardStatus) string

Types

type Cluster added in v1.0.0

type Cluster struct {
	ID           ClusterID
	Name         string
	MinNodeCount uint32
	// Deprecated: ReplicationFactor is deprecated after CeresMeta v1.2.0
	ReplicationFactor           uint32
	ShardTotal                  uint32
	EnableSchedule              bool
	TopologyType                TopologyType
	ProcedureExecutingBatchSize uint32
	CreatedAt                   uint64
	ModifiedAt                  uint64
}

type ClusterID added in v1.0.0

type ClusterID uint32

type ClusterState added in v1.0.0

type ClusterState int

type ClusterView added in v1.0.0

type ClusterView struct {
	ClusterID  ClusterID
	Version    uint64
	State      ClusterState
	ShardNodes []ShardNode
	CreatedAt  uint64
}

func NewClusterView added in v1.2.0

func NewClusterView(clusterID ClusterID, version uint64, state ClusterState, shardNodes []ShardNode) ClusterView

type CreateClusterRequest added in v1.0.0

type CreateClusterRequest struct {
	Cluster Cluster
}

type CreateClusterViewRequest added in v1.0.0

type CreateClusterViewRequest struct {
	ClusterView ClusterView
}

type CreateOrUpdateNodeRequest added in v1.0.0

type CreateOrUpdateNodeRequest struct {
	ClusterID ClusterID
	Node      Node
}

type CreateSchemaRequest added in v1.0.0

type CreateSchemaRequest struct {
	ClusterID ClusterID
	Schema    Schema
}

type CreateShardViewsRequest added in v1.0.0

type CreateShardViewsRequest struct {
	ClusterID  ClusterID
	ShardViews []ShardView
}

type CreateTableRequest added in v1.0.0

type CreateTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	Table     Table
}

type DeleteTableRequest added in v1.0.0

type DeleteTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	TableName string
}

type GetClusterViewRequest added in v1.0.0

type GetClusterViewRequest struct {
	ClusterID ClusterID
}

type GetClusterViewResult added in v1.0.0

type GetClusterViewResult struct {
	ClusterView ClusterView
}

type GetTableRequest added in v1.0.0

type GetTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	TableName string
}

type GetTableResult added in v1.0.0

type GetTableResult struct {
	Table  Table
	Exists bool
}

type ListClustersResult added in v1.0.0

type ListClustersResult struct {
	Clusters []Cluster
}

type ListNodesRequest added in v1.0.0

type ListNodesRequest struct {
	ClusterID ClusterID
}

type ListNodesResult added in v1.0.0

type ListNodesResult struct {
	Nodes []Node
}

type ListSchemasRequest added in v1.0.0

type ListSchemasRequest struct {
	ClusterID ClusterID
}

type ListSchemasResult added in v1.0.0

type ListSchemasResult struct {
	Schemas []Schema
}

type ListShardViewsRequest added in v1.0.0

type ListShardViewsRequest struct {
	ClusterID ClusterID
	ShardIDs  []ShardID
}

type ListShardViewsResult added in v1.0.0

type ListShardViewsResult struct {
	ShardViews []ShardView
}

type ListTableRequest added in v1.0.0

type ListTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
}

type ListTablesResult added in v1.0.0

type ListTablesResult struct {
	Tables []Table
}

type Node added in v1.0.0

type Node struct {
	Name          string
	NodeStats     NodeStats
	LastTouchTime uint64
	State         NodeState
}

type NodeState added in v1.0.0

type NodeState int
const (
	NodeStateOnline NodeState = iota + 1
	NodeStateOffline
)

type NodeStats added in v1.0.0

type NodeStats struct {
	Lease       uint32
	Zone        string
	NodeVersion string
}

type Options

type Options struct {
	// MaxScanLimit is the max limit of the number of keys in a scan.
	MaxScanLimit int
	// MinScanLimit is the min limit of the number of keys in a scan.
	MinScanLimit int
}

type PartitionInfo added in v1.0.0

type PartitionInfo struct {
	Info *clusterpb.PartitionInfo `json:"info,omitempty"`
}

type Schema added in v1.0.0

type Schema struct {
	ID        SchemaID
	ClusterID ClusterID
	Name      string
	CreatedAt uint64
}

type SchemaID added in v1.0.0

type SchemaID uint32

type ShardID added in v1.0.0

type ShardID uint32

type ShardNode added in v1.0.0

type ShardNode struct {
	ID        ShardID
	ShardRole ShardRole
	NodeName  string
}

type ShardRole added in v1.0.0

type ShardRole int
const (
	ShardRoleLeader ShardRole = iota + 1
	ShardRoleFollower
)

func ConvertShardRolePB added in v1.0.0

func ConvertShardRolePB(role clusterpb.ShardRole) ShardRole

type ShardStatus added in v1.2.5

type ShardStatus int
const (
	ShardStatusReady ShardStatus = iota + 1
	ShardStatusPartialOpen
)

func ConvertShardStatusPB added in v1.2.5

func ConvertShardStatusPB(status *metaservicepb.ShardInfo_Status) ShardStatus

type ShardView added in v1.0.0

type ShardView struct {
	ShardID   ShardID
	Version   uint64
	TableIDs  []TableID
	CreatedAt uint64
}

func NewShardView added in v1.2.0

func NewShardView(shardID ShardID, version uint64, tableIDs []TableID) ShardView

type Storage

type Storage interface {
	// GetCluster get cluster metadata by clusterID.
	GetCluster(ctx context.Context, clusterID ClusterID) (Cluster, error)
	// ListClusters list all clusters.
	ListClusters(ctx context.Context) (ListClustersResult, error)
	// CreateCluster create new cluster, return error if cluster already exists.
	CreateCluster(ctx context.Context, req CreateClusterRequest) error
	// UpdateCluster update cluster metadata.
	UpdateCluster(ctx context.Context, req UpdateClusterRequest) error

	// CreateClusterView create cluster view.
	CreateClusterView(ctx context.Context, req CreateClusterViewRequest) error
	// GetClusterView get cluster view by cluster id.
	GetClusterView(ctx context.Context, req GetClusterViewRequest) (GetClusterViewResult, error)
	// UpdateClusterView update cluster view.
	UpdateClusterView(ctx context.Context, req UpdateClusterViewRequest) error

	// ListSchemas list all schemas in specified cluster.
	ListSchemas(ctx context.Context, req ListSchemasRequest) (ListSchemasResult, error)
	// CreateSchema create schema in specified cluster.
	CreateSchema(ctx context.Context, req CreateSchemaRequest) error

	// CreateTable create new table in specified cluster and schema, return error if table already exists.
	CreateTable(ctx context.Context, req CreateTableRequest) error
	// GetTable get table by table name in specified cluster and schema.
	GetTable(ctx context.Context, req GetTableRequest) (GetTableResult, error)
	// ListTables list all tables in specified cluster and schema.
	ListTables(ctx context.Context, req ListTableRequest) (ListTablesResult, error)
	// DeleteTable delete table by table name in specified cluster and schema.
	DeleteTable(ctx context.Context, req DeleteTableRequest) error

	// CreateShardViews create shard views in specified cluster.
	CreateShardViews(ctx context.Context, req CreateShardViewsRequest) error
	// ListShardViews list all shard views in specified cluster.
	ListShardViews(ctx context.Context, req ListShardViewsRequest) (ListShardViewsResult, error)
	// UpdateShardView update shard views in specified cluster.
	UpdateShardView(ctx context.Context, req UpdateShardViewRequest) error

	// ListNodes list all nodes in specified cluster.
	ListNodes(ctx context.Context, req ListNodesRequest) (ListNodesResult, error)
	// CreateOrUpdateNode create or update node in specified cluster.
	CreateOrUpdateNode(ctx context.Context, req CreateOrUpdateNodeRequest) error
}

Storage defines the storage operations on the ceresdb cluster meta info.

func NewStorageWithEtcdBackend

func NewStorageWithEtcdBackend(client *clientv3.Client, rootPath string, opts Options) Storage

NewStorageWithEtcdBackend creates a new storage with etcd backend.

type Table added in v1.0.0

type Table struct {
	ID            TableID
	Name          string
	SchemaID      SchemaID
	CreatedAt     uint64
	PartitionInfo PartitionInfo
}

func (Table) IsPartitioned added in v1.0.0

func (t Table) IsPartitioned() bool

type TableID added in v1.0.0

type TableID uint64

type TopologyType added in v1.2.1

type TopologyType string

type UpdateClusterRequest added in v1.2.1

type UpdateClusterRequest struct {
	Cluster Cluster
}

type UpdateClusterViewRequest added in v1.0.0

type UpdateClusterViewRequest struct {
	ClusterID     ClusterID
	ClusterView   ClusterView
	LatestVersion uint64
}

type UpdateShardViewRequest added in v1.0.0

type UpdateShardViewRequest struct {
	ClusterID     ClusterID
	ShardView     ShardView
	LatestVersion uint64
}

Jump to

Keyboard shortcuts

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