本文整理匯總了Golang中k8s/io/kubernetes/plugin/pkg/scheduler/factory.GetAlgorithmProvider函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetAlgorithmProvider函數的具體用法?Golang GetAlgorithmProvider怎麽用?Golang GetAlgorithmProvider使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetAlgorithmProvider函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createConfig
func (s *SchedulerServer) createConfig(configFactory *factory.ConfigFactory) (*scheduler.Config, error) {
var policy schedulerapi.Policy
var configData []byte
if _, err := os.Stat(s.PolicyConfigFile); err == nil {
configData, err = ioutil.ReadFile(s.PolicyConfigFile)
if err != nil {
return nil, fmt.Errorf("Unable to read policy config: %v", err)
}
err = latestschedulerapi.Codec.DecodeInto(configData, &policy)
if err != nil {
return nil, fmt.Errorf("Invalid configuration: %v", err)
}
return configFactory.CreateFromConfig(policy)
}
// if the config file isn't provided, use the specified (or default) provider
// check of algorithm provider is registered and fail fast
_, err := factory.GetAlgorithmProvider(s.AlgorithmProvider)
if err != nil {
return nil, err
}
return configFactory.CreateFromProvider(s.AlgorithmProvider)
}
示例2: createConfigFromDefaultProvider
// The same method defined in scheduler server. Create config file for the default kubernetes scheduler.
func createConfigFromDefaultProvider(configFactory *factory.ConfigFactory) (*scheduler.Config, error) {
// if the config file isn't provided, use the specified (or default) provider
// check of algorithm provider is registered and fail fast
_, err := factory.GetAlgorithmProvider(factory.DefaultProvider)
if err != nil {
return nil, err
}
return configFactory.CreateFromProvider(factory.DefaultProvider)
}
示例3: TestDefaultConfigExists
func TestDefaultConfigExists(t *testing.T) {
p, err := factory.GetAlgorithmProvider(factory.DefaultProvider)
if err != nil {
t.Errorf("error retrieving default provider: %v", err)
}
if p == nil {
t.Error("algorithm provider config should not be nil")
}
if len(p.FitPredicateKeys) == 0 {
t.Error("default algorithm provider shouldn't have 0 fit predicates")
}
}
示例4: NewPredicateChecker
// NewPredicateChecker builds PredicateChecker.
func NewPredicateChecker(kubeClient *kube_client.Client) (*PredicateChecker, error) {
provider, err := factory.GetAlgorithmProvider(factory.DefaultProvider)
if err != nil {
return nil, err
}
schedulerConfigFactory := factory.NewConfigFactory(kubeClient, "", kube_api.DefaultHardPodAffinitySymmetricWeight, kube_api.DefaultFailureDomains)
predicates, err := schedulerConfigFactory.GetPredicates(provider.FitPredicateKeys)
if err != nil {
return nil, err
}
schedulerConfigFactory.Run()
return &PredicateChecker{
predicates: predicates,
}, nil
}
示例5: TestAlgorithmProviders
func TestAlgorithmProviders(t *testing.T) {
for _, pn := range algorithmProviderNames {
p, err := factory.GetAlgorithmProvider(pn)
if err != nil {
t.Errorf("error retrieving '%s' provider: %v", pn, err)
break
}
if len(p.PriorityFunctionKeys) == 0 {
t.Errorf("%s algorithm provider shouldn't have 0 priority functions", pn)
}
for _, pf := range p.PriorityFunctionKeys.List() {
if !factory.IsPriorityFunctionRegistered(pf) {
t.Errorf("priority function %s is not registered but is used in the %s algorithm provider", pf, pn)
}
}
for _, fp := range p.FitPredicateKeys.List() {
if !factory.IsFitPredicateRegistered(fp) {
t.Errorf("fit predicate %s is not registered but is used in the %s algorithm provider", fp, pn)
}
}
}
}