aboutsummaryrefslogtreecommitdiff
path: root/weed/worker/tasks/erasure_coding/ec.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-07-06 13:57:02 -0700
committerGitHub <noreply@github.com>2025-07-06 13:57:02 -0700
commitaa668523047c273dc4065dc0f40852efcdf9e9f0 (patch)
tree87f7f145d699cf1824c8251ae71435462bfd3318 /weed/worker/tasks/erasure_coding/ec.go
parent302e62d4805c60f3fdb6620b01e85859d68078ed (diff)
downloadseaweedfs-aa668523047c273dc4065dc0f40852efcdf9e9f0.tar.xz
seaweedfs-aa668523047c273dc4065dc0f40852efcdf9e9f0.zip
Admin UI add maintenance menu (#6944)
* add ui for maintenance * valid config loading. fix workers page. * refactor * grpc between admin and workers * add a long-running bidirectional grpc call between admin and worker * use the grpc call to heartbeat * use the grpc call to communicate * worker can remove the http client * admin uses http port + 10000 as its default grpc port * one task one package * handles connection failures gracefully with exponential backoff * grpc with insecure tls * grpc with optional tls * fix detecting tls * change time config from nano seconds to seconds * add tasks with 3 interfaces * compiles reducing hard coded * remove a couple of tasks * remove hard coded references * reduce hard coded values * remove hard coded values * remove hard coded from templ * refactor maintenance package * fix import cycle * simplify * simplify * auto register * auto register factory * auto register task types * self register types * refactor * simplify * remove one task * register ui * lazy init executor factories * use registered task types * DefaultWorkerConfig remove hard coded task types * remove more hard coded * implement get maintenance task * dynamic task configuration * "System Settings" should only have system level settings * adjust menu for tasks * ensure menu not collapsed * render job configuration well * use templ for ui of task configuration * fix ordering * fix bugs * saving duration in seconds * use value and unit for duration * Delete WORKER_REFACTORING_PLAN.md * Delete maintenance.json * Delete custom_worker_example.go * remove address from workers * remove old code from ec task * remove creating collection button * reconnect with exponential backoff * worker use security.toml * start admin server with tls info from security.toml * fix "weed admin" cli description
Diffstat (limited to 'weed/worker/tasks/erasure_coding/ec.go')
-rw-r--r--weed/worker/tasks/erasure_coding/ec.go79
1 files changed, 79 insertions, 0 deletions
diff --git a/weed/worker/tasks/erasure_coding/ec.go b/weed/worker/tasks/erasure_coding/ec.go
new file mode 100644
index 000000000..641dfc6b5
--- /dev/null
+++ b/weed/worker/tasks/erasure_coding/ec.go
@@ -0,0 +1,79 @@
+package erasure_coding
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/seaweedfs/seaweedfs/weed/glog"
+ "github.com/seaweedfs/seaweedfs/weed/worker/tasks"
+ "github.com/seaweedfs/seaweedfs/weed/worker/types"
+)
+
+// Task implements erasure coding operation to convert volumes to EC format
+type Task struct {
+ *tasks.BaseTask
+ server string
+ volumeID uint32
+}
+
+// NewTask creates a new erasure coding task instance
+func NewTask(server string, volumeID uint32) *Task {
+ task := &Task{
+ BaseTask: tasks.NewBaseTask(types.TaskTypeErasureCoding),
+ server: server,
+ volumeID: volumeID,
+ }
+ return task
+}
+
+// Execute executes the erasure coding task
+func (t *Task) Execute(params types.TaskParams) error {
+ glog.Infof("Starting erasure coding task for volume %d on server %s", t.volumeID, t.server)
+
+ // Simulate erasure coding operation with progress updates
+ steps := []struct {
+ name string
+ duration time.Duration
+ progress float64
+ }{
+ {"Analyzing volume", 2 * time.Second, 15},
+ {"Creating EC shards", 5 * time.Second, 50},
+ {"Verifying shards", 2 * time.Second, 75},
+ {"Finalizing EC volume", 1 * time.Second, 100},
+ }
+
+ for _, step := range steps {
+ if t.IsCancelled() {
+ return fmt.Errorf("erasure coding task cancelled")
+ }
+
+ glog.V(1).Infof("Erasure coding task step: %s", step.name)
+ t.SetProgress(step.progress)
+
+ // Simulate work
+ time.Sleep(step.duration)
+ }
+
+ glog.Infof("Erasure coding task completed for volume %d on server %s", t.volumeID, t.server)
+ return nil
+}
+
+// Validate validates the task parameters
+func (t *Task) Validate(params types.TaskParams) error {
+ if params.VolumeID == 0 {
+ return fmt.Errorf("volume_id is required")
+ }
+ if params.Server == "" {
+ return fmt.Errorf("server is required")
+ }
+ return nil
+}
+
+// EstimateTime estimates the time needed for the task
+func (t *Task) EstimateTime(params types.TaskParams) time.Duration {
+ // Base time for erasure coding operation
+ baseTime := 30 * time.Second
+
+ // Could adjust based on volume size or other factors
+ return baseTime
+}