mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
default to skip if less than 4 nodes
This commit is contained in:
parent
7b3c63a8af
commit
0fd7222d65
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
|
||||||
"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"
|
||||||
"io"
|
"io"
|
||||||
|
@ -39,14 +38,12 @@ func (c *commandEcDecode) Help() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
||||||
encodeCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
decodeCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
||||||
volumeId := encodeCommand.Int("volumeId", 0, "the volume id")
|
volumeId := decodeCommand.Int("volumeId", 0, "the volume id")
|
||||||
collection := encodeCommand.String("collection", "", "the collection name")
|
collection := decodeCommand.String("collection", "", "the collection name")
|
||||||
forceChanges := encodeCommand.Bool("force", false, "force the encoding even if the cluster has less than recommended 4 nodes")
|
if err = decodeCommand.Parse(args); err != nil {
|
||||||
if err = encodeCommand.Parse(args); err != nil {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
infoAboutSimulationMode(writer, *forceChanges, "-force")
|
|
||||||
|
|
||||||
if err = commandEnv.confirmIsLocked(args); err != nil {
|
if err = commandEnv.confirmIsLocked(args); err != nil {
|
||||||
return
|
return
|
||||||
|
@ -60,17 +57,6 @@ func (c *commandEcDecode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*forceChanges {
|
|
||||||
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
|
// volumeId is provided
|
||||||
if vid != 0 {
|
if vid != 0 {
|
||||||
return doEcDecode(commandEnv, topologyInfo, *collection, vid)
|
return doEcDecode(commandEnv, topologyInfo, *collection, vid)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
@ -62,6 +63,7 @@ func (c *commandEcEncode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
|
||||||
fullPercentage := encodeCommand.Float64("fullPercent", 95, "the volume reaches the percentage of max volume size")
|
fullPercentage := encodeCommand.Float64("fullPercent", 95, "the volume reaches the percentage of max volume size")
|
||||||
quietPeriod := encodeCommand.Duration("quietFor", time.Hour, "select volumes without no writes for this period")
|
quietPeriod := encodeCommand.Duration("quietFor", time.Hour, "select volumes without no writes for this period")
|
||||||
parallelCopy := encodeCommand.Bool("parallelCopy", true, "copy shards in parallel")
|
parallelCopy := encodeCommand.Bool("parallelCopy", true, "copy shards in parallel")
|
||||||
|
forceChanges := encodeCommand.Bool("force", false, "force the encoding even if the cluster has less than recommended 4 nodes")
|
||||||
if err = encodeCommand.Parse(args); err != nil {
|
if err = encodeCommand.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,23 @@ func (c *commandEcEncode) Do(args []string, commandEnv *CommandEnv, writer io.Wr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// collect topology information
|
||||||
|
topologyInfo, _, err := collectTopologyInfo(commandEnv, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !*forceChanges {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vid := needle.VolumeId(*volumeId)
|
vid := needle.VolumeId(*volumeId)
|
||||||
|
|
||||||
// volumeId is provided
|
// volumeId is provided
|
||||||
|
|
Loading…
Reference in a new issue