当前位置: 首页>>代码示例>>Golang>>正文


Golang factory.GetAlgorithmProvider函数代码示例

本文整理汇总了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)
}
开发者ID:erinboyd,项目名称:origin,代码行数:26,代码来源:server.go

示例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)
}
开发者ID:vmturbo,项目名称:kubernetes,代码行数:12,代码来源:config.go

示例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")
	}
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:12,代码来源:plugins_test.go

示例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
}
开发者ID:spxtr,项目名称:contrib,代码行数:16,代码来源:predicates.go

示例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)
			}
		}
	}
}
开发者ID:CodeJuan,项目名称:kubernetes,代码行数:22,代码来源:plugins_test.go


注:本文中的k8s/io/kubernetes/plugin/pkg/scheduler/factory.GetAlgorithmProvider函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。