diff --git a/scheduler/flags.go b/scheduler/flags.go new file mode 100644 index 000000000..90d0c0573 --- /dev/null +++ b/scheduler/flags.go @@ -0,0 +1,39 @@ +/* +http://www.apache.org/licenses/LICENSE-2.0.txt + + +Copyright 2015 Intel Corporation + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package scheduler + +import "github.com/codegangsta/cli" + +var ( + flSchedulerQueueSize = cli.IntFlag{ + Name: "work-manager-queue-size", + Usage: "Size of the work manager queue (default: 25)", + EnvVar: "WORK_MANAGER_QUEUE_SIZE", + } + + flSchedulerPoolSize = cli.IntFlag{ + Name: "work-manager-pool-size", + Usage: "Size of the work manager pool (default 4)", + EnvVar: "WORK_MANAGER_POOL_SIZE", + } + + // Flags consumed by snapd + Flags = []cli.Flag{flSchedulerQueueSize, flSchedulerPoolSize} +) 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 328d042a7..016961f77 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 @@ -585,6 +586,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) @@ -615,6 +623,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")