Documentation ¶
Index ¶
- func IsShardInLocal(shardId int, selfServerId int, clusterSize int, replicationFactor int) bool
- func ShardListContains(shards []ClusterShard, targetShard ClusterShard) bool
- type BootstrapPlan
- type BootstrapRequest
- type Cluster
- func (cluster *Cluster) CurrentSize() int
- func (cluster *Cluster) Debug(prefix string)
- func (cluster *Cluster) ExpectedSize() int
- func (cluster *Cluster) FindShardId(keyHash uint64) int
- func (cluster *Cluster) GetAllShards() []LogicalShardGroup
- func (cluster *Cluster) GetNextCluster() *Cluster
- func (cluster *Cluster) GetNode(shardId int, replica int) (*pb.ClusterNode, bool)
- func (cluster *Cluster) RemoveNextCluster()
- func (cluster *Cluster) RemoveShard(store *pb.StoreResource, shard *pb.ShardInfo) (storeDeleted bool)
- func (cluster *Cluster) RemoveStore(store *pb.StoreResource) (removedShards []*pb.ShardInfo)
- func (cluster *Cluster) ReplaceShard(newStore *pb.StoreResource, shard *pb.ShardInfo) (isReplaced bool)
- func (cluster *Cluster) ReplicationFactor() int
- func (cluster *Cluster) SetExpectedSize(expectedSize int)
- func (cluster *Cluster) SetNextCluster(expectedSize int, replicationFactor int) *Cluster
- func (cluster *Cluster) SetReplicationFactor(replicationFactor int)
- func (cluster *Cluster) SetShard(store *pb.StoreResource, shard *pb.ShardInfo) (oldShardInfo *pb.ShardInfo)
- func (cluster *Cluster) String() string
- func (cluster *Cluster) ToCluster() *pb.Cluster
- func (cluster *Cluster) WithConnection(name string, serverId int, fn func(*pb.ClusterNode, *grpc.ClientConn) error) error
- type ClusterShard
- func LocalShards(selfServerId int, clusterSize int, replicationFactor int) (shards []ClusterShard)
- func PartitionShards(selfServerId int, selfShardId int, clusterSize int, replicationFactor int) (shards []ClusterShard)
- func PeerShards(selfServerId int, selfShardId int, clusterSize int, replicationFactor int) (peers []ClusterShard)
- type LogicalShardGroup
- type VastoNodes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsShardInLocal ¶
IsShardInLocal returns true if the tuple if shard should be on current server
func ShardListContains ¶
func ShardListContains(shards []ClusterShard, targetShard ClusterShard) bool
ShardListContains check whether shards contains one target shard
Types ¶
type BootstrapPlan ¶
type BootstrapPlan struct { // 1. bootstrapSource the shard should read missing data from. // If a list of bootstrap, pickBestBootstrapSource determines whether it should pick the best, or read all and filter // 2. transitionalFollowSource the shard should follow these shards, with its filter(always use the follower's filter) BootstrapSource []ClusterShard PickBestBootstrapSource bool TransitionalFollowSource []ClusterShard FromClusterSize int ToClusterSize int }
BootstrapPlan contains detailed plan to bootstrap one shard.
func BootstrapPlanWithTopoChange ¶
func BootstrapPlanWithTopoChange(req *BootstrapRequest) (plan *BootstrapPlan)
BootstrapPlanWithTopoChange builds the bootstrap plan based on the bootstrap request.
func (*BootstrapPlan) String ¶
func (plan *BootstrapPlan) String() string
type BootstrapRequest ¶
type BootstrapRequest struct { ServerId int ShardId int FromClusterSize int ToClusterSize int ReplicationFactor int }
BootstrapRequest is a request to bootstrap one shard.
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster manages one cluster topology
func NewCluster ¶
NewCluster creates a new cluster.
func (*Cluster) CurrentSize ¶
CurrentSize returns the cluster current size
func (*Cluster) ExpectedSize ¶
ExpectedSize returns the expected size of the cluster
func (*Cluster) FindShardId ¶
FindShardId calculates a Jump hash for the keyHash provided
func (*Cluster) GetAllShards ¶
func (cluster *Cluster) GetAllShards() []LogicalShardGroup
GetAllShards returns a list of all logic shard groups.
func (*Cluster) GetNextCluster ¶
GetNextCluster returns the next cluster
func (*Cluster) GetNode ¶
GetNode returns the server having the shard. replica denotes the shard replica.
func (*Cluster) RemoveNextCluster ¶
func (cluster *Cluster) RemoveNextCluster()
RemoveNextCluster clears the pointer to the next cluster
func (*Cluster) RemoveShard ¶
func (cluster *Cluster) RemoveShard(store *pb.StoreResource, shard *pb.ShardInfo) (storeDeleted bool)
RemoveShard returns true if no other shards is on this store
func (*Cluster) RemoveStore ¶
func (cluster *Cluster) RemoveStore(store *pb.StoreResource) (removedShards []*pb.ShardInfo)
RemoveStore removes the server from the cluster. It returns the shards which were on the server.
func (*Cluster) ReplaceShard ¶
func (cluster *Cluster) ReplaceShard(newStore *pb.StoreResource, shard *pb.ShardInfo) (isReplaced bool)
ReplaceShard ReplaceShard the shardInfo on the server in the cluster. It returns true if the operation is successful.
func (*Cluster) ReplicationFactor ¶
ReplicationFactor returns the replication factor of the cluster
func (*Cluster) SetExpectedSize ¶
SetExpectedSize sets the expected size of the cluster
func (*Cluster) SetNextCluster ¶
SetNextCluster creates a new cluster and sets the size and replication factor
func (*Cluster) SetReplicationFactor ¶
SetReplicationFactor sets the replication factor of the cluster
func (*Cluster) SetShard ¶
func (cluster *Cluster) SetShard(store *pb.StoreResource, shard *pb.ShardInfo) (oldShardInfo *pb.ShardInfo)
SetShard sets the tuple of server and shardInfo to the cluster. It returns the previous shardInfo if found.
func (*Cluster) WithConnection ¶
func (cluster *Cluster) WithConnection(name string, serverId int, fn func(*pb.ClusterNode, *grpc.ClientConn) error) error
WithConnection dials a connection to a server in the cluster by serverId
type ClusterShard ¶
ClusterShard has the tuple of server id and shard id in a cluster.
func LocalShards ¶
func LocalShards(selfServerId int, clusterSize int, replicationFactor int) (shards []ClusterShard)
LocalShards list shards that local node should have
func PartitionShards ¶
func PartitionShards(selfServerId int, selfShardId int, clusterSize int, replicationFactor int) (shards []ClusterShard)
PartitionShards list shards that belongs to the same partition
func PeerShards ¶
func PeerShards(selfServerId int, selfShardId int, clusterSize int, replicationFactor int) (peers []ClusterShard)
PeerShards list peer shards that are on other cluster nodes
func (ClusterShard) String ¶
func (shard ClusterShard) String() string
type LogicalShardGroup ¶
type LogicalShardGroup []*pb.ClusterNode
LogicalShardGroup is a list of shards with the same shard id
func (LogicalShardGroup) String ¶
func (shards LogicalShardGroup) String() string
type VastoNodes ¶
type VastoNodes []*pb.ClusterNode
VastoNodes are the servers in a cluster
func (VastoNodes) WithConnection ¶
func (nodes VastoNodes) WithConnection(name string, serverId int, fn func(*pb.ClusterNode, *grpc.ClientConn) error) error
WithConnection dials a connection to a server of the cluster nodes by serverId