aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_decode.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-10-25 14:38:11 -0700
committerChris Lu <chris.lu@gmail.com>2021-10-25 14:38:11 -0700
commit5f2d7c1589d9f05e31166b4d0edfe7f9fb96d140 (patch)
tree67d89c508c586733106c753fda282f53bb1369de /weed/shell/command_ec_decode.go
parent5296c397f462cfdbc61d83d45298801558288529 (diff)
downloadseaweedfs-5f2d7c1589d9f05e31166b4d0edfe7f9fb96d140.tar.xz
seaweedfs-5f2d7c1589d9f05e31166b4d0edfe7f9fb96d140.zip
erasure coding: skip erasure coding if less than recommended 4 nodes
Diffstat (limited to 'weed/shell/command_ec_decode.go')
-rw-r--r--weed/shell/command_ec_decode.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/weed/shell/command_ec_decode.go b/weed/shell/command_ec_decode.go
index cfa24cc31..33ec520e5 100644
--- a/weed/shell/command_ec_decode.go
+++ b/weed/shell/command_ec_decode.go
@@ -4,6 +4,7 @@ import (
"context"
"flag"
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb"
"github.com/chrislusf/seaweedfs/weed/storage/types"
"io"
@@ -40,6 +41,7 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
encodeCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
volumeId := encodeCommand.Int("volumeId", 0, "the volume id")
collection := encodeCommand.String("collection", "", "the collection name")
+ applyChanges := fixCommand.Bool("force", false, "force the encoding even if the cluster has less than recommended 4 nodes")
if err = encodeCommand.Parse(args); err != nil {
return nil
}
@@ -56,6 +58,17 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
return err
}
+ if !applyChanges {
+ var nodeCount int
+ eachDataNode(topologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
+ nodeCount++
+ })
+ if nodeCount < erasure_coding.ParityShardsCount {
+ glog.V(0).Infof("skip erasure coding with %d nodes, less than recommended %d nodes", nodeCount, erasure_coding.ParityShardsCount)
+ return nil
+ }
+ }
+
// volumeId is provided
if vid != 0 {
return doEcDecode(commandEnv, topologyInfo, *collection, vid)