From 0e485cfc7eadee8984486e78947079f3bb835dbf Mon Sep 17 00:00:00 2001 From: Tom McSweeney Date: Thu, 10 Mar 2016 17:40:00 -0800 Subject: [PATCH] Feature #247: adds new command-line flags for work manager queue and pool sizes --- scheduler/scheduler.go | 8 ++++++++ snapd.go | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/scheduler/scheduler.go b/scheduler/scheduler.go index f2e4b5701..9528c1482 100644 --- a/scheduler/scheduler.go +++ b/scheduler/scheduler.go @@ -110,6 +110,14 @@ type managesWork interface { // The MetricManager must be set before the scheduler can be started. // The MetricManager must be started before it can be used. func New(cfg *Config) *scheduler { + schedulerLogger.WithFields(log.Fields{ + "_block": "New", + "value": cfg.WorkManagerQueueSize, + }).Info("Setting work manager queue size") + schedulerLogger.WithFields(log.Fields{ + "_block": "New", + "value": cfg.WorkManagerPoolSize, + }).Info("Setting work manager pool size") opts := []workManagerOption{ CollectQSizeOption(cfg.WorkManagerQueueSize), CollectWkrSizeOption(cfg.WorkManagerPoolSize), diff --git a/snapd.go b/snapd.go index afaf08db5..323bbc5e8 100644 --- a/snapd.go +++ b/snapd.go @@ -201,6 +201,7 @@ func main() { flRestKey, flRestAuth, } + app.Flags = append(app.Flags, scheduler.Flags...) app.Flags = append(app.Flags, tribe.Flags...) app.Action = action @@ -572,6 +573,13 @@ func setIntVal(field int, ctx *cli.Context, flagName string) int { return field } +func setUIntVal(field uint, ctx *cli.Context, flagName string) uint { + if ctx.IsSet(flagName) { + field = uint(ctx.Int(flagName)) + } + return field +} + func setDurationVal(field time.Duration, ctx *cli.Context, flagName string) time.Duration { if ctx.IsSet(flagName) { field = ctx.Duration(flagName) @@ -602,6 +610,9 @@ func applyCmdLineFlags(cfg *Config, ctx *cli.Context) { cfg.RestAPI.RestKey = setStringVal(cfg.RestAPI.RestKey, ctx, "rest-key") cfg.RestAPI.RestAuth = setBoolVal(cfg.RestAPI.RestAuth, ctx, "rest-auth") cfg.RestAPI.RestAuthPassword = setStringVal(cfg.RestAPI.RestAuthPassword, ctx, "rest-auth-pwd") + // next for the scheduler related flags + cfg.Scheduler.WorkManagerQueueSize = setUIntVal(cfg.Scheduler.WorkManagerQueueSize, ctx, "work-manager-queue-size") + cfg.Scheduler.WorkManagerPoolSize = setUIntVal(cfg.Scheduler.WorkManagerPoolSize, ctx, "work-manager-pool-size") // and finally for the tribe-related flags cfg.Tribe.Name = setStringVal(cfg.Tribe.Name, ctx, "tribe-node-name") cfg.Tribe.Enable = setBoolVal(cfg.Tribe.Enable, ctx, "tribe")