Skip to content

Commit

Permalink
Feature intelsdi-x#247: adds new command-line flags for work manager …
Browse files Browse the repository at this point in the history
…queue and pool sizes
  • Loading branch information
Tom McSweeney committed Mar 11, 2016
1 parent b00e41d commit 0e485cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 11 additions & 0 deletions snapd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0e485cf

Please sign in to comment.