diff options
| author | Viktor Kuzmin <kvaster@gmail.com> | 2022-10-07 21:27:15 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-07 11:27:15 -0700 |
| commit | f8d3ff466d8d2360c39132910710f5a33cf2b2be (patch) | |
| tree | 984cab8505ca500ff0ba9b5afb094b22a1a3beed | |
| parent | a522507f9566b4ff2f98860830693bc660b4353c (diff) | |
| download | seaweedfs-f8d3ff466d8d2360c39132910710f5a33cf2b2be.tar.xz seaweedfs-f8d3ff466d8d2360c39132910710f5a33cf2b2be.zip | |
Allow parallel volume loading from different dirs during startup. (#3802)
| -rw-r--r-- | weed/storage/store.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go index 8dea7496d..aa5c1809f 100644 --- a/weed/storage/store.go +++ b/weed/storage/store.go @@ -5,6 +5,7 @@ import ( "io" "path/filepath" "strings" + "sync" "sync/atomic" "github.com/seaweedfs/seaweedfs/weed/pb" @@ -82,12 +83,21 @@ func NewStore(grpcDialOption grpc.DialOption, ip string, port int, grpcPort int, minFreeSpaces []util.MinFreeSpace, idxFolder string, needleMapKind NeedleMapKind, diskTypes []DiskType) (s *Store) { s = &Store{grpcDialOption: grpcDialOption, Port: port, Ip: ip, GrpcPort: grpcPort, PublicUrl: publicUrl, NeedleMapKind: needleMapKind} s.Locations = make([]*DiskLocation, 0) + + var wg sync.WaitGroup for i := 0; i < len(dirnames); i++ { location := NewDiskLocation(dirnames[i], int32(maxVolumeCounts[i]), minFreeSpaces[i], idxFolder, diskTypes[i]) - location.loadExistingVolumes(needleMapKind) s.Locations = append(s.Locations, location) stats.VolumeServerMaxVolumeCounter.Add(float64(maxVolumeCounts[i])) + + wg.Add(1) + go func() { + defer wg.Done() + location.loadExistingVolumes(needleMapKind) + }() } + wg.Wait() + s.NewVolumesChan = make(chan master_pb.VolumeShortInformationMessage, 3) s.DeletedVolumesChan = make(chan master_pb.VolumeShortInformationMessage, 3) |
