mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix volume balance bug
This commit is contained in:
parent
9ce6b949bf
commit
55be09996d
|
@ -49,7 +49,7 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo
|
||||||
return fmt.Errorf("read volume file status failed, %v", err)
|
return fmt.Errorf("read volume file status failed, %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
volumeFileName = storage.VolumeFileName(volFileInfoResp.Collection, location.Directory, int(req.VolumeId))
|
volumeFileName = storage.VolumeFileName(location.Directory, volFileInfoResp.Collection, int(req.VolumeId))
|
||||||
|
|
||||||
// println("source:", volFileInfoResp.String())
|
// println("source:", volFileInfoResp.String())
|
||||||
// copy ecx file
|
// copy ecx file
|
||||||
|
@ -63,6 +63,10 @@ func (vs *VolumeServer) VolumeCopy(ctx context.Context, req *volume_server_pb.Vo
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
idxFileName = volumeFileName + ".idx"
|
||||||
|
datFileName = volumeFileName + ".dat"
|
||||||
|
|
||||||
if err != nil && volumeFileName != "" {
|
if err != nil && volumeFileName != "" {
|
||||||
if idxFileName != "" {
|
if idxFileName != "" {
|
||||||
os.Remove(idxFileName)
|
os.Remove(idxFileName)
|
||||||
|
@ -117,11 +121,11 @@ todo: maybe should check the received count and deleted count of the volume
|
||||||
func checkCopyFiles(originFileInf *volume_server_pb.ReadVolumeFileStatusResponse, idxFileName, datFileName string) error {
|
func checkCopyFiles(originFileInf *volume_server_pb.ReadVolumeFileStatusResponse, idxFileName, datFileName string) error {
|
||||||
stat, err := os.Stat(idxFileName)
|
stat, err := os.Stat(idxFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get idx file info failed, %v", err)
|
return fmt.Errorf("stat idx file %s failed, %v", idxFileName, err)
|
||||||
}
|
}
|
||||||
if originFileInf.IdxFileSize != uint64(stat.Size()) {
|
if originFileInf.IdxFileSize != uint64(stat.Size()) {
|
||||||
return fmt.Errorf("the idx file size [%v] is not same as origin file size [%v]",
|
return fmt.Errorf("idx file %s size [%v] is not same as origin file size [%v]",
|
||||||
stat.Size(), originFileInf.IdxFileSize)
|
idxFileName, stat.Size(), originFileInf.IdxFileSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
stat, err = os.Stat(datFileName)
|
stat, err = os.Stat(datFileName)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
@ -186,7 +187,7 @@ func balanceSelectedVolume(commandEnv *commandEnv, nodes []*Node, sortCandidates
|
||||||
selectedVolumeCount += len(dn.selectedVolumes)
|
selectedVolumeCount += len(dn.selectedVolumes)
|
||||||
}
|
}
|
||||||
|
|
||||||
idealSelectedVolumes := selectedVolumeCount / len(nodes)
|
idealSelectedVolumes := int(math.Ceil(float64(selectedVolumeCount) / float64(len(nodes))))
|
||||||
|
|
||||||
hasMove := true
|
hasMove := true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue