rename SinglePruner to LocalPruner

This commit is contained in:
Christian Schwarz 2019-03-17 21:18:25 +01:00
parent b25da7b9b0
commit 158d1175e3
2 changed files with 8 additions and 8 deletions

View File

@ -23,7 +23,7 @@ type SnapJob struct {
fsfilter zfs.DatasetFilter fsfilter zfs.DatasetFilter
snapper *snapper.PeriodicOrManual snapper *snapper.PeriodicOrManual
prunerFactory *pruner.SinglePrunerFactory prunerFactory *pruner.LocalPrunerFactory
promPruneSecs *prometheus.HistogramVec // labels: prune_side promPruneSecs *prometheus.HistogramVec // labels: prune_side
@ -53,7 +53,7 @@ func snapJobFromConfig(g *config.Global, in *config.SnapJob) (j *SnapJob, err er
Help: "seconds spent in pruner", Help: "seconds spent in pruner",
ConstLabels: prometheus.Labels{"zrepl_job": j.name}, ConstLabels: prometheus.Labels{"zrepl_job": j.name},
}, []string{"prune_side"}) }, []string{"prune_side"})
j.prunerFactory, err = pruner.NewSinglePrunerFactory(in.Pruning, j.promPruneSecs) j.prunerFactory, err = pruner.NewLocalPrunerFactory(in.Pruning, j.promPruneSecs)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "cannot build snapjob pruning rules") return nil, errors.Wrap(err, "cannot build snapjob pruning rules")
} }
@ -119,7 +119,7 @@ outer:
// cursor is present, which is why this pruner returns the // cursor is present, which is why this pruner returns the
// most recent filesystem version. // most recent filesystem version.
type alwaysUpToDateReplicationCursorHistory struct { type alwaysUpToDateReplicationCursorHistory struct {
// the Target passed as Target to BuildSinglePruner // the Target passed as Target to BuildLocalPruner
target pruner.Target target pruner.Target
} }
@ -156,7 +156,7 @@ func (j *SnapJob) doPrune(ctx context.Context) {
log := GetLogger(ctx) log := GetLogger(ctx)
ctx = logging.WithSubsystemLoggers(ctx, log) ctx = logging.WithSubsystemLoggers(ctx, log)
sender := endpoint.NewSender(j.fsfilter) sender := endpoint.NewSender(j.fsfilter)
j.pruner = j.prunerFactory.BuildSinglePruner(ctx, sender, alwaysUpToDateReplicationCursorHistory{sender}) j.pruner = j.prunerFactory.BuildLocalPruner(ctx, sender, alwaysUpToDateReplicationCursorHistory{sender})
log.Info("start pruning") log.Info("start pruning")
j.pruner.Prune() j.pruner.Prune()
log.Info("finished pruning") log.Info("finished pruning")

View File

@ -81,7 +81,7 @@ type PrunerFactory struct {
promPruneSecs *prometheus.HistogramVec promPruneSecs *prometheus.HistogramVec
} }
type SinglePrunerFactory struct { type LocalPrunerFactory struct {
keepRules []pruning.KeepRule keepRules []pruning.KeepRule
retryWait time.Duration retryWait time.Duration
promPruneSecs *prometheus.HistogramVec promPruneSecs *prometheus.HistogramVec
@ -100,7 +100,7 @@ func checkContainsKeep1(rules []pruning.KeepRule) error {
return errors.New("sender keep rules must contain last_n or be empty so that the last snapshot is definitely kept") return errors.New("sender keep rules must contain last_n or be empty so that the last snapshot is definitely kept")
} }
func NewSinglePrunerFactory(in config.PruningLocal, promPruneSecs *prometheus.HistogramVec) (*SinglePrunerFactory, error) { func NewLocalPrunerFactory(in config.PruningLocal, promPruneSecs *prometheus.HistogramVec) (*LocalPrunerFactory, error) {
rules, err := pruning.RulesFromConfig(in.Keep) rules, err := pruning.RulesFromConfig(in.Keep)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "cannot build pruning rules") return nil, errors.Wrap(err, "cannot build pruning rules")
@ -112,7 +112,7 @@ func NewSinglePrunerFactory(in config.PruningLocal, promPruneSecs *prometheus.Hi
return nil, fmt.Errorf("single-site pruner cannot support `not_replicated` keep rule") return nil, fmt.Errorf("single-site pruner cannot support `not_replicated` keep rule")
} }
} }
f := &SinglePrunerFactory{ f := &LocalPrunerFactory{
keepRules: rules, keepRules: rules,
retryWait: envconst.Duration("ZREPL_PRUNER_RETRY_INTERVAL", 10*time.Second), retryWait: envconst.Duration("ZREPL_PRUNER_RETRY_INTERVAL", 10*time.Second),
promPruneSecs: promPruneSecs, promPruneSecs: promPruneSecs,
@ -181,7 +181,7 @@ func (f *PrunerFactory) BuildReceiverPruner(ctx context.Context, target Target,
return p return p
} }
func (f *SinglePrunerFactory) BuildSinglePruner(ctx context.Context, target Target, receiver History) *Pruner { func (f *LocalPrunerFactory) BuildLocalPruner(ctx context.Context, target Target, receiver History) *Pruner {
p := &Pruner{ p := &Pruner{
args: args{ args: args{
ctx, ctx,