本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/podtask.T.AcceptOffer方法的典型用法代码示例。如果您正苦于以下问题:Golang T.AcceptOffer方法的具体用法?Golang T.AcceptOffer怎么用?Golang T.AcceptOffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/podtask.T
的用法示例。
在下文中一共展示了T.AcceptOffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: FCFSScheduleFunc
// A first-come-first-serve scheduler: acquires the first offer that can support the task
func FCFSScheduleFunc(r offers.Registry, unused SlaveIndex, task *podtask.T) (offers.Perishable, error) {
podName := fmt.Sprintf("%s/%s", task.Pod.Namespace, task.Pod.Name)
var acceptedOffer offers.Perishable
err := r.Walk(func(p offers.Perishable) (bool, error) {
offer := p.Details()
if offer == nil {
return false, fmt.Errorf("nil offer while scheduling task %v", task.ID)
}
if task.AcceptOffer(offer) {
if p.Acquire() {
acceptedOffer = p
log.V(3).Infof("Pod %s accepted offer %v", podName, offer.Id.GetValue())
return true, nil // stop, we found an offer
}
}
return false, nil // continue
})
if acceptedOffer != nil {
if err != nil {
log.Warningf("problems walking the offer registry: %v, attempting to continue", err)
}
return acceptedOffer, nil
}
if err != nil {
log.V(2).Infof("failed to find a fit for pod: %s, err = %v", podName, err)
return nil, err
}
log.V(2).Infof("failed to find a fit for pod: %s", podName)
return nil, noSuitableOffersErr
}