func()

in scheduler/client/cli/sched_alg_params.go [39:95]


func (g *getLBSSchedAlgParams) Run(cl *client.SimpleClient, cmd *cobra.Command, args []string) error {
	log.Info("Getting Scheduling Algorithm Parameters", args)

	var err error
	g.ClassLoadPercents, err = cl.ScootClient.GetClassLoadPercents()
	if err != nil {
		return returnError(err)
	}

	g.RequestorMap, err = cl.ScootClient.GetRequestorToClassMap()
	if err != nil {
		return returnError(err)
	}

	var tInt int32
	tInt, err = cl.ScootClient.GetRebalanceMinimumDuration()
	if err != nil {
		return returnError(err)
	}
	g.RebalanceMinimumDuration = int(tInt)

	tInt, err = cl.ScootClient.GetRebalanceThreshold()
	if err != nil {
		return returnError(err)
	}
	g.RebalanceThreshold = int(tInt)

	if g.printAsJSON {
		asJSON, err := json.Marshal(g.lbsSchedAlgParams)
		if err != nil {
			log.Errorf("Error converting status to JSON: %v", err.Error())
			return fmt.Errorf("Error converting status to JSON: %v", err.Error())
		}
		log.Infof("%s\n", string(asJSON))
		fmt.Printf("%s\n", string(asJSON)) // must also go to stdout in case caller looking in stdout for the results
	} else {
		log.Info("Class Load Percents:")
		fmt.Println("Class Load Percents:")
		for class, pct := range g.ClassLoadPercents {
			log.Infof("%s:%d", class, pct)
			fmt.Println(class, ":", pct)
		}
		log.Info("Requestor (reg exp) to class map:")
		fmt.Println("Requestor (reg exp) to class map:")
		for requestorRe, class := range g.RequestorMap {
			log.Infof("%s:%s", requestorRe, class)
			fmt.Println(requestorRe, ":", class)
		}
		log.Infof("Rebalance Duration:%d (minutes)\n", g.RebalanceMinimumDuration)
		fmt.Println("Rebalance Duration:", g.RebalanceMinimumDuration, " (minutes)")
		log.Infof("Rebalance Threshold:%d\n", g.RebalanceThreshold)
		fmt.Println("Rebalance Threshold:", g.RebalanceThreshold)

	}

	return nil
}