collect ec shard from multiple locations

fix https://github.com/seaweedfs/seaweedfs/issues/4365
This commit is contained in:
chrislu
2023-04-17 22:56:21 -07:00
parent d50d736e68
commit 0a22eea55d
4 changed files with 47 additions and 6 deletions

View File

@@ -151,7 +151,7 @@ func iterateEcjFile(baseFileName string, processNeedleFn func(key types.NeedleId
}
// WriteDatFile generates .dat from from .ec00 ~ .ec09 files
func WriteDatFile(baseFileName string, datFileSize int64) error {
func WriteDatFile(baseFileName string, datFileSize int64, shardFileNames []string) error {
datFile, openErr := os.OpenFile(baseFileName+".dat", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if openErr != nil {
@@ -161,13 +161,19 @@ func WriteDatFile(baseFileName string, datFileSize int64) error {
inputFiles := make([]*os.File, DataShardsCount)
defer func() {
for shardId := 0; shardId < DataShardsCount; shardId++ {
if inputFiles[shardId] != nil {
inputFiles[shardId].Close()
}
}
}()
for shardId := 0; shardId < DataShardsCount; shardId++ {
shardFileName := baseFileName + ToExt(shardId)
inputFiles[shardId], openErr = os.OpenFile(shardFileName, os.O_RDONLY, 0)
inputFiles[shardId], openErr = os.OpenFile(shardFileNames[shardId], os.O_RDONLY, 0)
if openErr != nil {
return openErr
}
defer inputFiles[shardId].Close()
}
for datFileSize >= DataShardsCount*ErasureCodingLargeBlockSize {