Documentation ¶
Index ¶
- Variables
- func NewLocalCoordinator(db qdb.QDB, cache *cache.SchemaCache) meta.EntityMgr
- type LocalCoordinator
- func (lc *LocalCoordinator) AddDataShard(ctx context.Context, ds *datashards.DataShard) error
- func (lc *LocalCoordinator) AddWorldShard(ctx context.Context, ds *datashards.DataShard) error
- func (lc *LocalCoordinator) AlterDistributionAttach(ctx context.Context, id string, rels []*distributions.DistributedRelation) error
- func (lc *LocalCoordinator) AlterDistributionDetach(ctx context.Context, id string, relName string) error
- func (lc *LocalCoordinator) BatchMoveKeyRange(_ context.Context, _ *kr.BatchMoveKeyRange) error
- func (lc *LocalCoordinator) Cache() *cache.SchemaCache
- func (lc *LocalCoordinator) CreateDistribution(ctx context.Context, ds *distributions.Distribution) error
- func (lc *LocalCoordinator) CreateKeyRange(ctx context.Context, kr *kr.KeyRange) error
- func (lc *LocalCoordinator) DataShardsRoutes() []*routingstate.DataShardRoute
- func (lc *LocalCoordinator) DropDistribution(ctx context.Context, id string) error
- func (lc *LocalCoordinator) DropKeyRange(ctx context.Context, id string) error
- func (lc *LocalCoordinator) DropKeyRangeAll(ctx context.Context) error
- func (lc *LocalCoordinator) DropShard(ctx context.Context, shardId string) error
- func (lc *LocalCoordinator) GetBalancerTask(context.Context) (*tasks.BalancerTask, error)
- func (lc *LocalCoordinator) GetCoordinator(ctx context.Context) (string, error)
- func (lc *LocalCoordinator) GetDistribution(ctx context.Context, id string) (*distributions.Distribution, error)
- func (lc *LocalCoordinator) GetKeyRange(ctx context.Context, krId string) (*kr.KeyRange, error)
- func (lc *LocalCoordinator) GetMoveTaskGroup(ctx context.Context) (*tasks.MoveTaskGroup, error)
- func (lc *LocalCoordinator) GetRelationDistribution(ctx context.Context, relation string) (*distributions.Distribution, error)
- func (lc *LocalCoordinator) GetShard(ctx context.Context, shardID string) (*datashards.DataShard, error)
- func (lc *LocalCoordinator) ListAllKeyRanges(ctx context.Context) ([]*kr.KeyRange, error)
- func (lc *LocalCoordinator) ListDataShards(ctx context.Context) []*datashards.DataShard
- func (lc *LocalCoordinator) ListDistributions(ctx context.Context) ([]*distributions.Distribution, error)
- func (lc *LocalCoordinator) ListKeyRanges(ctx context.Context, distribution string) ([]*kr.KeyRange, error)
- func (lc *LocalCoordinator) ListRouters(ctx context.Context) ([]*topology.Router, error)
- func (lc *LocalCoordinator) ListShards(ctx context.Context) ([]*datashards.DataShard, error)
- func (lc *LocalCoordinator) LockKeyRange(ctx context.Context, krid string) (*kr.KeyRange, error)
- func (lc *LocalCoordinator) Move(ctx context.Context, req *kr.MoveKeyRange) error
- func (lc *LocalCoordinator) MoveKeyRange(_ context.Context, _ *kr.KeyRange) error
- func (lc *LocalCoordinator) QDB() qdb.QDB
- func (lc *LocalCoordinator) RedistributeKeyRange(_ context.Context, _ *kr.RedistributeKeyRange) error
- func (lc *LocalCoordinator) RegisterRouter(ctx context.Context, r *topology.Router) error
- func (lc *LocalCoordinator) RemoveBalancerTask(context.Context) error
- func (lc *LocalCoordinator) RemoveMoveTaskGroup(ctx context.Context) error
- func (lc *LocalCoordinator) RenameKeyRange(ctx context.Context, krId, krIdNew string) error
- func (lc *LocalCoordinator) Shards() []string
- func (lc *LocalCoordinator) ShareKeyRange(id string) error
- func (lc *LocalCoordinator) Split(ctx context.Context, req *kr.SplitKeyRange) error
- func (lc *LocalCoordinator) SyncRouterCoordinatorAddress(ctx context.Context, router *topology.Router) error
- func (lc *LocalCoordinator) SyncRouterMetadata(ctx context.Context, router *topology.Router) error
- func (lc *LocalCoordinator) Unite(ctx context.Context, req *kr.UniteKeyRange) error
- func (lc *LocalCoordinator) UnlockKeyRange(ctx context.Context, krid string) error
- func (lc *LocalCoordinator) UnregisterRouter(ctx context.Context, id string) error
- func (lc *LocalCoordinator) UpdateCoordinator(ctx context.Context, addr string) error
- func (lc *LocalCoordinator) WorldShards() []string
- func (lc *LocalCoordinator) WorldShardsRoutes() []*routingstate.DataShardRoute
- func (lc *LocalCoordinator) WriteBalancerTask(context.Context, *tasks.BalancerTask) error
- func (lc *LocalCoordinator) WriteMoveTaskGroup(ctx context.Context, taskGroup *tasks.MoveTaskGroup) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotCoordinator = fmt.Errorf("request is unprocessable in router")
Functions ¶
func NewLocalCoordinator ¶
NewLocalCoordinator creates a new LocalCoordinator instance.
Parameters: - db (qdb.QDB): The QDB instance to associate with the LocalCoordinator.
Returns: - meta.EntityMgr: The newly created LocalCoordinator instance.
Types ¶
type LocalCoordinator ¶
type LocalCoordinator struct { ColumnMapping map[string]struct{} LocalTables map[string]struct{} // shards DataShardCfgs map[string]*config.Shard WorldShardCfgs map[string]*config.Shard // contains filtered or unexported fields }
func (*LocalCoordinator) AddDataShard ¶
func (lc *LocalCoordinator) AddDataShard(ctx context.Context, ds *datashards.DataShard) error
AddDataShard adds a new data shard to the LocalCoordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - ds: a pointer to a DataShard object containing the information of the data shard to be added.
Returns: - error: an error if the operation encounters any issues.
func (*LocalCoordinator) AddWorldShard ¶
func (lc *LocalCoordinator) AddWorldShard(ctx context.Context, ds *datashards.DataShard) error
AddWorldShard adds a world shard to the LocalCoordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - ds (*datashards.DataShard): The datashards.DataShard object representing the world shard to be added.
Returns: - error: An error if the addition of the world shard fails.
func (*LocalCoordinator) AlterDistributionAttach ¶
func (lc *LocalCoordinator) AlterDistributionAttach(ctx context.Context, id string, rels []*distributions.DistributedRelation) error
AlterDistributionAttach alters the distribution by attaching additional distributed relations.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime. - id (string): the ID of the distribution to be altered. - rels ([]*distributions.DistributedRelation): the slice of distributions.DistributedRelation objects representing the relations to be attached.
Returns: - error: an error if the alteration operation fails.
func (*LocalCoordinator) AlterDistributionDetach ¶
func (lc *LocalCoordinator) AlterDistributionDetach(ctx context.Context, id string, relName string) error
AlterDistributionDetach alters the distribution by detaching a specific distributed relation.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime. - id (string): the ID of the distribution to be altered. - relName (string): the name of the distributed relation to be detached.
Returns: - error: an error if the alteration operation fails.
func (*LocalCoordinator) BatchMoveKeyRange ¶
func (lc *LocalCoordinator) BatchMoveKeyRange(_ context.Context, _ *kr.BatchMoveKeyRange) error
BatchMoveKeyRange is disabled in LocalCoordinator
func (*LocalCoordinator) Cache ¶
func (lc *LocalCoordinator) Cache() *cache.SchemaCache
func (*LocalCoordinator) CreateDistribution ¶
func (lc *LocalCoordinator) CreateDistribution(ctx context.Context, ds *distributions.Distribution) error
CreateDistribution creates a distribution in the local coordinator's QDB.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime. - ds (*distributions.Distribution): the distributions.Distribution object to be created.
Returns: - error: an error if the creation operation fails.
func (*LocalCoordinator) CreateKeyRange ¶
CreateKeyRange creates a new key range in the LocalCoordinator.
Parameters: - ctx (context.Context): The context of the operation. - kr (*kr.KeyRange): The key range object to be created.
Returns: - error: An error if the creation encounters any issues.
func (*LocalCoordinator) DataShardsRoutes ¶
func (lc *LocalCoordinator) DataShardsRoutes() []*routingstate.DataShardRoute
DataShardsRoutes returns a slice of DataShardRoute objects representing the data shards routes.
Parameters: - None
Returns: - []*routingstate.DataShardRoute: A slice of DataShardRoute objects representing the data shards routes.
func (*LocalCoordinator) DropDistribution ¶
func (lc *LocalCoordinator) DropDistribution(ctx context.Context, id string) error
DropDistribution removes a distribution with the specified ID from the local coordinator's QDB.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - id (string): The ID of the distribution to be dropped.
Returns: - error: An error if the removal operation fails.
func (*LocalCoordinator) DropKeyRange ¶
func (lc *LocalCoordinator) DropKeyRange(ctx context.Context, id string) error
DropKeyRange drops a key range from the LocalCoordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - id (string): The ID of the key range to be dropped.
Returns: - error: An error if the dropping of the key range fails.
func (*LocalCoordinator) DropKeyRangeAll ¶
func (lc *LocalCoordinator) DropKeyRangeAll(ctx context.Context) error
DropKeyRangeAll drops all key ranges from the LocalCoordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime.
Returns: - error: An error if the dropping of all key ranges fails.
func (*LocalCoordinator) DropShard ¶
func (lc *LocalCoordinator) DropShard(ctx context.Context, shardId string) error
DropShard drops a shard from the LocalCoordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - shardId (string): The ID of the shard to be dropped.
Returns: - error: An error if the dropping of the shard fails.
func (*LocalCoordinator) GetBalancerTask ¶
func (lc *LocalCoordinator) GetBalancerTask(context.Context) (*tasks.BalancerTask, error)
GetBalancerTask is disabled in LocalCoordinator
func (*LocalCoordinator) GetCoordinator ¶
func (lc *LocalCoordinator) GetCoordinator(ctx context.Context) (string, error)
GetCoordinator retrieves the coordinator address from the local coordinator.
Parameters: - ctx (context.Context): The context of the operation.
Returns: - string: The address of the coordinator. - error: An error indicating the retrieval status.
func (*LocalCoordinator) GetDistribution ¶
func (lc *LocalCoordinator) GetDistribution(ctx context.Context, id string) (*distributions.Distribution, error)
GetDistribution retrieves a distribution from the local coordinator's QDB by its ID.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime. - id (string): the ID of the distribution to retrieve.
Returns: - *distributions.Distribution: a pointer to the distributions.Distribution object representing the retrieved distribution. - error: an error if the retrieval operation fails.
func (*LocalCoordinator) GetKeyRange ¶
GetKeyRange gets key range by id GetKeyRange retrieves a key range identified by krId from the LocalCoordinator.
Parameters: - ctx (context.Context): the context of the operation. - krId (string): the ID of the key range to retrieve.
Returns: - *kr.KeyRange: the KeyRange object retrieved. - error: an error if the retrieval encounters any issues.
func (*LocalCoordinator) GetMoveTaskGroup ¶
func (lc *LocalCoordinator) GetMoveTaskGroup(ctx context.Context) (*tasks.MoveTaskGroup, error)
GetMoveTaskGroup retrieves the MoveTask group from the local coordinator's QDB.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime.
Returns: - *tasks.MoveTaskGroup: the retrieved task group, or nil if an error occurred. - error: an error if the retrieval process fails.
func (*LocalCoordinator) GetRelationDistribution ¶
func (lc *LocalCoordinator) GetRelationDistribution(ctx context.Context, relation string) (*distributions.Distribution, error)
GetRelationDistribution retrieves a distribution based on the given relation from the local coordinator's QDB.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - relation (string): The name of the relation for which to retrieve the distribution.
Returns: - *distributions.Distribution: A pointer to the distributions.Distribution object representing the retrieved distribution. - error: An error if the retrieval operation fails.
func (*LocalCoordinator) GetShard ¶
func (lc *LocalCoordinator) GetShard(ctx context.Context, shardID string) (*datashards.DataShard, error)
GetShard retrieves a DataShard by its ID from the LocalCoordinator.
Parameters: - ctx (context.Context): The context of the operation. - shardID (string): The ID of the DataShard to retrieve.
Returns: - *datashards.DataShard: The retrieved DataShard, or nil if it doesn't exist. - error: An error indicating the retrieval status, or ErrNotCoordinator if the operation is not supported by the LocalCoordinator.
func (*LocalCoordinator) ListAllKeyRanges ¶
ListAllKeyRanges retrieves a list of all key ranges stored in the LocalCoordinator.
Parameters: - ctx: the context of the operation.
Returns: - []*kr.KeyRange: a slice of KeyRange objects representing all key ranges. - error: an error if the retrieval encounters any issues.
func (*LocalCoordinator) ListDataShards ¶
func (lc *LocalCoordinator) ListDataShards(ctx context.Context) []*datashards.DataShard
ListDataShards retrieves a list of data shards from the local coordinator.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime.
Returns: - []*datashards.DataShard: A slice of datashards.DataShard objects representing the list of data shards.
func (*LocalCoordinator) ListDistributions ¶
func (lc *LocalCoordinator) ListDistributions(ctx context.Context) ([]*distributions.Distribution, error)
ListDistributions retrieves a list of distributions from the local coordinator's QDB.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime.
Returns: - []*distributions.Distribution: a slice of distributions.Distribution objects representing the retrieved distributions. - error: an error if the retrieval operation fails.
func (*LocalCoordinator) ListKeyRanges ¶
func (lc *LocalCoordinator) ListKeyRanges(ctx context.Context, distribution string) ([]*kr.KeyRange, error)
ListKeyRanges retrieves a list of key ranges associated with the specified distribution from the LocalCoordinator.
Parameters: - ctx: the context of the operation. - distribution: the distribution to filter the key ranges by.
Returns: - []*kr.KeyRange: a slice of KeyRange objects retrieved. - error: an error if the retrieval encounters any issues.
func (*LocalCoordinator) ListRouters ¶
ListRouters retrieves a list of routers stored in the LocalCoordinator.
Parameters: - ctx: the context of the operation.
Returns: - []*topology.Router: a slice of Router objects representing all routers. - error: an error if the retrieval encounters any issues.
func (*LocalCoordinator) ListShards ¶
func (lc *LocalCoordinator) ListShards(ctx context.Context) ([]*datashards.DataShard, error)
ListShards retrieves a list of data shards from the local coordinator's QDB.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime.
Returns: - []*datashards.DataShard: A slice of datashards.DataShard objects representing the list of data shards. - error: An error if the retrieval operation fails.
func (*LocalCoordinator) LockKeyRange ¶
LockKeyRange locks a key range identified by krid and returns the corresponding KeyRange object.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - krid (string): the ID of the key range to lock.
Returns: - *kr.KeyRange: the locked KeyRange object. - error: an error if the lock operation encounters any issues.
func (*LocalCoordinator) Move ¶
func (lc *LocalCoordinator) Move(ctx context.Context, req *kr.MoveKeyRange) error
Move moves a key range identified by req.Krid to a new shard specified by req.ShardId
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - req (*kr.MoveKeyRange): a pointer to a MoveKeyRange object containing the necessary information for the move operation.
Returns: - error: an error if the move operation encounters any issues.
func (*LocalCoordinator) MoveKeyRange ¶
MoveKeyRange is disabled in LocalCoordinator
Returns: - error: SPQR_INVALID_REQUEST error
func (*LocalCoordinator) QDB ¶
func (lc *LocalCoordinator) QDB() qdb.QDB
QDB returns the QDB instance associated with the LocalCoordinator.
Parameters: - None.
Returns: - qdb.QDB: The QDB instance.
func (*LocalCoordinator) RedistributeKeyRange ¶
func (lc *LocalCoordinator) RedistributeKeyRange(_ context.Context, _ *kr.RedistributeKeyRange) error
RedistributeKeyRange is disabled in LocalCoordinator
func (*LocalCoordinator) RegisterRouter ¶
RegisterRouter registers a router in the local coordinator.
Parameters: - ctx (context.Context): The context of the operation. - r (*topology.Router): The router to be registered.
Returns: - error: An error indicating the registration status.
func (*LocalCoordinator) RemoveBalancerTask ¶
func (lc *LocalCoordinator) RemoveBalancerTask(context.Context) error
RemoveBalancerTask is disabled in LocalCoordinator
func (*LocalCoordinator) RemoveMoveTaskGroup ¶
func (lc *LocalCoordinator) RemoveMoveTaskGroup(ctx context.Context) error
RemoveMoveTaskGroup removes the task group from the local coordinator's QDB.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime.
Returns: - error: an error if the removal operation fails.
func (*LocalCoordinator) RenameKeyRange ¶
func (lc *LocalCoordinator) RenameKeyRange(ctx context.Context, krId, krIdNew string) error
RenameKeyRange is disabled in LocalCoordinator
func (*LocalCoordinator) Shards ¶
func (lc *LocalCoordinator) Shards() []string
Shards returns a slice of strings containing the names of the data shards stored in the LocalCoordinator.
Parameters: - None.
Returns: - []string: a slice of strings containing the names of the data shards.
func (*LocalCoordinator) ShareKeyRange ¶
func (lc *LocalCoordinator) ShareKeyRange(id string) error
ShareKeyRange shares a key range with the LocalCoordinator.
Parameters: - id (string): The ID of the key range to be shared.
Returns: - error: An error indicating the sharing status.
func (*LocalCoordinator) Split ¶
func (lc *LocalCoordinator) Split(ctx context.Context, req *kr.SplitKeyRange) error
Split splits an existing key range identified by req.SourceID into two new key ranges.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - req (*kr.SplitKeyRange): a pointer to a SplitKeyRange object containing the necessary information for the split operation.
Returns: - error: an error if the split operation encounters any issues.
func (*LocalCoordinator) SyncRouterCoordinatorAddress ¶
func (lc *LocalCoordinator) SyncRouterCoordinatorAddress(ctx context.Context, router *topology.Router) error
SyncRouterCoordinatorAddress updates the coordinator address for the specified router.
Parameters: - ctx (context.Context): The context of the operation. - router (*topology.Router): The router for which the coordinator address needs to be updated.
Returns: - error: An error indicating the update status.
func (*LocalCoordinator) SyncRouterMetadata ¶
SyncRouterMetadata synchronizes the metadata of a router in the local coordinator.
Parameters: - ctx (context.Context): The context of the operation. - router (*topology.Router): The router whose metadata needs to be synchronized.
Returns: - error: An error indicating the synchronization status. In this case, it returns ErrNotCoordinator.
func (*LocalCoordinator) Unite ¶
func (lc *LocalCoordinator) Unite(ctx context.Context, req *kr.UniteKeyRange) error
Unite merges two key ranges identified by req.BaseKeyRangeId and req.AppendageKeyRangeId into a single key range.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - req (*kr.UniteKeyRange): a pointer to a UniteKeyRange object containing the necessary information for the unite operation.
Returns: - error: an error if the unite operation encounters any issues.
func (*LocalCoordinator) UnlockKeyRange ¶
func (lc *LocalCoordinator) UnlockKeyRange(ctx context.Context, krid string) error
UnlockKeyRange unlocks a key range identified by krid.
Parameters: - ctx (context.Context): The context.Context object for managing the request's lifetime. - krid (string): the ID of the key range to lock.
Returns: - error: an error if the unlock operation encounters any issues.
func (*LocalCoordinator) UnregisterRouter ¶
func (lc *LocalCoordinator) UnregisterRouter(ctx context.Context, id string) error
UnregisterRouter unregisters a router in the local coordinator.
Parameters: - ctx (context.Context): The context of the operation. - id (string): The ID of the router to be unregistered.
Returns: - error: An error indicating the unregistration status.
func (*LocalCoordinator) UpdateCoordinator ¶
func (lc *LocalCoordinator) UpdateCoordinator(ctx context.Context, addr string) error
UpdateCoordinator updates the coordinator address in the local coordinator.
Parameters: - ctx (context.Context): The context of the operation. - addr (string): The new address of the coordinator.
Returns: - error: An error indicating the update status.
func (*LocalCoordinator) WorldShards ¶
func (lc *LocalCoordinator) WorldShards() []string
WorldShards returns a slice of strings containing the names of the world shards stored in the LocalCoordinator.
Parameters: - None.
Returns: - []string: a slice of strings containing the names of the world shards.
func (*LocalCoordinator) WorldShardsRoutes ¶
func (lc *LocalCoordinator) WorldShardsRoutes() []*routingstate.DataShardRoute
WorldShardsRoutes returns a slice of DataShardRoute objects representing the world shards routes in a round-robin fashion.
Parameters: - None
Returns: - []*routingstate.DataShardRoute: A slice of DataShardRoute objects representing the world shards routes after applying round-robin.
func (*LocalCoordinator) WriteBalancerTask ¶
func (lc *LocalCoordinator) WriteBalancerTask(context.Context, *tasks.BalancerTask) error
WriteBalancerTask is disabled in LocalCoordinator
func (*LocalCoordinator) WriteMoveTaskGroup ¶
func (lc *LocalCoordinator) WriteMoveTaskGroup(ctx context.Context, taskGroup *tasks.MoveTaskGroup) error
WriteMoveTaskGroup writes the given task group to the local coordinator's QDB.
Parameters: - ctx (context.Context): the context.Context object for managing the request's lifetime. - taskGroup (*tasks.MoveTaskGroup): the task group to be written to the QDB.
Returns: - error: an error if the write operation fails.