Browse Source

support concurrent ec.decode

pull/5630/head
Misty 7 months ago
parent
commit
6f8333b2e5
  1. 19
      weed/shell/command_ec_decode.go

19
weed/shell/command_ec_decode.go

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/seaweedfs/seaweedfs/weed/pb" "github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/storage/types"
"golang.org/x/sync/errgroup"
"io" "io"
"time" "time"
@ -41,6 +42,7 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
decodeCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) decodeCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
volumeId := decodeCommand.Int("volumeId", 0, "the volume id") volumeId := decodeCommand.Int("volumeId", 0, "the volume id")
collection := decodeCommand.String("collection", "", "the collection name") collection := decodeCommand.String("collection", "", "the collection name")
concurrency := decodeCommand.Int("concurrency", 0, "number of parallel ec decode threads")
if err = decodeCommand.Parse(args); err != nil { if err = decodeCommand.Parse(args); err != nil {
return nil return nil
} }
@ -65,13 +67,18 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
// apply to all volumes in the collection // apply to all volumes in the collection
volumeIds := collectEcShardIds(topologyInfo, *collection) volumeIds := collectEcShardIds(topologyInfo, *collection)
fmt.Printf("ec encode volumes: %v\n", volumeIds) fmt.Printf("ec encode volumes: %v\n", volumeIds)
for _, vid := range volumeIds {
if err = doEcDecode(commandEnv, topologyInfo, *collection, vid); err != nil {
return err
}
eg, _ := errgroup.WithContext(context.Background())
eg.SetLimit(*concurrency)
for _, _vid := range volumeIds {
vid := _vid
eg.Go(func() error {
if err = doEcDecode(commandEnv, topologyInfo, *collection, vid); err != nil {
return err
}
return nil
})
} }
return nil
return eg.Wait()
} }
func doEcDecode(commandEnv *CommandEnv, topoInfo *master_pb.TopologyInfo, collection string, vid needle.VolumeId) (err error) { func doEcDecode(commandEnv *CommandEnv, topoInfo *master_pb.TopologyInfo, collection string, vid needle.VolumeId) (err error) {

Loading…
Cancel
Save