cluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllocClusterIDPrefix = "ClusterID"
	AllocSchemaIDPrefix  = "SchemaID"
	AllocTableIDPrefix   = "TableID"
)
View Source
const DefaultHeartbeatInterval = time.Second * 3

TODO: heartbeatInterval should be set in config

Variables

View Source
var (
	ErrCreateCluster           = coderr.NewCodeError(coderr.BadRequest, "create clusters")
	ErrClusterAlreadyExists    = coderr.NewCodeError(coderr.Internal, "clusters already exists")
	ErrClusterNotFound         = coderr.NewCodeError(coderr.NotFound, "cluster not found")
	ErrClusterTopologyNotFound = coderr.NewCodeError(coderr.NotFound, "cluster topology not found")
	ErrSchemaNotFound          = coderr.NewCodeError(coderr.NotFound, "schema not found")
	ErrTableNotFound           = coderr.NewCodeError(coderr.NotFound, "Table not found")
	ErrShardNotFound           = coderr.NewCodeError(coderr.NotFound, "shard not found")
	ErrNodeNotFound            = coderr.NewCodeError(coderr.NotFound, "node not found")
	ErrNodeShardsIsEmpty       = coderr.NewCodeError(coderr.Internal, "node's shard list is empty")
	ErrGetShardTopology        = coderr.NewCodeError(coderr.Internal, "get shard topology")
)

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster(meta *clusterpb.Cluster, storage storage.Storage, kv clientv3.KV, hbstream *schedule.HeartbeatStreams, rootPath string, idAllocatorStep uint) *Cluster

func (*Cluster) DropTable

func (c *Cluster) DropTable(ctx context.Context, schemaName, tableName string, tableID uint64) error

func (*Cluster) GetNodes

func (c *Cluster) GetNodes(_ context.Context) (*GetNodesResult, error)

func (*Cluster) GetOrCreateSchema

func (c *Cluster) GetOrCreateSchema(ctx context.Context, schemaName string) (*Schema, error)

func (*Cluster) GetOrCreateTable

func (c *Cluster) GetOrCreateTable(ctx context.Context, nodeName string, schemaName string, tableName string) (*Table, error)

func (*Cluster) GetShardIDs

func (c *Cluster) GetShardIDs(nodeName string) ([]uint32, error)

func (*Cluster) GetTable

func (c *Cluster) GetTable(ctx context.Context, schemaName, tableName string) (*Table, bool, error)

func (*Cluster) GetTables

func (c *Cluster) GetTables(_ context.Context, shardIDs []uint32, nodeName string) (map[uint32]*ShardTablesWithRole, error)

func (*Cluster) Load

func (c *Cluster) Load(ctx context.Context) error

Load data from storage to memory.

func (*Cluster) Name

func (c *Cluster) Name() string

func (*Cluster) RegisterNode

func (c *Cluster) RegisterNode(ctx context.Context, nodeInfo *metaservicepb.NodeInfo) error

func (*Cluster) RouteTables

func (c *Cluster) RouteTables(_ context.Context, schemaName string, tableNames []string) (*RouteTablesResult, error)

type GetNodesResult

type GetNodesResult struct {
	ClusterTopologyVersion uint64
	NodeShards             []*NodeShard
}

type Manager

type Manager interface {
	// Start must be called before manager is used.
	Start(ctx context.Context) error
	// Stop must be called before manager is dropped.
	Stop(ctx context.Context) error

	CreateCluster(ctx context.Context, clusterName string, nodeCount, replicationFactor, shardTotal uint32) (*Cluster, error)
	AllocSchemaID(ctx context.Context, clusterName, schemaName string) (uint32, error)
	AllocTableID(ctx context.Context, clusterName, schemaName, tableName, nodeName string) (*Table, error)
	GetTables(ctx context.Context, clusterName, nodeName string, shardIDs []uint32) (map[uint32]*ShardTables, error)
	DropTable(ctx context.Context, clusterName, schemaName, tableName string, tableID uint64) error
	RegisterNode(ctx context.Context, clusterName string, nodeInfo *metaservicepb.NodeInfo) error
	GetShards(ctx context.Context, clusterName, nodeName string) ([]uint32, error)
	RouteTables(ctx context.Context, clusterName, schemaName string, tableNames []string) (*RouteTablesResult, error)
	GetNodes(ctx context.Context, clusterName string) (*GetNodesResult, error)
}

func NewManagerImpl

func NewManagerImpl(storage storage.Storage, kv clientv3.KV, hbstream *schedule.HeartbeatStreams, rootPath string, idAllocatorStep uint) (Manager, error)

type Node

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

type NodeShard

type NodeShard struct {
	Endpoint  string
	ShardInfo *ShardInfo
}

type RouteEntry

type RouteEntry struct {
	Table      *TableInfo
	NodeShards []*NodeShard
}

type RouteTablesResult

type RouteTablesResult struct {
	Version      uint64
	RouteEntries map[string]*RouteEntry
}

type Schema

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

func (*Schema) GetID

func (s *Schema) GetID() uint32

type Shard

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

type ShardInfo

type ShardInfo struct {
	ShardID   uint32
	ShardRole clusterpb.ShardRole
	Version   uint64
}

type ShardTables

type ShardTables struct {
	ShardRole clusterpb.ShardRole
	Tables    []*TableInfo
	Version   uint64
}

type ShardTablesWithRole

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

type Table

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

func (*Table) GetID

func (t *Table) GetID() uint64

func (*Table) GetName

func (t *Table) GetName() string

func (*Table) GetSchemaID

func (t *Table) GetSchemaID() uint32

func (*Table) GetSchemaName

func (t *Table) GetSchemaName() string

func (*Table) GetShardID

func (t *Table) GetShardID() uint32

type TableInfo

type TableInfo struct {
	ID         uint64
	Name       string
	SchemaID   uint32
	SchemaName string
}

Jump to

Keyboard shortcuts

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