mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-24 16:53:14 +08:00
more self contained tasks
This commit is contained in:
@@ -30,24 +30,8 @@ func VerifyProtobufConfig() error {
|
||||
return fmt.Errorf("expected global max concurrent to be 4, got %d", config.Policy.GlobalMaxConcurrent)
|
||||
}
|
||||
|
||||
// Note: Task policies are now only configured for implemented task types
|
||||
// Vacuum, balance, and replication task configs have been removed
|
||||
|
||||
// Verify erasure coding configuration
|
||||
ecPolicy := config.Policy.TaskPolicies["erasure_coding"]
|
||||
if ecPolicy == nil {
|
||||
return fmt.Errorf("expected EC policy to be configured")
|
||||
}
|
||||
|
||||
ecConfig := ecPolicy.GetErasureCodingConfig()
|
||||
if ecConfig == nil {
|
||||
return fmt.Errorf("expected EC config to be accessible")
|
||||
}
|
||||
|
||||
// Verify configurable EC fields only
|
||||
if ecConfig.FullnessRatio <= 0 || ecConfig.FullnessRatio > 1 {
|
||||
return fmt.Errorf("expected EC config to have valid fullness ratio (0-1), got %f", ecConfig.FullnessRatio)
|
||||
}
|
||||
// Note: Task policies are now generic - each task manages its own configuration
|
||||
// The maintenance system no longer knows about specific task types
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -79,21 +63,10 @@ func CreateCustomConfig() *worker_pb.MaintenanceConfig {
|
||||
ScanIntervalSeconds: 60 * 60, // 1 hour
|
||||
MaxRetries: 5,
|
||||
Policy: &worker_pb.MaintenancePolicy{
|
||||
GlobalMaxConcurrent: 8,
|
||||
TaskPolicies: map[string]*worker_pb.TaskPolicy{
|
||||
"custom_erasure_coding": {
|
||||
Enabled: true,
|
||||
MaxConcurrent: 2,
|
||||
TaskConfig: &worker_pb.TaskPolicy_ErasureCodingConfig{
|
||||
ErasureCodingConfig: &worker_pb.ErasureCodingTaskConfig{
|
||||
FullnessRatio: 0.95,
|
||||
QuietForSeconds: 1800,
|
||||
MinVolumeSizeMb: 200,
|
||||
CollectionFilter: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
GlobalMaxConcurrent: 8,
|
||||
DefaultRepeatIntervalSeconds: 7200, // 2 hours
|
||||
DefaultCheckIntervalSeconds: 1800, // 30 minutes
|
||||
TaskPolicies: make(map[string]*worker_pb.TaskPolicy),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,12 @@ func DefaultMaintenanceConfigProto() *worker_pb.MaintenanceConfig {
|
||||
MaxRetries: 3,
|
||||
CleanupIntervalSeconds: 24 * 60 * 60, // 24 hours
|
||||
TaskRetentionSeconds: 7 * 24 * 60 * 60, // 7 days
|
||||
// Policy field will be populated dynamically from separate task configuration files
|
||||
Policy: nil,
|
||||
Policy: &worker_pb.MaintenancePolicy{
|
||||
GlobalMaxConcurrent: 4,
|
||||
DefaultRepeatIntervalSeconds: 24 * 60 * 60, // 24 hours
|
||||
DefaultCheckIntervalSeconds: 60 * 60, // 1 hour
|
||||
TaskPolicies: make(map[string]*worker_pb.TaskPolicy),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,30 +44,7 @@ func (mcm *MaintenanceConfigManager) GetConfig() *worker_pb.MaintenanceConfig {
|
||||
return mcm.config
|
||||
}
|
||||
|
||||
// Type-safe configuration accessors
|
||||
|
||||
// GetErasureCodingConfig returns EC-specific configuration for a task type
|
||||
func (mcm *MaintenanceConfigManager) GetErasureCodingConfig(taskType string) *worker_pb.ErasureCodingTaskConfig {
|
||||
if policy := mcm.getTaskPolicy(taskType); policy != nil {
|
||||
if ecConfig := policy.GetErasureCodingConfig(); ecConfig != nil {
|
||||
return ecConfig
|
||||
}
|
||||
}
|
||||
// Return defaults if not configured
|
||||
return &worker_pb.ErasureCodingTaskConfig{
|
||||
FullnessRatio: 0.95,
|
||||
QuietForSeconds: 3600,
|
||||
MinVolumeSizeMb: 100,
|
||||
CollectionFilter: "",
|
||||
}
|
||||
}
|
||||
|
||||
// Typed convenience methods for getting task configurations
|
||||
|
||||
// GetErasureCodingTaskConfigForType returns erasure coding configuration for a specific task type
|
||||
func (mcm *MaintenanceConfigManager) GetErasureCodingTaskConfigForType(taskType string) *worker_pb.ErasureCodingTaskConfig {
|
||||
return GetErasureCodingTaskConfig(mcm.config.Policy, MaintenanceTaskType(taskType))
|
||||
}
|
||||
// Generic configuration accessors - tasks manage their own specific configs
|
||||
|
||||
// Helper methods
|
||||
|
||||
|
||||
@@ -232,29 +232,8 @@ func GetRepeatInterval(mp *MaintenancePolicy, taskType MaintenanceTaskType) int
|
||||
return int(policy.RepeatIntervalSeconds)
|
||||
}
|
||||
|
||||
// GetErasureCodingTaskConfig returns the erasure coding task configuration
|
||||
func GetErasureCodingTaskConfig(mp *MaintenancePolicy, taskType MaintenanceTaskType) *worker_pb.ErasureCodingTaskConfig {
|
||||
policy := GetTaskPolicy(mp, taskType)
|
||||
if policy == nil {
|
||||
return nil
|
||||
}
|
||||
return policy.GetErasureCodingConfig()
|
||||
}
|
||||
|
||||
// Note: GetTaskConfig was removed - use typed getter: GetErasureCodingTaskConfig
|
||||
|
||||
// SetErasureCodingTaskConfig sets the erasure coding task configuration
|
||||
func SetErasureCodingTaskConfig(mp *MaintenancePolicy, taskType MaintenanceTaskType, config *worker_pb.ErasureCodingTaskConfig) {
|
||||
policy := GetTaskPolicy(mp, taskType)
|
||||
if policy != nil {
|
||||
policy.TaskConfig = &worker_pb.TaskPolicy_ErasureCodingConfig{
|
||||
ErasureCodingConfig: config,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetTaskConfig sets a configuration value for a task type (legacy method - use typed setter above)
|
||||
// Note: SetTaskConfig was removed - use typed setter: SetErasureCodingTaskConfig
|
||||
// Note: Task-specific configuration getters/setters removed.
|
||||
// Each task type should manage its own configuration through the generic TaskPolicy interface.
|
||||
|
||||
// MaintenanceWorker represents a worker instance
|
||||
type MaintenanceWorker struct {
|
||||
|
||||
Reference in New Issue
Block a user