Merge pull request #3549 from mikedanese/standardize-name-key

Standardize on variable name
This commit is contained in:
Brendan Burns 2015-01-16 12:27:34 -08:00
commit 0e751dad01

View File

@ -45,49 +45,49 @@ type AlgorithmProviderConfig struct {
PriorityFunctionKeys util.StringSet PriorityFunctionKeys util.StringSet
} }
// RegisterFitPredicate registers a fit predicate with the algorithm registry. Returns the key, // RegisterFitPredicate registers a fit predicate with the algorithm registry. Returns the name,
// with which the predicate was registered. // with which the predicate was registered.
func RegisterFitPredicate(key string, predicate algorithm.FitPredicate) string { func RegisterFitPredicate(name string, predicate algorithm.FitPredicate) string {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
validateAlgorithmNameOrDie(key) validateAlgorithmNameOrDie(name)
fitPredicateMap[key] = predicate fitPredicateMap[name] = predicate
return key return name
} }
// IsFitPredicateRegistered check is useful for testing providers. // IsFitPredicateRegistered check is useful for testing providers.
func IsFitPredicateRegistered(key string) bool { func IsFitPredicateRegistered(name string) bool {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
_, ok := fitPredicateMap[key] _, ok := fitPredicateMap[name]
return ok return ok
} }
// RegisterFitPredicate registers a priority function with the algorithm registry. Returns the key, // RegisterFitPredicate registers a priority function with the algorithm registry. Returns the name,
// with which the function was registered. // with which the function was registered.
func RegisterPriorityFunction(key string, function algorithm.PriorityFunction, weight int) string { func RegisterPriorityFunction(name string, function algorithm.PriorityFunction, weight int) string {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
validateAlgorithmNameOrDie(key) validateAlgorithmNameOrDie(name)
priorityFunctionMap[key] = algorithm.PriorityConfig{Function: function, Weight: weight} priorityFunctionMap[name] = algorithm.PriorityConfig{Function: function, Weight: weight}
return key return name
} }
// IsPriorityFunctionRegistered check is useful for testing providers. // IsPriorityFunctionRegistered check is useful for testing providers.
func IsPriorityFunctionRegistered(key string) bool { func IsPriorityFunctionRegistered(name string) bool {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
_, ok := priorityFunctionMap[key] _, ok := priorityFunctionMap[name]
return ok return ok
} }
// SetPriorityFunctionWeight sets the weight of an already registered priority function. // SetPriorityFunctionWeight sets the weight of an already registered priority function.
func SetPriorityFunctionWeight(key string, weight int) { func SetPriorityFunctionWeight(name string, weight int) {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
config, ok := priorityFunctionMap[key] config, ok := priorityFunctionMap[name]
if !ok { if !ok {
glog.Errorf("Invalid priority key %s specified - no corresponding function found", key) glog.Errorf("Invalid priority name %s specified - no corresponding function found", name)
return return
} }
config.Weight = weight config.Weight = weight
@ -120,30 +120,30 @@ func GetAlgorithmProvider(name string) (*AlgorithmProviderConfig, error) {
return &provider, nil return &provider, nil
} }
func getFitPredicateFunctions(keys util.StringSet) ([]algorithm.FitPredicate, error) { func getFitPredicateFunctions(names util.StringSet) ([]algorithm.FitPredicate, error) {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
predicates := []algorithm.FitPredicate{} predicates := []algorithm.FitPredicate{}
for _, key := range keys.List() { for _, name := range names.List() {
function, ok := fitPredicateMap[key] function, ok := fitPredicateMap[name]
if !ok { if !ok {
return nil, fmt.Errorf("Invalid predicate key %q specified - no corresponding function found", key) return nil, fmt.Errorf("Invalid predicate name %q specified - no corresponding function found", name)
} }
predicates = append(predicates, function) predicates = append(predicates, function)
} }
return predicates, nil return predicates, nil
} }
func getPriorityFunctionConfigs(keys util.StringSet) ([]algorithm.PriorityConfig, error) { func getPriorityFunctionConfigs(names util.StringSet) ([]algorithm.PriorityConfig, error) {
schedulerFactoryMutex.Lock() schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock() defer schedulerFactoryMutex.Unlock()
configs := []algorithm.PriorityConfig{} configs := []algorithm.PriorityConfig{}
for _, key := range keys.List() { for _, name := range names.List() {
config, ok := priorityFunctionMap[key] config, ok := priorityFunctionMap[name]
if !ok { if !ok {
return nil, fmt.Errorf("Invalid priority key %s specified - no corresponding function found", key) return nil, fmt.Errorf("Invalid priority name %s specified - no corresponding function found", name)
} }
configs = append(configs, config) configs = append(configs, config)
} }