Storage node config params descriptions cleanup (#1004)
* Storage node params descriptions cleanup * reorg agreements sender param * review changes
This commit is contained in:
parent
cfbaeaf8f2
commit
e5920ae0a4
@ -24,8 +24,8 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
flagBucketSize = flag.Int("kademlia.bucket-size", 20, "Size of each Kademlia bucket")
|
||||
flagReplacementCacheSize = flag.Int("kademlia.replacement-cache-size", 5, "Size of Kademlia replacement cache")
|
||||
flagBucketSize = flag.Int("kademlia.bucket-size", 20, "size of each Kademlia bucket")
|
||||
flagReplacementCacheSize = flag.Int("kademlia.replacement-cache-size", 5, "size of Kademlia replacement cache")
|
||||
)
|
||||
|
||||
//CtxKey Used as kademlia key
|
||||
@ -37,17 +37,17 @@ const (
|
||||
|
||||
// OperatorConfig defines properties related to storage node operator metadata
|
||||
type OperatorConfig struct {
|
||||
Email string `help:"Operator email address" default:""`
|
||||
Wallet string `help:"Operator wallet adress" default:""`
|
||||
Email string `help:"operator email address" default:""`
|
||||
Wallet string `help:"operator wallet adress" default:""`
|
||||
}
|
||||
|
||||
// Config defines all of the things that are needed to start up Kademlia
|
||||
// server endpoints (and not necessarily client code).
|
||||
type Config struct {
|
||||
BootstrapAddr string `help:"the kademlia node to bootstrap against" default:"127.0.0.1:7778"`
|
||||
DBPath string `help:"the path for our db services to be created on" default:"$CONFDIR/kademlia"`
|
||||
Alpha int `help:"alpha is a system wide concurrency parameter." default:"5"`
|
||||
ExternalAddress string `help:"the public address of the kademlia node; defaults to the gRPC server address." default:""`
|
||||
BootstrapAddr string `help:"the Kademlia node to bootstrap against" default:"127.0.0.1:7778"`
|
||||
DBPath string `help:"the path for storage node db services to be created on" default:"$CONFDIR/kademlia"`
|
||||
Alpha int `help:"alpha is a system wide concurrency parameter" default:"5"`
|
||||
ExternalAddress string `help:"the public address of the Kademlia node, useful for nodes behind NAT" default:""`
|
||||
Operator OperatorConfig
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
package agreementsender
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"time"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
@ -20,32 +19,31 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
//todo: cache kad responses if this interval is very small
|
||||
defaultCheckInterval = flag.Duration("piecestore.agreementsender.check-interval", time.Hour, "duration to sleep between agreement checks")
|
||||
// ASError wraps errors returned from agreementsender package
|
||||
ASError = errs.Class("agreement sender error")
|
||||
)
|
||||
|
||||
// AgreementSender maintains variables required for reading bandwidth agreements from a DB and sending them to a Payers
|
||||
type AgreementSender struct {
|
||||
DB *psdb.DB
|
||||
log *zap.Logger
|
||||
transport transport.Client
|
||||
kad *kademlia.Kademlia
|
||||
DB *psdb.DB
|
||||
log *zap.Logger
|
||||
transport transport.Client
|
||||
kad *kademlia.Kademlia
|
||||
checkInterval time.Duration
|
||||
}
|
||||
|
||||
// New creates an Agreement Sender
|
||||
func New(log *zap.Logger, DB *psdb.DB, identity *provider.FullIdentity, kad *kademlia.Kademlia) *AgreementSender {
|
||||
return &AgreementSender{DB: DB, log: log, transport: transport.NewClient(identity), kad: kad}
|
||||
func New(log *zap.Logger, DB *psdb.DB, identity *provider.FullIdentity, kad *kademlia.Kademlia, checkInterval time.Duration) *AgreementSender {
|
||||
return &AgreementSender{DB: DB, log: log, transport: transport.NewClient(identity), kad: kad, checkInterval: checkInterval}
|
||||
}
|
||||
|
||||
// Run the agreement sender with a context to check for cancel
|
||||
func (as *AgreementSender) Run(ctx context.Context) {
|
||||
//todo: we likely don't want to stop on err, but consider returning errors via a channel
|
||||
ticker := time.NewTicker(*defaultCheckInterval)
|
||||
ticker := time.NewTicker(as.checkInterval)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
as.log.Debug("AgreementSender is running", zap.Duration("duration", *defaultCheckInterval))
|
||||
as.log.Debug("AgreementSender is running", zap.Duration("duration", as.checkInterval))
|
||||
agreementGroups, err := as.DB.GetBandwidthAllocations()
|
||||
if err != nil {
|
||||
as.log.Error("Agreementsender could not retrieve bandwidth allocations", zap.Error(err))
|
||||
@ -65,6 +63,7 @@ func (as *AgreementSender) Run(ctx context.Context) {
|
||||
|
||||
func (as *AgreementSender) sendAgreementsToSatellite(ctx context.Context, satID storj.NodeID, agreements []*psdb.Agreement) {
|
||||
as.log.Info("Sending agreements to satellite", zap.Int("number of agreements", len(agreements)), zap.String("satellite id", satID.String()))
|
||||
// todo: cache kad responses if this interval is very small
|
||||
// Get satellite ip from kademlia
|
||||
satellite, err := as.kad.FindNode(ctx, satID)
|
||||
if err != nil {
|
||||
|
@ -26,10 +26,11 @@ var (
|
||||
|
||||
// Config contains everything necessary for a server
|
||||
type Config struct {
|
||||
Path string `help:"path to store data in" default:"$CONFDIR"`
|
||||
AllocatedDiskSpace int64 `help:"total allocated disk space, default(1GB)" default:"1073741824"`
|
||||
AllocatedBandwidth int64 `help:"total allocated bandwidth, default(100GB)" default:"107374182400"`
|
||||
KBucketRefreshInterval time.Duration `help:"how frequently checker should audit segments" default:"3600s"`
|
||||
Path string `help:"path to store data in" default:"$CONFDIR"`
|
||||
AllocatedDiskSpace int64 `help:"total allocated disk space in bytes, default(1GB)" default:"1073741824"`
|
||||
AllocatedBandwidth int64 `help:"total allocated bandwidth in bytes, default(100GB)" default:"107374182400"`
|
||||
KBucketRefreshInterval time.Duration `help:"how frequently Kademlia bucket should be refreshed with node stats" default:"1h0m0s"`
|
||||
AgreementSenderCheckInterval time.Duration `help:"duration between agreement checks" default:"1h0m0s"`
|
||||
}
|
||||
|
||||
// Run implements provider.Responsibility
|
||||
@ -69,8 +70,8 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
|
||||
}()
|
||||
|
||||
//agreementsender
|
||||
agreementsender := agreementsender.New(zap.L(), s.DB, server.Identity(), k)
|
||||
go agreementsender.Run(ctx)
|
||||
agreementSender := agreementsender.New(zap.L(), s.DB, server.Identity(), k, c.AgreementSenderCheckInterval)
|
||||
go agreementSender.Run(ctx)
|
||||
|
||||
defer func() { log.Fatal(s.Stop(ctx)) }()
|
||||
s.log.Info("Started Node", zap.String("ID", fmt.Sprint(server.Identity().ID)))
|
||||
|
Loading…
Reference in New Issue
Block a user