Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertShardsInfoToPB(shard ShardInfo) *metaservicepb.ShardInfo
- func ConvertTableInfoToPB(table TableInfo) *metaservicepb.TableInfo
- func ParseTopologyType(rawString string) (storage.TopologyType, error)
- type CloseTableRequest
- type ClusterMetadata
- func (c *ClusterMetadata) AddTableTopology(ctx context.Context, shardID storage.ShardID, table storage.Table) (CreateTableResult, error)
- func (c *ClusterMetadata) AllocShardID(ctx context.Context) (uint32, error)
- func (c *ClusterMetadata) CreateShardViews(ctx context.Context, views []CreateShardView) error
- func (c *ClusterMetadata) CreateTable(ctx context.Context, request CreateTableRequest) (CreateTableResult, error)
- func (c *ClusterMetadata) CreateTableMetadata(ctx context.Context, request CreateTableMetadataRequest) (CreateTableMetadataResult, error)
- func (c *ClusterMetadata) DropShardNode(ctx context.Context, shardNodes []storage.ShardNode) error
- func (c *ClusterMetadata) DropTable(ctx context.Context, schemaName, tableName string) (DropTableResult, error)
- func (c *ClusterMetadata) DropTableMetadata(ctx context.Context, schemaName, tableName string) (DropTableMetadataResult, error)
- func (c *ClusterMetadata) GetClusterID() storage.ClusterID
- func (c *ClusterMetadata) GetClusterMinNodeCount() uint32
- func (c *ClusterMetadata) GetClusterSnapshot() Snapshot
- func (c *ClusterMetadata) GetClusterState() storage.ClusterState
- func (c *ClusterMetadata) GetClusterView() storage.ClusterView
- func (c *ClusterMetadata) GetClusterViewVersion() uint64
- func (c *ClusterMetadata) GetCreateTime() uint64
- func (c *ClusterMetadata) GetEnableSchedule() bool
- func (c *ClusterMetadata) GetNodeShards(_ context.Context) (GetNodeShardsResult, error)
- func (c *ClusterMetadata) GetOrCreateSchema(ctx context.Context, schemaName string) (storage.Schema, bool, error)
- func (c *ClusterMetadata) GetProcedureExecutingBatchSize() uint32
- func (c *ClusterMetadata) GetRegisteredNodeByName(nodeName string) (RegisteredNode, bool)
- func (c *ClusterMetadata) GetRegisteredNodes() []RegisteredNode
- func (c *ClusterMetadata) GetShardNodeByTableIDs(tableIDs []storage.TableID) (GetShardNodesByTableIDsResult, error)
- func (c *ClusterMetadata) GetShardNodesByShardID(id storage.ShardID) ([]storage.ShardNode, error)
- func (c *ClusterMetadata) GetShardTables(shardIDs []storage.ShardID) map[storage.ShardID]ShardTables
- func (c *ClusterMetadata) GetStorageMetadata() storage.Cluster
- func (c *ClusterMetadata) GetTable(schemaName, tableName string) (storage.Table, bool, error)
- func (c *ClusterMetadata) GetTopologyType() storage.TopologyType
- func (c *ClusterMetadata) GetTotalShardNum() uint32
- func (c *ClusterMetadata) Init(ctx context.Context) error
- func (c *ClusterMetadata) Load(ctx context.Context) error
- func (c *ClusterMetadata) LoadMetadata(ctx context.Context) error
- func (c *ClusterMetadata) MigrateTable(ctx context.Context, request MigrateTableRequest) error
- func (c *ClusterMetadata) Name() string
- func (c *ClusterMetadata) RegisterNode(ctx context.Context, registeredNode RegisteredNode) error
- func (c *ClusterMetadata) RouteTables(_ context.Context, schemaName string, tableNames []string) (RouteTablesResult, error)
- func (c *ClusterMetadata) UpdateClusterView(ctx context.Context, state storage.ClusterState, ...) error
- func (c *ClusterMetadata) UpdateClusterViewByNode(ctx context.Context, shardNodes map[string][]storage.ShardNode) error
- type CreateClusterOpts
- type CreateShardView
- type CreateTableMetadataRequest
- type CreateTableMetadataResult
- type CreateTableRequest
- type CreateTableResult
- type DropTableMetadataResult
- type DropTableResult
- type GetNodeShardsResult
- type GetShardNodesByTableIDsResult
- type GetShardNodesResult
- type GetShardTablesByNodeResult
- type MigrateTableRequest
- type OpenTableRequest
- type RegisteredNode
- type RouteEntry
- type RouteTablesResult
- type ShardInfo
- type ShardNodeWithVersion
- type ShardTableIDs
- type ShardTables
- type ShardVersionUpdate
- type Snapshot
- type TableInfo
- type TableManager
- type TableManagerImpl
- func (m *TableManagerImpl) CreateTable(ctx context.Context, schemaName string, tableName string, ...) (storage.Table, error)
- func (m *TableManagerImpl) DropTable(ctx context.Context, schemaName string, tableName string) error
- func (m *TableManagerImpl) GetOrCreateSchema(ctx context.Context, schemaName string) (storage.Schema, bool, error)
- func (m *TableManagerImpl) GetSchemaByName(schemaName string) (storage.Schema, bool)
- func (m *TableManagerImpl) GetSchemas() []storage.Schema
- func (m *TableManagerImpl) GetTable(schemaName, tableName string) (storage.Table, bool, error)
- func (m *TableManagerImpl) GetTablesByIDs(tableIDs []storage.TableID) []storage.Table
- func (m *TableManagerImpl) Load(ctx context.Context) error
- type Tables
- type Topology
- type TopologyManager
- type TopologyManagerImpl
- func (m *TopologyManagerImpl) AddTable(ctx context.Context, shardID storage.ShardID, tables []storage.Table) (ShardVersionUpdate, error)
- func (m *TopologyManagerImpl) CreateShardViews(ctx context.Context, createShardViews []CreateShardView) error
- func (m *TopologyManagerImpl) DropShardNodes(ctx context.Context, shardNodes []storage.ShardNode) error
- func (m *TopologyManagerImpl) EvictTable(ctx context.Context, tableID storage.TableID) ([]ShardVersionUpdate, error)
- func (m *TopologyManagerImpl) GetClusterState() storage.ClusterState
- func (m *TopologyManagerImpl) GetClusterView() storage.ClusterView
- func (m *TopologyManagerImpl) GetShardNodes() GetShardNodesResult
- func (m *TopologyManagerImpl) GetShardNodesByID(shardID storage.ShardID) ([]storage.ShardNode, error)
- func (m *TopologyManagerImpl) GetShardNodesByTableIDs(tableIDs []storage.TableID) (GetShardNodesByTableIDsResult, error)
- func (m *TopologyManagerImpl) GetTableIDs(shardIDs []storage.ShardID) map[storage.ShardID]ShardTableIDs
- func (m *TopologyManagerImpl) GetTopology() Topology
- func (m *TopologyManagerImpl) GetVersion() uint64
- func (m *TopologyManagerImpl) InitClusterView(ctx context.Context) error
- func (m *TopologyManagerImpl) Load(ctx context.Context) error
- func (m *TopologyManagerImpl) RemoveTable(ctx context.Context, shardID storage.ShardID, tableIDs []storage.TableID) (ShardVersionUpdate, error)
- func (m *TopologyManagerImpl) UpdateClusterView(ctx context.Context, state storage.ClusterState, ...) error
- func (m *TopologyManagerImpl) UpdateClusterViewByNode(ctx context.Context, shardNodes map[string][]storage.ShardNode) error
- type UpdateClusterOpts
Constants ¶
const ( AllocSchemaIDPrefix = "SchemaID" AllocTableIDPrefix = "TableID" )
const ( MinShardID = 0 HeartbeatKeepAliveIntervalSec uint64 = 15 )
Variables ¶
var ( ErrCreateCluster = coderr.NewCodeError(coderr.BadRequest, "create cluster") ErrUpdateCluster = coderr.NewCodeError(coderr.Internal, "update cluster") ErrStartCluster = coderr.NewCodeError(coderr.Internal, "start cluster") ErrClusterAlreadyExists = coderr.NewCodeError(coderr.ClusterAlreadyExists, "cluster already exists") ErrClusterNotFound = coderr.NewCodeError(coderr.NotFound, "cluster not found") ErrClusterStateInvalid = coderr.NewCodeError(coderr.Internal, "cluster state invalid") 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, "NodeName not found") ErrTableAlreadyExists = coderr.NewCodeError(coderr.Internal, "table already exists") ErrOpenTable = coderr.NewCodeError(coderr.Internal, "open table") ErrParseTopologyType = coderr.NewCodeError(coderr.Internal, "parse topology type") )
Functions ¶
func ConvertShardsInfoToPB ¶
func ConvertShardsInfoToPB(shard ShardInfo) *metaservicepb.ShardInfo
func ConvertTableInfoToPB ¶
func ConvertTableInfoToPB(table TableInfo) *metaservicepb.TableInfo
func ParseTopologyType ¶
func ParseTopologyType(rawString string) (storage.TopologyType, error)
Types ¶
type CloseTableRequest ¶
type ClusterMetadata ¶
type ClusterMetadata struct {
// contains filtered or unexported fields
}
func NewClusterMetadata ¶
func (*ClusterMetadata) AddTableTopology ¶
func (c *ClusterMetadata) AddTableTopology(ctx context.Context, shardID storage.ShardID, table storage.Table) (CreateTableResult, error)
func (*ClusterMetadata) AllocShardID ¶
func (c *ClusterMetadata) AllocShardID(ctx context.Context) (uint32, error)
func (*ClusterMetadata) CreateShardViews ¶
func (c *ClusterMetadata) CreateShardViews(ctx context.Context, views []CreateShardView) error
func (*ClusterMetadata) CreateTable ¶
func (c *ClusterMetadata) CreateTable(ctx context.Context, request CreateTableRequest) (CreateTableResult, error)
func (*ClusterMetadata) CreateTableMetadata ¶
func (c *ClusterMetadata) CreateTableMetadata(ctx context.Context, request CreateTableMetadataRequest) (CreateTableMetadataResult, error)
func (*ClusterMetadata) DropShardNode ¶
func (*ClusterMetadata) DropTable ¶
func (c *ClusterMetadata) DropTable(ctx context.Context, schemaName, tableName string) (DropTableResult, error)
DropTable will drop table metadata and all mapping of this table. If the table to be dropped has been opened multiple times, all its mapping will be dropped.
func (*ClusterMetadata) DropTableMetadata ¶
func (c *ClusterMetadata) DropTableMetadata(ctx context.Context, schemaName, tableName string) (DropTableMetadataResult, error)
func (*ClusterMetadata) GetClusterID ¶
func (c *ClusterMetadata) GetClusterID() storage.ClusterID
func (*ClusterMetadata) GetClusterMinNodeCount ¶
func (c *ClusterMetadata) GetClusterMinNodeCount() uint32
func (*ClusterMetadata) GetClusterSnapshot ¶
func (c *ClusterMetadata) GetClusterSnapshot() Snapshot
func (*ClusterMetadata) GetClusterState ¶
func (c *ClusterMetadata) GetClusterState() storage.ClusterState
func (*ClusterMetadata) GetClusterView ¶
func (c *ClusterMetadata) GetClusterView() storage.ClusterView
func (*ClusterMetadata) GetClusterViewVersion ¶
func (c *ClusterMetadata) GetClusterViewVersion() uint64
func (*ClusterMetadata) GetCreateTime ¶ added in v1.2.1
func (c *ClusterMetadata) GetCreateTime() uint64
func (*ClusterMetadata) GetEnableSchedule ¶ added in v1.2.1
func (c *ClusterMetadata) GetEnableSchedule() bool
func (*ClusterMetadata) GetNodeShards ¶
func (c *ClusterMetadata) GetNodeShards(_ context.Context) (GetNodeShardsResult, error)
func (*ClusterMetadata) GetOrCreateSchema ¶
func (c *ClusterMetadata) GetOrCreateSchema(ctx context.Context, schemaName string) (storage.Schema, bool, error)
GetOrCreateSchema the second output parameter bool: returns true if the schema was newly created.
func (*ClusterMetadata) GetProcedureExecutingBatchSize ¶ added in v1.2.4
func (c *ClusterMetadata) GetProcedureExecutingBatchSize() uint32
func (*ClusterMetadata) GetRegisteredNodeByName ¶
func (c *ClusterMetadata) GetRegisteredNodeByName(nodeName string) (RegisteredNode, bool)
func (*ClusterMetadata) GetRegisteredNodes ¶
func (c *ClusterMetadata) GetRegisteredNodes() []RegisteredNode
func (*ClusterMetadata) GetShardNodeByTableIDs ¶
func (c *ClusterMetadata) GetShardNodeByTableIDs(tableIDs []storage.TableID) (GetShardNodesByTableIDsResult, error)
func (*ClusterMetadata) GetShardNodesByShardID ¶
func (*ClusterMetadata) GetShardTables ¶
func (c *ClusterMetadata) GetShardTables(shardIDs []storage.ShardID) map[storage.ShardID]ShardTables
func (*ClusterMetadata) GetStorageMetadata ¶ added in v1.2.1
func (c *ClusterMetadata) GetStorageMetadata() storage.Cluster
func (*ClusterMetadata) GetTable ¶
GetTable the second output parameter bool: returns true if the table exists.
func (*ClusterMetadata) GetTopologyType ¶ added in v1.2.1
func (c *ClusterMetadata) GetTopologyType() storage.TopologyType
func (*ClusterMetadata) GetTotalShardNum ¶
func (c *ClusterMetadata) GetTotalShardNum() uint32
func (*ClusterMetadata) Init ¶
func (c *ClusterMetadata) Init(ctx context.Context) error
Initialize the cluster view and shard view of the cluster. It will be used when we create the cluster.
func (*ClusterMetadata) Load ¶
func (c *ClusterMetadata) Load(ctx context.Context) error
Load cluster NodeName from storage into memory.
func (*ClusterMetadata) LoadMetadata ¶ added in v1.2.1
func (c *ClusterMetadata) LoadMetadata(ctx context.Context) error
LoadMetadata load cluster metadata from storage.
func (*ClusterMetadata) MigrateTable ¶
func (c *ClusterMetadata) MigrateTable(ctx context.Context, request MigrateTableRequest) error
MigrateTable used to migrate tables from old shard to new shard. The mapping relationship between table and shard will be modified.
func (*ClusterMetadata) Name ¶
func (c *ClusterMetadata) Name() string
func (*ClusterMetadata) RegisterNode ¶
func (c *ClusterMetadata) RegisterNode(ctx context.Context, registeredNode RegisteredNode) error
func (*ClusterMetadata) RouteTables ¶
func (c *ClusterMetadata) RouteTables(_ context.Context, schemaName string, tableNames []string) (RouteTablesResult, error)
func (*ClusterMetadata) UpdateClusterView ¶
func (c *ClusterMetadata) UpdateClusterView(ctx context.Context, state storage.ClusterState, shardNodes []storage.ShardNode) error
func (*ClusterMetadata) UpdateClusterViewByNode ¶
type CreateClusterOpts ¶
type CreateShardView ¶
type CreateTableMetadataRequest ¶
type CreateTableMetadataRequest struct { SchemaName string TableName string PartitionInfo storage.PartitionInfo }
type CreateTableRequest ¶
type CreateTableResult ¶
type CreateTableResult struct { Table storage.Table ShardVersionUpdate ShardVersionUpdate }
type DropTableMetadataResult ¶
type DropTableResult ¶
type DropTableResult struct {
ShardVersionUpdate []ShardVersionUpdate
}
type GetNodeShardsResult ¶
type GetNodeShardsResult struct { ClusterTopologyVersion uint64 NodeShards []ShardNodeWithVersion }
type GetShardNodesResult ¶
type GetShardNodesResult struct {
// contains filtered or unexported fields
}
type GetShardTablesByNodeResult ¶
type GetShardTablesByNodeResult struct {
ShardTableIDs map[storage.ShardID]ShardTableIDs
}
type MigrateTableRequest ¶
type OpenTableRequest ¶
type RegisteredNode ¶
func NewRegisteredNode ¶
func NewRegisteredNode(meta storage.Node, shardInfos []ShardInfo) RegisteredNode
type RouteEntry ¶
type RouteEntry struct { Table TableInfo NodeShards []ShardNodeWithVersion }
type RouteTablesResult ¶
type RouteTablesResult struct { ClusterViewVersion uint64 RouteEntries map[string]RouteEntry }
type ShardInfo ¶
type ShardInfo struct { ID storage.ShardID Role storage.ShardRole // ShardViewVersion Version uint64 }
func ConvertShardsInfoPB ¶
func ConvertShardsInfoPB(shard *metaservicepb.ShardInfo) ShardInfo
type ShardNodeWithVersion ¶
type ShardTableIDs ¶
type ShardTables ¶
type ShardVersionUpdate ¶
type Snapshot ¶
type Snapshot struct { Topology Topology RegisteredNodes []RegisteredNode }
type TableManager ¶
type TableManager interface { // Load load table meta data from storage. Load(ctx context.Context) error // GetTable get table with schemaName and tableName, the second output parameter bool: returns true if the table exists. GetTable(schemaName string, tableName string) (storage.Table, bool, error) // GetTablesByIDs get tables with tableIDs. GetTablesByIDs(tableIDs []storage.TableID) []storage.Table // CreateTable create table with schemaName and tableName. CreateTable(ctx context.Context, schemaName string, tableName string, partitionInfo storage.PartitionInfo) (storage.Table, error) // DropTable drop table with schemaName and tableName. DropTable(ctx context.Context, schemaName string, tableName string) error // GetSchemaByName get schema with schemaName. GetSchemaByName(schemaName string) (storage.Schema, bool) // GetSchemas get all schemas in cluster. GetSchemas() []storage.Schema // GetOrCreateSchema get or create schema with schemaName. GetOrCreateSchema(ctx context.Context, schemaName string) (storage.Schema, bool, error) }
TableManager manages table metadata by schema.
type TableManagerImpl ¶
type TableManagerImpl struct {
// contains filtered or unexported fields
}
func (*TableManagerImpl) CreateTable ¶
func (m *TableManagerImpl) CreateTable(ctx context.Context, schemaName string, tableName string, partitionInfo storage.PartitionInfo) (storage.Table, error)
func (*TableManagerImpl) GetOrCreateSchema ¶
func (*TableManagerImpl) GetSchemaByName ¶
func (m *TableManagerImpl) GetSchemaByName(schemaName string) (storage.Schema, bool)
func (*TableManagerImpl) GetSchemas ¶
func (m *TableManagerImpl) GetSchemas() []storage.Schema
func (*TableManagerImpl) GetTablesByIDs ¶
func (m *TableManagerImpl) GetTablesByIDs(tableIDs []storage.TableID) []storage.Table
type Topology ¶
type Topology struct { ShardViewsMapping map[storage.ShardID]storage.ShardView ClusterView storage.ClusterView }
func (*Topology) IsPrepareFinished ¶
type TopologyManager ¶
type TopologyManager interface { // Load load cluster topology from storage. Load(ctx context.Context) error // GetVersion get cluster view version. GetVersion() uint64 // GetClusterState get cluster view state. GetClusterState() storage.ClusterState // GetTableIDs get shardNode and tablesIDs with shardID and nodeName. GetTableIDs(shardIDs []storage.ShardID) map[storage.ShardID]ShardTableIDs // AddTable add table to cluster topology. AddTable(ctx context.Context, shardID storage.ShardID, tables []storage.Table) (ShardVersionUpdate, error) // RemoveTable remove table on target shards from cluster topology. RemoveTable(ctx context.Context, shardID storage.ShardID, tableIDs []storage.TableID) (ShardVersionUpdate, error) // EvictTable evict table from cluster topology. EvictTable(ctx context.Context, tableID storage.TableID) ([]ShardVersionUpdate, error) // GetShardNodesByID get shardNodes with shardID. GetShardNodesByID(shardID storage.ShardID) ([]storage.ShardNode, error) // GetShardNodesByTableIDs get shardNodes with tableIDs. GetShardNodesByTableIDs(tableID []storage.TableID) (GetShardNodesByTableIDsResult, error) // GetShardNodes get all shardNodes in cluster topology. GetShardNodes() GetShardNodesResult // DropShardNodes drop target shardNodes in cluster topology. DropShardNodes(ctx context.Context, shardNodes []storage.ShardNode) error // InitClusterView init cluster view when create new cluster. InitClusterView(ctx context.Context) error // UpdateClusterView update cluster view with shardNodes. UpdateClusterView(ctx context.Context, state storage.ClusterState, shardNodes []storage.ShardNode) error // UpdateClusterViewByNode update cluster view with target shardNodes, it will only update shardNodes corresponding the node name. UpdateClusterViewByNode(ctx context.Context, shardNodes map[string][]storage.ShardNode) error // GetClusterView return current cluster view. GetClusterView() storage.ClusterView // CreateShardViews create shardViews. CreateShardViews(ctx context.Context, shardViews []CreateShardView) error // GetTopology get current topology snapshot. GetTopology() Topology }
TopologyManager manages the cluster topology, including the mapping relationship between shards, nodes, and tables.
type TopologyManagerImpl ¶
type TopologyManagerImpl struct {
// contains filtered or unexported fields
}
func (*TopologyManagerImpl) AddTable ¶
func (m *TopologyManagerImpl) AddTable(ctx context.Context, shardID storage.ShardID, tables []storage.Table) (ShardVersionUpdate, error)
func (*TopologyManagerImpl) CreateShardViews ¶
func (m *TopologyManagerImpl) CreateShardViews(ctx context.Context, createShardViews []CreateShardView) error
func (*TopologyManagerImpl) DropShardNodes ¶
func (*TopologyManagerImpl) EvictTable ¶
func (m *TopologyManagerImpl) EvictTable(ctx context.Context, tableID storage.TableID) ([]ShardVersionUpdate, error)
func (*TopologyManagerImpl) GetClusterState ¶
func (m *TopologyManagerImpl) GetClusterState() storage.ClusterState
func (*TopologyManagerImpl) GetClusterView ¶
func (m *TopologyManagerImpl) GetClusterView() storage.ClusterView
func (*TopologyManagerImpl) GetShardNodes ¶
func (m *TopologyManagerImpl) GetShardNodes() GetShardNodesResult
func (*TopologyManagerImpl) GetShardNodesByID ¶
func (*TopologyManagerImpl) GetShardNodesByTableIDs ¶
func (m *TopologyManagerImpl) GetShardNodesByTableIDs(tableIDs []storage.TableID) (GetShardNodesByTableIDsResult, error)
func (*TopologyManagerImpl) GetTableIDs ¶
func (m *TopologyManagerImpl) GetTableIDs(shardIDs []storage.ShardID) map[storage.ShardID]ShardTableIDs
func (*TopologyManagerImpl) GetTopology ¶
func (m *TopologyManagerImpl) GetTopology() Topology
func (*TopologyManagerImpl) GetVersion ¶
func (m *TopologyManagerImpl) GetVersion() uint64
func (*TopologyManagerImpl) InitClusterView ¶
func (m *TopologyManagerImpl) InitClusterView(ctx context.Context) error
func (*TopologyManagerImpl) RemoveTable ¶
func (m *TopologyManagerImpl) RemoveTable(ctx context.Context, shardID storage.ShardID, tableIDs []storage.TableID) (ShardVersionUpdate, error)
func (*TopologyManagerImpl) UpdateClusterView ¶
func (m *TopologyManagerImpl) UpdateClusterView(ctx context.Context, state storage.ClusterState, shardNodes []storage.ShardNode) error
func (*TopologyManagerImpl) UpdateClusterViewByNode ¶
type UpdateClusterOpts ¶ added in v1.2.1
type UpdateClusterOpts struct { EnableSchedule bool TopologyType storage.TopologyType ProcedureExecutingBatchSize uint32 }