mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-16 20:26:45 +00:00
* shell: move ErrorWaitGroup to weed/util * shell: remove unused CandidateEcNode and EcRack types * ec: extract EC orchestration logic from weed/shell into weed/ec Move the EC node/topology model, balance engine, encode pipeline, decode pipeline, and rebuild engine into a new weed/ec package so shell commands and maintenance workers can share the logic. Shell commands keep flag parsing and delegate through a small ec.Env (dial option, topology fetch, volume locations, lock check). Tests move along with the code. * shell: remove unused proportional-rebalance type stubs * ec: move scrub, replication check, and shard unmount engines into weed/ec * worker: share the EC generation-aware shard counter from weed/ec * ec: gofmt * shell: drop EC aliases with no remaining callers * ec: guard a missing topology hook and nil disk entries in topology helpers * ec: drop trailing newlines from decode error strings * ec: re-check the shell lock before applying shard unmounts * shell: trim -node entries in ec.scrub
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
// Package ec holds the EC (erasure coding) cluster orchestration logic shared
|
|
// by the weed shell commands and the maintenance workers: topology analysis of
|
|
// EC shards, the encode/balance pipelines, and the volume-server RPC wrappers
|
|
// they drive. The placement policy itself lives in
|
|
// weed/storage/erasure_coding/ecbalancer; low-level shard mechanics live in
|
|
// weed/storage/erasure_coding.
|
|
package ec
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
// Env carries the cluster access hooks EC operations need, decoupled from any
|
|
// particular caller (shell CommandEnv, worker task, admin server).
|
|
type Env struct {
|
|
GrpcDialOption grpc.DialOption
|
|
// FetchTopology returns a fresh master topology snapshot (and the master's
|
|
// volume size limit in MB) after an optional delay.
|
|
FetchTopology func(delay time.Duration) (*master_pb.TopologyInfo, uint64, error)
|
|
// GetVolumeLocations returns the current replica locations for a volume id,
|
|
// or false if the volume is unknown.
|
|
GetVolumeLocations func(vid uint32) ([]wdclient.Location, bool)
|
|
// IsLocked reports whether the caller still holds the cluster admin lock.
|
|
// Callers without a lock concept return true.
|
|
IsLocked func() bool
|
|
}
|
|
|
|
// isLocked treats a nil Env or nil hook as locked, matching the shell's
|
|
// nil-receiver behavior so dry-run paths work without a cluster connection.
|
|
func (env *Env) isLocked() bool {
|
|
if env == nil || env.IsLocked == nil {
|
|
return true
|
|
}
|
|
return env.IsLocked()
|
|
}
|