Skip to content

Commit

Permalink
scheduler: updated to mesos 1.2.x proto API
Browse files Browse the repository at this point in the history
  • Loading branch information
James DeFelice committed Jun 24, 2017
1 parent d959fa0 commit 6376f08
Show file tree
Hide file tree
Showing 6 changed files with 1,768 additions and 248 deletions.
3 changes: 2 additions & 1 deletion api/v1/lib/httpcli/httpsched/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestDisconnectionDecoder(t *testing.T) {
// ERROR event triggers disconnect
latch.Reset()
errtype := scheduler.Event_ERROR
event := &scheduler.Event{Type: &errtype}
event := &scheduler.Event{Type: errtype}
decoder = encoding.DecoderFunc(func(um encoding.Unmarshaler) error { return nil })
d = disconnectionDecoder(decoder, latch.Close)
_ = d.Decode(event)
Expand All @@ -39,6 +39,7 @@ func TestDisconnectionDecoder(t *testing.T) {
// sanity: non-ERROR event does not trigger disconnect
latch.Reset()
errtype = scheduler.Event_SUBSCRIBED
event = &scheduler.Event{Type: errtype}
_ = d.Decode(event)
if latch.Closed() {
t.Error("disconnect func was unexpectedly called")
Expand Down
28 changes: 14 additions & 14 deletions api/v1/lib/scheduler/calls/calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// Filters sets a scheduler.Call's internal Filters, required for Accept and Decline calls.
func Filters(fo ...mesos.FilterOpt) scheduler.CallOpt {
return func(c *scheduler.Call) {
switch *c.Type {
switch c.Type {
case scheduler.Call_ACCEPT:
c.Accept.Filters = mesos.OptionalFilters(fo...)
case scheduler.Call_ACCEPT_INVERSE_OFFERS:
Expand Down Expand Up @@ -55,7 +55,7 @@ func Framework(id string) scheduler.CallOpt {
// The call's FrameworkID is automatically filled in from the info specification.
func Subscribe(info *mesos.FrameworkInfo) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_SUBSCRIBE.Enum(),
Type: scheduler.Call_SUBSCRIBE,
FrameworkID: info.GetID(),
Subscribe: &scheduler.Call_Subscribe{FrameworkInfo: info},
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func Accept(ops ...AcceptOpt) *scheduler.Call {
offerIDs = append(offerIDs, id)
}
return &scheduler.Call{
Type: scheduler.Call_ACCEPT.Enum(),
Type: scheduler.Call_ACCEPT,
Accept: &scheduler.Call_Accept{
OfferIDs: offerIDs,
Operations: ab.operations,
Expand All @@ -124,7 +124,7 @@ func Accept(ops ...AcceptOpt) *scheduler.Call {
// Callers are expected to fill in the FrameworkID and Filters.
func AcceptInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_ACCEPT_INVERSE_OFFERS.Enum(),
Type: scheduler.Call_ACCEPT_INVERSE_OFFERS,
AcceptInverseOffers: &scheduler.Call_AcceptInverseOffers{
InverseOfferIDs: offerIDs,
},
Expand All @@ -135,7 +135,7 @@ func AcceptInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call {
// Callers are expected to fill in the FrameworkID and Filters.
func DeclineInverseOffers(offerIDs ...mesos.OfferID) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_DECLINE_INVERSE_OFFERS.Enum(),
Type: scheduler.Call_DECLINE_INVERSE_OFFERS,
DeclineInverseOffers: &scheduler.Call_DeclineInverseOffers{
InverseOfferIDs: offerIDs,
},
Expand Down Expand Up @@ -204,23 +204,23 @@ func OpDestroy(rs ...mesos.Resource) mesos.Offer_Operation {
// Callers are expected to fill in the FrameworkID.
func Revive() *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_REVIVE.Enum(),
Type: scheduler.Call_REVIVE,
}
}

// Suppress returns a suppress call.
// Callers are expected to fill in the FrameworkID.
func Suppress() *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_SUPPRESS.Enum(),
Type: scheduler.Call_SUPPRESS,
}
}

// Decline returns a decline call with the given parameters.
// Callers are expected to fill in the FrameworkID and Filters.
func Decline(offerIDs ...mesos.OfferID) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_DECLINE.Enum(),
Type: scheduler.Call_DECLINE,
Decline: &scheduler.Call_Decline{
OfferIDs: offerIDs,
},
Expand All @@ -231,7 +231,7 @@ func Decline(offerIDs ...mesos.OfferID) *scheduler.Call {
// Callers are expected to fill in the FrameworkID.
func Kill(taskID, agentID string) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_KILL.Enum(),
Type: scheduler.Call_KILL,
Kill: &scheduler.Call_Kill{
TaskID: mesos.TaskID{Value: taskID},
AgentID: optionalAgentID(agentID),
Expand All @@ -243,7 +243,7 @@ func Kill(taskID, agentID string) *scheduler.Call {
// Callers are expected to fill in the FrameworkID.
func Shutdown(executorID, agentID string) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_SHUTDOWN.Enum(),
Type: scheduler.Call_SHUTDOWN,
Shutdown: &scheduler.Call_Shutdown{
ExecutorID: mesos.ExecutorID{Value: executorID},
AgentID: mesos.AgentID{Value: agentID},
Expand All @@ -255,7 +255,7 @@ func Shutdown(executorID, agentID string) *scheduler.Call {
// Callers are expected to fill in the FrameworkID.
func Acknowledge(agentID, taskID string, uuid []byte) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_ACKNOWLEDGE.Enum(),
Type: scheduler.Call_ACKNOWLEDGE,
Acknowledge: &scheduler.Call_Acknowledge{
AgentID: mesos.AgentID{Value: agentID},
TaskID: mesos.TaskID{Value: taskID},
Expand Down Expand Up @@ -289,7 +289,7 @@ func ReconcileTasks(tasks map[string]string) scheduler.ReconcileOpt {
// Callers are expected to fill in the FrameworkID.
func Reconcile(opts ...scheduler.ReconcileOpt) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_RECONCILE.Enum(),
Type: scheduler.Call_RECONCILE,
Reconcile: (&scheduler.Call_Reconcile{}).With(opts...),
}
}
Expand All @@ -298,7 +298,7 @@ func Reconcile(opts ...scheduler.ReconcileOpt) *scheduler.Call {
// Callers are expected to fill in the FrameworkID.
func Message(agentID, executorID string, data []byte) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_MESSAGE.Enum(),
Type: scheduler.Call_MESSAGE,
Message: &scheduler.Call_Message{
AgentID: mesos.AgentID{Value: agentID},
ExecutorID: mesos.ExecutorID{Value: executorID},
Expand All @@ -311,7 +311,7 @@ func Message(agentID, executorID string, data []byte) *scheduler.Call {
// Callers are expected to fill in the FrameworkID.
func Request(requests ...mesos.Request) *scheduler.Call {
return &scheduler.Call{
Type: scheduler.Call_REQUEST.Enum(),
Type: scheduler.Call_REQUEST,
Request: &scheduler.Call_Request{
Requests: requests,
},
Expand Down
Loading

0 comments on commit 6376f08

Please sign in to comment.