Declining offers
In this recipe, we will handle offers by declining them so they can be presented to other frameworks.
How to do it...
So far, our framework has been acquiring resources, although it's not using them. This is because it gets offers but does not respond to them. To make offers free, we need to explicitly refuse them.
To refuse Offers
, we need to handle the Offers
event. We can do this by adding the following code in the event
type switch:
case Event_OFFERS: log.Printf("Handle offers returns: %v", handleOffers(event.Offers))
Of course, we need to implement the handleOffers()
function. But before that, we should prepare the call()
function, which will be useful for implementation. This function will be used to send messages to Mesos:
func call(message *Call) error { message.FrameworkId = frameworkInfo.Id body, _ := marshaller.MarshalToString(message) req, _ := http.NewRequest("POST", schedulerApiUrl, bytes.NewBuffer([]byte(body))) req.Header...