allocate ec shards to volume servers

This commit is contained in:
Chris Lu
2019-05-25 02:02:44 -07:00
parent 6f4b09b6a4
commit f0e6574d5e
6 changed files with 172 additions and 14 deletions

View File

@@ -36,6 +36,10 @@ func (ecInfo *EcVolumeInfo) ShardIds() (ret []ShardId) {
return ecInfo.ShardBits.ShardIds()
}
func (ecInfo *EcVolumeInfo) ShardIdCount() (count int) {
return ecInfo.ShardBits.ShardIdCount()
}
func (ecInfo *EcVolumeInfo) Minus(other *EcVolumeInfo) (*EcVolumeInfo) {
ret := &EcVolumeInfo{
VolumeId: ecInfo.VolumeId,
@@ -69,7 +73,7 @@ func (b ShardBits) HasShardId(id ShardId) bool {
}
func (b ShardBits) ShardIds() (ret []ShardId) {
for i := ShardId(0); i < DataShardsCount+ParityShardsCount; i++ {
for i := ShardId(0); i < TotalShardsCount; i++ {
if b.HasShardId(i) {
ret = append(ret, i)
}
@@ -77,6 +81,13 @@ func (b ShardBits) ShardIds() (ret []ShardId) {
return
}
func (b ShardBits) ShardIdCount() (count int) {
for count = 0; b > 0; count++ {
b &= b - 1
}
return
}
func (b ShardBits) Minus(other ShardBits) (ShardBits) {
return b &^ other
}