2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-10-12 18:49:49 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package repairer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2019-01-14 21:19:15 +00:00
|
|
|
"storj.io/storj/internal/memory"
|
2019-03-18 10:55:06 +00:00
|
|
|
"storj.io/storj/pkg/identity"
|
2018-11-06 14:52:11 +00:00
|
|
|
"storj.io/storj/pkg/overlay"
|
2019-03-18 10:55:06 +00:00
|
|
|
"storj.io/storj/pkg/pointerdb"
|
2018-12-20 13:57:54 +00:00
|
|
|
ecclient "storj.io/storj/pkg/storage/ec"
|
2018-12-13 07:12:36 +00:00
|
|
|
"storj.io/storj/pkg/storage/segments"
|
2019-02-11 11:17:32 +00:00
|
|
|
"storj.io/storj/pkg/transport"
|
2019-03-28 20:09:23 +00:00
|
|
|
"storj.io/storj/satellite/orders"
|
2018-10-12 18:49:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config contains configurable values for repairer
|
|
|
|
type Config struct {
|
2019-03-18 10:55:06 +00:00
|
|
|
MaxRepair int `help:"maximum segments that can be repaired concurrently" default:"100"`
|
2019-03-19 13:14:59 +00:00
|
|
|
Interval time.Duration `help:"how frequently checker should audit segments" default:"1h0m0s"`
|
|
|
|
Timeout time.Duration `help:"time limit for uploading repaired pieces to new storage nodes" default:"1m0s"`
|
2019-03-18 10:55:06 +00:00
|
|
|
MaxBufferMem memory.Size `help:"maximum buffer memory (in bytes) to be allocated for read buffers" default:"4M"`
|
2018-10-12 18:49:49 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 13:54:08 +00:00
|
|
|
// GetSegmentRepairer creates a new segment repairer from storeConfig values
|
2019-03-28 20:09:23 +00:00
|
|
|
func (c Config) GetSegmentRepairer(ctx context.Context, tc transport.Client, pointerdb *pointerdb.Service, orders *orders.Service, cache *overlay.Cache, identity *identity.FullIdentity) (ss SegmentRepairer, err error) {
|
2018-11-06 14:52:11 +00:00
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
2019-02-11 11:17:32 +00:00
|
|
|
ec := ecclient.NewClient(tc, c.MaxBufferMem.Int())
|
2019-03-18 10:55:06 +00:00
|
|
|
|
2019-03-28 20:09:23 +00:00
|
|
|
return segments.NewSegmentRepairer(pointerdb, orders, cache, ec, identity, c.Timeout), nil
|
2018-11-06 14:52:11 +00:00
|
|
|
}
|