本文整理匯總了Golang中github.com/mesos/mesos-go/mesosproto.Offer.GetId方法的典型用法代碼示例。如果您正苦於以下問題:Golang Offer.GetId方法的具體用法?Golang Offer.GetId怎麽用?Golang Offer.GetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mesos/mesos-go/mesosproto.Offer
的用法示例。
在下文中一共展示了Offer.GetId方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: launchTask
func (s *Scheduler) launchTask(driver scheduler.SchedulerDriver, offer *mesos.Offer) {
taskName := fmt.Sprintf("syslog-%s", offer.GetSlaveId().GetValue())
taskId := &mesos.TaskID{
Value: proto.String(fmt.Sprintf("%s-%s", taskName, uuid())),
}
data, err := json.Marshal(Config)
if err != nil {
panic(err) //shouldn't happen
}
Logger.Debugf("Task data: %s", string(data))
tcpPort := uint64(s.getPort(Config.TcpPort, offer, -1))
udpPort := uint64(s.getPort(Config.UdpPort, offer, int(tcpPort)))
task := &mesos.TaskInfo{
Name: proto.String(taskName),
TaskId: taskId,
SlaveId: offer.GetSlaveId(),
Executor: s.createExecutor(offer, tcpPort, udpPort),
Resources: []*mesos.Resource{
util.NewScalarResource("cpus", Config.Cpus),
util.NewScalarResource("mem", Config.Mem),
util.NewRangesResource("ports", []*mesos.Value_Range{util.NewValueRange(tcpPort, tcpPort)}),
util.NewRangesResource("ports", []*mesos.Value_Range{util.NewValueRange(udpPort, udpPort)}),
},
Data: data,
Labels: utils.StringToLabels(s.labels),
}
s.cluster.Add(offer.GetSlaveId().GetValue(), task)
driver.LaunchTasks([]*mesos.OfferID{offer.GetId()}, []*mesos.TaskInfo{task}, &mesos.Filters{RefuseSeconds: proto.Float64(1)})
}
示例2: launchTask
func (s *Scheduler) launchTask(driver scheduler.SchedulerDriver, offer *mesos.Offer) {
taskName := fmt.Sprintf("syscol-%s", offer.GetSlaveId().GetValue())
taskId := &mesos.TaskID{
Value: proto.String(fmt.Sprintf("%s-%s", taskName, uuid())),
}
data, err := json.Marshal(Config)
if err != nil {
panic(err) //shouldn't happen
}
Logger.Debugf("Task data: %s", string(data))
task := &mesos.TaskInfo{
Name: proto.String(taskName),
TaskId: taskId,
SlaveId: offer.GetSlaveId(),
Executor: s.createExecutor(offer.GetSlaveId().GetValue()),
Resources: []*mesos.Resource{
util.NewScalarResource("cpus", Config.Cpus),
util.NewScalarResource("mem", Config.Mem),
},
Data: data,
}
s.cluster.Add(offer.GetSlaveId().GetValue(), task)
driver.LaunchTasks([]*mesos.OfferID{offer.GetId()}, []*mesos.TaskInfo{task}, &mesos.Filters{RefuseSeconds: proto.Float64(1)})
}
示例3: Push
func (oc *OfferCache) Push(newOffer *mesos.Offer) bool {
oc.mut.Lock()
defer oc.mut.Unlock()
if len(oc.offerSet) < oc.maxOffers {
// Reject offers from existing slaves.
for _, offer := range oc.offerSet {
if offer.SlaveId.GetValue() == newOffer.SlaveId.GetValue() &&
oc.singleInstancePerSlave {
log.Info("Offer already exists for slave ", newOffer.SlaveId.GetValue())
return false
}
}
oc.offerSet[newOffer.GetId().GetValue()] = newOffer
// Try to add offer to the queue, clearing out invalid
// offers in order to make room if necessary.
for i := 0; i < 2; i++ {
select {
case oc.offerQueue <- newOffer:
return true
default:
oc.gc()
}
}
}
log.Info("We already have enough offers cached.")
return false
}
示例4: launchTask
func (s *Scheduler) launchTask(task Task, offer *mesos.Offer) {
taskInfo := task.NewTaskInfo(offer)
task.Data().State = TaskStateStaging
task.Data().Attributes = utils.OfferAttributes(offer)
task.Data().ExecutorID = taskInfo.GetExecutor().GetExecutorId().GetValue()
task.Data().SlaveID = taskInfo.GetSlaveId().GetValue()
task.Data().TaskID = taskInfo.GetTaskId().GetValue()
s.driver.LaunchTasks([]*mesos.OfferID{offer.GetId()}, []*mesos.TaskInfo{taskInfo}, &mesos.Filters{RefuseSeconds: proto.Float64(10)})
}
示例5: LaunchTask
func (ctx *RunOnceApplicationContext) LaunchTask(driver scheduler.SchedulerDriver, offer *mesos.Offer) error {
ctx.lock.Lock()
defer ctx.lock.Unlock()
ctx.InstancesLeftToRun--
taskInfo := ctx.newTaskInfo(offer)
ctx.tasks = append(ctx.tasks, newRunOnceTask(offer, taskInfo.GetTaskId().GetValue()))
_, err := driver.LaunchTasks([]*mesos.OfferID{offer.GetId()}, []*mesos.TaskInfo{taskInfo}, &mesos.Filters{RefuseSeconds: proto.Float64(10)})
return err
}
示例6: Offer
func Offer(offer *mesos.Offer) string {
var buffer bytes.Buffer
buffer.WriteString(offer.GetHostname())
buffer.WriteString(ID(offer.GetId().GetValue()))
resources := Resources(offer.GetResources())
if resources != "" {
buffer.WriteString(" ")
buffer.WriteString(resources)
}
attributes := Attributes(offer.GetAttributes())
if attributes != "" {
buffer.WriteString(" ")
buffer.WriteString(attributes)
}
return buffer.String()
}
示例7: offerString
func offerString(offer *mesos.Offer) string {
return fmt.Sprintf("\n%s%s %s %s", offer.GetHostname(), idString(offer.GetId().GetValue()), resourcesString(offer.GetResources()), attributesString(offer.GetAttributes()))
}