本文整理匯總了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
}