diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1f74d47f878..5ce6fbd5ef4 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1503,31 +1503,6 @@ "ImportPath": "github.com/matttproud/golang_protobuf_extensions/pbutil", "Rev": "fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a" }, - { - "ImportPath": "github.com/mesos/mesos-go/auth", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/auth/callback", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/auth/sasl", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/auth/sasl/mech", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/auth/sasl/mech/crammd5", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, { "ImportPath": "github.com/mesos/mesos-go/detector", "Comment": "before-0.26-protos-33-g45c8b08", @@ -1538,46 +1513,16 @@ "Comment": "before-0.26-protos-33-g45c8b08", "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" }, - { - "ImportPath": "github.com/mesos/mesos-go/executor", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, { "ImportPath": "github.com/mesos/mesos-go/mesosproto", "Comment": "before-0.26-protos-33-g45c8b08", "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" }, - { - "ImportPath": "github.com/mesos/mesos-go/mesosproto/scheduler", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, { "ImportPath": "github.com/mesos/mesos-go/mesosutil", "Comment": "before-0.26-protos-33-g45c8b08", "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" }, - { - "ImportPath": "github.com/mesos/mesos-go/mesosutil/process", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/messenger", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/messenger/sessionid", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, - { - "ImportPath": "github.com/mesos/mesos-go/scheduler", - "Comment": "before-0.26-protos-33-g45c8b08", - "Rev": "45c8b08e9af666add36a6f93ff8c1c75812367b0" - }, { "ImportPath": "github.com/mesos/mesos-go/upid", "Comment": "before-0.26-protos-33-g45c8b08", diff --git a/vendor/github.com/mesos/mesos-go/auth/callback/interface.go b/vendor/github.com/mesos/mesos-go/auth/callback/interface.go deleted file mode 100644 index d870fd3c729..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/callback/interface.go +++ /dev/null @@ -1,28 +0,0 @@ -package callback - -import ( - "fmt" -) - -type Unsupported struct { - Callback Interface -} - -func (uc *Unsupported) Error() string { - return fmt.Sprintf("Unsupported callback <%T>: %v", uc.Callback, uc.Callback) -} - -type Interface interface { - // marker interface -} - -type Handler interface { - // may return an Unsupported error on failure - Handle(callbacks ...Interface) error -} - -type HandlerFunc func(callbacks ...Interface) error - -func (f HandlerFunc) Handle(callbacks ...Interface) error { - return f(callbacks...) -} diff --git a/vendor/github.com/mesos/mesos-go/auth/callback/interprocess.go b/vendor/github.com/mesos/mesos-go/auth/callback/interprocess.go deleted file mode 100644 index d9b389cafc0..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/callback/interprocess.go +++ /dev/null @@ -1,27 +0,0 @@ -package callback - -import ( - "github.com/mesos/mesos-go/upid" -) - -type Interprocess struct { - client upid.UPID - server upid.UPID -} - -func NewInterprocess() *Interprocess { - return &Interprocess{} -} - -func (cb *Interprocess) Client() upid.UPID { - return cb.client -} - -func (cb *Interprocess) Server() upid.UPID { - return cb.server -} - -func (cb *Interprocess) Set(server, client upid.UPID) { - cb.server = server - cb.client = client -} diff --git a/vendor/github.com/mesos/mesos-go/auth/callback/name.go b/vendor/github.com/mesos/mesos-go/auth/callback/name.go deleted file mode 100644 index 246020a9f2a..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/callback/name.go +++ /dev/null @@ -1,17 +0,0 @@ -package callback - -type Name struct { - name string -} - -func NewName() *Name { - return &Name{} -} - -func (cb *Name) Get() string { - return cb.name -} - -func (cb *Name) Set(name string) { - cb.name = name -} diff --git a/vendor/github.com/mesos/mesos-go/auth/callback/password.go b/vendor/github.com/mesos/mesos-go/auth/callback/password.go deleted file mode 100644 index 6beadd07b42..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/callback/password.go +++ /dev/null @@ -1,20 +0,0 @@ -package callback - -type Password struct { - password []byte -} - -func NewPassword() *Password { - return &Password{} -} - -func (cb *Password) Get() []byte { - clone := make([]byte, len(cb.password)) - copy(clone, cb.password) - return clone -} - -func (cb *Password) Set(password []byte) { - cb.password = make([]byte, len(password)) - copy(cb.password, password) -} diff --git a/vendor/github.com/mesos/mesos-go/auth/interface.go b/vendor/github.com/mesos/mesos-go/auth/interface.go deleted file mode 100644 index 94420f5af26..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/interface.go +++ /dev/null @@ -1,63 +0,0 @@ -package auth - -import ( - "errors" - "fmt" - "sync" - - log "github.com/golang/glog" - "github.com/mesos/mesos-go/auth/callback" - "golang.org/x/net/context" -) - -// SPI interface: login provider implementations support this interface, clients -// do not authenticate against this directly, instead they should use Login() -type Authenticatee interface { - // Returns no errors if successfully authenticated, otherwise a single - // error. - Authenticate(ctx context.Context, handler callback.Handler) error -} - -// Func adapter for interface: allow func's to implement the Authenticatee interface -// as long as the func signature matches -type AuthenticateeFunc func(ctx context.Context, handler callback.Handler) error - -func (f AuthenticateeFunc) Authenticate(ctx context.Context, handler callback.Handler) error { - return f(ctx, handler) -} - -var ( - // Authentication was attempted and failed (likely due to incorrect credentials, too - // many retries within a time window, etc). Distinctly different from authentication - // errors (e.g. network errors, configuration errors, etc). - AuthenticationFailed = errors.New("authentication failed") - - authenticateeProviders = make(map[string]Authenticatee) // authentication providers dict - providerLock sync.Mutex -) - -// Register an authentication provider (aka "login provider"). packages that -// provide Authenticatee implementations should invoke this func in their -// init() to register. -func RegisterAuthenticateeProvider(name string, auth Authenticatee) (err error) { - providerLock.Lock() - defer providerLock.Unlock() - - if _, found := authenticateeProviders[name]; found { - err = fmt.Errorf("authentication provider already registered: %v", name) - } else { - authenticateeProviders[name] = auth - log.V(1).Infof("registered authentication provider: %v", name) - } - return -} - -// Look up an authentication provider by name, returns non-nil and true if such -// a provider is found. -func getAuthenticateeProvider(name string) (provider Authenticatee, ok bool) { - providerLock.Lock() - defer providerLock.Unlock() - - provider, ok = authenticateeProviders[name] - return -} diff --git a/vendor/github.com/mesos/mesos-go/auth/login.go b/vendor/github.com/mesos/mesos-go/auth/login.go deleted file mode 100644 index 58dc9d3e993..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/login.go +++ /dev/null @@ -1,100 +0,0 @@ -package auth - -import ( - "errors" - "fmt" - "time" - - "github.com/mesos/mesos-go/auth/callback" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -var ( - // No login provider name has been specified in a context.Context - NoLoginProviderName = errors.New("missing login provider name in context") -) - -// Main client entrypoint into the authentication APIs: clients are expected to -// invoke this func with a context containing a login provider name value. -// This may be written as: -// providerName := ... // the user has probably configured this via some flag -// handler := ... // handlers provide data like usernames and passwords -// ctx := ... // obtain some initial or timed context -// err := auth.Login(auth.WithLoginProvider(ctx, providerName), handler) -func Login(ctx context.Context, handler callback.Handler) error { - name, ok := LoginProviderFrom(ctx) - if !ok { - return NoLoginProviderName - } - provider, ok := getAuthenticateeProvider(name) - if !ok { - return fmt.Errorf("unrecognized login provider name in context: %s", name) - } - return provider.Authenticate(ctx, handler) -} - -// Unexported key type, avoids conflicts with other context-using packages. All -// context items registered from this package should use keys of this type. -type loginKeyType int - -const ( - // name of login provider to use - loginProviderNameKey loginKeyType = iota - - // upid.UPID of some parent process - parentUpidKey - - // time.Duration that limits the overall duration of an auth attempt - timeoutKey -) - -// Return a context that inherits all values from the parent ctx and specifies -// the login provider name given here. Intended to be invoked before calls to -// Login(). -func WithLoginProvider(ctx context.Context, providerName string) context.Context { - return context.WithValue(ctx, loginProviderNameKey, providerName) -} - -// Return the name of the login provider specified in this context. -func LoginProviderFrom(ctx context.Context) (name string, ok bool) { - name, ok = ctx.Value(loginProviderNameKey).(string) - return -} - -// Return the name of the login provider specified in this context, or empty -// string if none. -func LoginProvider(ctx context.Context) string { - name, _ := LoginProviderFrom(ctx) - return name -} - -func WithParentUPID(ctx context.Context, pid upid.UPID) context.Context { - return context.WithValue(ctx, parentUpidKey, pid) -} - -func ParentUPIDFrom(ctx context.Context) (pid upid.UPID, ok bool) { - pid, ok = ctx.Value(parentUpidKey).(upid.UPID) - return -} - -func ParentUPID(ctx context.Context) (upid *upid.UPID) { - if upid, ok := ParentUPIDFrom(ctx); ok { - return &upid - } - return nil -} - -func TimeoutFrom(ctx context.Context) (d time.Duration, ok bool) { - d, ok = ctx.Value(timeoutKey).(time.Duration) - return -} - -func Timeout(ctx context.Context) (d time.Duration) { - d, _ = TimeoutFrom(ctx) - return -} - -func WithTimeout(ctx context.Context, d time.Duration) context.Context { - return context.WithValue(ctx, timeoutKey, d) -} diff --git a/vendor/github.com/mesos/mesos-go/auth/sasl/authenticatee.go b/vendor/github.com/mesos/mesos-go/auth/sasl/authenticatee.go deleted file mode 100644 index 2b9477a6df8..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/sasl/authenticatee.go +++ /dev/null @@ -1,358 +0,0 @@ -package sasl - -import ( - "errors" - "fmt" - "sync/atomic" - - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - "github.com/mesos/mesos-go/auth" - "github.com/mesos/mesos-go/auth/callback" - "github.com/mesos/mesos-go/auth/sasl/mech" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/mesosutil/process" - "github.com/mesos/mesos-go/messenger" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -var ( - UnexpectedAuthenticationMechanisms = errors.New("Unexpected authentication 'mechanisms' received") - UnexpectedAuthenticationStep = errors.New("Unexpected authentication 'step' received") - UnexpectedAuthenticationCompleted = errors.New("Unexpected authentication 'completed' received") - UnexpectedAuthenticatorPid = errors.New("Unexpected authentator pid") // authenticator pid changed mid-process - UnsupportedMechanism = errors.New("failed to identify a compatible mechanism") -) - -type statusType int32 - -const ( - statusReady statusType = iota - statusStarting - statusStepping - _statusTerminal // meta status, should never be assigned: all status types following are "terminal" - statusCompleted - statusFailed - statusError - statusDiscarded - - // this login provider name is automatically registered with the auth package; see init() - ProviderName = "SASL" -) - -type authenticateeProcess struct { - transport messenger.Messenger - client upid.UPID - status statusType - done chan struct{} - err error - mech mech.Interface - stepFn mech.StepFunc - from *upid.UPID - handler callback.Handler -} - -type authenticateeConfig struct { - client upid.UPID // pid of the client we're attempting to authenticate - handler callback.Handler - transport messenger.Messenger // mesos communications transport -} - -type transportFactory interface { - makeTransport() messenger.Messenger -} - -type transportFactoryFunc func() messenger.Messenger - -func (f transportFactoryFunc) makeTransport() messenger.Messenger { - return f() -} - -func init() { - factory := func(ctx context.Context) transportFactoryFunc { - return transportFactoryFunc(func() messenger.Messenger { - parent := auth.ParentUPID(ctx) - if parent == nil { - log.Fatal("expected to have a parent UPID in context") - } - process := process.New("sasl_authenticatee") - tpid := upid.UPID{ - ID: process.Label(), - Host: parent.Host, - } - return messenger.NewHttpWithBindingAddress(tpid, BindingAddressFrom(ctx)) - }) - } - delegate := auth.AuthenticateeFunc(func(ctx context.Context, handler callback.Handler) error { - if impl, err := makeAuthenticatee(handler, factory(ctx)); err != nil { - return err - } else { - return impl.Authenticate(ctx, handler) - } - }) - if err := auth.RegisterAuthenticateeProvider(ProviderName, delegate); err != nil { - log.Error(err) - } -} - -func (s *statusType) get() statusType { - return statusType(atomic.LoadInt32((*int32)(s))) -} - -func (s *statusType) swap(old, new statusType) bool { - return old != new && atomic.CompareAndSwapInt32((*int32)(s), int32(old), int32(new)) -} - -// build a new authenticatee implementation using the given callbacks and a new transport instance -func makeAuthenticatee(handler callback.Handler, factory transportFactory) (auth.Authenticatee, error) { - - ip := callback.NewInterprocess() - if err := handler.Handle(ip); err != nil { - return nil, err - } - config := &authenticateeConfig{ - client: ip.Client(), - handler: handler, - transport: factory.makeTransport(), - } - return auth.AuthenticateeFunc(func(ctx context.Context, handler callback.Handler) error { - ctx, auth := newAuthenticatee(ctx, config) - auth.authenticate(ctx, ip.Server()) - - select { - case <-ctx.Done(): - return auth.discard(ctx) - case <-auth.done: - return auth.err - } - }), nil -} - -// Terminate the authentication process upon context cancellation; -// only to be called if/when ctx.Done() has been signalled. -func (self *authenticateeProcess) discard(ctx context.Context) error { - err := ctx.Err() - status := statusFrom(ctx) - for ; status < _statusTerminal; status = (&self.status).get() { - if self.terminate(status, statusDiscarded, err) { - break - } - } - return err -} - -func newAuthenticatee(ctx context.Context, config *authenticateeConfig) (context.Context, *authenticateeProcess) { - initialStatus := statusReady - proc := &authenticateeProcess{ - transport: config.transport, - client: config.client, - handler: config.handler, - status: initialStatus, - done: make(chan struct{}), - } - ctx = withStatus(ctx, initialStatus) - err := proc.installHandlers(ctx) - if err == nil { - err = proc.startTransport() - } - if err != nil { - proc.terminate(initialStatus, statusError, err) - } - return ctx, proc -} - -func (self *authenticateeProcess) startTransport() error { - if err := self.transport.Start(); err != nil { - return err - } else { - go func() { - // stop the authentication transport upon termination of the - // authenticator process - select { - case <-self.done: - log.V(2).Infof("stopping authenticator transport: %v", self.transport.UPID()) - self.transport.Stop() - } - }() - } - return nil -} - -// returns true when handlers are installed without error, otherwise terminates the -// authentication process. -func (self *authenticateeProcess) installHandlers(ctx context.Context) error { - - type handlerFn func(ctx context.Context, from *upid.UPID, pbMsg proto.Message) - - withContext := func(f handlerFn) messenger.MessageHandler { - return func(from *upid.UPID, m proto.Message) { - status := (&self.status).get() - if self.from != nil && !self.from.Equal(from) { - self.terminate(status, statusError, UnexpectedAuthenticatorPid) - } else { - f(withStatus(ctx, status), from, m) - } - } - } - - // Anticipate mechanisms and steps from the server - handlers := []struct { - f handlerFn - m proto.Message - }{ - {self.mechanisms, &mesos.AuthenticationMechanismsMessage{}}, - {self.step, &mesos.AuthenticationStepMessage{}}, - {self.completed, &mesos.AuthenticationCompletedMessage{}}, - {self.failed, &mesos.AuthenticationFailedMessage{}}, - {self.errored, &mesos.AuthenticationErrorMessage{}}, - } - for _, h := range handlers { - if err := self.transport.Install(withContext(h.f), h.m); err != nil { - return err - } - } - return nil -} - -// return true if the authentication status was updated (if true, self.done will have been closed) -func (self *authenticateeProcess) terminate(old, new statusType, err error) bool { - if (&self.status).swap(old, new) { - self.err = err - if self.mech != nil { - self.mech.Discard() - } - close(self.done) - return true - } - return false -} - -func (self *authenticateeProcess) authenticate(ctx context.Context, pid upid.UPID) { - status := statusFrom(ctx) - if status != statusReady { - return - } - message := &mesos.AuthenticateMessage{ - Pid: proto.String(self.client.String()), - } - if err := self.transport.Send(ctx, &pid, message); err != nil { - self.terminate(status, statusError, err) - } else { - (&self.status).swap(status, statusStarting) - } -} - -func (self *authenticateeProcess) mechanisms(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - status := statusFrom(ctx) - if status != statusStarting { - self.terminate(status, statusError, UnexpectedAuthenticationMechanisms) - return - } - - msg, ok := pbMsg.(*mesos.AuthenticationMechanismsMessage) - if !ok { - self.terminate(status, statusError, fmt.Errorf("Expected AuthenticationMechanismsMessage, not %T", pbMsg)) - return - } - - mechanisms := msg.GetMechanisms() - log.Infof("Received SASL authentication mechanisms: %v", mechanisms) - - selectedMech, factory := mech.SelectSupported(mechanisms) - if selectedMech == "" { - self.terminate(status, statusError, UnsupportedMechanism) - return - } - - if m, f, err := factory(self.handler); err != nil { - self.terminate(status, statusError, err) - return - } else { - self.mech = m - self.stepFn = f - self.from = from - } - - // execute initialization step... - nextf, data, err := self.stepFn(self.mech, nil) - if err != nil { - self.terminate(status, statusError, err) - return - } else { - self.stepFn = nextf - } - - message := &mesos.AuthenticationStartMessage{ - Mechanism: proto.String(selectedMech), - Data: data, // may be nil, depends on init step - } - - if err := self.transport.Send(ctx, from, message); err != nil { - self.terminate(status, statusError, err) - } else { - (&self.status).swap(status, statusStepping) - } -} - -func (self *authenticateeProcess) step(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - status := statusFrom(ctx) - if status != statusStepping { - self.terminate(status, statusError, UnexpectedAuthenticationStep) - return - } - - log.Info("Received SASL authentication step") - - msg, ok := pbMsg.(*mesos.AuthenticationStepMessage) - if !ok { - self.terminate(status, statusError, fmt.Errorf("Expected AuthenticationStepMessage, not %T", pbMsg)) - return - } - - input := msg.GetData() - fn, output, err := self.stepFn(self.mech, input) - - if err != nil { - self.terminate(status, statusError, fmt.Errorf("failed to perform authentication step: %v", err)) - return - } - self.stepFn = fn - - // We don't start the client with SASL_SUCCESS_DATA so we may - // need to send one more "empty" message to the server. - message := &mesos.AuthenticationStepMessage{} - if len(output) > 0 { - message.Data = output - } - if err := self.transport.Send(ctx, from, message); err != nil { - self.terminate(status, statusError, err) - } -} - -func (self *authenticateeProcess) completed(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - status := statusFrom(ctx) - if status != statusStepping { - self.terminate(status, statusError, UnexpectedAuthenticationCompleted) - return - } - - log.Info("Authentication success") - self.terminate(status, statusCompleted, nil) -} - -func (self *authenticateeProcess) failed(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - status := statusFrom(ctx) - self.terminate(status, statusFailed, auth.AuthenticationFailed) -} - -func (self *authenticateeProcess) errored(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - var err error - if msg, ok := pbMsg.(*mesos.AuthenticationErrorMessage); !ok { - err = fmt.Errorf("Expected AuthenticationErrorMessage, not %T", pbMsg) - } else { - err = fmt.Errorf("Authentication error: %s", msg.GetError()) - } - status := statusFrom(ctx) - self.terminate(status, statusError, err) -} diff --git a/vendor/github.com/mesos/mesos-go/auth/sasl/context.go b/vendor/github.com/mesos/mesos-go/auth/sasl/context.go deleted file mode 100644 index 8058ac34e6c..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/sasl/context.go +++ /dev/null @@ -1,43 +0,0 @@ -package sasl - -import ( - "net" - - "golang.org/x/net/context" -) - -// unexported to prevent collisions with context keys defined in -// other packages. -type _key int - -// If this package defined other context keys, they would have -// different integer values. -const ( - statusKey _key = iota - bindingAddressKey // bind address for login-related network ops -) - -func withStatus(ctx context.Context, s statusType) context.Context { - return context.WithValue(ctx, statusKey, s) -} - -func statusFrom(ctx context.Context) statusType { - s, ok := ctx.Value(statusKey).(statusType) - if !ok { - panic("missing status in context") - } - return s -} - -func WithBindingAddress(ctx context.Context, address net.IP) context.Context { - return context.WithValue(ctx, bindingAddressKey, address) -} - -func BindingAddressFrom(ctx context.Context) net.IP { - obj := ctx.Value(bindingAddressKey) - if addr, ok := obj.(net.IP); ok { - return addr - } else { - return nil - } -} diff --git a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/crammd5/mechanism.go b/vendor/github.com/mesos/mesos-go/auth/sasl/mech/crammd5/mechanism.go deleted file mode 100644 index d6b4dafa155..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/crammd5/mechanism.go +++ /dev/null @@ -1,72 +0,0 @@ -package crammd5 - -import ( - "crypto/hmac" - "crypto/md5" - "encoding/hex" - "errors" - "io" - - log "github.com/golang/glog" - "github.com/mesos/mesos-go/auth/callback" - "github.com/mesos/mesos-go/auth/sasl/mech" -) - -var ( - Name = "CRAM-MD5" // name this mechanism is registered with - - //TODO(jdef) is this a generic SASL error? if so, move it up to mech - challengeDataRequired = errors.New("challenge data may not be empty") -) - -func init() { - mech.Register(Name, newInstance) -} - -type mechanism struct { - handler callback.Handler -} - -func (m *mechanism) Handler() callback.Handler { - return m.handler -} - -func (m *mechanism) Discard() { - // noop -} - -func newInstance(h callback.Handler) (mech.Interface, mech.StepFunc, error) { - m := &mechanism{ - handler: h, - } - fn := func(m mech.Interface, data []byte) (mech.StepFunc, []byte, error) { - // noop: no initialization needed - return challengeResponse, nil, nil - } - return m, fn, nil -} - -// algorithm lifted from wikipedia: http://en.wikipedia.org/wiki/CRAM-MD5 -// except that the SASL mechanism used by Mesos doesn't leverage base64 encoding -func challengeResponse(m mech.Interface, data []byte) (mech.StepFunc, []byte, error) { - if len(data) == 0 { - return mech.IllegalState, nil, challengeDataRequired - } - decoded := string(data) - log.V(4).Infof("challenge(decoded): %s", decoded) // for deep debugging only - - username := callback.NewName() - secret := callback.NewPassword() - - if err := m.Handler().Handle(username, secret); err != nil { - return mech.IllegalState, nil, err - } - hash := hmac.New(md5.New, secret.Get()) - if _, err := io.WriteString(hash, decoded); err != nil { - return mech.IllegalState, nil, err - } - - codes := hex.EncodeToString(hash.Sum(nil)) - msg := username.Get() + " " + codes - return nil, []byte(msg), nil -} diff --git a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/interface.go b/vendor/github.com/mesos/mesos-go/auth/sasl/mech/interface.go deleted file mode 100644 index 56b53bf56a5..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/interface.go +++ /dev/null @@ -1,33 +0,0 @@ -package mech - -import ( - "errors" - - "github.com/mesos/mesos-go/auth/callback" -) - -var ( - IllegalStateErr = errors.New("illegal mechanism state") -) - -type Interface interface { - Handler() callback.Handler - Discard() // clean up resources or sensitive information; idempotent -} - -// return a mechanism and it's initialization step (may be a noop that returns -// a nil data blob and handle to the first "real" challenge step). -type Factory func(h callback.Handler) (Interface, StepFunc, error) - -// StepFunc implementations should never return a nil StepFunc result. This -// helps keep the logic in the SASL authticatee simpler: step functions are -// never nil. Mechanisms that end up an error state (for example, some decoding -// logic fails...) should return a StepFunc that represents an error state. -// Some mechanisms may be able to recover from such. -type StepFunc func(m Interface, data []byte) (StepFunc, []byte, error) - -// reflects an unrecoverable, illegal mechanism state; always returns IllegalState -// as the next step along with an IllegalStateErr -func IllegalState(m Interface, data []byte) (StepFunc, []byte, error) { - return IllegalState, nil, IllegalStateErr -} diff --git a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/plugins.go b/vendor/github.com/mesos/mesos-go/auth/sasl/mech/plugins.go deleted file mode 100644 index 3642fccbeed..00000000000 --- a/vendor/github.com/mesos/mesos-go/auth/sasl/mech/plugins.go +++ /dev/null @@ -1,49 +0,0 @@ -package mech - -import ( - "fmt" - "sync" - - log "github.com/golang/glog" -) - -var ( - mechLock sync.Mutex - supportedMechs = make(map[string]Factory) -) - -func Register(name string, f Factory) error { - mechLock.Lock() - defer mechLock.Unlock() - - if _, found := supportedMechs[name]; found { - return fmt.Errorf("Mechanism registered twice: %s", name) - } - supportedMechs[name] = f - log.V(1).Infof("Registered mechanism %s", name) - return nil -} - -func ListSupported() (list []string) { - mechLock.Lock() - defer mechLock.Unlock() - - for mechname := range supportedMechs { - list = append(list, mechname) - } - return list -} - -func SelectSupported(mechanisms []string) (selectedMech string, factory Factory) { - mechLock.Lock() - defer mechLock.Unlock() - - for _, m := range mechanisms { - if f, ok := supportedMechs[m]; ok { - selectedMech = m - factory = f - break - } - } - return -} diff --git a/vendor/github.com/mesos/mesos-go/executor/doc.go b/vendor/github.com/mesos/mesos-go/executor/doc.go deleted file mode 100644 index 0f37d2c2237..00000000000 --- a/vendor/github.com/mesos/mesos-go/executor/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -/* -Package executor includes the interfaces of the mesos executor and -the mesos executor driver, as well as an implementation of the driver. -*/ -package executor diff --git a/vendor/github.com/mesos/mesos-go/executor/exectype.go b/vendor/github.com/mesos/mesos-go/executor/exectype.go deleted file mode 100644 index 1c70b4450af..00000000000 --- a/vendor/github.com/mesos/mesos-go/executor/exectype.go +++ /dev/null @@ -1,142 +0,0 @@ -package executor - -import ( - "github.com/mesos/mesos-go/mesosproto" -) - -/** - * Executor callback interface to be implemented by frameworks' executors. Note - * that only one callback will be invoked at a time, so it is not - * recommended that you block within a callback because it may cause a - * deadlock. - * - * Each callback includes an instance to the executor driver that was - * used to run this executor. The driver will not change for the - * duration of an executor (i.e., from the point you do - * ExecutorDriver.Start() to the point that ExecutorDriver.Join() - * returns). This is intended for convenience so that an executor - * doesn't need to store a pointer to the driver itself. - */ -type Executor interface { - /** - * Invoked once the executor driver has been able to successfully - * connect with Mesos. In particular, a scheduler can pass some - * data to its executors through the FrameworkInfo.ExecutorInfo's - * data field. - */ - Registered(ExecutorDriver, *mesosproto.ExecutorInfo, *mesosproto.FrameworkInfo, *mesosproto.SlaveInfo) - - /** - * Invoked when the executor re-registers with a restarted slave. - */ - Reregistered(ExecutorDriver, *mesosproto.SlaveInfo) - - /** - * Invoked when the executor becomes "disconnected" from the slave - * (e.g., the slave is being restarted due to an upgrade). - */ - Disconnected(ExecutorDriver) - - /** - * Invoked when a task has been launched on this executor (initiated - * via SchedulerDriver.LaunchTasks). Note that this task can be realized - * with a goroutine, an external process, or some simple computation, however, - * no other callbacks will be invoked on this executor until this - * callback has returned. - */ - LaunchTask(ExecutorDriver, *mesosproto.TaskInfo) - - /** - * Invoked when a task running within this executor has been killed - * (via SchedulerDriver.KillTask). Note that no status update will - * be sent on behalf of the executor, the executor is responsible - * for creating a new TaskStatus (i.e., with TASK_KILLED) and - * invoking ExecutorDriver.SendStatusUpdate. - */ - KillTask(ExecutorDriver, *mesosproto.TaskID) - - /** - * Invoked when a framework message has arrived for this - * executor. These messages are best effort; do not expect a - * framework message to be retransmitted in any reliable fashion. - */ - FrameworkMessage(ExecutorDriver, string) - - /** - * Invoked when the executor should terminate all of its currently - * running tasks. Note that after Mesos has determined that an - * executor has terminated, any tasks that the executor did not send - * terminal status updates for (e.g., TASK_KILLED, TASK_FINISHED, - * TASK_FAILED, etc) a TASK_LOST status update will be created. - */ - Shutdown(ExecutorDriver) - - /** - * Invoked when a fatal error has occured with the executor and/or - * executor driver. The driver will be aborted BEFORE invoking this - * callback. - */ - Error(ExecutorDriver, string) -} - -/** - * ExecutorDriver interface for connecting an executor to Mesos. This - * interface is used both to manage the executor's lifecycle (start - * it, stop it, or wait for it to finish) and to interact with Mesos - * (e.g., send status updates, send framework messages, etc.). - * A driver method is expected to fail-fast and return an error when possible. - * Other internal errors (or remote error) that occur asynchronously are handled - * using the the Executor.Error() callback. - */ -type ExecutorDriver interface { - /** - * Starts the executor driver. This needs to be called before any - * other driver calls are made. - */ - Start() (mesosproto.Status, error) - - /** - * Stops the executor driver. - */ - Stop() (mesosproto.Status, error) - - /** - * Aborts the driver so that no more callbacks can be made to the - * executor. The semantics of abort and stop have deliberately been - * separated so that code can detect an aborted driver (i.e., via - * the return status of ExecutorDriver.Join, see below), and - * instantiate and start another driver if desired (from within the - * same process ... although this functionality is currently not - * supported for executors). - */ - Abort() (mesosproto.Status, error) - - /** - * Waits for the driver to be stopped or aborted, possibly - * blocking the calling goroutine indefinitely. The return status of - * this function can be used to determine if the driver was aborted - * (see package mesosproto for a description of Status). - */ - Join() (mesosproto.Status, error) - - /** - * Starts and immediately joins (i.e., blocks on) the driver. - */ - Run() (mesosproto.Status, error) - - /** - * Sends a status update to the framework scheduler, retrying as - * necessary until an acknowledgement has been received or the - * executor is terminated (in which case, a TASK_LOST status update - * will be sent). See Scheduler.StatusUpdate for more information - * about status update acknowledgements. - */ - SendStatusUpdate(*mesosproto.TaskStatus) (mesosproto.Status, error) - - /** - * Sends a message to the framework scheduler. These messages are - * best effort; do not expect a framework message to be - * retransmitted in any reliable fashion. - */ - SendFrameworkMessage(string) (mesosproto.Status, error) -} diff --git a/vendor/github.com/mesos/mesos-go/executor/executor.go b/vendor/github.com/mesos/mesos-go/executor/executor.go deleted file mode 100644 index 06c0c9317eb..00000000000 --- a/vendor/github.com/mesos/mesos-go/executor/executor.go +++ /dev/null @@ -1,750 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package executor - -import ( - "fmt" - "net" - "os" - "sync" - "time" - - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/mesosutil" - "github.com/mesos/mesos-go/mesosutil/process" - "github.com/mesos/mesos-go/messenger" - "github.com/mesos/mesos-go/messenger/sessionid" - "github.com/mesos/mesos-go/upid" - "github.com/pborman/uuid" - "golang.org/x/net/context" -) - -const ( - defaultRecoveryTimeout = 15 * time.Minute -) - -type DriverConfig struct { - Executor Executor - HostnameOverride string // optional - BindingAddress net.IP // optional - BindingPort uint16 // optional - PublishedAddress net.IP // optional - NewMessenger func() (messenger.Messenger, error) // optional -} - -// MesosExecutorDriver is a implementation of the ExecutorDriver. -type MesosExecutorDriver struct { - lock sync.RWMutex - cond *sync.Cond - self *upid.UPID - stopCh chan struct{} - status mesosproto.Status - messenger messenger.Messenger - slaveUPID *upid.UPID - slaveID *mesosproto.SlaveID - frameworkID *mesosproto.FrameworkID - executorID *mesosproto.ExecutorID - workDir string - connected bool - connection uuid.UUID - local bool // TODO(yifan): Not used yet. - directory string // TODO(yifan): Not used yet. - checkpoint bool - recoveryTimeout time.Duration - recoveryTimer *time.Timer - updates map[string]*mesosproto.StatusUpdate // Key is a UUID string. TODO(yifan): Not used yet. - tasks map[string]*mesosproto.TaskInfo // Key is a UUID string. TODO(yifan): Not used yet. - withExecutor func(f func(e Executor)) - started chan struct{} // signal chan that closes once start has been invoked -} - -// NewMesosExecutorDriver creates a new mesos executor driver. -func NewMesosExecutorDriver(config DriverConfig) (*MesosExecutorDriver, error) { - if config.Executor == nil { - msg := "Executor callback interface cannot be nil." - log.Errorln(msg) - return nil, fmt.Errorf(msg) - } - - hostname := mesosutil.GetHostname(config.HostnameOverride) - newMessenger := config.NewMessenger - if newMessenger == nil { - newMessenger = func() (messenger.Messenger, error) { - process := process.New("executor") - return messenger.ForHostname(process, hostname, config.BindingAddress, config.BindingPort, config.PublishedAddress) - } - } - - driver := &MesosExecutorDriver{ - status: mesosproto.Status_DRIVER_NOT_STARTED, - stopCh: make(chan struct{}), - updates: make(map[string]*mesosproto.StatusUpdate), - tasks: make(map[string]*mesosproto.TaskInfo), - workDir: ".", - started: make(chan struct{}), - recoveryTimeout: defaultRecoveryTimeout, - } - driver.cond = sync.NewCond(&driver.lock) - // decouple serialized executor callback execution from goroutines of this driver - var execLock sync.Mutex - driver.withExecutor = func(f func(e Executor)) { - go func() { - execLock.Lock() - defer execLock.Unlock() - f(config.Executor) - }() - } - var err error - if driver.messenger, err = newMessenger(); err != nil { - return nil, err - } - if err = driver.init(); err != nil { - log.Errorf("failed to initialize the driver: %v", err) - return nil, err - } - return driver, nil -} - -// context returns the driver context, expects driver.lock to be locked -func (driver *MesosExecutorDriver) context() context.Context { - return sessionid.NewContext(context.TODO(), driver.connection.String()) -} - -// init initializes the driver. -func (driver *MesosExecutorDriver) init() error { - log.Infof("Init mesos executor driver\n") - log.Infof("Protocol Version: %v\n", mesosutil.MesosVersion) - - // Parse environments. - if err := driver.parseEnviroments(); err != nil { - log.Errorf("Failed to parse environments: %v\n", err) - return err - } - - type messageHandler func(context.Context, *upid.UPID, proto.Message) - - guard := func(h messageHandler) messenger.MessageHandler { - return messenger.MessageHandler(func(from *upid.UPID, pbMsg proto.Message) { - driver.lock.Lock() - defer driver.lock.Unlock() - h(driver.context(), from, pbMsg) - }) - } - - // Install handlers. - driver.messenger.Install(guard(driver.registered), &mesosproto.ExecutorRegisteredMessage{}) - driver.messenger.Install(guard(driver.reregistered), &mesosproto.ExecutorReregisteredMessage{}) - driver.messenger.Install(guard(driver.reconnect), &mesosproto.ReconnectExecutorMessage{}) - driver.messenger.Install(guard(driver.runTask), &mesosproto.RunTaskMessage{}) - driver.messenger.Install(guard(driver.killTask), &mesosproto.KillTaskMessage{}) - driver.messenger.Install(guard(driver.statusUpdateAcknowledgement), &mesosproto.StatusUpdateAcknowledgementMessage{}) - driver.messenger.Install(guard(driver.frameworkMessage), &mesosproto.FrameworkToExecutorMessage{}) - driver.messenger.Install(guard(driver.shutdown), &mesosproto.ShutdownExecutorMessage{}) - driver.messenger.Install(guard(driver.frameworkError), &mesosproto.FrameworkErrorMessage{}) - driver.messenger.Install(guard(driver.networkError), &mesosproto.InternalNetworkError{}) - return nil -} - -func (driver *MesosExecutorDriver) parseEnviroments() error { - var value string - - value = os.Getenv("MESOS_LOCAL") - if len(value) > 0 { - driver.local = true - } - - value = os.Getenv("MESOS_SLAVE_PID") - if len(value) == 0 { - return fmt.Errorf("Cannot find MESOS_SLAVE_PID in the environment") - } - upid, err := upid.Parse(value) - if err != nil { - log.Errorf("Cannot parse UPID %v\n", err) - return err - } - driver.slaveUPID = upid - - value = os.Getenv("MESOS_SLAVE_ID") - driver.slaveID = &mesosproto.SlaveID{Value: proto.String(value)} - - value = os.Getenv("MESOS_FRAMEWORK_ID") - driver.frameworkID = &mesosproto.FrameworkID{Value: proto.String(value)} - - value = os.Getenv("MESOS_EXECUTOR_ID") - driver.executorID = &mesosproto.ExecutorID{Value: proto.String(value)} - - value = os.Getenv("MESOS_DIRECTORY") - if len(value) > 0 { - driver.workDir = value - } - - value = os.Getenv("MESOS_CHECKPOINT") - if value == "1" { - driver.checkpoint = true - } - - /* - if driver.checkpoint { - value = os.Getenv("MESOS_RECOVERY_TIMEOUT") - } - // TODO(yifan): Parse the duration. For now just use default. - */ - return nil -} - -// ------------------------- Accessors ----------------------- // -func (driver *MesosExecutorDriver) Status() mesosproto.Status { - driver.lock.RLock() - defer driver.lock.RUnlock() - return driver.status -} - -func (driver *MesosExecutorDriver) Running() bool { - driver.lock.RLock() - defer driver.lock.RUnlock() - return driver.status == mesosproto.Status_DRIVER_RUNNING -} - -func (driver *MesosExecutorDriver) stopped() bool { - return driver.status != mesosproto.Status_DRIVER_RUNNING -} - -func (driver *MesosExecutorDriver) Connected() bool { - driver.lock.RLock() - defer driver.lock.RUnlock() - return driver.connected -} - -// --------------------- Message Handlers --------------------- // - -// networkError is invoked when there's a network-level error communicating with the mesos slave. -// The driver reacts by entering a "disconnected" state and invoking the Executor.Disconnected -// callback. The assumption is that if this driver was previously connected, and then there's a -// network error, then the slave process must be dying/dead. The native driver implementation makes -// this same assumption. I have some concerns that this may be a false-positive in some situations; -// some network errors (timeouts) may be indicative of something other than a dead slave process. -func (driver *MesosExecutorDriver) networkError(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Info("ignoring network error because aborted") - return - } - if driver.connected { - driver.connected = false - msg := pbMsg.(*mesosproto.InternalNetworkError) - session := msg.GetSession() - - if session != driver.connection.String() { - log.V(1).Infoln("ignoring netwok error for disconnected/stale session") - return - } - - if driver.checkpoint { - log.Infoln("slave disconnected, will wait for recovery") - driver.withExecutor(func(e Executor) { e.Disconnected(driver) }) - - if driver.recoveryTimer != nil { - driver.recoveryTimer.Stop() - } - t := time.NewTimer(driver.recoveryTimeout) - driver.recoveryTimer = t - go func() { - select { - case <-t.C: - // timer expired - driver.lock.Lock() - defer driver.lock.Unlock() - driver.recoveryTimedOut(session) - - case <-driver.stopCh: - // driver stopped - return - } - }() - return - } - } - log.Infoln("slave exited ... shutting down") - driver.withExecutor(func(e Executor) { e.Shutdown(driver) }) // abnormal shutdown - driver.abort() -} - -func (driver *MesosExecutorDriver) recoveryTimedOut(connection string) { - if driver.connected { - return - } - // ensure that connection ID's match otherwise we've been re-registered - if connection == driver.connection.String() { - log.Info("recovery timeout of %v exceeded; shutting down", driver.recoveryTimeout) - driver.shutdown(driver.context(), nil, nil) - } -} - -func (driver *MesosExecutorDriver) registered(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring registration message from slave because aborted") - return - } - log.Infoln("Executor driver registered") - - msg := pbMsg.(*mesosproto.ExecutorRegisteredMessage) - slaveID := msg.GetSlaveId() - executorInfo := msg.GetExecutorInfo() - frameworkInfo := msg.GetFrameworkInfo() - slaveInfo := msg.GetSlaveInfo() - - if driver.stopped() { - log.Infof("Ignoring registered message from slave %v, because the driver is stopped!\n", slaveID) - return - } - - log.Infof("Registered on slave %v\n", slaveID) - driver.connected = true - driver.connection = uuid.NewUUID() - driver.cond.Broadcast() // useful for testing - driver.withExecutor(func(e Executor) { e.Registered(driver, executorInfo, frameworkInfo, slaveInfo) }) -} - -func (driver *MesosExecutorDriver) reregistered(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring reregistration message from slave because aborted") - return - } - log.Infoln("Executor driver reregistered") - - msg := pbMsg.(*mesosproto.ExecutorReregisteredMessage) - slaveID := msg.GetSlaveId() - slaveInfo := msg.GetSlaveInfo() - - if driver.stopped() { - log.Infof("Ignoring re-registered message from slave %v, because the driver is stopped!\n", slaveID) - return - } - - log.Infof("Re-registered on slave %v\n", slaveID) - driver.connected = true - driver.connection = uuid.NewUUID() - driver.cond.Broadcast() // useful for testing - driver.withExecutor(func(e Executor) { e.Reregistered(driver, slaveInfo) }) -} - -func (driver *MesosExecutorDriver) send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { - c := make(chan error, 1) - go func() { c <- driver.messenger.Send(ctx, upid, msg) }() - - select { - case <-ctx.Done(): - <-c // wait for Send(...) - return ctx.Err() - case err := <-c: - return err - } -} - -func (driver *MesosExecutorDriver) reconnect(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring reconnect message from slave because aborted") - return - } - log.Infoln("Executor driver reconnect") - - msg := pbMsg.(*mesosproto.ReconnectExecutorMessage) - slaveID := msg.GetSlaveId() - - if driver.stopped() { - log.Infof("Ignoring reconnect message from slave %v, because the driver is stopped!\n", slaveID) - return - } - - log.Infof("Received reconnect request from slave %v\n", slaveID) - driver.slaveUPID = from - - message := &mesosproto.ReregisterExecutorMessage{ - ExecutorId: driver.executorID, - FrameworkId: driver.frameworkID, - } - // Send all unacknowledged updates. - for _, u := range driver.updates { - message.Updates = append(message.Updates, u) - } - // Send all unacknowledged tasks. - for _, t := range driver.tasks { - message.Tasks = append(message.Tasks, t) - } - // Send the message. - if err := driver.send(ctx, driver.slaveUPID, message); err != nil { - log.Errorf("Failed to send %v: %v\n", message, err) - } -} - -func (driver *MesosExecutorDriver) runTask(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring runTask message from slave because aborted") - return - } - log.Infoln("Executor driver runTask") - - msg := pbMsg.(*mesosproto.RunTaskMessage) - task := msg.GetTask() - taskID := task.GetTaskId() - - if driver.stopped() { - log.Infof("Ignoring run task message for task %v because the driver is stopped!\n", taskID) - return - } - if _, ok := driver.tasks[taskID.String()]; ok { - log.Fatalf("Unexpected duplicate task %v\n", taskID) - } - - log.Infof("Executor asked to run task '%v'\n", taskID) - driver.tasks[taskID.String()] = task - driver.withExecutor(func(e Executor) { e.LaunchTask(driver, task) }) -} - -func (driver *MesosExecutorDriver) killTask(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring killTask message from slave because aborted") - return - } - log.Infoln("Executor driver killTask") - - msg := pbMsg.(*mesosproto.KillTaskMessage) - taskID := msg.GetTaskId() - - if driver.stopped() { - log.Infof("Ignoring kill task message for task %v, because the driver is stopped!\n", taskID) - return - } - - log.Infof("Executor driver is asked to kill task '%v'\n", taskID) - driver.withExecutor(func(e Executor) { e.KillTask(driver, taskID) }) -} - -func (driver *MesosExecutorDriver) statusUpdateAcknowledgement(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring status update ack message because aborted") - return - } - log.Infoln("Executor statusUpdateAcknowledgement") - - msg := pbMsg.(*mesosproto.StatusUpdateAcknowledgementMessage) - log.Infof("Receiving status update acknowledgement %v", msg) - - frameworkID := msg.GetFrameworkId() - taskID := msg.GetTaskId() - uuid := uuid.UUID(msg.GetUuid()) - - if driver.stopped() { - log.Infof("Ignoring status update acknowledgement %v for task %v of framework %v because the driver is stopped!\n", - uuid, taskID, frameworkID) - } - - // Remove the corresponding update. - delete(driver.updates, uuid.String()) - // Remove the corresponding task. - delete(driver.tasks, taskID.String()) -} - -func (driver *MesosExecutorDriver) frameworkMessage(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring frameworkMessage message from slave because aborted") - return - } - log.Infoln("Executor driver received frameworkMessage") - - msg := pbMsg.(*mesosproto.FrameworkToExecutorMessage) - data := msg.GetData() - - if driver.stopped() { - log.Infof("Ignoring framework message because the driver is stopped!\n") - return - } - - log.Infof("Executor driver receives framework message\n") - driver.withExecutor(func(e Executor) { e.FrameworkMessage(driver, string(data)) }) -} - -func (driver *MesosExecutorDriver) shutdown(_ context.Context, _ *upid.UPID, _ proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring shutdown message because aborted") - return - } - log.Infoln("Executor driver received shutdown") - - if driver.stopped() { - log.Infof("Ignoring shutdown message because the driver is stopped!\n") - return - } - - log.Infof("Executor driver is asked to shutdown\n") - - driver.withExecutor(func(e Executor) { e.Shutdown(driver) }) - // driver.stop() will cause process to eventually stop. - driver.stop() -} - -func (driver *MesosExecutorDriver) frameworkError(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesosproto.Status_DRIVER_ABORTED { - log.V(1).Infof("ignoring framework error message because aborted") - return - } - log.Infoln("Executor driver received error") - - msg := pbMsg.(*mesosproto.FrameworkErrorMessage) - driver.withExecutor(func(e Executor) { e.Error(driver, msg.GetMessage()) }) -} - -// ------------------------ Driver Implementation ----------------- // - -// Start starts the executor driver -func (driver *MesosExecutorDriver) Start() (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.start() -} - -func (driver *MesosExecutorDriver) start() (mesosproto.Status, error) { - log.Infoln("Starting the executor driver") - - if driver.status != mesosproto.Status_DRIVER_NOT_STARTED { - return driver.status, fmt.Errorf("Unable to Start, expecting status %s, but got %s", mesosproto.Status_DRIVER_NOT_STARTED, driver.status) - } - - // Start the messenger. - if err := driver.messenger.Start(); err != nil { - log.Errorf("Failed to start executor: %v\n", err) - return driver.status, err - } - - pid := driver.messenger.UPID() - driver.self = &pid - - // Register with slave. - log.V(3).Infoln("Sending Executor registration") - message := &mesosproto.RegisterExecutorMessage{ - FrameworkId: driver.frameworkID, - ExecutorId: driver.executorID, - } - - if err := driver.send(driver.context(), driver.slaveUPID, message); err != nil { - log.Errorf("Stopping the executor, failed to send %v: %v\n", message, err) - err0 := driver._stop(driver.status) - if err0 != nil { - log.Errorf("Failed to stop executor: %v\n", err) - return driver.status, err0 - } - return driver.status, err - } - - driver.status = mesosproto.Status_DRIVER_RUNNING - close(driver.started) - - log.Infoln("Mesos executor is started with PID=", driver.self.String()) - return driver.status, nil -} - -// Stop stops the driver by sending a 'stopEvent' to the event loop, and -// receives the result from the response channel. -func (driver *MesosExecutorDriver) Stop() (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.stop() -} - -func (driver *MesosExecutorDriver) stop() (mesosproto.Status, error) { - log.Infoln("Stopping the executor driver") - if driver.status != mesosproto.Status_DRIVER_RUNNING { - return driver.status, fmt.Errorf("Unable to Stop, expecting status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - return mesosproto.Status_DRIVER_STOPPED, driver._stop(mesosproto.Status_DRIVER_STOPPED) -} - -// internal function for stopping the driver and set reason for stopping -// Note that messages inflight or queued will not be processed. -func (driver *MesosExecutorDriver) _stop(stopStatus mesosproto.Status) error { - err := driver.messenger.Stop() - defer func() { - select { - case <-driver.stopCh: - // already closed - default: - close(driver.stopCh) - } - driver.cond.Broadcast() - }() - - driver.status = stopStatus - if err != nil { - return err - } - return nil -} - -// Abort aborts the driver by sending an 'abortEvent' to the event loop, and -// receives the result from the response channel. -func (driver *MesosExecutorDriver) Abort() (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.abort() -} - -func (driver *MesosExecutorDriver) abort() (mesosproto.Status, error) { - if driver.status != mesosproto.Status_DRIVER_RUNNING { - return driver.status, fmt.Errorf("Unable to Stop, expecting status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - - log.Infoln("Aborting the executor driver") - return mesosproto.Status_DRIVER_ABORTED, driver._stop(mesosproto.Status_DRIVER_ABORTED) -} - -// Join waits for the driver by sending a 'joinEvent' to the event loop, and wait -// on a channel for the notification of driver termination. -func (driver *MesosExecutorDriver) Join() (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.join() -} - -func (driver *MesosExecutorDriver) join() (mesosproto.Status, error) { - log.Infoln("Waiting for the executor driver to stop") - if driver.status != mesosproto.Status_DRIVER_RUNNING { - return driver.status, fmt.Errorf("Unable to Join, expecting status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - for { - select { - case <-driver.stopCh: // wait for stop signal - return driver.status, nil - default: - driver.cond.Wait() - } - } -} - -// Run starts the driver and calls Join() to wait for stop request. -func (driver *MesosExecutorDriver) Run() (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.run() -} - -func (driver *MesosExecutorDriver) run() (mesosproto.Status, error) { - stat, err := driver.start() - - if err != nil { - return driver.stop() - } - - if stat != mesosproto.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to continue to Run, expecting status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - - return driver.join() -} - -// SendStatusUpdate sends status updates to the slave. -func (driver *MesosExecutorDriver) SendStatusUpdate(taskStatus *mesosproto.TaskStatus) (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.sendStatusUpdate(taskStatus) -} - -func (driver *MesosExecutorDriver) sendStatusUpdate(taskStatus *mesosproto.TaskStatus) (mesosproto.Status, error) { - log.V(3).Infoln("Sending task status update: ", taskStatus.String()) - - if driver.status != mesosproto.Status_DRIVER_RUNNING { - return driver.status, fmt.Errorf("Unable to SendStatusUpdate, expecting driver.status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - - if taskStatus.GetState() == mesosproto.TaskState_TASK_STAGING { - err := fmt.Errorf("Executor is not allowed to send TASK_STAGING status update. Aborting!") - log.Errorln(err) - if err0 := driver._stop(mesosproto.Status_DRIVER_ABORTED); err0 != nil { - log.Errorln("Error while stopping the driver", err0) - } - - return driver.status, err - } - - // Set up status update. - update := driver.makeStatusUpdate(taskStatus) - log.Infof("Executor sending status update %v\n", update.String()) - - // Capture the status update. - driver.updates[uuid.UUID(update.GetUuid()).String()] = update - - // Put the status update in the message. - message := &mesosproto.StatusUpdateMessage{ - Update: update, - Pid: proto.String(driver.self.String()), - } - // Send the message. - if err := driver.send(driver.context(), driver.slaveUPID, message); err != nil { - log.Errorf("Failed to send %v: %v\n", message, err) - return driver.status, err - } - - return driver.status, nil -} - -func (driver *MesosExecutorDriver) makeStatusUpdate(taskStatus *mesosproto.TaskStatus) *mesosproto.StatusUpdate { - now := float64(time.Now().Unix()) - // Fill in all the fields. - taskStatus.Timestamp = proto.Float64(now) - taskStatus.SlaveId = driver.slaveID - update := &mesosproto.StatusUpdate{ - FrameworkId: driver.frameworkID, - ExecutorId: driver.executorID, - SlaveId: driver.slaveID, - Status: taskStatus, - Timestamp: proto.Float64(now), - Uuid: uuid.NewUUID(), - } - return update -} - -// SendFrameworkMessage sends the framework message by sending a 'sendFrameworkMessageEvent' -// to the event loop, and receives the result from the response channel. -func (driver *MesosExecutorDriver) SendFrameworkMessage(data string) (mesosproto.Status, error) { - driver.lock.Lock() - defer driver.lock.Unlock() - return driver.sendFrameworkMessage(data) -} - -func (driver *MesosExecutorDriver) sendFrameworkMessage(data string) (mesosproto.Status, error) { - log.V(3).Infoln("Sending framework message", string(data)) - - if driver.status != mesosproto.Status_DRIVER_RUNNING { - return driver.status, fmt.Errorf("Unable to SendFrameworkMessage, expecting status %s, but got %s", mesosproto.Status_DRIVER_RUNNING, driver.status) - } - - message := &mesosproto.ExecutorToFrameworkMessage{ - SlaveId: driver.slaveID, - FrameworkId: driver.frameworkID, - ExecutorId: driver.executorID, - Data: []byte(data), - } - - // Send the message. - if err := driver.send(driver.context(), driver.slaveUPID, message); err != nil { - log.Errorln("Failed to send message %v: %v", message, err) - return driver.status, err - } - return driver.status, nil -} diff --git a/vendor/github.com/mesos/mesos-go/executor/testing.go b/vendor/github.com/mesos/mesos-go/executor/testing.go deleted file mode 100644 index c3cb0e5d584..00000000000 --- a/vendor/github.com/mesos/mesos-go/executor/testing.go +++ /dev/null @@ -1,42 +0,0 @@ -package executor - -import ( - "github.com/gogo/protobuf/proto" - "github.com/mesos/mesos-go/messenger" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -type TestDriver struct { - *MesosExecutorDriver -} - -func (e *TestDriver) SetConnected(b bool) { - e.guarded(func() { - e.connected = b - }) -} - -func (e *TestDriver) SetMessenger(m messenger.Messenger) { - e.messenger = m -} - -func (e *TestDriver) Started() <-chan struct{} { - return e.started -} - -func (e *TestDriver) guarded(f func()) { - e.lock.Lock() - defer e.lock.Unlock() - f() -} - -func (e *TestDriver) Context() context.Context { - return e.context() -} - -func (e *TestDriver) StatusUpdateAcknowledgement(ctx context.Context, from *upid.UPID, msg proto.Message) { - e.guarded(func() { - e.statusUpdateAcknowledgement(ctx, from, msg) - }) -} diff --git a/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.pb.go b/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.pb.go deleted file mode 100644 index 486868eb605..00000000000 --- a/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.pb.go +++ /dev/null @@ -1,7536 +0,0 @@ -// Code generated by protoc-gen-gogo. -// source: scheduler/scheduler.proto -// DO NOT EDIT! - -/* - Package scheduler is a generated protocol buffer package. - - It is generated from these files: - scheduler/scheduler.proto - - It has these top-level messages: - Event - Call -*/ -package scheduler - -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" -import mesosproto "github.com/mesos/mesos-go/mesosproto" - -// discarding unused import gogoproto "github.com/gogo/protobuf/gogoproto" - -import bytes "bytes" - -import strings "strings" -import github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" -import sort "sort" -import strconv "strconv" -import reflect "reflect" - -import io "io" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// Possible event types, followed by message definitions if -// applicable. -type Event_Type int32 - -const ( - Event_SUBSCRIBED Event_Type = 1 - Event_OFFERS Event_Type = 2 - Event_RESCIND Event_Type = 3 - Event_UPDATE Event_Type = 4 - Event_MESSAGE Event_Type = 5 - Event_FAILURE Event_Type = 6 - Event_ERROR Event_Type = 7 - // Periodic message sent by the Mesos master according to - // 'Subscribed.heartbeat_interval_seconds'. If the scheduler does - // not receive any events (including heartbeats) for an extended - // period of time (e.g., 5 x heartbeat_interval_seconds), there is - // likely a network partition. In such a case the scheduler should - // close the existing subscription connection and resubscribe - // using a backoff strategy. - Event_HEARTBEAT Event_Type = 8 -) - -var Event_Type_name = map[int32]string{ - 1: "SUBSCRIBED", - 2: "OFFERS", - 3: "RESCIND", - 4: "UPDATE", - 5: "MESSAGE", - 6: "FAILURE", - 7: "ERROR", - 8: "HEARTBEAT", -} -var Event_Type_value = map[string]int32{ - "SUBSCRIBED": 1, - "OFFERS": 2, - "RESCIND": 3, - "UPDATE": 4, - "MESSAGE": 5, - "FAILURE": 6, - "ERROR": 7, - "HEARTBEAT": 8, -} - -func (x Event_Type) Enum() *Event_Type { - p := new(Event_Type) - *p = x - return p -} -func (x Event_Type) String() string { - return proto.EnumName(Event_Type_name, int32(x)) -} -func (x *Event_Type) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Event_Type_value, data, "Event_Type") - if err != nil { - return err - } - *x = Event_Type(value) - return nil -} - -// Possible call types, followed by message definitions if -// applicable. -type Call_Type int32 - -const ( - Call_SUBSCRIBE Call_Type = 1 - Call_TEARDOWN Call_Type = 2 - Call_ACCEPT Call_Type = 3 - Call_DECLINE Call_Type = 4 - Call_REVIVE Call_Type = 5 - Call_KILL Call_Type = 6 - Call_SHUTDOWN Call_Type = 7 - Call_ACKNOWLEDGE Call_Type = 8 - Call_RECONCILE Call_Type = 9 - Call_MESSAGE Call_Type = 10 - Call_REQUEST Call_Type = 11 - Call_SUPPRESS Call_Type = 12 -) - -var Call_Type_name = map[int32]string{ - 1: "SUBSCRIBE", - 2: "TEARDOWN", - 3: "ACCEPT", - 4: "DECLINE", - 5: "REVIVE", - 6: "KILL", - 7: "SHUTDOWN", - 8: "ACKNOWLEDGE", - 9: "RECONCILE", - 10: "MESSAGE", - 11: "REQUEST", - 12: "SUPPRESS", -} -var Call_Type_value = map[string]int32{ - "SUBSCRIBE": 1, - "TEARDOWN": 2, - "ACCEPT": 3, - "DECLINE": 4, - "REVIVE": 5, - "KILL": 6, - "SHUTDOWN": 7, - "ACKNOWLEDGE": 8, - "RECONCILE": 9, - "MESSAGE": 10, - "REQUEST": 11, - "SUPPRESS": 12, -} - -func (x Call_Type) Enum() *Call_Type { - p := new(Call_Type) - *p = x - return p -} -func (x Call_Type) String() string { - return proto.EnumName(Call_Type_name, int32(x)) -} -func (x *Call_Type) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Call_Type_value, data, "Call_Type") - if err != nil { - return err - } - *x = Call_Type(value) - return nil -} - -// * -// Scheduler event API. -// -// An event is described using the standard protocol buffer "union" -// trick, see: -// https://developers.google.com/protocol-buffers/docs/techniques#union. -type Event struct { - // Type of the event, indicates which optional field below should be - // present if that type has a nested message definition. - Type *Event_Type `protobuf:"varint,1,req,name=type,enum=mesosproto.scheduler.Event_Type" json:"type,omitempty"` - Subscribed *Event_Subscribed `protobuf:"bytes,2,opt,name=subscribed" json:"subscribed,omitempty"` - Offers *Event_Offers `protobuf:"bytes,3,opt,name=offers" json:"offers,omitempty"` - Rescind *Event_Rescind `protobuf:"bytes,4,opt,name=rescind" json:"rescind,omitempty"` - Update *Event_Update `protobuf:"bytes,5,opt,name=update" json:"update,omitempty"` - Message *Event_Message `protobuf:"bytes,6,opt,name=message" json:"message,omitempty"` - Failure *Event_Failure `protobuf:"bytes,7,opt,name=failure" json:"failure,omitempty"` - Error *Event_Error `protobuf:"bytes,8,opt,name=error" json:"error,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event) Reset() { *m = Event{} } -func (*Event) ProtoMessage() {} - -func (m *Event) GetType() Event_Type { - if m != nil && m.Type != nil { - return *m.Type - } - return Event_SUBSCRIBED -} - -func (m *Event) GetSubscribed() *Event_Subscribed { - if m != nil { - return m.Subscribed - } - return nil -} - -func (m *Event) GetOffers() *Event_Offers { - if m != nil { - return m.Offers - } - return nil -} - -func (m *Event) GetRescind() *Event_Rescind { - if m != nil { - return m.Rescind - } - return nil -} - -func (m *Event) GetUpdate() *Event_Update { - if m != nil { - return m.Update - } - return nil -} - -func (m *Event) GetMessage() *Event_Message { - if m != nil { - return m.Message - } - return nil -} - -func (m *Event) GetFailure() *Event_Failure { - if m != nil { - return m.Failure - } - return nil -} - -func (m *Event) GetError() *Event_Error { - if m != nil { - return m.Error - } - return nil -} - -// First event received when the scheduler subscribes. -type Event_Subscribed struct { - FrameworkId *mesosproto.FrameworkID `protobuf:"bytes,1,req,name=framework_id" json:"framework_id,omitempty"` - // This value will be set if the master is sending heartbeats. See - // the comment above on 'HEARTBEAT' for more details. - HeartbeatIntervalSeconds *float64 `protobuf:"fixed64,2,opt,name=heartbeat_interval_seconds" json:"heartbeat_interval_seconds,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Subscribed) Reset() { *m = Event_Subscribed{} } -func (*Event_Subscribed) ProtoMessage() {} - -func (m *Event_Subscribed) GetFrameworkId() *mesosproto.FrameworkID { - if m != nil { - return m.FrameworkId - } - return nil -} - -func (m *Event_Subscribed) GetHeartbeatIntervalSeconds() float64 { - if m != nil && m.HeartbeatIntervalSeconds != nil { - return *m.HeartbeatIntervalSeconds - } - return 0 -} - -// Received whenever there are new resources that are offered to the -// scheduler or resources requested back from the scheduler. Each -// offer corresponds to a set of resources on a slave. Until the -// scheduler accepts or declines an offer the resources are -// considered allocated to the scheduler. Accepting or Declining an -// inverse offer informs the allocator of the scheduler's ability to -// release the resources without violating an SLA. -type Event_Offers struct { - Offers []*mesosproto.Offer `protobuf:"bytes,1,rep,name=offers" json:"offers,omitempty"` - InverseOffers []*mesosproto.InverseOffer `protobuf:"bytes,2,rep,name=inverse_offers" json:"inverse_offers,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Offers) Reset() { *m = Event_Offers{} } -func (*Event_Offers) ProtoMessage() {} - -func (m *Event_Offers) GetOffers() []*mesosproto.Offer { - if m != nil { - return m.Offers - } - return nil -} - -func (m *Event_Offers) GetInverseOffers() []*mesosproto.InverseOffer { - if m != nil { - return m.InverseOffers - } - return nil -} - -// Received when a particular offer is no longer valid (e.g., the -// slave corresponding to the offer has been removed) and hence -// needs to be rescinded. Any future calls ('Accept' / 'Decline') made -// by the scheduler regarding this offer will be invalid. -type Event_Rescind struct { - OfferId *mesosproto.OfferID `protobuf:"bytes,1,req,name=offer_id" json:"offer_id,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Rescind) Reset() { *m = Event_Rescind{} } -func (*Event_Rescind) ProtoMessage() {} - -func (m *Event_Rescind) GetOfferId() *mesosproto.OfferID { - if m != nil { - return m.OfferId - } - return nil -} - -// Received whenever there is a status update that is generated by -// the executor or slave or master. Status updates should be used by -// executors to reliably communicate the status of the tasks that -// they manage. It is crucial that a terminal update (see TaskState -// in mesos.proto) is sent by the executor as soon as the task -// terminates, in order for Mesos to release the resources allocated -// to the task. It is also the responsibility of the scheduler to -// explicitly acknowledge the receipt of a status update. See -// 'Acknowledge' in the 'Call' section below for the semantics. -type Event_Update struct { - Status *mesosproto.TaskStatus `protobuf:"bytes,1,req,name=status" json:"status,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Update) Reset() { *m = Event_Update{} } -func (*Event_Update) ProtoMessage() {} - -func (m *Event_Update) GetStatus() *mesosproto.TaskStatus { - if m != nil { - return m.Status - } - return nil -} - -// Received when a custom message generated by the executor is -// forwarded by the master. Note that this message is not -// interpreted by Mesos and is only forwarded (without reliability -// guarantees) to the scheduler. It is up to the executor to retry -// if the message is dropped for any reason. -type Event_Message struct { - SlaveId *mesosproto.SlaveID `protobuf:"bytes,1,req,name=slave_id" json:"slave_id,omitempty"` - ExecutorId *mesosproto.ExecutorID `protobuf:"bytes,2,req,name=executor_id" json:"executor_id,omitempty"` - Data []byte `protobuf:"bytes,3,req,name=data" json:"data,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Message) Reset() { *m = Event_Message{} } -func (*Event_Message) ProtoMessage() {} - -func (m *Event_Message) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -func (m *Event_Message) GetExecutorId() *mesosproto.ExecutorID { - if m != nil { - return m.ExecutorId - } - return nil -} - -func (m *Event_Message) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -// Received when a slave is removed from the cluster (e.g., failed -// health checks) or when an executor is terminated. Note that, this -// event coincides with receipt of terminal UPDATE events for any -// active tasks belonging to the slave or executor and receipt of -// 'Rescind' events for any outstanding offers belonging to the -// slave. Note that there is no guaranteed order between the -// 'Failure', 'Update' and 'Rescind' events when a slave or executor -// is removed. -// TODO(vinod): Consider splitting the lost slave and terminated -// executor into separate events and ensure it's reliably generated. -type Event_Failure struct { - SlaveId *mesosproto.SlaveID `protobuf:"bytes,1,opt,name=slave_id" json:"slave_id,omitempty"` - // If this was just a failure of an executor on a slave then - // 'executor_id' will be set and possibly 'status' (if we were - // able to determine the exit status). - ExecutorId *mesosproto.ExecutorID `protobuf:"bytes,2,opt,name=executor_id" json:"executor_id,omitempty"` - Status *int32 `protobuf:"varint,3,opt,name=status" json:"status,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Failure) Reset() { *m = Event_Failure{} } -func (*Event_Failure) ProtoMessage() {} - -func (m *Event_Failure) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -func (m *Event_Failure) GetExecutorId() *mesosproto.ExecutorID { - if m != nil { - return m.ExecutorId - } - return nil -} - -func (m *Event_Failure) GetStatus() int32 { - if m != nil && m.Status != nil { - return *m.Status - } - return 0 -} - -// Received when an invalid framework (e.g., unauthenticated, -// unauthorized) attempts to subscribe with the master. Error can -// also be received if scheduler sends invalid Calls (e.g., not -// properly initialized). -// TODO(vinod): Remove this once the old scheduler driver is no -// longer supported. With HTTP API all errors will be signaled via -// HTTP response codes. -type Event_Error struct { - Message *string `protobuf:"bytes,1,req,name=message" json:"message,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Event_Error) Reset() { *m = Event_Error{} } -func (*Event_Error) ProtoMessage() {} - -func (m *Event_Error) GetMessage() string { - if m != nil && m.Message != nil { - return *m.Message - } - return "" -} - -// * -// Scheduler call API. -// -// Like Event, a Call is described using the standard protocol buffer -// "union" trick (see above). -type Call struct { - // Identifies who generated this call. Master assigns a framework id - // when a new scheduler subscribes for the first time. Once assigned, - // the scheduler must set the 'framework_id' here and within its - // FrameworkInfo (in any further 'Subscribe' calls). This allows the - // master to identify a scheduler correctly across disconnections, - // failovers, etc. - FrameworkId *mesosproto.FrameworkID `protobuf:"bytes,1,opt,name=framework_id" json:"framework_id,omitempty"` - // Type of the call, indicates which optional field below should be - // present if that type has a nested message definition. - Type *Call_Type `protobuf:"varint,2,req,name=type,enum=mesosproto.scheduler.Call_Type" json:"type,omitempty"` - Subscribe *Call_Subscribe `protobuf:"bytes,3,opt,name=subscribe" json:"subscribe,omitempty"` - Accept *Call_Accept `protobuf:"bytes,4,opt,name=accept" json:"accept,omitempty"` - Decline *Call_Decline `protobuf:"bytes,5,opt,name=decline" json:"decline,omitempty"` - Kill *Call_Kill `protobuf:"bytes,6,opt,name=kill" json:"kill,omitempty"` - Shutdown *Call_Shutdown `protobuf:"bytes,7,opt,name=shutdown" json:"shutdown,omitempty"` - Acknowledge *Call_Acknowledge `protobuf:"bytes,8,opt,name=acknowledge" json:"acknowledge,omitempty"` - Reconcile *Call_Reconcile `protobuf:"bytes,9,opt,name=reconcile" json:"reconcile,omitempty"` - Message *Call_Message `protobuf:"bytes,10,opt,name=message" json:"message,omitempty"` - Request *Call_Request `protobuf:"bytes,11,opt,name=request" json:"request,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call) Reset() { *m = Call{} } -func (*Call) ProtoMessage() {} - -func (m *Call) GetFrameworkId() *mesosproto.FrameworkID { - if m != nil { - return m.FrameworkId - } - return nil -} - -func (m *Call) GetType() Call_Type { - if m != nil && m.Type != nil { - return *m.Type - } - return Call_SUBSCRIBE -} - -func (m *Call) GetSubscribe() *Call_Subscribe { - if m != nil { - return m.Subscribe - } - return nil -} - -func (m *Call) GetAccept() *Call_Accept { - if m != nil { - return m.Accept - } - return nil -} - -func (m *Call) GetDecline() *Call_Decline { - if m != nil { - return m.Decline - } - return nil -} - -func (m *Call) GetKill() *Call_Kill { - if m != nil { - return m.Kill - } - return nil -} - -func (m *Call) GetShutdown() *Call_Shutdown { - if m != nil { - return m.Shutdown - } - return nil -} - -func (m *Call) GetAcknowledge() *Call_Acknowledge { - if m != nil { - return m.Acknowledge - } - return nil -} - -func (m *Call) GetReconcile() *Call_Reconcile { - if m != nil { - return m.Reconcile - } - return nil -} - -func (m *Call) GetMessage() *Call_Message { - if m != nil { - return m.Message - } - return nil -} - -func (m *Call) GetRequest() *Call_Request { - if m != nil { - return m.Request - } - return nil -} - -// Subscribes the scheduler with the master to receive events. A -// scheduler must send other calls only after it has received the -// SUBCRIBED event. -type Call_Subscribe struct { - // See the comments below on 'framework_id' on the semantics for - // 'framework_info.id'. - FrameworkInfo *mesosproto.FrameworkInfo `protobuf:"bytes,1,req,name=framework_info" json:"framework_info,omitempty"` - // 'force' field is only relevant when 'framework_info.id' is set. - // It tells the master what to do in case an instance of the - // scheduler attempts to subscribe when another instance of it is - // already connected (e.g., split brain due to network partition). - // If 'force' is true, this scheduler instance is allowed and the - // old connected scheduler instance is disconnected. If false, - // this scheduler instance is disallowed subscription in favor of - // the already connected scheduler instance. - // - // It is recommended to set this to true only when a newly elected - // scheduler instance is attempting to subscribe but not when a - // scheduler is retrying subscription (e.g., disconnection or - // master failover; see sched/sched.cpp for an example). - Force *bool `protobuf:"varint,2,opt,name=force" json:"force,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Subscribe) Reset() { *m = Call_Subscribe{} } -func (*Call_Subscribe) ProtoMessage() {} - -func (m *Call_Subscribe) GetFrameworkInfo() *mesosproto.FrameworkInfo { - if m != nil { - return m.FrameworkInfo - } - return nil -} - -func (m *Call_Subscribe) GetForce() bool { - if m != nil && m.Force != nil { - return *m.Force - } - return false -} - -// Accepts an offer, performing the specified operations -// in a sequential manner. -// -// E.g. Launch a task with a newly reserved persistent volume: -// -// Accept { -// offer_ids: [ ... ] -// operations: [ -// { type: RESERVE, -// reserve: { resources: [ disk(role):2 ] } } -// { type: CREATE, -// create: { volumes: [ disk(role):1+persistence ] } } -// { type: LAUNCH, -// launch: { task_infos ... disk(role):1;disk(role):1+persistence } } -// ] -// } -// -// Note that any of the offer’s resources not used in the 'Accept' -// call (e.g., to launch a task) are considered unused and might be -// reoffered to other frameworks. In other words, the same OfferID -// cannot be used in more than one 'Accept' call. -type Call_Accept struct { - OfferIds []*mesosproto.OfferID `protobuf:"bytes,1,rep,name=offer_ids" json:"offer_ids,omitempty"` - Operations []*mesosproto.Offer_Operation `protobuf:"bytes,2,rep,name=operations" json:"operations,omitempty"` - Filters *mesosproto.Filters `protobuf:"bytes,3,opt,name=filters" json:"filters,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Accept) Reset() { *m = Call_Accept{} } -func (*Call_Accept) ProtoMessage() {} - -func (m *Call_Accept) GetOfferIds() []*mesosproto.OfferID { - if m != nil { - return m.OfferIds - } - return nil -} - -func (m *Call_Accept) GetOperations() []*mesosproto.Offer_Operation { - if m != nil { - return m.Operations - } - return nil -} - -func (m *Call_Accept) GetFilters() *mesosproto.Filters { - if m != nil { - return m.Filters - } - return nil -} - -// Declines an offer, signaling the master to potentially reoffer -// the resources to a different framework. Note that this is same -// as sending an Accept call with no operations. See comments on -// top of 'Accept' for semantics. -type Call_Decline struct { - OfferIds []*mesosproto.OfferID `protobuf:"bytes,1,rep,name=offer_ids" json:"offer_ids,omitempty"` - Filters *mesosproto.Filters `protobuf:"bytes,2,opt,name=filters" json:"filters,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Decline) Reset() { *m = Call_Decline{} } -func (*Call_Decline) ProtoMessage() {} - -func (m *Call_Decline) GetOfferIds() []*mesosproto.OfferID { - if m != nil { - return m.OfferIds - } - return nil -} - -func (m *Call_Decline) GetFilters() *mesosproto.Filters { - if m != nil { - return m.Filters - } - return nil -} - -// Kills a specific task. If the scheduler has a custom executor, -// the kill is forwarded to the executor and it is up to the -// executor to kill the task and send a TASK_KILLED (or TASK_FAILED) -// update. Note that Mesos releases the resources for a task once it -// receives a terminal update (See TaskState in mesos.proto) for it. -// If the task is unknown to the master, a TASK_LOST update is -// generated. -type Call_Kill struct { - TaskId *mesosproto.TaskID `protobuf:"bytes,1,req,name=task_id" json:"task_id,omitempty"` - SlaveId *mesosproto.SlaveID `protobuf:"bytes,2,opt,name=slave_id" json:"slave_id,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Kill) Reset() { *m = Call_Kill{} } -func (*Call_Kill) ProtoMessage() {} - -func (m *Call_Kill) GetTaskId() *mesosproto.TaskID { - if m != nil { - return m.TaskId - } - return nil -} - -func (m *Call_Kill) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -// Shuts down a custom executor. When the executor gets a shutdown -// event, it is expected to kill all its tasks (and send TASK_KILLED -// updates) and terminate. If the executor doesn’t terminate within -// a certain timeout (configurable via -// '--executor_shutdown_grace_period' slave flag), the slave will -// forcefully destroy the container (executor and its tasks) and -// transition its active tasks to TASK_LOST. -type Call_Shutdown struct { - ExecutorId *mesosproto.ExecutorID `protobuf:"bytes,1,req,name=executor_id" json:"executor_id,omitempty"` - SlaveId *mesosproto.SlaveID `protobuf:"bytes,2,req,name=slave_id" json:"slave_id,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Shutdown) Reset() { *m = Call_Shutdown{} } -func (*Call_Shutdown) ProtoMessage() {} - -func (m *Call_Shutdown) GetExecutorId() *mesosproto.ExecutorID { - if m != nil { - return m.ExecutorId - } - return nil -} - -func (m *Call_Shutdown) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -// Acknowledges the receipt of status update. Schedulers are -// responsible for explicitly acknowledging the receipt of status -// updates that have 'Update.status().uuid()' field set. Such status -// updates are retried by the slave until they are acknowledged by -// the scheduler. -type Call_Acknowledge struct { - SlaveId *mesosproto.SlaveID `protobuf:"bytes,1,req,name=slave_id" json:"slave_id,omitempty"` - TaskId *mesosproto.TaskID `protobuf:"bytes,2,req,name=task_id" json:"task_id,omitempty"` - Uuid []byte `protobuf:"bytes,3,req,name=uuid" json:"uuid,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Acknowledge) Reset() { *m = Call_Acknowledge{} } -func (*Call_Acknowledge) ProtoMessage() {} - -func (m *Call_Acknowledge) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -func (m *Call_Acknowledge) GetTaskId() *mesosproto.TaskID { - if m != nil { - return m.TaskId - } - return nil -} - -func (m *Call_Acknowledge) GetUuid() []byte { - if m != nil { - return m.Uuid - } - return nil -} - -// Allows the scheduler to query the status for non-terminal tasks. -// This causes the master to send back the latest task status for -// each task in 'tasks', if possible. Tasks that are no longer known -// will result in a TASK_LOST update. If 'statuses' is empty, then -// the master will send the latest status for each task currently -// known. -type Call_Reconcile struct { - Tasks []*Call_Reconcile_Task `protobuf:"bytes,1,rep,name=tasks" json:"tasks,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Reconcile) Reset() { *m = Call_Reconcile{} } -func (*Call_Reconcile) ProtoMessage() {} - -func (m *Call_Reconcile) GetTasks() []*Call_Reconcile_Task { - if m != nil { - return m.Tasks - } - return nil -} - -// TODO(vinod): Support arbitrary queries than just state of tasks. -type Call_Reconcile_Task struct { - TaskId *mesosproto.TaskID `protobuf:"bytes,1,req,name=task_id" json:"task_id,omitempty"` - SlaveId *mesosproto.SlaveID `protobuf:"bytes,2,opt,name=slave_id" json:"slave_id,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Reconcile_Task) Reset() { *m = Call_Reconcile_Task{} } -func (*Call_Reconcile_Task) ProtoMessage() {} - -func (m *Call_Reconcile_Task) GetTaskId() *mesosproto.TaskID { - if m != nil { - return m.TaskId - } - return nil -} - -func (m *Call_Reconcile_Task) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -// Sends arbitrary binary data to the executor. Note that Mesos -// neither interprets this data nor makes any guarantees about the -// delivery of this message to the executor. -type Call_Message struct { - SlaveId *mesosproto.SlaveID `protobuf:"bytes,1,req,name=slave_id" json:"slave_id,omitempty"` - ExecutorId *mesosproto.ExecutorID `protobuf:"bytes,2,req,name=executor_id" json:"executor_id,omitempty"` - Data []byte `protobuf:"bytes,3,req,name=data" json:"data,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Message) Reset() { *m = Call_Message{} } -func (*Call_Message) ProtoMessage() {} - -func (m *Call_Message) GetSlaveId() *mesosproto.SlaveID { - if m != nil { - return m.SlaveId - } - return nil -} - -func (m *Call_Message) GetExecutorId() *mesosproto.ExecutorID { - if m != nil { - return m.ExecutorId - } - return nil -} - -func (m *Call_Message) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -// Requests a specific set of resources from Mesos's allocator. If -// the allocator has support for this, corresponding offers will be -// sent asynchronously via the OFFERS event(s). -// -// NOTE: The built-in hierarchical allocator doesn't have support -// for this call and hence simply ignores it. -type Call_Request struct { - Requests []*mesosproto.Request `protobuf:"bytes,1,rep,name=requests" json:"requests,omitempty"` - XXX_unrecognized []byte `json:"-"` -} - -func (m *Call_Request) Reset() { *m = Call_Request{} } -func (*Call_Request) ProtoMessage() {} - -func (m *Call_Request) GetRequests() []*mesosproto.Request { - if m != nil { - return m.Requests - } - return nil -} - -func init() { - proto.RegisterEnum("mesosproto.scheduler.Event_Type", Event_Type_name, Event_Type_value) - proto.RegisterEnum("mesosproto.scheduler.Call_Type", Call_Type_name, Call_Type_value) -} -func (this *Event) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event) - if !ok { - return fmt.Errorf("that is not of type *Event") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Eventbut is not nil && this == nil") - } - if this.Type != nil && that1.Type != nil { - if *this.Type != *that1.Type { - return fmt.Errorf("Type this(%v) Not Equal that(%v)", *this.Type, *that1.Type) - } - } else if this.Type != nil { - return fmt.Errorf("this.Type == nil && that.Type != nil") - } else if that1.Type != nil { - return fmt.Errorf("Type this(%v) Not Equal that(%v)", this.Type, that1.Type) - } - if !this.Subscribed.Equal(that1.Subscribed) { - return fmt.Errorf("Subscribed this(%v) Not Equal that(%v)", this.Subscribed, that1.Subscribed) - } - if !this.Offers.Equal(that1.Offers) { - return fmt.Errorf("Offers this(%v) Not Equal that(%v)", this.Offers, that1.Offers) - } - if !this.Rescind.Equal(that1.Rescind) { - return fmt.Errorf("Rescind this(%v) Not Equal that(%v)", this.Rescind, that1.Rescind) - } - if !this.Update.Equal(that1.Update) { - return fmt.Errorf("Update this(%v) Not Equal that(%v)", this.Update, that1.Update) - } - if !this.Message.Equal(that1.Message) { - return fmt.Errorf("Message this(%v) Not Equal that(%v)", this.Message, that1.Message) - } - if !this.Failure.Equal(that1.Failure) { - return fmt.Errorf("Failure this(%v) Not Equal that(%v)", this.Failure, that1.Failure) - } - if !this.Error.Equal(that1.Error) { - return fmt.Errorf("Error this(%v) Not Equal that(%v)", this.Error, that1.Error) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if this.Type != nil && that1.Type != nil { - if *this.Type != *that1.Type { - return false - } - } else if this.Type != nil { - return false - } else if that1.Type != nil { - return false - } - if !this.Subscribed.Equal(that1.Subscribed) { - return false - } - if !this.Offers.Equal(that1.Offers) { - return false - } - if !this.Rescind.Equal(that1.Rescind) { - return false - } - if !this.Update.Equal(that1.Update) { - return false - } - if !this.Message.Equal(that1.Message) { - return false - } - if !this.Failure.Equal(that1.Failure) { - return false - } - if !this.Error.Equal(that1.Error) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Subscribed) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Subscribed) - if !ok { - return fmt.Errorf("that is not of type *Event_Subscribed") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Subscribed but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Subscribedbut is not nil && this == nil") - } - if !this.FrameworkId.Equal(that1.FrameworkId) { - return fmt.Errorf("FrameworkId this(%v) Not Equal that(%v)", this.FrameworkId, that1.FrameworkId) - } - if this.HeartbeatIntervalSeconds != nil && that1.HeartbeatIntervalSeconds != nil { - if *this.HeartbeatIntervalSeconds != *that1.HeartbeatIntervalSeconds { - return fmt.Errorf("HeartbeatIntervalSeconds this(%v) Not Equal that(%v)", *this.HeartbeatIntervalSeconds, *that1.HeartbeatIntervalSeconds) - } - } else if this.HeartbeatIntervalSeconds != nil { - return fmt.Errorf("this.HeartbeatIntervalSeconds == nil && that.HeartbeatIntervalSeconds != nil") - } else if that1.HeartbeatIntervalSeconds != nil { - return fmt.Errorf("HeartbeatIntervalSeconds this(%v) Not Equal that(%v)", this.HeartbeatIntervalSeconds, that1.HeartbeatIntervalSeconds) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Subscribed) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Subscribed) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.FrameworkId.Equal(that1.FrameworkId) { - return false - } - if this.HeartbeatIntervalSeconds != nil && that1.HeartbeatIntervalSeconds != nil { - if *this.HeartbeatIntervalSeconds != *that1.HeartbeatIntervalSeconds { - return false - } - } else if this.HeartbeatIntervalSeconds != nil { - return false - } else if that1.HeartbeatIntervalSeconds != nil { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Offers) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Offers) - if !ok { - return fmt.Errorf("that is not of type *Event_Offers") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Offers but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Offersbut is not nil && this == nil") - } - if len(this.Offers) != len(that1.Offers) { - return fmt.Errorf("Offers this(%v) Not Equal that(%v)", len(this.Offers), len(that1.Offers)) - } - for i := range this.Offers { - if !this.Offers[i].Equal(that1.Offers[i]) { - return fmt.Errorf("Offers this[%v](%v) Not Equal that[%v](%v)", i, this.Offers[i], i, that1.Offers[i]) - } - } - if len(this.InverseOffers) != len(that1.InverseOffers) { - return fmt.Errorf("InverseOffers this(%v) Not Equal that(%v)", len(this.InverseOffers), len(that1.InverseOffers)) - } - for i := range this.InverseOffers { - if !this.InverseOffers[i].Equal(that1.InverseOffers[i]) { - return fmt.Errorf("InverseOffers this[%v](%v) Not Equal that[%v](%v)", i, this.InverseOffers[i], i, that1.InverseOffers[i]) - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Offers) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Offers) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if len(this.Offers) != len(that1.Offers) { - return false - } - for i := range this.Offers { - if !this.Offers[i].Equal(that1.Offers[i]) { - return false - } - } - if len(this.InverseOffers) != len(that1.InverseOffers) { - return false - } - for i := range this.InverseOffers { - if !this.InverseOffers[i].Equal(that1.InverseOffers[i]) { - return false - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Rescind) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Rescind) - if !ok { - return fmt.Errorf("that is not of type *Event_Rescind") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Rescind but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Rescindbut is not nil && this == nil") - } - if !this.OfferId.Equal(that1.OfferId) { - return fmt.Errorf("OfferId this(%v) Not Equal that(%v)", this.OfferId, that1.OfferId) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Rescind) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Rescind) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.OfferId.Equal(that1.OfferId) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Update) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Update) - if !ok { - return fmt.Errorf("that is not of type *Event_Update") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Update but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Updatebut is not nil && this == nil") - } - if !this.Status.Equal(that1.Status) { - return fmt.Errorf("Status this(%v) Not Equal that(%v)", this.Status, that1.Status) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Update) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Update) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.Status.Equal(that1.Status) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Message) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Message) - if !ok { - return fmt.Errorf("that is not of type *Event_Message") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Message but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Messagebut is not nil && this == nil") - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return fmt.Errorf("ExecutorId this(%v) Not Equal that(%v)", this.ExecutorId, that1.ExecutorId) - } - if !bytes.Equal(this.Data, that1.Data) { - return fmt.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Message) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Message) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return false - } - if !bytes.Equal(this.Data, that1.Data) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Failure) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Failure) - if !ok { - return fmt.Errorf("that is not of type *Event_Failure") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Failure but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Failurebut is not nil && this == nil") - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return fmt.Errorf("ExecutorId this(%v) Not Equal that(%v)", this.ExecutorId, that1.ExecutorId) - } - if this.Status != nil && that1.Status != nil { - if *this.Status != *that1.Status { - return fmt.Errorf("Status this(%v) Not Equal that(%v)", *this.Status, *that1.Status) - } - } else if this.Status != nil { - return fmt.Errorf("this.Status == nil && that.Status != nil") - } else if that1.Status != nil { - return fmt.Errorf("Status this(%v) Not Equal that(%v)", this.Status, that1.Status) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Failure) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Failure) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return false - } - if this.Status != nil && that1.Status != nil { - if *this.Status != *that1.Status { - return false - } - } else if this.Status != nil { - return false - } else if that1.Status != nil { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event_Error) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Event_Error) - if !ok { - return fmt.Errorf("that is not of type *Event_Error") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Event_Error but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Event_Errorbut is not nil && this == nil") - } - if this.Message != nil && that1.Message != nil { - if *this.Message != *that1.Message { - return fmt.Errorf("Message this(%v) Not Equal that(%v)", *this.Message, *that1.Message) - } - } else if this.Message != nil { - return fmt.Errorf("this.Message == nil && that.Message != nil") - } else if that1.Message != nil { - return fmt.Errorf("Message this(%v) Not Equal that(%v)", this.Message, that1.Message) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Event_Error) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Event_Error) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if this.Message != nil && that1.Message != nil { - if *this.Message != *that1.Message { - return false - } - } else if this.Message != nil { - return false - } else if that1.Message != nil { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call) - if !ok { - return fmt.Errorf("that is not of type *Call") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Callbut is not nil && this == nil") - } - if !this.FrameworkId.Equal(that1.FrameworkId) { - return fmt.Errorf("FrameworkId this(%v) Not Equal that(%v)", this.FrameworkId, that1.FrameworkId) - } - if this.Type != nil && that1.Type != nil { - if *this.Type != *that1.Type { - return fmt.Errorf("Type this(%v) Not Equal that(%v)", *this.Type, *that1.Type) - } - } else if this.Type != nil { - return fmt.Errorf("this.Type == nil && that.Type != nil") - } else if that1.Type != nil { - return fmt.Errorf("Type this(%v) Not Equal that(%v)", this.Type, that1.Type) - } - if !this.Subscribe.Equal(that1.Subscribe) { - return fmt.Errorf("Subscribe this(%v) Not Equal that(%v)", this.Subscribe, that1.Subscribe) - } - if !this.Accept.Equal(that1.Accept) { - return fmt.Errorf("Accept this(%v) Not Equal that(%v)", this.Accept, that1.Accept) - } - if !this.Decline.Equal(that1.Decline) { - return fmt.Errorf("Decline this(%v) Not Equal that(%v)", this.Decline, that1.Decline) - } - if !this.Kill.Equal(that1.Kill) { - return fmt.Errorf("Kill this(%v) Not Equal that(%v)", this.Kill, that1.Kill) - } - if !this.Shutdown.Equal(that1.Shutdown) { - return fmt.Errorf("Shutdown this(%v) Not Equal that(%v)", this.Shutdown, that1.Shutdown) - } - if !this.Acknowledge.Equal(that1.Acknowledge) { - return fmt.Errorf("Acknowledge this(%v) Not Equal that(%v)", this.Acknowledge, that1.Acknowledge) - } - if !this.Reconcile.Equal(that1.Reconcile) { - return fmt.Errorf("Reconcile this(%v) Not Equal that(%v)", this.Reconcile, that1.Reconcile) - } - if !this.Message.Equal(that1.Message) { - return fmt.Errorf("Message this(%v) Not Equal that(%v)", this.Message, that1.Message) - } - if !this.Request.Equal(that1.Request) { - return fmt.Errorf("Request this(%v) Not Equal that(%v)", this.Request, that1.Request) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.FrameworkId.Equal(that1.FrameworkId) { - return false - } - if this.Type != nil && that1.Type != nil { - if *this.Type != *that1.Type { - return false - } - } else if this.Type != nil { - return false - } else if that1.Type != nil { - return false - } - if !this.Subscribe.Equal(that1.Subscribe) { - return false - } - if !this.Accept.Equal(that1.Accept) { - return false - } - if !this.Decline.Equal(that1.Decline) { - return false - } - if !this.Kill.Equal(that1.Kill) { - return false - } - if !this.Shutdown.Equal(that1.Shutdown) { - return false - } - if !this.Acknowledge.Equal(that1.Acknowledge) { - return false - } - if !this.Reconcile.Equal(that1.Reconcile) { - return false - } - if !this.Message.Equal(that1.Message) { - return false - } - if !this.Request.Equal(that1.Request) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Subscribe) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Subscribe) - if !ok { - return fmt.Errorf("that is not of type *Call_Subscribe") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Subscribe but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Subscribebut is not nil && this == nil") - } - if !this.FrameworkInfo.Equal(that1.FrameworkInfo) { - return fmt.Errorf("FrameworkInfo this(%v) Not Equal that(%v)", this.FrameworkInfo, that1.FrameworkInfo) - } - if this.Force != nil && that1.Force != nil { - if *this.Force != *that1.Force { - return fmt.Errorf("Force this(%v) Not Equal that(%v)", *this.Force, *that1.Force) - } - } else if this.Force != nil { - return fmt.Errorf("this.Force == nil && that.Force != nil") - } else if that1.Force != nil { - return fmt.Errorf("Force this(%v) Not Equal that(%v)", this.Force, that1.Force) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Subscribe) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Subscribe) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.FrameworkInfo.Equal(that1.FrameworkInfo) { - return false - } - if this.Force != nil && that1.Force != nil { - if *this.Force != *that1.Force { - return false - } - } else if this.Force != nil { - return false - } else if that1.Force != nil { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Accept) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Accept) - if !ok { - return fmt.Errorf("that is not of type *Call_Accept") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Accept but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Acceptbut is not nil && this == nil") - } - if len(this.OfferIds) != len(that1.OfferIds) { - return fmt.Errorf("OfferIds this(%v) Not Equal that(%v)", len(this.OfferIds), len(that1.OfferIds)) - } - for i := range this.OfferIds { - if !this.OfferIds[i].Equal(that1.OfferIds[i]) { - return fmt.Errorf("OfferIds this[%v](%v) Not Equal that[%v](%v)", i, this.OfferIds[i], i, that1.OfferIds[i]) - } - } - if len(this.Operations) != len(that1.Operations) { - return fmt.Errorf("Operations this(%v) Not Equal that(%v)", len(this.Operations), len(that1.Operations)) - } - for i := range this.Operations { - if !this.Operations[i].Equal(that1.Operations[i]) { - return fmt.Errorf("Operations this[%v](%v) Not Equal that[%v](%v)", i, this.Operations[i], i, that1.Operations[i]) - } - } - if !this.Filters.Equal(that1.Filters) { - return fmt.Errorf("Filters this(%v) Not Equal that(%v)", this.Filters, that1.Filters) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Accept) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Accept) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if len(this.OfferIds) != len(that1.OfferIds) { - return false - } - for i := range this.OfferIds { - if !this.OfferIds[i].Equal(that1.OfferIds[i]) { - return false - } - } - if len(this.Operations) != len(that1.Operations) { - return false - } - for i := range this.Operations { - if !this.Operations[i].Equal(that1.Operations[i]) { - return false - } - } - if !this.Filters.Equal(that1.Filters) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Decline) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Decline) - if !ok { - return fmt.Errorf("that is not of type *Call_Decline") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Decline but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Declinebut is not nil && this == nil") - } - if len(this.OfferIds) != len(that1.OfferIds) { - return fmt.Errorf("OfferIds this(%v) Not Equal that(%v)", len(this.OfferIds), len(that1.OfferIds)) - } - for i := range this.OfferIds { - if !this.OfferIds[i].Equal(that1.OfferIds[i]) { - return fmt.Errorf("OfferIds this[%v](%v) Not Equal that[%v](%v)", i, this.OfferIds[i], i, that1.OfferIds[i]) - } - } - if !this.Filters.Equal(that1.Filters) { - return fmt.Errorf("Filters this(%v) Not Equal that(%v)", this.Filters, that1.Filters) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Decline) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Decline) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if len(this.OfferIds) != len(that1.OfferIds) { - return false - } - for i := range this.OfferIds { - if !this.OfferIds[i].Equal(that1.OfferIds[i]) { - return false - } - } - if !this.Filters.Equal(that1.Filters) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Kill) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Kill) - if !ok { - return fmt.Errorf("that is not of type *Call_Kill") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Kill but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Killbut is not nil && this == nil") - } - if !this.TaskId.Equal(that1.TaskId) { - return fmt.Errorf("TaskId this(%v) Not Equal that(%v)", this.TaskId, that1.TaskId) - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Kill) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Kill) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.TaskId.Equal(that1.TaskId) { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Shutdown) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Shutdown) - if !ok { - return fmt.Errorf("that is not of type *Call_Shutdown") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Shutdown but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Shutdownbut is not nil && this == nil") - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return fmt.Errorf("ExecutorId this(%v) Not Equal that(%v)", this.ExecutorId, that1.ExecutorId) - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Shutdown) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Shutdown) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Acknowledge) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Acknowledge) - if !ok { - return fmt.Errorf("that is not of type *Call_Acknowledge") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Acknowledge but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Acknowledgebut is not nil && this == nil") - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !this.TaskId.Equal(that1.TaskId) { - return fmt.Errorf("TaskId this(%v) Not Equal that(%v)", this.TaskId, that1.TaskId) - } - if !bytes.Equal(this.Uuid, that1.Uuid) { - return fmt.Errorf("Uuid this(%v) Not Equal that(%v)", this.Uuid, that1.Uuid) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Acknowledge) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Acknowledge) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !this.TaskId.Equal(that1.TaskId) { - return false - } - if !bytes.Equal(this.Uuid, that1.Uuid) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Reconcile) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Reconcile) - if !ok { - return fmt.Errorf("that is not of type *Call_Reconcile") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Reconcile but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Reconcilebut is not nil && this == nil") - } - if len(this.Tasks) != len(that1.Tasks) { - return fmt.Errorf("Tasks this(%v) Not Equal that(%v)", len(this.Tasks), len(that1.Tasks)) - } - for i := range this.Tasks { - if !this.Tasks[i].Equal(that1.Tasks[i]) { - return fmt.Errorf("Tasks this[%v](%v) Not Equal that[%v](%v)", i, this.Tasks[i], i, that1.Tasks[i]) - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Reconcile) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Reconcile) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if len(this.Tasks) != len(that1.Tasks) { - return false - } - for i := range this.Tasks { - if !this.Tasks[i].Equal(that1.Tasks[i]) { - return false - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Reconcile_Task) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Reconcile_Task) - if !ok { - return fmt.Errorf("that is not of type *Call_Reconcile_Task") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Reconcile_Task but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Reconcile_Taskbut is not nil && this == nil") - } - if !this.TaskId.Equal(that1.TaskId) { - return fmt.Errorf("TaskId this(%v) Not Equal that(%v)", this.TaskId, that1.TaskId) - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Reconcile_Task) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Reconcile_Task) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.TaskId.Equal(that1.TaskId) { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Message) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Message) - if !ok { - return fmt.Errorf("that is not of type *Call_Message") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Message but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Messagebut is not nil && this == nil") - } - if !this.SlaveId.Equal(that1.SlaveId) { - return fmt.Errorf("SlaveId this(%v) Not Equal that(%v)", this.SlaveId, that1.SlaveId) - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return fmt.Errorf("ExecutorId this(%v) Not Equal that(%v)", this.ExecutorId, that1.ExecutorId) - } - if !bytes.Equal(this.Data, that1.Data) { - return fmt.Errorf("Data this(%v) Not Equal that(%v)", this.Data, that1.Data) - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Message) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Message) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if !this.SlaveId.Equal(that1.SlaveId) { - return false - } - if !this.ExecutorId.Equal(that1.ExecutorId) { - return false - } - if !bytes.Equal(this.Data, that1.Data) { - return false - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Call_Request) VerboseEqual(that interface{}) error { - if that == nil { - if this == nil { - return nil - } - return fmt.Errorf("that == nil && this != nil") - } - - that1, ok := that.(*Call_Request) - if !ok { - return fmt.Errorf("that is not of type *Call_Request") - } - if that1 == nil { - if this == nil { - return nil - } - return fmt.Errorf("that is type *Call_Request but is nil && this != nil") - } else if this == nil { - return fmt.Errorf("that is type *Call_Requestbut is not nil && this == nil") - } - if len(this.Requests) != len(that1.Requests) { - return fmt.Errorf("Requests this(%v) Not Equal that(%v)", len(this.Requests), len(that1.Requests)) - } - for i := range this.Requests { - if !this.Requests[i].Equal(that1.Requests[i]) { - return fmt.Errorf("Requests this[%v](%v) Not Equal that[%v](%v)", i, this.Requests[i], i, that1.Requests[i]) - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return fmt.Errorf("XXX_unrecognized this(%v) Not Equal that(%v)", this.XXX_unrecognized, that1.XXX_unrecognized) - } - return nil -} -func (this *Call_Request) Equal(that interface{}) bool { - if that == nil { - if this == nil { - return true - } - return false - } - - that1, ok := that.(*Call_Request) - if !ok { - return false - } - if that1 == nil { - if this == nil { - return true - } - return false - } else if this == nil { - return false - } - if len(this.Requests) != len(that1.Requests) { - return false - } - for i := range this.Requests { - if !this.Requests[i].Equal(that1.Requests[i]) { - return false - } - } - if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { - return false - } - return true -} -func (this *Event) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 12) - s = append(s, "&scheduler.Event{") - if this.Type != nil { - s = append(s, "Type: "+valueToGoStringScheduler(this.Type, "scheduler.Event_Type")+",\n") - } - if this.Subscribed != nil { - s = append(s, "Subscribed: "+fmt.Sprintf("%#v", this.Subscribed)+",\n") - } - if this.Offers != nil { - s = append(s, "Offers: "+fmt.Sprintf("%#v", this.Offers)+",\n") - } - if this.Rescind != nil { - s = append(s, "Rescind: "+fmt.Sprintf("%#v", this.Rescind)+",\n") - } - if this.Update != nil { - s = append(s, "Update: "+fmt.Sprintf("%#v", this.Update)+",\n") - } - if this.Message != nil { - s = append(s, "Message: "+fmt.Sprintf("%#v", this.Message)+",\n") - } - if this.Failure != nil { - s = append(s, "Failure: "+fmt.Sprintf("%#v", this.Failure)+",\n") - } - if this.Error != nil { - s = append(s, "Error: "+fmt.Sprintf("%#v", this.Error)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Subscribed) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Event_Subscribed{") - if this.FrameworkId != nil { - s = append(s, "FrameworkId: "+fmt.Sprintf("%#v", this.FrameworkId)+",\n") - } - if this.HeartbeatIntervalSeconds != nil { - s = append(s, "HeartbeatIntervalSeconds: "+valueToGoStringScheduler(this.HeartbeatIntervalSeconds, "float64")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Offers) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Event_Offers{") - if this.Offers != nil { - s = append(s, "Offers: "+fmt.Sprintf("%#v", this.Offers)+",\n") - } - if this.InverseOffers != nil { - s = append(s, "InverseOffers: "+fmt.Sprintf("%#v", this.InverseOffers)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Rescind) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&scheduler.Event_Rescind{") - if this.OfferId != nil { - s = append(s, "OfferId: "+fmt.Sprintf("%#v", this.OfferId)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Update) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&scheduler.Event_Update{") - if this.Status != nil { - s = append(s, "Status: "+fmt.Sprintf("%#v", this.Status)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Message) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 7) - s = append(s, "&scheduler.Event_Message{") - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.ExecutorId != nil { - s = append(s, "ExecutorId: "+fmt.Sprintf("%#v", this.ExecutorId)+",\n") - } - if this.Data != nil { - s = append(s, "Data: "+valueToGoStringScheduler(this.Data, "byte")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Failure) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 7) - s = append(s, "&scheduler.Event_Failure{") - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.ExecutorId != nil { - s = append(s, "ExecutorId: "+fmt.Sprintf("%#v", this.ExecutorId)+",\n") - } - if this.Status != nil { - s = append(s, "Status: "+valueToGoStringScheduler(this.Status, "int32")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Event_Error) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&scheduler.Event_Error{") - if this.Message != nil { - s = append(s, "Message: "+valueToGoStringScheduler(this.Message, "string")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 15) - s = append(s, "&scheduler.Call{") - if this.FrameworkId != nil { - s = append(s, "FrameworkId: "+fmt.Sprintf("%#v", this.FrameworkId)+",\n") - } - if this.Type != nil { - s = append(s, "Type: "+valueToGoStringScheduler(this.Type, "scheduler.Call_Type")+",\n") - } - if this.Subscribe != nil { - s = append(s, "Subscribe: "+fmt.Sprintf("%#v", this.Subscribe)+",\n") - } - if this.Accept != nil { - s = append(s, "Accept: "+fmt.Sprintf("%#v", this.Accept)+",\n") - } - if this.Decline != nil { - s = append(s, "Decline: "+fmt.Sprintf("%#v", this.Decline)+",\n") - } - if this.Kill != nil { - s = append(s, "Kill: "+fmt.Sprintf("%#v", this.Kill)+",\n") - } - if this.Shutdown != nil { - s = append(s, "Shutdown: "+fmt.Sprintf("%#v", this.Shutdown)+",\n") - } - if this.Acknowledge != nil { - s = append(s, "Acknowledge: "+fmt.Sprintf("%#v", this.Acknowledge)+",\n") - } - if this.Reconcile != nil { - s = append(s, "Reconcile: "+fmt.Sprintf("%#v", this.Reconcile)+",\n") - } - if this.Message != nil { - s = append(s, "Message: "+fmt.Sprintf("%#v", this.Message)+",\n") - } - if this.Request != nil { - s = append(s, "Request: "+fmt.Sprintf("%#v", this.Request)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Subscribe) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Call_Subscribe{") - if this.FrameworkInfo != nil { - s = append(s, "FrameworkInfo: "+fmt.Sprintf("%#v", this.FrameworkInfo)+",\n") - } - if this.Force != nil { - s = append(s, "Force: "+valueToGoStringScheduler(this.Force, "bool")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Accept) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 7) - s = append(s, "&scheduler.Call_Accept{") - if this.OfferIds != nil { - s = append(s, "OfferIds: "+fmt.Sprintf("%#v", this.OfferIds)+",\n") - } - if this.Operations != nil { - s = append(s, "Operations: "+fmt.Sprintf("%#v", this.Operations)+",\n") - } - if this.Filters != nil { - s = append(s, "Filters: "+fmt.Sprintf("%#v", this.Filters)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Decline) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Call_Decline{") - if this.OfferIds != nil { - s = append(s, "OfferIds: "+fmt.Sprintf("%#v", this.OfferIds)+",\n") - } - if this.Filters != nil { - s = append(s, "Filters: "+fmt.Sprintf("%#v", this.Filters)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Kill) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Call_Kill{") - if this.TaskId != nil { - s = append(s, "TaskId: "+fmt.Sprintf("%#v", this.TaskId)+",\n") - } - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Shutdown) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Call_Shutdown{") - if this.ExecutorId != nil { - s = append(s, "ExecutorId: "+fmt.Sprintf("%#v", this.ExecutorId)+",\n") - } - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Acknowledge) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 7) - s = append(s, "&scheduler.Call_Acknowledge{") - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.TaskId != nil { - s = append(s, "TaskId: "+fmt.Sprintf("%#v", this.TaskId)+",\n") - } - if this.Uuid != nil { - s = append(s, "Uuid: "+valueToGoStringScheduler(this.Uuid, "byte")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Reconcile) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&scheduler.Call_Reconcile{") - if this.Tasks != nil { - s = append(s, "Tasks: "+fmt.Sprintf("%#v", this.Tasks)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Reconcile_Task) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 6) - s = append(s, "&scheduler.Call_Reconcile_Task{") - if this.TaskId != nil { - s = append(s, "TaskId: "+fmt.Sprintf("%#v", this.TaskId)+",\n") - } - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Message) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 7) - s = append(s, "&scheduler.Call_Message{") - if this.SlaveId != nil { - s = append(s, "SlaveId: "+fmt.Sprintf("%#v", this.SlaveId)+",\n") - } - if this.ExecutorId != nil { - s = append(s, "ExecutorId: "+fmt.Sprintf("%#v", this.ExecutorId)+",\n") - } - if this.Data != nil { - s = append(s, "Data: "+valueToGoStringScheduler(this.Data, "byte")+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *Call_Request) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&scheduler.Call_Request{") - if this.Requests != nil { - s = append(s, "Requests: "+fmt.Sprintf("%#v", this.Requests)+",\n") - } - if this.XXX_unrecognized != nil { - s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func valueToGoStringScheduler(v interface{}, typ string) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) -} -func extensionToGoStringScheduler(e map[int32]github_com_gogo_protobuf_proto.Extension) string { - if e == nil { - return "nil" - } - s := "map[int32]proto.Extension{" - keys := make([]int, 0, len(e)) - for k := range e { - keys = append(keys, int(k)) - } - sort.Ints(keys) - ss := []string{} - for _, k := range keys { - ss = append(ss, strconv.Itoa(k)+": "+e[int32(k)].GoString()) - } - s += strings.Join(ss, ",") + "}" - return s -} -func (m *Event) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Type == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("type") - } else { - data[i] = 0x8 - i++ - i = encodeVarintScheduler(data, i, uint64(*m.Type)) - } - if m.Subscribed != nil { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Subscribed.Size())) - n1, err := m.Subscribed.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n1 - } - if m.Offers != nil { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Offers.Size())) - n2, err := m.Offers.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n2 - } - if m.Rescind != nil { - data[i] = 0x22 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Rescind.Size())) - n3, err := m.Rescind.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n3 - } - if m.Update != nil { - data[i] = 0x2a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Update.Size())) - n4, err := m.Update.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n4 - } - if m.Message != nil { - data[i] = 0x32 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Message.Size())) - n5, err := m.Message.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n5 - } - if m.Failure != nil { - data[i] = 0x3a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Failure.Size())) - n6, err := m.Failure.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n6 - } - if m.Error != nil { - data[i] = 0x42 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Error.Size())) - n7, err := m.Error.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n7 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Subscribed) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Subscribed) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.FrameworkId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("framework_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.FrameworkId.Size())) - n8, err := m.FrameworkId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n8 - } - if m.HeartbeatIntervalSeconds != nil { - data[i] = 0x11 - i++ - i = encodeFixed64Scheduler(data, i, uint64(math.Float64bits(*m.HeartbeatIntervalSeconds))) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Offers) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Offers) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Offers) > 0 { - for _, msg := range m.Offers { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.InverseOffers) > 0 { - for _, msg := range m.InverseOffers { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Rescind) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Rescind) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.OfferId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("offer_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.OfferId.Size())) - n9, err := m.OfferId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n9 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Update) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Update) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Status == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("status") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.Status.Size())) - n10, err := m.Status.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n10 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Message) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Message) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.SlaveId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n11, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n11 - } - if m.ExecutorId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } else { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.ExecutorId.Size())) - n12, err := m.ExecutorId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n12 - } - if m.Data == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("data") - } else { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(len(m.Data))) - i += copy(data[i:], m.Data) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Failure) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Failure) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.SlaveId != nil { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n13, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n13 - } - if m.ExecutorId != nil { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.ExecutorId.Size())) - n14, err := m.ExecutorId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n14 - } - if m.Status != nil { - data[i] = 0x18 - i++ - i = encodeVarintScheduler(data, i, uint64(*m.Status)) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Event_Error) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event_Error) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Message == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("message") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(len(*m.Message))) - i += copy(data[i:], *m.Message) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.FrameworkId != nil { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.FrameworkId.Size())) - n15, err := m.FrameworkId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n15 - } - if m.Type == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("type") - } else { - data[i] = 0x10 - i++ - i = encodeVarintScheduler(data, i, uint64(*m.Type)) - } - if m.Subscribe != nil { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Subscribe.Size())) - n16, err := m.Subscribe.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n16 - } - if m.Accept != nil { - data[i] = 0x22 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Accept.Size())) - n17, err := m.Accept.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n17 - } - if m.Decline != nil { - data[i] = 0x2a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Decline.Size())) - n18, err := m.Decline.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n18 - } - if m.Kill != nil { - data[i] = 0x32 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Kill.Size())) - n19, err := m.Kill.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n19 - } - if m.Shutdown != nil { - data[i] = 0x3a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Shutdown.Size())) - n20, err := m.Shutdown.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n20 - } - if m.Acknowledge != nil { - data[i] = 0x42 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Acknowledge.Size())) - n21, err := m.Acknowledge.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n21 - } - if m.Reconcile != nil { - data[i] = 0x4a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Reconcile.Size())) - n22, err := m.Reconcile.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n22 - } - if m.Message != nil { - data[i] = 0x52 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Message.Size())) - n23, err := m.Message.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n23 - } - if m.Request != nil { - data[i] = 0x5a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Request.Size())) - n24, err := m.Request.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n24 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Subscribe) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Subscribe) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.FrameworkInfo == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("framework_info") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.FrameworkInfo.Size())) - n25, err := m.FrameworkInfo.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n25 - } - if m.Force != nil { - data[i] = 0x10 - i++ - if *m.Force { - data[i] = 1 - } else { - data[i] = 0 - } - i++ - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Accept) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Accept) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.OfferIds) > 0 { - for _, msg := range m.OfferIds { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if len(m.Operations) > 0 { - for _, msg := range m.Operations { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.Filters != nil { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(m.Filters.Size())) - n26, err := m.Filters.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n26 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Decline) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Decline) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.OfferIds) > 0 { - for _, msg := range m.OfferIds { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.Filters != nil { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.Filters.Size())) - n27, err := m.Filters.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n27 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Kill) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Kill) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.TaskId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.TaskId.Size())) - n28, err := m.TaskId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n28 - } - if m.SlaveId != nil { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n29, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n29 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Shutdown) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Shutdown) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.ExecutorId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.ExecutorId.Size())) - n30, err := m.ExecutorId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n30 - } - if m.SlaveId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } else { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n31, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n31 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Acknowledge) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Acknowledge) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.SlaveId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n32, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n32 - } - if m.TaskId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } else { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.TaskId.Size())) - n33, err := m.TaskId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n33 - } - if m.Uuid == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("uuid") - } else { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(len(m.Uuid))) - i += copy(data[i:], m.Uuid) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Reconcile) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Reconcile) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Tasks) > 0 { - for _, msg := range m.Tasks { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Reconcile_Task) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Reconcile_Task) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.TaskId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.TaskId.Size())) - n34, err := m.TaskId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n34 - } - if m.SlaveId != nil { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n35, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n35 - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Message) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Message) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.SlaveId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } else { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(m.SlaveId.Size())) - n36, err := m.SlaveId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n36 - } - if m.ExecutorId == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } else { - data[i] = 0x12 - i++ - i = encodeVarintScheduler(data, i, uint64(m.ExecutorId.Size())) - n37, err := m.ExecutorId.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n37 - } - if m.Data == nil { - return 0, github_com_gogo_protobuf_proto.NewRequiredNotSetError("data") - } else { - data[i] = 0x1a - i++ - i = encodeVarintScheduler(data, i, uint64(len(m.Data))) - i += copy(data[i:], m.Data) - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func (m *Call_Request) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Call_Request) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Requests) > 0 { - for _, msg := range m.Requests { - data[i] = 0xa - i++ - i = encodeVarintScheduler(data, i, uint64(msg.Size())) - n, err := msg.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n - } - } - if m.XXX_unrecognized != nil { - i += copy(data[i:], m.XXX_unrecognized) - } - return i, nil -} - -func encodeFixed64Scheduler(data []byte, offset int, v uint64) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - data[offset+4] = uint8(v >> 32) - data[offset+5] = uint8(v >> 40) - data[offset+6] = uint8(v >> 48) - data[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Scheduler(data []byte, offset int, v uint32) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - return offset + 4 -} -func encodeVarintScheduler(data []byte, offset int, v uint64) int { - for v >= 1<<7 { - data[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - data[offset] = uint8(v) - return offset + 1 -} -func NewPopulatedEvent(r randyScheduler, easy bool) *Event { - this := &Event{} - v1 := Event_Type([]int32{1, 2, 3, 4, 5, 6, 7, 8}[r.Intn(8)]) - this.Type = &v1 - if r.Intn(10) != 0 { - this.Subscribed = NewPopulatedEvent_Subscribed(r, easy) - } - if r.Intn(10) != 0 { - this.Offers = NewPopulatedEvent_Offers(r, easy) - } - if r.Intn(10) != 0 { - this.Rescind = NewPopulatedEvent_Rescind(r, easy) - } - if r.Intn(10) != 0 { - this.Update = NewPopulatedEvent_Update(r, easy) - } - if r.Intn(10) != 0 { - this.Message = NewPopulatedEvent_Message(r, easy) - } - if r.Intn(10) != 0 { - this.Failure = NewPopulatedEvent_Failure(r, easy) - } - if r.Intn(10) != 0 { - this.Error = NewPopulatedEvent_Error(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 9) - } - return this -} - -func NewPopulatedEvent_Subscribed(r randyScheduler, easy bool) *Event_Subscribed { - this := &Event_Subscribed{} - this.FrameworkId = mesosproto.NewPopulatedFrameworkID(r, easy) - if r.Intn(10) != 0 { - v2 := float64(r.Float64()) - if r.Intn(2) == 0 { - v2 *= -1 - } - this.HeartbeatIntervalSeconds = &v2 - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedEvent_Offers(r randyScheduler, easy bool) *Event_Offers { - this := &Event_Offers{} - if r.Intn(10) != 0 { - v3 := r.Intn(10) - this.Offers = make([]*mesosproto.Offer, v3) - for i := 0; i < v3; i++ { - this.Offers[i] = mesosproto.NewPopulatedOffer(r, easy) - } - } - if r.Intn(10) != 0 { - v4 := r.Intn(10) - this.InverseOffers = make([]*mesosproto.InverseOffer, v4) - for i := 0; i < v4; i++ { - this.InverseOffers[i] = mesosproto.NewPopulatedInverseOffer(r, easy) - } - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedEvent_Rescind(r randyScheduler, easy bool) *Event_Rescind { - this := &Event_Rescind{} - this.OfferId = mesosproto.NewPopulatedOfferID(r, easy) - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 2) - } - return this -} - -func NewPopulatedEvent_Update(r randyScheduler, easy bool) *Event_Update { - this := &Event_Update{} - this.Status = mesosproto.NewPopulatedTaskStatus(r, easy) - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 2) - } - return this -} - -func NewPopulatedEvent_Message(r randyScheduler, easy bool) *Event_Message { - this := &Event_Message{} - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - this.ExecutorId = mesosproto.NewPopulatedExecutorID(r, easy) - v5 := r.Intn(100) - this.Data = make([]byte, v5) - for i := 0; i < v5; i++ { - this.Data[i] = byte(r.Intn(256)) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 4) - } - return this -} - -func NewPopulatedEvent_Failure(r randyScheduler, easy bool) *Event_Failure { - this := &Event_Failure{} - if r.Intn(10) != 0 { - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - } - if r.Intn(10) != 0 { - this.ExecutorId = mesosproto.NewPopulatedExecutorID(r, easy) - } - if r.Intn(10) != 0 { - v6 := int32(r.Int31()) - if r.Intn(2) == 0 { - v6 *= -1 - } - this.Status = &v6 - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 4) - } - return this -} - -func NewPopulatedEvent_Error(r randyScheduler, easy bool) *Event_Error { - this := &Event_Error{} - v7 := randStringScheduler(r) - this.Message = &v7 - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 2) - } - return this -} - -func NewPopulatedCall(r randyScheduler, easy bool) *Call { - this := &Call{} - if r.Intn(10) != 0 { - this.FrameworkId = mesosproto.NewPopulatedFrameworkID(r, easy) - } - v8 := Call_Type([]int32{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}[r.Intn(12)]) - this.Type = &v8 - if r.Intn(10) != 0 { - this.Subscribe = NewPopulatedCall_Subscribe(r, easy) - } - if r.Intn(10) != 0 { - this.Accept = NewPopulatedCall_Accept(r, easy) - } - if r.Intn(10) != 0 { - this.Decline = NewPopulatedCall_Decline(r, easy) - } - if r.Intn(10) != 0 { - this.Kill = NewPopulatedCall_Kill(r, easy) - } - if r.Intn(10) != 0 { - this.Shutdown = NewPopulatedCall_Shutdown(r, easy) - } - if r.Intn(10) != 0 { - this.Acknowledge = NewPopulatedCall_Acknowledge(r, easy) - } - if r.Intn(10) != 0 { - this.Reconcile = NewPopulatedCall_Reconcile(r, easy) - } - if r.Intn(10) != 0 { - this.Message = NewPopulatedCall_Message(r, easy) - } - if r.Intn(10) != 0 { - this.Request = NewPopulatedCall_Request(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 12) - } - return this -} - -func NewPopulatedCall_Subscribe(r randyScheduler, easy bool) *Call_Subscribe { - this := &Call_Subscribe{} - this.FrameworkInfo = mesosproto.NewPopulatedFrameworkInfo(r, easy) - if r.Intn(10) != 0 { - v9 := bool(bool(r.Intn(2) == 0)) - this.Force = &v9 - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedCall_Accept(r randyScheduler, easy bool) *Call_Accept { - this := &Call_Accept{} - if r.Intn(10) != 0 { - v10 := r.Intn(10) - this.OfferIds = make([]*mesosproto.OfferID, v10) - for i := 0; i < v10; i++ { - this.OfferIds[i] = mesosproto.NewPopulatedOfferID(r, easy) - } - } - if r.Intn(10) != 0 { - v11 := r.Intn(10) - this.Operations = make([]*mesosproto.Offer_Operation, v11) - for i := 0; i < v11; i++ { - this.Operations[i] = mesosproto.NewPopulatedOffer_Operation(r, easy) - } - } - if r.Intn(10) != 0 { - this.Filters = mesosproto.NewPopulatedFilters(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 4) - } - return this -} - -func NewPopulatedCall_Decline(r randyScheduler, easy bool) *Call_Decline { - this := &Call_Decline{} - if r.Intn(10) != 0 { - v12 := r.Intn(10) - this.OfferIds = make([]*mesosproto.OfferID, v12) - for i := 0; i < v12; i++ { - this.OfferIds[i] = mesosproto.NewPopulatedOfferID(r, easy) - } - } - if r.Intn(10) != 0 { - this.Filters = mesosproto.NewPopulatedFilters(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedCall_Kill(r randyScheduler, easy bool) *Call_Kill { - this := &Call_Kill{} - this.TaskId = mesosproto.NewPopulatedTaskID(r, easy) - if r.Intn(10) != 0 { - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedCall_Shutdown(r randyScheduler, easy bool) *Call_Shutdown { - this := &Call_Shutdown{} - this.ExecutorId = mesosproto.NewPopulatedExecutorID(r, easy) - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedCall_Acknowledge(r randyScheduler, easy bool) *Call_Acknowledge { - this := &Call_Acknowledge{} - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - this.TaskId = mesosproto.NewPopulatedTaskID(r, easy) - v13 := r.Intn(100) - this.Uuid = make([]byte, v13) - for i := 0; i < v13; i++ { - this.Uuid[i] = byte(r.Intn(256)) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 4) - } - return this -} - -func NewPopulatedCall_Reconcile(r randyScheduler, easy bool) *Call_Reconcile { - this := &Call_Reconcile{} - if r.Intn(10) != 0 { - v14 := r.Intn(10) - this.Tasks = make([]*Call_Reconcile_Task, v14) - for i := 0; i < v14; i++ { - this.Tasks[i] = NewPopulatedCall_Reconcile_Task(r, easy) - } - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 2) - } - return this -} - -func NewPopulatedCall_Reconcile_Task(r randyScheduler, easy bool) *Call_Reconcile_Task { - this := &Call_Reconcile_Task{} - this.TaskId = mesosproto.NewPopulatedTaskID(r, easy) - if r.Intn(10) != 0 { - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 3) - } - return this -} - -func NewPopulatedCall_Message(r randyScheduler, easy bool) *Call_Message { - this := &Call_Message{} - this.SlaveId = mesosproto.NewPopulatedSlaveID(r, easy) - this.ExecutorId = mesosproto.NewPopulatedExecutorID(r, easy) - v15 := r.Intn(100) - this.Data = make([]byte, v15) - for i := 0; i < v15; i++ { - this.Data[i] = byte(r.Intn(256)) - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 4) - } - return this -} - -func NewPopulatedCall_Request(r randyScheduler, easy bool) *Call_Request { - this := &Call_Request{} - if r.Intn(10) != 0 { - v16 := r.Intn(10) - this.Requests = make([]*mesosproto.Request, v16) - for i := 0; i < v16; i++ { - this.Requests[i] = mesosproto.NewPopulatedRequest(r, easy) - } - } - if !easy && r.Intn(10) != 0 { - this.XXX_unrecognized = randUnrecognizedScheduler(r, 2) - } - return this -} - -type randyScheduler interface { - Float32() float32 - Float64() float64 - Int63() int64 - Int31() int32 - Uint32() uint32 - Intn(n int) int -} - -func randUTF8RuneScheduler(r randyScheduler) rune { - ru := r.Intn(62) - if ru < 10 { - return rune(ru + 48) - } else if ru < 36 { - return rune(ru + 55) - } - return rune(ru + 61) -} -func randStringScheduler(r randyScheduler) string { - v17 := r.Intn(100) - tmps := make([]rune, v17) - for i := 0; i < v17; i++ { - tmps[i] = randUTF8RuneScheduler(r) - } - return string(tmps) -} -func randUnrecognizedScheduler(r randyScheduler, maxFieldNumber int) (data []byte) { - l := r.Intn(5) - for i := 0; i < l; i++ { - wire := r.Intn(4) - if wire == 3 { - wire = 5 - } - fieldNumber := maxFieldNumber + r.Intn(100) - data = randFieldScheduler(data, r, fieldNumber, wire) - } - return data -} -func randFieldScheduler(data []byte, r randyScheduler, fieldNumber int, wire int) []byte { - key := uint32(fieldNumber)<<3 | uint32(wire) - switch wire { - case 0: - data = encodeVarintPopulateScheduler(data, uint64(key)) - v18 := r.Int63() - if r.Intn(2) == 0 { - v18 *= -1 - } - data = encodeVarintPopulateScheduler(data, uint64(v18)) - case 1: - data = encodeVarintPopulateScheduler(data, uint64(key)) - data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) - case 2: - data = encodeVarintPopulateScheduler(data, uint64(key)) - ll := r.Intn(100) - data = encodeVarintPopulateScheduler(data, uint64(ll)) - for j := 0; j < ll; j++ { - data = append(data, byte(r.Intn(256))) - } - default: - data = encodeVarintPopulateScheduler(data, uint64(key)) - data = append(data, byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256)), byte(r.Intn(256))) - } - return data -} -func encodeVarintPopulateScheduler(data []byte, v uint64) []byte { - for v >= 1<<7 { - data = append(data, uint8(uint64(v)&0x7f|0x80)) - v >>= 7 - } - data = append(data, uint8(v)) - return data -} -func (m *Event) Size() (n int) { - var l int - _ = l - if m.Type != nil { - n += 1 + sovScheduler(uint64(*m.Type)) - } - if m.Subscribed != nil { - l = m.Subscribed.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Offers != nil { - l = m.Offers.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Rescind != nil { - l = m.Rescind.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Update != nil { - l = m.Update.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Message != nil { - l = m.Message.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Failure != nil { - l = m.Failure.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Error != nil { - l = m.Error.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Subscribed) Size() (n int) { - var l int - _ = l - if m.FrameworkId != nil { - l = m.FrameworkId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.HeartbeatIntervalSeconds != nil { - n += 9 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Offers) Size() (n int) { - var l int - _ = l - if len(m.Offers) > 0 { - for _, e := range m.Offers { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if len(m.InverseOffers) > 0 { - for _, e := range m.InverseOffers { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Rescind) Size() (n int) { - var l int - _ = l - if m.OfferId != nil { - l = m.OfferId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Update) Size() (n int) { - var l int - _ = l - if m.Status != nil { - l = m.Status.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Message) Size() (n int) { - var l int - _ = l - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.ExecutorId != nil { - l = m.ExecutorId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Data != nil { - l = len(m.Data) - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Failure) Size() (n int) { - var l int - _ = l - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.ExecutorId != nil { - l = m.ExecutorId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Status != nil { - n += 1 + sovScheduler(uint64(*m.Status)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Event_Error) Size() (n int) { - var l int - _ = l - if m.Message != nil { - l = len(*m.Message) - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call) Size() (n int) { - var l int - _ = l - if m.FrameworkId != nil { - l = m.FrameworkId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Type != nil { - n += 1 + sovScheduler(uint64(*m.Type)) - } - if m.Subscribe != nil { - l = m.Subscribe.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Accept != nil { - l = m.Accept.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Decline != nil { - l = m.Decline.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Kill != nil { - l = m.Kill.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Shutdown != nil { - l = m.Shutdown.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Acknowledge != nil { - l = m.Acknowledge.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Reconcile != nil { - l = m.Reconcile.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Message != nil { - l = m.Message.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Request != nil { - l = m.Request.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Subscribe) Size() (n int) { - var l int - _ = l - if m.FrameworkInfo != nil { - l = m.FrameworkInfo.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Force != nil { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Accept) Size() (n int) { - var l int - _ = l - if len(m.OfferIds) > 0 { - for _, e := range m.OfferIds { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if len(m.Operations) > 0 { - for _, e := range m.Operations { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if m.Filters != nil { - l = m.Filters.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Decline) Size() (n int) { - var l int - _ = l - if len(m.OfferIds) > 0 { - for _, e := range m.OfferIds { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if m.Filters != nil { - l = m.Filters.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Kill) Size() (n int) { - var l int - _ = l - if m.TaskId != nil { - l = m.TaskId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Shutdown) Size() (n int) { - var l int - _ = l - if m.ExecutorId != nil { - l = m.ExecutorId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Acknowledge) Size() (n int) { - var l int - _ = l - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.TaskId != nil { - l = m.TaskId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Uuid != nil { - l = len(m.Uuid) - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Reconcile) Size() (n int) { - var l int - _ = l - if len(m.Tasks) > 0 { - for _, e := range m.Tasks { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Reconcile_Task) Size() (n int) { - var l int - _ = l - if m.TaskId != nil { - l = m.TaskId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Message) Size() (n int) { - var l int - _ = l - if m.SlaveId != nil { - l = m.SlaveId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.ExecutorId != nil { - l = m.ExecutorId.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - if m.Data != nil { - l = len(m.Data) - n += 1 + l + sovScheduler(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Call_Request) Size() (n int) { - var l int - _ = l - if len(m.Requests) > 0 { - for _, e := range m.Requests { - l = e.Size() - n += 1 + l + sovScheduler(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovScheduler(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozScheduler(x uint64) (n int) { - return sovScheduler(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *Event) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event{`, - `Type:` + valueToStringScheduler(this.Type) + `,`, - `Subscribed:` + strings.Replace(fmt.Sprintf("%v", this.Subscribed), "Event_Subscribed", "Event_Subscribed", 1) + `,`, - `Offers:` + strings.Replace(fmt.Sprintf("%v", this.Offers), "Event_Offers", "Event_Offers", 1) + `,`, - `Rescind:` + strings.Replace(fmt.Sprintf("%v", this.Rescind), "Event_Rescind", "Event_Rescind", 1) + `,`, - `Update:` + strings.Replace(fmt.Sprintf("%v", this.Update), "Event_Update", "Event_Update", 1) + `,`, - `Message:` + strings.Replace(fmt.Sprintf("%v", this.Message), "Event_Message", "Event_Message", 1) + `,`, - `Failure:` + strings.Replace(fmt.Sprintf("%v", this.Failure), "Event_Failure", "Event_Failure", 1) + `,`, - `Error:` + strings.Replace(fmt.Sprintf("%v", this.Error), "Event_Error", "Event_Error", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Subscribed) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Subscribed{`, - `FrameworkId:` + strings.Replace(fmt.Sprintf("%v", this.FrameworkId), "FrameworkID", "mesosproto.FrameworkID", 1) + `,`, - `HeartbeatIntervalSeconds:` + valueToStringScheduler(this.HeartbeatIntervalSeconds) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Offers) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Offers{`, - `Offers:` + strings.Replace(fmt.Sprintf("%v", this.Offers), "Offer", "mesosproto.Offer", 1) + `,`, - `InverseOffers:` + strings.Replace(fmt.Sprintf("%v", this.InverseOffers), "InverseOffer", "mesosproto.InverseOffer", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Rescind) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Rescind{`, - `OfferId:` + strings.Replace(fmt.Sprintf("%v", this.OfferId), "OfferID", "mesosproto.OfferID", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Update) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Update{`, - `Status:` + strings.Replace(fmt.Sprintf("%v", this.Status), "TaskStatus", "mesosproto.TaskStatus", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Message) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Message{`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `ExecutorId:` + strings.Replace(fmt.Sprintf("%v", this.ExecutorId), "ExecutorID", "mesosproto.ExecutorID", 1) + `,`, - `Data:` + valueToStringScheduler(this.Data) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Failure) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Failure{`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `ExecutorId:` + strings.Replace(fmt.Sprintf("%v", this.ExecutorId), "ExecutorID", "mesosproto.ExecutorID", 1) + `,`, - `Status:` + valueToStringScheduler(this.Status) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Event_Error) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Event_Error{`, - `Message:` + valueToStringScheduler(this.Message) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call{`, - `FrameworkId:` + strings.Replace(fmt.Sprintf("%v", this.FrameworkId), "FrameworkID", "mesosproto.FrameworkID", 1) + `,`, - `Type:` + valueToStringScheduler(this.Type) + `,`, - `Subscribe:` + strings.Replace(fmt.Sprintf("%v", this.Subscribe), "Call_Subscribe", "Call_Subscribe", 1) + `,`, - `Accept:` + strings.Replace(fmt.Sprintf("%v", this.Accept), "Call_Accept", "Call_Accept", 1) + `,`, - `Decline:` + strings.Replace(fmt.Sprintf("%v", this.Decline), "Call_Decline", "Call_Decline", 1) + `,`, - `Kill:` + strings.Replace(fmt.Sprintf("%v", this.Kill), "Call_Kill", "Call_Kill", 1) + `,`, - `Shutdown:` + strings.Replace(fmt.Sprintf("%v", this.Shutdown), "Call_Shutdown", "Call_Shutdown", 1) + `,`, - `Acknowledge:` + strings.Replace(fmt.Sprintf("%v", this.Acknowledge), "Call_Acknowledge", "Call_Acknowledge", 1) + `,`, - `Reconcile:` + strings.Replace(fmt.Sprintf("%v", this.Reconcile), "Call_Reconcile", "Call_Reconcile", 1) + `,`, - `Message:` + strings.Replace(fmt.Sprintf("%v", this.Message), "Call_Message", "Call_Message", 1) + `,`, - `Request:` + strings.Replace(fmt.Sprintf("%v", this.Request), "Call_Request", "Call_Request", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Subscribe) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Subscribe{`, - `FrameworkInfo:` + strings.Replace(fmt.Sprintf("%v", this.FrameworkInfo), "FrameworkInfo", "mesosproto.FrameworkInfo", 1) + `,`, - `Force:` + valueToStringScheduler(this.Force) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Accept) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Accept{`, - `OfferIds:` + strings.Replace(fmt.Sprintf("%v", this.OfferIds), "OfferID", "mesosproto.OfferID", 1) + `,`, - `Operations:` + strings.Replace(fmt.Sprintf("%v", this.Operations), "Offer_Operation", "mesosproto.Offer_Operation", 1) + `,`, - `Filters:` + strings.Replace(fmt.Sprintf("%v", this.Filters), "Filters", "mesosproto.Filters", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Decline) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Decline{`, - `OfferIds:` + strings.Replace(fmt.Sprintf("%v", this.OfferIds), "OfferID", "mesosproto.OfferID", 1) + `,`, - `Filters:` + strings.Replace(fmt.Sprintf("%v", this.Filters), "Filters", "mesosproto.Filters", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Kill) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Kill{`, - `TaskId:` + strings.Replace(fmt.Sprintf("%v", this.TaskId), "TaskID", "mesosproto.TaskID", 1) + `,`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Shutdown) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Shutdown{`, - `ExecutorId:` + strings.Replace(fmt.Sprintf("%v", this.ExecutorId), "ExecutorID", "mesosproto.ExecutorID", 1) + `,`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Acknowledge) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Acknowledge{`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `TaskId:` + strings.Replace(fmt.Sprintf("%v", this.TaskId), "TaskID", "mesosproto.TaskID", 1) + `,`, - `Uuid:` + valueToStringScheduler(this.Uuid) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Reconcile) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Reconcile{`, - `Tasks:` + strings.Replace(fmt.Sprintf("%v", this.Tasks), "Call_Reconcile_Task", "Call_Reconcile_Task", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Reconcile_Task) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Reconcile_Task{`, - `TaskId:` + strings.Replace(fmt.Sprintf("%v", this.TaskId), "TaskID", "mesosproto.TaskID", 1) + `,`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Message) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Message{`, - `SlaveId:` + strings.Replace(fmt.Sprintf("%v", this.SlaveId), "SlaveID", "mesosproto.SlaveID", 1) + `,`, - `ExecutorId:` + strings.Replace(fmt.Sprintf("%v", this.ExecutorId), "ExecutorID", "mesosproto.ExecutorID", 1) + `,`, - `Data:` + valueToStringScheduler(this.Data) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func (this *Call_Request) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&Call_Request{`, - `Requests:` + strings.Replace(fmt.Sprintf("%v", this.Requests), "Request", "mesosproto.Request", 1) + `,`, - `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, - `}`, - }, "") - return s -} -func valueToStringScheduler(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *Event) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Event: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var v Event_Type - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - v |= (Event_Type(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Type = &v - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subscribed", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Subscribed == nil { - m.Subscribed = &Event_Subscribed{} - } - if err := m.Subscribed.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Offers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Offers == nil { - m.Offers = &Event_Offers{} - } - if err := m.Offers.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rescind", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Rescind == nil { - m.Rescind = &Event_Rescind{} - } - if err := m.Rescind.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Update", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Update == nil { - m.Update = &Event_Update{} - } - if err := m.Update.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Message == nil { - m.Message = &Event_Message{} - } - if err := m.Message.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Failure", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Failure == nil { - m.Failure = &Event_Failure{} - } - if err := m.Failure.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Error == nil { - m.Error = &Event_Error{} - } - if err := m.Error.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("type") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Subscribed) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Subscribed: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Subscribed: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FrameworkId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FrameworkId == nil { - m.FrameworkId = &mesosproto.FrameworkID{} - } - if err := m.FrameworkId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field HeartbeatIntervalSeconds", wireType) - } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF - } - iNdEx += 8 - v = uint64(data[iNdEx-8]) - v |= uint64(data[iNdEx-7]) << 8 - v |= uint64(data[iNdEx-6]) << 16 - v |= uint64(data[iNdEx-5]) << 24 - v |= uint64(data[iNdEx-4]) << 32 - v |= uint64(data[iNdEx-3]) << 40 - v |= uint64(data[iNdEx-2]) << 48 - v |= uint64(data[iNdEx-1]) << 56 - v2 := float64(math.Float64frombits(v)) - m.HeartbeatIntervalSeconds = &v2 - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("framework_id") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Offers) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Offers: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Offers: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Offers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Offers = append(m.Offers, &mesosproto.Offer{}) - if err := m.Offers[len(m.Offers)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InverseOffers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.InverseOffers = append(m.InverseOffers, &mesosproto.InverseOffer{}) - if err := m.InverseOffers[len(m.InverseOffers)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Rescind) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Rescind: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Rescind: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OfferId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.OfferId == nil { - m.OfferId = &mesosproto.OfferID{} - } - if err := m.OfferId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("offer_id") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Update) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Update: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Update: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Status == nil { - m.Status = &mesosproto.TaskStatus{} - } - if err := m.Status.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("status") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Message) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutorId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ExecutorId == nil { - m.ExecutorId = &mesosproto.ExecutorID{} - } - if err := m.ExecutorId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000002) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append([]byte{}, data[iNdEx:postIndex]...) - iNdEx = postIndex - hasFields[0] |= uint64(0x00000004) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } - if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } - if hasFields[0]&uint64(0x00000004) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("data") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Failure) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Failure: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Failure: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutorId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ExecutorId == nil { - m.ExecutorId = &mesosproto.ExecutorID{} - } - if err := m.ExecutorId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - var v int32 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - v |= (int32(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Status = &v - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Event_Error) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Error: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Error: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - s := string(data[iNdEx:postIndex]) - m.Message = &s - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("message") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Call: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Call: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FrameworkId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FrameworkId == nil { - m.FrameworkId = &mesosproto.FrameworkID{} - } - if err := m.FrameworkId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var v Call_Type - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - v |= (Call_Type(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Type = &v - hasFields[0] |= uint64(0x00000001) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subscribe", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Subscribe == nil { - m.Subscribe = &Call_Subscribe{} - } - if err := m.Subscribe.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Accept", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Accept == nil { - m.Accept = &Call_Accept{} - } - if err := m.Accept.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Decline", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Decline == nil { - m.Decline = &Call_Decline{} - } - if err := m.Decline.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kill", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Kill == nil { - m.Kill = &Call_Kill{} - } - if err := m.Kill.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shutdown", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Shutdown == nil { - m.Shutdown = &Call_Shutdown{} - } - if err := m.Shutdown.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Acknowledge", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Acknowledge == nil { - m.Acknowledge = &Call_Acknowledge{} - } - if err := m.Acknowledge.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Reconcile", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Reconcile == nil { - m.Reconcile = &Call_Reconcile{} - } - if err := m.Reconcile.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Message == nil { - m.Message = &Call_Message{} - } - if err := m.Message.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Request == nil { - m.Request = &Call_Request{} - } - if err := m.Request.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("type") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Subscribe) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Subscribe: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Subscribe: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FrameworkInfo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FrameworkInfo == nil { - m.FrameworkInfo = &mesosproto.FrameworkInfo{} - } - if err := m.FrameworkInfo.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Force", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - b := bool(v != 0) - m.Force = &b - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("framework_info") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Accept) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Accept: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Accept: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OfferIds", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OfferIds = append(m.OfferIds, &mesosproto.OfferID{}) - if err := m.OfferIds[len(m.OfferIds)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Operations = append(m.Operations, &mesosproto.Offer_Operation{}) - if err := m.Operations[len(m.Operations)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Filters == nil { - m.Filters = &mesosproto.Filters{} - } - if err := m.Filters.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Decline) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Decline: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Decline: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OfferIds", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OfferIds = append(m.OfferIds, &mesosproto.OfferID{}) - if err := m.OfferIds[len(m.OfferIds)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Filters", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Filters == nil { - m.Filters = &mesosproto.Filters{} - } - if err := m.Filters.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Kill) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Kill: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Kill: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TaskId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TaskId == nil { - m.TaskId = &mesosproto.TaskID{} - } - if err := m.TaskId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Shutdown) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Shutdown: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Shutdown: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutorId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ExecutorId == nil { - m.ExecutorId = &mesosproto.ExecutorID{} - } - if err := m.ExecutorId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000002) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } - if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Acknowledge) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Acknowledge: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Acknowledge: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TaskId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TaskId == nil { - m.TaskId = &mesosproto.TaskID{} - } - if err := m.TaskId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000002) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Uuid = append([]byte{}, data[iNdEx:postIndex]...) - iNdEx = postIndex - hasFields[0] |= uint64(0x00000004) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } - if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } - if hasFields[0]&uint64(0x00000004) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("uuid") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Reconcile) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Reconcile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Reconcile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tasks", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Tasks = append(m.Tasks, &Call_Reconcile_Task{}) - if err := m.Tasks[len(m.Tasks)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Reconcile_Task) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Task: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Task: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TaskId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TaskId == nil { - m.TaskId = &mesosproto.TaskID{} - } - if err := m.TaskId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("task_id") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Message) Unmarshal(data []byte) error { - var hasFields [1]uint64 - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlaveId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.SlaveId == nil { - m.SlaveId = &mesosproto.SlaveID{} - } - if err := m.SlaveId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000001) - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExecutorId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ExecutorId == nil { - m.ExecutorId = &mesosproto.ExecutorID{} - } - if err := m.ExecutorId.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - hasFields[0] |= uint64(0x00000002) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append([]byte{}, data[iNdEx:postIndex]...) - iNdEx = postIndex - hasFields[0] |= uint64(0x00000004) - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - if hasFields[0]&uint64(0x00000001) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("slave_id") - } - if hasFields[0]&uint64(0x00000002) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("executor_id") - } - if hasFields[0]&uint64(0x00000004) == 0 { - return github_com_gogo_protobuf_proto.NewRequiredNotSetError("data") - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Call_Request) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowScheduler - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthScheduler - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Requests = append(m.Requests, &mesosproto.Request{}) - if err := m.Requests[len(m.Requests)-1].Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipScheduler(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthScheduler - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, data[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipScheduler(data []byte) (n int, err error) { - l := len(data) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowScheduler - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowScheduler - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if data[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowScheduler - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthScheduler - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowScheduler - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipScheduler(data[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthScheduler = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowScheduler = fmt.Errorf("proto: integer overflow") -) diff --git a/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.proto b/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.proto deleted file mode 100644 index 34b6be803dc..00000000000 --- a/vendor/github.com/mesos/mesos-go/mesosproto/scheduler/scheduler.proto +++ /dev/null @@ -1,347 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package mesosproto.scheduler; - -import "github.com/mesos/mesos-go/mesosproto/mesos.proto"; -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; - -option go_package = "scheduler"; -option (gogoproto.gostring_all) = true; -option (gogoproto.equal_all) = true; -option (gogoproto.verbose_equal_all) = true; -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = true; -option (gogoproto.populate_all) = true; -option (gogoproto.testgen_all) = true; -option (gogoproto.benchgen_all) = true; -option (gogoproto.marshaler_all) = true; -option (gogoproto.sizer_all) = true; -option (gogoproto.unmarshaler_all) = true; - -/** - * Scheduler event API. - * - * An event is described using the standard protocol buffer "union" - * trick, see: - * https://developers.google.com/protocol-buffers/docs/techniques#union. - */ -message Event { - // Possible event types, followed by message definitions if - // applicable. - enum Type { - SUBSCRIBED = 1; // See 'Subscribed' below. - OFFERS = 2; // See 'Offers' below. - RESCIND = 3; // See 'Rescind' below. - UPDATE = 4; // See 'Update' below. - MESSAGE = 5; // See 'Message' below. - FAILURE = 6; // See 'Failure' below. - ERROR = 7; // See 'Error' below. - - // Periodic message sent by the Mesos master according to - // 'Subscribed.heartbeat_interval_seconds'. If the scheduler does - // not receive any events (including heartbeats) for an extended - // period of time (e.g., 5 x heartbeat_interval_seconds), there is - // likely a network partition. In such a case the scheduler should - // close the existing subscription connection and resubscribe - // using a backoff strategy. - HEARTBEAT = 8; - } - - // First event received when the scheduler subscribes. - message Subscribed { - required FrameworkID framework_id = 1; - - // This value will be set if the master is sending heartbeats. See - // the comment above on 'HEARTBEAT' for more details. - optional double heartbeat_interval_seconds = 2; - } - - // Received whenever there are new resources that are offered to the - // scheduler or resources requested back from the scheduler. Each - // offer corresponds to a set of resources on a slave. Until the - // scheduler accepts or declines an offer the resources are - // considered allocated to the scheduler. Accepting or Declining an - // inverse offer informs the allocator of the scheduler's ability to - // release the resources without violating an SLA. - message Offers { - repeated Offer offers = 1; - repeated InverseOffer inverse_offers = 2; - } - - // Received when a particular offer is no longer valid (e.g., the - // slave corresponding to the offer has been removed) and hence - // needs to be rescinded. Any future calls ('Accept' / 'Decline') made - // by the scheduler regarding this offer will be invalid. - message Rescind { - required OfferID offer_id = 1; - } - - // Received whenever there is a status update that is generated by - // the executor or slave or master. Status updates should be used by - // executors to reliably communicate the status of the tasks that - // they manage. It is crucial that a terminal update (see TaskState - // in mesos.proto) is sent by the executor as soon as the task - // terminates, in order for Mesos to release the resources allocated - // to the task. It is also the responsibility of the scheduler to - // explicitly acknowledge the receipt of a status update. See - // 'Acknowledge' in the 'Call' section below for the semantics. - message Update { - required TaskStatus status = 1; - } - - // Received when a custom message generated by the executor is - // forwarded by the master. Note that this message is not - // interpreted by Mesos and is only forwarded (without reliability - // guarantees) to the scheduler. It is up to the executor to retry - // if the message is dropped for any reason. - message Message { - required SlaveID slave_id = 1; - required ExecutorID executor_id = 2; - required bytes data = 3; - } - - // Received when a slave is removed from the cluster (e.g., failed - // health checks) or when an executor is terminated. Note that, this - // event coincides with receipt of terminal UPDATE events for any - // active tasks belonging to the slave or executor and receipt of - // 'Rescind' events for any outstanding offers belonging to the - // slave. Note that there is no guaranteed order between the - // 'Failure', 'Update' and 'Rescind' events when a slave or executor - // is removed. - // TODO(vinod): Consider splitting the lost slave and terminated - // executor into separate events and ensure it's reliably generated. - message Failure { - optional SlaveID slave_id = 1; - - // If this was just a failure of an executor on a slave then - // 'executor_id' will be set and possibly 'status' (if we were - // able to determine the exit status). - optional ExecutorID executor_id = 2; - optional int32 status = 3; - } - - // Received when an invalid framework (e.g., unauthenticated, - // unauthorized) attempts to subscribe with the master. Error can - // also be received if scheduler sends invalid Calls (e.g., not - // properly initialized). - // TODO(vinod): Remove this once the old scheduler driver is no - // longer supported. With HTTP API all errors will be signaled via - // HTTP response codes. - message Error { - required string message = 1; - } - - // Type of the event, indicates which optional field below should be - // present if that type has a nested message definition. - required Type type = 1; - - optional Subscribed subscribed = 2; - optional Offers offers = 3; - optional Rescind rescind = 4; - optional Update update = 5; - optional Message message = 6; - optional Failure failure = 7; - optional Error error = 8; -} - - -/** - * Scheduler call API. - * - * Like Event, a Call is described using the standard protocol buffer - * "union" trick (see above). - */ -message Call { - // Possible call types, followed by message definitions if - // applicable. - enum Type { - SUBSCRIBE = 1; // See 'Subscribe' below. - TEARDOWN = 2; // Shuts down all tasks/executors and removes framework. - ACCEPT = 3; // See 'Accept' below. - DECLINE = 4; // See 'Decline' below. - REVIVE = 5; // Removes any previous filters set via ACCEPT or DECLINE. - KILL = 6; // See 'Kill' below. - SHUTDOWN = 7; // See 'Shutdown' below. - ACKNOWLEDGE = 8; // See 'Acknowledge' below. - RECONCILE = 9; // See 'Reconcile' below. - MESSAGE = 10; // See 'Message' below. - REQUEST = 11; // See 'Request' below. - SUPPRESS = 12; // Inform master to stop sending offers to the framework. - - // TODO(benh): Consider adding an 'ACTIVATE' and 'DEACTIVATE' for - // already subscribed frameworks as a way of stopping offers from - // being generated and other events from being sent by the master. - // Note that this functionality existed originally to support - // SchedulerDriver::abort which was only necessary to handle - // exceptions getting thrown from within Scheduler callbacks, - // something that is not an issue with the Event/Call API. - } - - // Subscribes the scheduler with the master to receive events. A - // scheduler must send other calls only after it has received the - // SUBCRIBED event. - message Subscribe { - // See the comments below on 'framework_id' on the semantics for - // 'framework_info.id'. - required FrameworkInfo framework_info = 1; - - // 'force' field is only relevant when 'framework_info.id' is set. - // It tells the master what to do in case an instance of the - // scheduler attempts to subscribe when another instance of it is - // already connected (e.g., split brain due to network partition). - // If 'force' is true, this scheduler instance is allowed and the - // old connected scheduler instance is disconnected. If false, - // this scheduler instance is disallowed subscription in favor of - // the already connected scheduler instance. - // - // It is recommended to set this to true only when a newly elected - // scheduler instance is attempting to subscribe but not when a - // scheduler is retrying subscription (e.g., disconnection or - // master failover; see sched/sched.cpp for an example). - optional bool force = 2; - } - - // Accepts an offer, performing the specified operations - // in a sequential manner. - // - // E.g. Launch a task with a newly reserved persistent volume: - // - // Accept { - // offer_ids: [ ... ] - // operations: [ - // { type: RESERVE, - // reserve: { resources: [ disk(role):2 ] } } - // { type: CREATE, - // create: { volumes: [ disk(role):1+persistence ] } } - // { type: LAUNCH, - // launch: { task_infos ... disk(role):1;disk(role):1+persistence } } - // ] - // } - // - // Note that any of the offer’s resources not used in the 'Accept' - // call (e.g., to launch a task) are considered unused and might be - // reoffered to other frameworks. In other words, the same OfferID - // cannot be used in more than one 'Accept' call. - message Accept { - repeated OfferID offer_ids = 1; - repeated Offer.Operation operations = 2; - optional Filters filters = 3; - } - - // Declines an offer, signaling the master to potentially reoffer - // the resources to a different framework. Note that this is same - // as sending an Accept call with no operations. See comments on - // top of 'Accept' for semantics. - message Decline { - repeated OfferID offer_ids = 1; - optional Filters filters = 2; - } - - // Kills a specific task. If the scheduler has a custom executor, - // the kill is forwarded to the executor and it is up to the - // executor to kill the task and send a TASK_KILLED (or TASK_FAILED) - // update. Note that Mesos releases the resources for a task once it - // receives a terminal update (See TaskState in mesos.proto) for it. - // If the task is unknown to the master, a TASK_LOST update is - // generated. - message Kill { - required TaskID task_id = 1; - optional SlaveID slave_id = 2; - } - - // Shuts down a custom executor. When the executor gets a shutdown - // event, it is expected to kill all its tasks (and send TASK_KILLED - // updates) and terminate. If the executor doesn’t terminate within - // a certain timeout (configurable via - // '--executor_shutdown_grace_period' slave flag), the slave will - // forcefully destroy the container (executor and its tasks) and - // transition its active tasks to TASK_LOST. - message Shutdown { - required ExecutorID executor_id = 1; - required SlaveID slave_id = 2; - } - - // Acknowledges the receipt of status update. Schedulers are - // responsible for explicitly acknowledging the receipt of status - // updates that have 'Update.status().uuid()' field set. Such status - // updates are retried by the slave until they are acknowledged by - // the scheduler. - message Acknowledge { - required SlaveID slave_id = 1; - required TaskID task_id = 2; - required bytes uuid = 3; - } - - // Allows the scheduler to query the status for non-terminal tasks. - // This causes the master to send back the latest task status for - // each task in 'tasks', if possible. Tasks that are no longer known - // will result in a TASK_LOST update. If 'statuses' is empty, then - // the master will send the latest status for each task currently - // known. - message Reconcile { - // TODO(vinod): Support arbitrary queries than just state of tasks. - message Task { - required TaskID task_id = 1; - optional SlaveID slave_id = 2; - } - - repeated Task tasks = 1; - } - - // Sends arbitrary binary data to the executor. Note that Mesos - // neither interprets this data nor makes any guarantees about the - // delivery of this message to the executor. - message Message { - required SlaveID slave_id = 1; - required ExecutorID executor_id = 2; - required bytes data = 3; - } - - // Requests a specific set of resources from Mesos's allocator. If - // the allocator has support for this, corresponding offers will be - // sent asynchronously via the OFFERS event(s). - // - // NOTE: The built-in hierarchical allocator doesn't have support - // for this call and hence simply ignores it. - message Request { - repeated mesosproto.Request requests = 1; - } - - // Identifies who generated this call. Master assigns a framework id - // when a new scheduler subscribes for the first time. Once assigned, - // the scheduler must set the 'framework_id' here and within its - // FrameworkInfo (in any further 'Subscribe' calls). This allows the - // master to identify a scheduler correctly across disconnections, - // failovers, etc. - optional FrameworkID framework_id = 1; - - // Type of the call, indicates which optional field below should be - // present if that type has a nested message definition. - required Type type = 2; - - optional Subscribe subscribe = 3; - optional Accept accept = 4; - optional Decline decline = 5; - optional Kill kill = 6; - optional Shutdown shutdown = 7; - optional Acknowledge acknowledge = 8; - optional Reconcile reconcile = 9; - optional Message message = 10; - optional Request request = 11; -} diff --git a/vendor/github.com/mesos/mesos-go/mesosutil/process/process.go b/vendor/github.com/mesos/mesos-go/mesosutil/process/process.go deleted file mode 100644 index 544b25f89c0..00000000000 --- a/vendor/github.com/mesos/mesos-go/mesosutil/process/process.go +++ /dev/null @@ -1,34 +0,0 @@ -package process - -import ( - "fmt" - "sync" -) - -var ( - pidLock sync.Mutex - pid uint64 -) - -func nextPid() uint64 { - pidLock.Lock() - defer pidLock.Unlock() - pid++ - return pid -} - -//TODO(jdef) add lifecycle funcs -//TODO(jdef) add messaging funcs -type Process struct { - label string -} - -func New(kind string) *Process { - return &Process{ - label: fmt.Sprintf("%s(%d)", kind, nextPid()), - } -} - -func (p *Process) Label() string { - return p.label -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/README.md b/vendor/github.com/mesos/mesos-go/messenger/README.md deleted file mode 100644 index d3535253d31..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/README.md +++ /dev/null @@ -1,39 +0,0 @@ -####Benchmark of the messenger. - -```shell -$ go test -v -run=Benckmark* -bench=. -PASS -BenchmarkMessengerSendSmallMessage 50000 70568 ns/op -BenchmarkMessengerSendMediumMessage 50000 70265 ns/op -BenchmarkMessengerSendBigMessage 50000 72693 ns/op -BenchmarkMessengerSendLargeMessage 50000 72896 ns/op -BenchmarkMessengerSendMixedMessage 50000 72631 ns/op -BenchmarkMessengerSendRecvSmallMessage 20000 78409 ns/op -BenchmarkMessengerSendRecvMediumMessage 20000 80471 ns/op -BenchmarkMessengerSendRecvBigMessage 20000 82629 ns/op -BenchmarkMessengerSendRecvLargeMessage 20000 85987 ns/op -BenchmarkMessengerSendRecvMixedMessage 20000 83678 ns/op -ok github.com/mesos/mesos-go/messenger 115.135s - -$ go test -v -run=Benckmark* -bench=. -cpu=4 -send-routines=4 2>/dev/null -PASS -BenchmarkMessengerSendSmallMessage-4 50000 35529 ns/op -BenchmarkMessengerSendMediumMessage-4 50000 35997 ns/op -BenchmarkMessengerSendBigMessage-4 50000 36871 ns/op -BenchmarkMessengerSendLargeMessage-4 50000 37310 ns/op -BenchmarkMessengerSendMixedMessage-4 50000 37419 ns/op -BenchmarkMessengerSendRecvSmallMessage-4 50000 39320 ns/op -BenchmarkMessengerSendRecvMediumMessage-4 50000 41990 ns/op -BenchmarkMessengerSendRecvBigMessage-4 50000 42157 ns/op -BenchmarkMessengerSendRecvLargeMessage-4 50000 45472 ns/op -BenchmarkMessengerSendRecvMixedMessage-4 50000 47393 ns/op -ok github.com/mesos/mesos-go/messenger 105.173s -``` - -####environment: - -``` -OS: Linux yifan-laptop 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux -CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz -MEM: 4G DDR3 1600MHz -``` diff --git a/vendor/github.com/mesos/mesos-go/messenger/decoder.go b/vendor/github.com/mesos/mesos-go/messenger/decoder.go deleted file mode 100644 index a1f8bac75ae..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/decoder.go +++ /dev/null @@ -1,638 +0,0 @@ -package messenger - -import ( - "bufio" - "bytes" - "errors" - "io" - "net" - "net/http" - "net/textproto" - "net/url" - "strconv" - "strings" - "sync" - "sync/atomic" - "syscall" - "time" - - log "github.com/golang/glog" -) - -const ( - // writeFlushPeriod is the amount of time we're willing to wait for a single - // response buffer to be fully written to the underlying TCP connection; after - // this amount of time the remaining bytes of the response are discarded. see - // responseWriter(). - writeFlushPeriod = 30 * time.Second -) - -type decoderID int32 - -func (did decoderID) String() string { - return "[" + strconv.Itoa(int(did)) + "]" -} - -func (did *decoderID) next() decoderID { - return decoderID(atomic.AddInt32((*int32)(did), 1)) -} - -var ( - errHijackFailed = errors.New("failed to hijack http connection") - did decoderID // decoder ID counter -) - -type Decoder interface { - Requests() <-chan *Request - Err() <-chan error - Cancel(bool) -} - -type Request struct { - *http.Request - response chan<- Response // callers that are finished with a Request should ensure that response is *always* closed, regardless of whether a Response has been written. -} - -type Response struct { - code int - reason string -} - -type httpDecoder struct { - req *http.Request // original request - kalive bool // keepalive - chunked bool // chunked - msg chan *Request - con net.Conn - rw *bufio.ReadWriter - errCh chan error - buf *bytes.Buffer - lrc *io.LimitedReader - shouldQuit chan struct{} // signal chan, closes upon calls to Cancel(...) - forceQuit chan struct{} // signal chan, indicates that quit is NOT graceful; closes upon Cancel(false) - cancelGuard sync.Mutex - readTimeout time.Duration - writeTimeout time.Duration - idtag string // useful for debugging - sendError func(err error) // abstraction for error handling - outCh chan *bytes.Buffer // chan of responses to be written to the connection -} - -// DecodeHTTP hijacks an HTTP server connection and generates mesos libprocess HTTP -// requests via the returned chan. Upon generation of an error in the error chan the -// decoder's internal goroutine will terminate. This func returns immediately. -// The caller should immediately *stop* using the ResponseWriter and Request that were -// passed as parameters; the decoder assumes full control of the HTTP transport. -func DecodeHTTP(w http.ResponseWriter, r *http.Request) Decoder { - id := did.next() - d := &httpDecoder{ - msg: make(chan *Request), - errCh: make(chan error, 1), - req: r, - shouldQuit: make(chan struct{}), - forceQuit: make(chan struct{}), - readTimeout: ReadTimeout, - writeTimeout: WriteTimeout, - idtag: id.String(), - outCh: make(chan *bytes.Buffer), - } - d.sendError = d.defaultSendError - go d.run(w) - return d -} - -func (d *httpDecoder) Requests() <-chan *Request { - return d.msg -} - -func (d *httpDecoder) Err() <-chan error { - return d.errCh -} - -// Cancel the decoding process; if graceful then process pending responses before terminating -func (d *httpDecoder) Cancel(graceful bool) { - log.V(2).Infof("%scancel:%t", d.idtag, graceful) - d.cancelGuard.Lock() - defer d.cancelGuard.Unlock() - select { - case <-d.shouldQuit: - // already quitting, but perhaps gracefully? - default: - close(d.shouldQuit) - } - // allow caller to "upgrade" from a graceful cancel to a forced one - if !graceful { - select { - case <-d.forceQuit: - // already forcefully quitting - default: - close(d.forceQuit) // push it! - } - } -} - -func (d *httpDecoder) run(res http.ResponseWriter) { - defer func() { - close(d.outCh) // we're finished generating response objects - log.V(2).Infoln(d.idtag + "run: terminating") - }() - - for state := d.bootstrapState(res); state != nil; { - next := state(d) - state = next - } -} - -// tryFlushResponse flushes the response buffer (if not empty); returns true if flush succeeded -func (d *httpDecoder) tryFlushResponse(out *bytes.Buffer) { - log.V(2).Infof(d.idtag+"try-flush-responses: %d bytes to flush", out.Len()) - // set a write deadline here so that we don't block for very long. - err := d.setWriteTimeout() - if err != nil { - // this is a problem because if we can't set the timeout then we can't guarantee - // how long a write op might block for. Log the error and skip this response. - log.Errorln("failed to set write deadline, aborting response:", err.Error()) - } else { - _, err = out.WriteTo(d.rw.Writer) - if err != nil { - if neterr, ok := err.(net.Error); ok && neterr.Timeout() && out.Len() > 0 { - // we couldn't fully write before timing out, return rch and hope that - // we have better luck next time. - return - } - // we don't really know how to deal with other kinds of errors, so - // log it and skip the rest of the response. - log.Errorln("failed to write response buffer:", err.Error()) - } - err = d.rw.Flush() - if err != nil { - if neterr, ok := err.(net.Error); ok && neterr.Timeout() && out.Len() > 0 { - return - } - log.Errorln("failed to flush response buffer:", err.Error()) - } - } -} - -// TODO(jdef) make this a func on Response, to write its contents to a *bytes.Buffer -func (d *httpDecoder) buildResponseEntity(resp *Response) *bytes.Buffer { - log.V(2).Infoln(d.idtag + "build-response-entity") - - out := &bytes.Buffer{} - - // generate new response buffer content and continue; buffer should have - // at least a response status-line w/ Content-Length: 0 - out.WriteString("HTTP/1.1 ") - out.WriteString(strconv.Itoa(resp.code)) - out.WriteString(" ") - out.WriteString(resp.reason) - out.WriteString(crlf + "Content-Length: 0" + crlf) - - select { - case <-d.shouldQuit: - // this is the last request in the pipeline and we've been told to quit, so - // indicate that the server will close the connection. - out.WriteString("Connection: Close" + crlf) - default: - } - out.WriteString(crlf) // this ends the HTTP response entity - return out -} - -// updateForRequest updates the chunked and kalive fields of the decoder to align -// with the header values of the request -func (d *httpDecoder) updateForRequest(bootstrapping bool) { - // check "Transfer-Encoding" for "chunked" - d.chunked = false - for _, v := range d.req.Header["Transfer-Encoding"] { - if v == "chunked" { - d.chunked = true - break - } - } - if !d.chunked && d.req.ContentLength < 0 { - if bootstrapping { - // strongly suspect that Go's internal net/http lib is stripping - // the Transfer-Encoding header from the initial request, so this - // workaround makes a very mesos-specific assumption: an unknown - // Content-Length indicates a chunked stream. - d.chunked = true - } else { - // via https://tools.ietf.org/html/rfc7230#section-3.3.2 - d.req.ContentLength = 0 - } - } - - // check "Connection" for "Keep-Alive" - d.kalive = d.req.Header.Get("Connection") == "Keep-Alive" - - log.V(2).Infof(d.idtag+"update-for-request: chunked %v keep-alive %v", d.chunked, d.kalive) -} - -func (d *httpDecoder) readBodyContent() httpState { - log.V(2).Info(d.idtag + "read-body-content") - if d.chunked { - d.buf = &bytes.Buffer{} - return readChunkHeaderState - } else { - d.lrc = limit(d.rw.Reader, d.req.ContentLength) - d.buf = &bytes.Buffer{} - return readBodyState - } -} - -const http202response = "HTTP/1.1 202 OK\r\nContent-Length: 0\r\n\r\n" - -func (d *httpDecoder) generateRequest() httpState { - log.V(2).Infof(d.idtag + "generate-request") - // send a Request to msg - b := d.buf.Bytes() - rch := make(chan Response, 1) - r := &Request{ - Request: &http.Request{ - Method: d.req.Method, - URL: d.req.URL, - Proto: d.req.Proto, - ProtoMajor: d.req.ProtoMajor, - ProtoMinor: d.req.ProtoMinor, - Header: d.req.Header, - Close: !d.kalive, - Host: d.req.Host, - RequestURI: d.req.RequestURI, - Body: &body{bytes.NewBuffer(b)}, - ContentLength: int64(len(b)), - }, - response: rch, - } - - select { - case d.msg <- r: - case <-d.forceQuit: - return terminateState - } - - select { - case <-d.forceQuit: - return terminateState - case resp, ok := <-rch: - if ok { - // response required, so build it and ship it - out := d.buildResponseEntity(&resp) - select { - case <-d.forceQuit: - return terminateState - case d.outCh <- out: - } - } - } - - if d.kalive { - d.req = &http.Request{ - ContentLength: -1, - Header: make(http.Header), - } - return awaitRequestState - } else { - return gracefulTerminateState - } -} - -func (d *httpDecoder) defaultSendError(err error) { - d.errCh <- err -} - -type httpState func(d *httpDecoder) httpState - -// terminateState forcefully shuts down the state machine -func terminateState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "terminate-state") - // closing these chans tells Decoder users that it's wrapping up - close(d.msg) - close(d.errCh) - - // attempt to forcefully close the connection and signal response handlers that - // no further responses should be written - d.Cancel(false) - - if d.con != nil { - d.con.Close() - } - - // there is no spoon - return nil -} - -func gracefulTerminateState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "gracefully-terminate-state") - // closing these chans tells Decoder users that it's wrapping up - close(d.msg) - close(d.errCh) - - // gracefully terminate the connection; signal that we should flush pending - // responses before closing the connection. - d.Cancel(true) - - return nil -} - -func limit(r *bufio.Reader, limit int64) *io.LimitedReader { - return &io.LimitedReader{ - R: r, - N: limit, - } -} - -// bootstrapState expects to be called when the standard net/http lib has already -// read the initial request query line + headers from a connection. the request -// is ready to be hijacked at this point. -func (d *httpDecoder) bootstrapState(res http.ResponseWriter) httpState { - log.V(2).Infoln(d.idtag + "bootstrap-state") - - d.updateForRequest(true) - - // hijack - hj, ok := res.(http.Hijacker) - if !ok { - http.Error(res, "server does not support hijack", http.StatusInternalServerError) - d.sendError(errHijackFailed) - return terminateState - } - c, rw, err := hj.Hijack() - if err != nil { - http.Error(res, "failed to hijack the connection", http.StatusInternalServerError) - d.sendError(errHijackFailed) - return terminateState - } - - d.rw = rw - d.con = c - - go d.responseWriter() - return d.readBodyContent() -} - -func (d *httpDecoder) responseWriter() { - defer func() { - log.V(3).Infoln(d.idtag + "response-writer: closing connection") - d.con.Close() - }() - for buf := range d.outCh { - //TODO(jdef) I worry about this busy-looping - - // write & flush the buffer until there's nothing left in it, or else - // we exceed the write/flush period. - now := time.Now() - for buf.Len() > 0 && time.Since(now) < writeFlushPeriod { - select { - case <-d.forceQuit: - return - default: - } - d.tryFlushResponse(buf) - } - if buf.Len() > 0 { - //TODO(jdef) should we abort the entire connection instead? a partially written - // response doesn't do anyone any good. That said, real libprocess agents don't - // really care about the response channel anyway - the entire system is fire and - // forget. So I've decided to err on the side that we might lose response bytes - // in favor of completely reading the connection request stream before we terminate. - log.Errorln(d.idtag + "failed to fully flush output buffer within write-flush period") - } - } -} - -type body struct { - *bytes.Buffer -} - -func (b *body) Close() error { return nil } - -// checkTimeoutOrFail tests whether the given error is related to a timeout condition. -// returns true if the caller should advance to the returned state. -func (d *httpDecoder) checkTimeoutOrFail(err error, stateContinue httpState) (httpState, bool) { - if err != nil { - if neterr, ok := err.(net.Error); ok && neterr.Timeout() { - select { - case <-d.forceQuit: - return terminateState, true - case <-d.shouldQuit: - return gracefulTerminateState, true - default: - return stateContinue, true - } - } - d.sendError(err) - return terminateState, true - } - return nil, false -} - -func (d *httpDecoder) setReadTimeoutOrFail() bool { - if d.readTimeout > 0 { - err := d.con.SetReadDeadline(time.Now().Add(d.readTimeout)) - if err != nil { - d.sendError(err) - return false - } - } - return true -} - -func (d *httpDecoder) setWriteTimeout() error { - if d.writeTimeout > 0 { - return d.con.SetWriteDeadline(time.Now().Add(d.writeTimeout)) - } - return nil -} - -func readChunkHeaderState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "read-chunk-header-state") - tr := textproto.NewReader(d.rw.Reader) - if !d.setReadTimeoutOrFail() { - return terminateState - } - hexlen, err := tr.ReadLine() - if next, ok := d.checkTimeoutOrFail(err, readChunkHeaderState); ok { - return next - } - - clen, err := strconv.ParseInt(hexlen, 16, 64) - if err != nil { - d.sendError(err) - return terminateState - } - - if clen == 0 { - return readEndOfChunkStreamState - } - - d.lrc = limit(d.rw.Reader, clen) - return readChunkState -} - -func readChunkState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag+"read-chunk-state, bytes remaining:", d.lrc.N) - if !d.setReadTimeoutOrFail() { - return terminateState - } - _, err := d.buf.ReadFrom(d.lrc) - if next, ok := d.checkTimeoutOrFail(err, readChunkState); ok { - return next - } - return readEndOfChunkState -} - -const crlf = "\r\n" - -func readEndOfChunkState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "read-end-of-chunk-state") - if !d.setReadTimeoutOrFail() { - return terminateState - } - b, err := d.rw.Reader.Peek(2) - if len(b) == 2 { - if string(b) == crlf { - d.rw.ReadByte() - d.rw.ReadByte() - return readChunkHeaderState - } - d.sendError(errors.New(d.idtag + "unexpected data at end-of-chunk marker")) - return terminateState - } - // less than two bytes avail - if next, ok := d.checkTimeoutOrFail(err, readEndOfChunkState); ok { - return next - } - panic("couldn't peek 2 bytes, but didn't get an error?!") -} - -func readEndOfChunkStreamState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "read-end-of-chunk-stream-state") - if !d.setReadTimeoutOrFail() { - return terminateState - } - b, err := d.rw.Reader.Peek(2) - if len(b) == 2 { - if string(b) == crlf { - d.rw.ReadByte() - d.rw.ReadByte() - return d.generateRequest() - } - d.sendError(errors.New(d.idtag + "unexpected data at end-of-chunk marker")) - return terminateState - } - // less than 2 bytes avail - if next, ok := d.checkTimeoutOrFail(err, readEndOfChunkStreamState); ok { - return next - } - panic("couldn't peek 2 bytes, but didn't get an error?!") -} - -func readBodyState(d *httpDecoder) httpState { - log.V(2).Infof(d.idtag+"read-body-state: %d bytes remaining", d.lrc.N) - // read remaining bytes into the buffer - var err error - if d.lrc.N > 0 { - if !d.setReadTimeoutOrFail() { - return terminateState - } - _, err = d.buf.ReadFrom(d.lrc) - } - if d.lrc.N <= 0 { - return d.generateRequest() - } - if next, ok := d.checkTimeoutOrFail(err, readBodyState); ok { - return next - } - return readBodyState -} - -func isGracefulTermSignal(err error) bool { - if err == io.EOF { - return true - } - if operr, ok := err.(*net.OpError); ok { - return operr.Op == "read" && err == syscall.ECONNRESET - } - return false -} - -func awaitRequestState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "await-request-state") - tr := textproto.NewReader(d.rw.Reader) - if !d.setReadTimeoutOrFail() { - return terminateState - } - requestLine, err := tr.ReadLine() - if requestLine == "" && isGracefulTermSignal(err) { - // we're actually expecting this at some point, so don't react poorly - return gracefulTerminateState - } - if next, ok := d.checkTimeoutOrFail(err, awaitRequestState); ok { - return next - } - ss := strings.SplitN(requestLine, " ", 3) - if len(ss) < 3 { - if err == io.EOF { - return gracefulTerminateState - } - d.sendError(errors.New(d.idtag + "illegal request line")) - return terminateState - } - r := d.req - r.Method = ss[0] - r.RequestURI = ss[1] - r.URL, err = url.ParseRequestURI(ss[1]) - if err != nil { - d.sendError(err) - return terminateState - } - major, minor, ok := http.ParseHTTPVersion(ss[2]) - if !ok { - d.sendError(errors.New(d.idtag + "malformed HTTP version")) - return terminateState - } - r.ProtoMajor = major - r.ProtoMinor = minor - r.Proto = ss[2] - return readHeaderState -} - -func readHeaderState(d *httpDecoder) httpState { - log.V(2).Infoln(d.idtag + "read-header-state") - if !d.setReadTimeoutOrFail() { - return terminateState - } - r := d.req - tr := textproto.NewReader(d.rw.Reader) - h, err := tr.ReadMIMEHeader() - // merge any headers that were read successfully (before a possible error) - for k, v := range h { - if rh, exists := r.Header[k]; exists { - r.Header[k] = append(rh, v...) - } else { - r.Header[k] = v - } - log.V(2).Infoln(d.idtag+"request header", k, v) - } - if next, ok := d.checkTimeoutOrFail(err, readHeaderState); ok { - return next - } - - // special headers: Host, Content-Length, Transfer-Encoding - r.Host = r.Header.Get("Host") - r.TransferEncoding = r.Header["Transfer-Encoding"] - if cl := r.Header.Get("Content-Length"); cl != "" { - l, err := strconv.ParseInt(cl, 10, 64) - if err != nil { - d.sendError(err) - return terminateState - } - if l > -1 { - r.ContentLength = l - log.V(2).Infoln(d.idtag+"set content length", r.ContentLength) - } - } - d.updateForRequest(false) - return d.readBodyContent() -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/doc.go b/vendor/github.com/mesos/mesos-go/messenger/doc.go deleted file mode 100644 index 3b7bd8147c8..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -/* -Package messenger includes a messenger and a transporter. -The messenger provides interfaces to send a protobuf message -through the underlying transporter. It also dispatches messages -to installed handlers. -*/ -package messenger diff --git a/vendor/github.com/mesos/mesos-go/messenger/http_transporter.go b/vendor/github.com/mesos/mesos-go/messenger/http_transporter.go deleted file mode 100644 index 0214d96edde..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/http_transporter.go +++ /dev/null @@ -1,598 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package messenger - -import ( - "bytes" - "crypto/tls" - "encoding/hex" - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "os" - "strings" - "sync" - "time" - - log "github.com/golang/glog" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -const ( - DefaultReadTimeout = 10 * time.Second - DefaultWriteTimeout = 10 * time.Second -) - -var ( - ReadTimeout = DefaultReadTimeout - WriteTimeout = DefaultWriteTimeout - - discardOnStopError = fmt.Errorf("discarding message because transport is shutting down") - errNotStarted = errors.New("HTTP transport has not been started") - errTerminal = errors.New("HTTP transport is terminated") - errAlreadyRunning = errors.New("HTTP transport is already running") - - httpTransport = http.Transport{ - Dial: (&net.Dialer{ - Timeout: 10 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - ResponseHeaderTimeout: DefaultReadTimeout, - } - - // HttpClient is used for sending messages to remote processes - HttpClient = http.Client{ - Timeout: DefaultReadTimeout, - } -) - -// httpTransporter is a subset of the Transporter interface -type httpTransporter interface { - Send(ctx context.Context, msg *Message) error - Recv() (*Message, error) - Install(messageName string) - Start() (upid.UPID, <-chan error) - Stop(graceful bool) error -} - -type notStartedState struct { - h *HTTPTransporter -} - -type stoppedState struct{} - -type runningState struct { - *notStartedState -} - -/* -- not-started state */ - -func (s *notStartedState) Send(ctx context.Context, msg *Message) error { return errNotStarted } -func (s *notStartedState) Recv() (*Message, error) { return nil, errNotStarted } -func (s *notStartedState) Stop(graceful bool) error { return errNotStarted } -func (s *notStartedState) Install(messageName string) { s.h.install(messageName) } -func (s *notStartedState) Start() (upid.UPID, <-chan error) { - s.h.state = &runningState{s} - return s.h.start() -} - -/* -- stopped state */ - -func (s *stoppedState) Send(ctx context.Context, msg *Message) error { return errTerminal } -func (s *stoppedState) Recv() (*Message, error) { return nil, errTerminal } -func (s *stoppedState) Stop(graceful bool) error { return errTerminal } -func (s *stoppedState) Install(messageName string) {} -func (s *stoppedState) Start() (upid.UPID, <-chan error) { - ch := make(chan error, 1) - ch <- errTerminal - return upid.UPID{}, ch -} - -/* -- running state */ - -func (s *runningState) Send(ctx context.Context, msg *Message) error { return s.h.send(ctx, msg) } -func (s *runningState) Recv() (*Message, error) { return s.h.recv() } -func (s *runningState) Stop(graceful bool) error { - s.h.state = &stoppedState{} - return s.h.stop(graceful) -} -func (s *runningState) Start() (upid.UPID, <-chan error) { - ch := make(chan error, 1) - ch <- errAlreadyRunning - return upid.UPID{}, ch -} - -// httpOpt is a functional option type -type httpOpt func(*HTTPTransporter) - -// HTTPTransporter implements the interfaces of the Transporter. -type HTTPTransporter struct { - // If the host is empty("") then it will listen on localhost. - // If the port is empty("") then it will listen on random port. - upid upid.UPID - listener net.Listener // TODO(yifan): Change to TCPListener. - mux *http.ServeMux - tr *http.Transport - client *http.Client - messageQueue chan *Message - address net.IP // optional binding address - shouldQuit chan struct{} - stateLock sync.RWMutex // protect lifecycle (start/stop) funcs - state httpTransporter - server *http.Server -} - -// NewHTTPTransporter creates a new http transporter with an optional binding address. -func NewHTTPTransporter(upid upid.UPID, address net.IP, opts ...httpOpt) *HTTPTransporter { - transport := httpTransport - client := HttpClient - client.Transport = &transport - mux := http.NewServeMux() - - result := &HTTPTransporter{ - upid: upid, - messageQueue: make(chan *Message, defaultQueueSize), - mux: mux, - client: &client, - tr: &transport, - address: address, - shouldQuit: make(chan struct{}), - server: &http.Server{ - ReadTimeout: ReadTimeout, - WriteTimeout: WriteTimeout, - Handler: mux, - }, - } - for _, f := range opts { - f(result) - } - result.state = ¬StartedState{result} - return result -} - -func ServerTLSConfig(config *tls.Config, nextProto map[string]func(*http.Server, *tls.Conn, http.Handler)) httpOpt { - return func(transport *HTTPTransporter) { - transport.server.TLSConfig = config - transport.server.TLSNextProto = nextProto - } -} - -func ClientTLSConfig(config *tls.Config, handshakeTimeout time.Duration) httpOpt { - return func(transport *HTTPTransporter) { - transport.tr.TLSClientConfig = config - transport.tr.TLSHandshakeTimeout = handshakeTimeout - } -} - -func (t *HTTPTransporter) getState() httpTransporter { - t.stateLock.RLock() - defer t.stateLock.RUnlock() - return t.state -} - -// Send sends the message to its specified upid. -func (t *HTTPTransporter) Send(ctx context.Context, msg *Message) (sendError error) { - return t.getState().Send(ctx, msg) -} - -type mesosError struct { - errorCode int - upid string - uri string - status string -} - -func (e *mesosError) Error() string { - return fmt.Sprintf("master %s rejected %s, returned status %q", - e.upid, e.uri, e.status) -} - -type networkError struct { - cause error -} - -func (e *networkError) Error() string { - return e.cause.Error() -} - -// send delivers a message to a mesos component via HTTP, returns a mesosError if the -// communication with the remote process was successful but rejected. A networkError -// error indicates that communication with the remote process failed at the network layer. -func (t *HTTPTransporter) send(ctx context.Context, msg *Message) (sendError error) { - log.V(2).Infof("Sending message to %v via http\n", msg.UPID) - req, err := t.makeLibprocessRequest(msg) - if err != nil { - return err - } - - return t.httpDo(ctx, req, func(resp *http.Response, err error) error { - if err != nil { - log.V(1).Infof("Failed to POST: %v\n", err) - return &networkError{err} - } - defer resp.Body.Close() - - // ensure master acknowledgement. - if (resp.StatusCode != http.StatusOK) && (resp.StatusCode != http.StatusAccepted) { - return &mesosError{ - errorCode: resp.StatusCode, - upid: msg.UPID.String(), - uri: msg.RequestURI(), - status: resp.Status, - } - } - return nil - }) -} - -func (t *HTTPTransporter) httpDo(ctx context.Context, req *http.Request, f func(*http.Response, error) error) error { - select { - case <-ctx.Done(): - return ctx.Err() - case <-t.shouldQuit: - return discardOnStopError - default: // continue - } - - c := make(chan error, 1) - go func() { c <- f(t.client.Do(req)) }() - select { - case <-ctx.Done(): - t.tr.CancelRequest(req) - <-c // Wait for f to return. - return ctx.Err() - case err := <-c: - return err - case <-t.shouldQuit: - t.tr.CancelRequest(req) - <-c // Wait for f to return. - return discardOnStopError - } -} - -// Recv returns the message, one at a time. -func (t *HTTPTransporter) Recv() (*Message, error) { - return t.getState().Recv() -} - -func (t *HTTPTransporter) recv() (*Message, error) { - select { - default: - select { - case msg := <-t.messageQueue: - return msg, nil - case <-t.shouldQuit: - } - case <-t.shouldQuit: - } - return nil, discardOnStopError -} - -// Install the request URI according to the message's name. -func (t *HTTPTransporter) Install(msgName string) { - t.getState().Install(msgName) -} - -func (t *HTTPTransporter) install(msgName string) { - requestURI := fmt.Sprintf("/%s/%s", t.upid.ID, msgName) - t.mux.HandleFunc(requestURI, t.messageDecoder) -} - -type loggedListener struct { - delegate net.Listener - done <-chan struct{} -} - -func (l *loggedListener) Accept() (c net.Conn, err error) { - c, err = l.delegate.Accept() - if c != nil { - log.Infoln("accepted connection from", c.RemoteAddr()) - c = logConnection(c) - } else if err != nil { - select { - case <-l.done: - default: - log.Errorln("failed to accept connection:", err.Error()) - } - } - return -} - -func (l *loggedListener) Close() (err error) { - err = l.delegate.Close() - if err != nil { - select { - case <-l.done: - default: - log.Errorln("error closing listener:", err.Error()) - } - } else { - log.Infoln("closed listener") - } - return -} - -func (l *loggedListener) Addr() net.Addr { return l.delegate.Addr() } - -func logConnection(c net.Conn) net.Conn { - w := hex.Dumper(os.Stdout) - r := io.TeeReader(c, w) - return &loggedConnection{ - Conn: c, - reader: r, - } -} - -type loggedConnection struct { - net.Conn - reader io.Reader -} - -func (c *loggedConnection) Read(b []byte) (int, error) { - return c.reader.Read(b) -} - -// Listen starts listen on UPID. If UPID is empty, the transporter -// will listen on a random port, and then fill the UPID with the -// host:port it is listening. -func (t *HTTPTransporter) listen() error { - var host string - if t.address != nil { - host = t.address.String() - } else { - host = t.upid.Host - } - - var port string - if t.upid.Port != "" { - port = t.upid.Port - } else { - port = "0" - } - - // NOTE: Explicitly specifies IPv4 because Libprocess - // only supports IPv4 for now. - ln, err := net.Listen("tcp4", net.JoinHostPort(host, port)) - if err != nil { - log.Errorf("HTTPTransporter failed to listen: %v\n", err) - return err - } - // Save the host:port in case they are not specified in upid. - host, port, _ = net.SplitHostPort(ln.Addr().String()) - log.Infoln("listening on", host, "port", port) - - if len(t.upid.Host) == 0 { - t.upid.Host = host - } - - if len(t.upid.Port) == 0 || t.upid.Port == "0" { - t.upid.Port = port - } - - if log.V(3) { - t.listener = &loggedListener{delegate: ln, done: t.shouldQuit} - } else { - t.listener = ln - } - return nil -} - -// Start starts the http transporter -func (t *HTTPTransporter) Start() (upid.UPID, <-chan error) { - t.stateLock.Lock() - defer t.stateLock.Unlock() - return t.state.Start() -} - -// start expects to be guarded by stateLock -func (t *HTTPTransporter) start() (upid.UPID, <-chan error) { - ch := make(chan error, 1) - if err := t.listen(); err != nil { - ch <- err - return upid.UPID{}, ch - } - - // TODO(yifan): Set read/write deadline. - go func() { - err := t.server.Serve(t.listener) - select { - case <-t.shouldQuit: - log.V(1).Infof("HTTP server stopped because of shutdown") - ch <- nil - default: - if err != nil && log.V(1) { - log.Errorln("HTTP server stopped with error", err.Error()) - } else { - log.V(1).Infof("HTTP server stopped") - } - ch <- err - t.Stop(false) - } - }() - return t.upid, ch -} - -// Stop stops the http transporter by closing the listener. -func (t *HTTPTransporter) Stop(graceful bool) error { - t.stateLock.Lock() - defer t.stateLock.Unlock() - return t.state.Stop(graceful) -} - -// stop expects to be guarded by stateLock -func (t *HTTPTransporter) stop(graceful bool) error { - close(t.shouldQuit) - - log.Info("stopping HTTP transport") - - //TODO(jdef) if graceful, wait for pending requests to terminate - - err := t.listener.Close() - return err -} - -// UPID returns the upid of the transporter. -func (t *HTTPTransporter) UPID() upid.UPID { - t.stateLock.Lock() - defer t.stateLock.Unlock() - return t.upid -} - -func (t *HTTPTransporter) messageDecoder(w http.ResponseWriter, r *http.Request) { - // Verify it's a libprocess request. - from, err := getLibprocessFrom(r) - if err != nil { - log.Errorf("Ignoring the request, because it's not a libprocess request: %v\n", err) - w.WriteHeader(http.StatusBadRequest) - return - } - decoder := DecodeHTTP(w, r) - defer decoder.Cancel(true) - - t.processRequests(from, decoder.Requests()) - - // log an error if there's one waiting, otherwise move on - select { - case err, ok := <-decoder.Err(): - if ok { - log.Errorf("failed to decode HTTP message: %v", err) - } - default: - } -} - -func (t *HTTPTransporter) processRequests(from *upid.UPID, incoming <-chan *Request) { - for { - select { - case r, ok := <-incoming: - if !ok || !t.processOneRequest(from, r) { - return - } - case <-t.shouldQuit: - return - } - } -} - -func (t *HTTPTransporter) processOneRequest(from *upid.UPID, request *Request) (keepGoing bool) { - // regardless of whether we write a Response we must close this chan - defer close(request.response) - keepGoing = true - - //TODO(jdef) this is probably inefficient given the current implementation of the - // decoder: no need to make another copy of data that's already competely buffered - data, err := ioutil.ReadAll(request.Body) - if err != nil { - // this is unlikely given the current implementation of the decoder: - // the body has been completely buffered in memory already - log.Errorf("failed to read HTTP body: %v", err) - return - } - log.V(2).Infof("Receiving %q %v from %v, length %v", request.Method, request.URL, from, len(data)) - m := &Message{ - UPID: from, - Name: extractNameFromRequestURI(request.RequestURI), - Bytes: data, - } - - // deterministic behavior and output.. - select { - case <-t.shouldQuit: - keepGoing = false - select { - case t.messageQueue <- m: - default: - } - case t.messageQueue <- m: - select { - case <-t.shouldQuit: - keepGoing = false - default: - } - } - - // Only send back an HTTP response if this isn't from libprocess - // (which we determine by looking at the User-Agent). This is - // necessary because older versions of libprocess would try and - // recv the data and parse it as an HTTP request which would - // fail thus causing the socket to get closed (but now - // libprocess will ignore responses, see ignore_data). - // see https://github.com/apache/mesos/blob/adecbfa6a216815bd7dc7d26e721c4c87e465c30/3rdparty/libprocess/src/process.cpp#L2192 - if _, ok := parseLibprocessAgent(request.Header); !ok { - log.V(2).Infof("not libprocess agent, sending a 202") - request.response <- Response{ - code: 202, - reason: "Accepted", - } // should never block - } - return -} - -func (t *HTTPTransporter) makeLibprocessRequest(msg *Message) (*http.Request, error) { - if msg.UPID == nil { - panic(fmt.Sprintf("message is missing UPID: %+v", msg)) - } - hostport := net.JoinHostPort(msg.UPID.Host, msg.UPID.Port) - targetURL := fmt.Sprintf("http://%s%s", hostport, msg.RequestURI()) - log.V(2).Infof("libproc target URL %s", targetURL) - req, err := http.NewRequest("POST", targetURL, bytes.NewReader(msg.Bytes)) - if err != nil { - log.V(1).Infof("Failed to create request: %v\n", err) - return nil, err - } - if !msg.isV1API() { - req.Header.Add("Libprocess-From", t.upid.String()) - req.Header.Add("Connection", "Keep-Alive") - } - req.Header.Add("Content-Type", "application/x-protobuf") - - return req, nil -} - -func getLibprocessFrom(r *http.Request) (*upid.UPID, error) { - if r.Method != "POST" { - return nil, fmt.Errorf("Not a POST request") - } - if agent, ok := parseLibprocessAgent(r.Header); ok { - return upid.Parse(agent) - } - lf, ok := r.Header["Libprocess-From"] - if ok { - // TODO(yifan): Just take the first field for now. - return upid.Parse(lf[0]) - } - return nil, fmt.Errorf("Cannot find 'User-Agent' or 'Libprocess-From'") -} - -func parseLibprocessAgent(h http.Header) (string, bool) { - const prefix = "libprocess/" - if ua, ok := h["User-Agent"]; ok { - for _, agent := range ua { - if strings.HasPrefix(agent, prefix) { - return agent[len(prefix):], true - } - } - } - return "", false -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/message.go b/vendor/github.com/mesos/mesos-go/messenger/message.go deleted file mode 100644 index ae441bb3aa0..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/message.go +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package messenger - -import ( - "fmt" - "strings" - - "github.com/gogo/protobuf/proto" - "github.com/mesos/mesos-go/upid" -) - -// Message defines the type that passes in the Messenger. -type Message struct { - UPID *upid.UPID - Name string - ProtoMessage proto.Message - Bytes []byte -} - -// RequestURI returns the request URI of the message. -func (m *Message) RequestURI() string { - if m.isV1API() { - return fmt.Sprintf("/api/v1/%s", m.Name) - } - - return fmt.Sprintf("/%s/%s", m.UPID.ID, m.Name) -} - -func (m *Message) isV1API() bool { - return !strings.HasPrefix(m.Name, "mesos.internal") -} - -// NOTE: This should not fail or panic. -func extractNameFromRequestURI(requestURI string) string { - return strings.Split(requestURI, "/")[2] -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/messenger.go b/vendor/github.com/mesos/mesos-go/messenger/messenger.go deleted file mode 100644 index 066464b3c44..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/messenger.go +++ /dev/null @@ -1,417 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package messenger - -import ( - "fmt" - "net" - "reflect" - "strconv" - "sync" - - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/mesosproto/scheduler" - "github.com/mesos/mesos-go/mesosutil/process" - "github.com/mesos/mesos-go/messenger/sessionid" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -const ( - defaultQueueSize = 1024 -) - -// MessageHandler is the callback of the message. When the callback -// is invoked, the sender's upid and the message is passed to the callback. -type MessageHandler func(from *upid.UPID, pbMsg proto.Message) - -// Messenger defines the interfaces that should be implemented. -type Messenger interface { - Install(handler MessageHandler, msg proto.Message) error - Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error - Route(ctx context.Context, from *upid.UPID, msg proto.Message) error - Start() error - Stop() error - UPID() upid.UPID -} - -type errorHandlerFunc func(context.Context, *Message, error) error -type dispatchFunc func(errorHandlerFunc) - -// MesosMessenger is an implementation of the Messenger interface. -type MesosMessenger struct { - upid upid.UPID - sendingQueue chan dispatchFunc - installedMessages map[string]reflect.Type - installedHandlers map[string]MessageHandler - stop chan struct{} - stopOnce sync.Once - tr Transporter - guardHandlers sync.RWMutex // protect simultaneous changes to messages/handlers maps -} - -// ForHostname creates a new default messenger (HTTP), using UPIDBindingAddress to -// determine the binding-address used for both the UPID.Host and Transport binding address. -func ForHostname(proc *process.Process, hostname string, bindingAddress net.IP, port uint16, publishedAddress net.IP) (Messenger, error) { - upid := upid.UPID{ - ID: proc.Label(), - Port: strconv.Itoa(int(port)), - } - host, err := UPIDBindingAddress(hostname, bindingAddress) - if err != nil { - return nil, err - } - - var publishedHost string - if publishedAddress != nil { - publishedHost, err = UPIDBindingAddress(hostname, publishedAddress) - if err != nil { - return nil, err - } - } - - if publishedHost != "" { - upid.Host = publishedHost - } else { - upid.Host = host - } - - return NewHttpWithBindingAddress(upid, bindingAddress), nil -} - -// UPIDBindingAddress determines the value of UPID.Host that will be used to build -// a Transport. If a non-nil, non-wildcard bindingAddress is specified then it will be used -// for both the UPID and Transport binding address. Otherwise hostname is resolved to an IP -// address and the UPID.Host is set to that address and the bindingAddress is passed through -// to the Transport. -func UPIDBindingAddress(hostname string, bindingAddress net.IP) (string, error) { - upidHost := "" - if bindingAddress != nil && "0.0.0.0" != bindingAddress.String() { - upidHost = bindingAddress.String() - } else { - if hostname == "" || hostname == "0.0.0.0" { - return "", fmt.Errorf("invalid hostname (%q) specified with binding address %v", hostname, bindingAddress) - } - ip := net.ParseIP(hostname) - if ip != nil { - ip = ip.To4() - } - if ip == nil { - ips, err := net.LookupIP(hostname) - if err != nil { - return "", err - } - // try to find an ipv4 and use that - for _, addr := range ips { - if ip = addr.To4(); ip != nil { - break - } - } - if ip == nil { - // no ipv4? best guess, just take the first addr - if len(ips) > 0 { - ip = ips[0] - log.Warningf("failed to find an IPv4 address for '%v', best guess is '%v'", hostname, ip) - } else { - return "", fmt.Errorf("failed to determine IP address for host '%v'", hostname) - } - } - } - upidHost = ip.String() - } - return upidHost, nil -} - -// NewMesosMessenger creates a new mesos messenger. -func NewHttp(upid upid.UPID, opts ...httpOpt) *MesosMessenger { - return NewHttpWithBindingAddress(upid, nil, opts...) -} - -func NewHttpWithBindingAddress(upid upid.UPID, address net.IP, opts ...httpOpt) *MesosMessenger { - return New(NewHTTPTransporter(upid, address, opts...)) -} - -func New(t Transporter) *MesosMessenger { - return &MesosMessenger{ - sendingQueue: make(chan dispatchFunc, defaultQueueSize), - installedMessages: make(map[string]reflect.Type), - installedHandlers: make(map[string]MessageHandler), - tr: t, - } -} - -/// Install installs the handler with the given message. -func (m *MesosMessenger) Install(handler MessageHandler, msg proto.Message) error { - // Check if the message is a pointer. - mtype := reflect.TypeOf(msg) - if mtype.Kind() != reflect.Ptr { - return fmt.Errorf("Message %v is not a Ptr type", msg) - } - - // Check if the message is already installed. - name := getMessageName(msg) - if _, ok := m.installedMessages[name]; ok { - return fmt.Errorf("Message %v is already installed", name) - } - - m.guardHandlers.Lock() - defer m.guardHandlers.Unlock() - - m.installedMessages[name] = mtype.Elem() - m.installedHandlers[name] = handler - m.tr.Install(name) - return nil -} - -// Send puts a message into the outgoing queue, waiting to be sent. -// With buffered channels, this will not block under moderate throughput. -// When an error is generated, the error can be communicated by placing -// a message on the incoming queue to be handled upstream. -func (m *MesosMessenger) Send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { - if upid == nil { - panic("cannot sent a message to a nil pid") - } else if *upid == m.upid { - return fmt.Errorf("Send the message to self") - } - - b, err := proto.Marshal(msg) - if err != nil { - return err - } - - name := getMessageName(msg) - log.V(2).Infof("Sending message %v to %v\n", name, upid) - - wrapped := &Message{upid, name, msg, b} - d := dispatchFunc(func(rf errorHandlerFunc) { - err := m.tr.Send(ctx, wrapped) - err = rf(ctx, wrapped, err) - if err != nil { - m.reportError("send", wrapped, err) - } - }) - select { - case <-ctx.Done(): - return ctx.Err() - case m.sendingQueue <- d: - return nil - } -} - -// Route puts a message either in the incoming or outgoing queue. -// This method is useful for: -// 1) routing internal error to callback handlers -// 2) testing components without starting remote servers. -func (m *MesosMessenger) Route(ctx context.Context, upid *upid.UPID, msg proto.Message) error { - if upid == nil { - panic("cannot route a message to a nil pid") - } else if *upid != m.upid { - // if destination is not self, send to outbound. - return m.Send(ctx, upid, msg) - } - - name := getMessageName(msg) - log.V(2).Infof("routing message %q to self", name) - - _, handler, ok := m.messageBinding(name) - if !ok { - return fmt.Errorf("failed to route message, no message binding for %q", name) - } - - // the implication of this is that messages can be delivered to self even if the - // messenger has been stopped. is that OK? - go handler(upid, msg) - return nil -} - -// Start starts the messenger; expects to be called once and only once. -func (m *MesosMessenger) Start() error { - - m.stop = make(chan struct{}) - - pid, errChan := m.tr.Start() - if pid == (upid.UPID{}) { - err := <-errChan - return fmt.Errorf("failed to start messenger: %v", err) - } - - // the pid that we're actually bound as - m.upid = pid - - go m.sendLoop() - go m.decodeLoop() - - // wait for a listener error or a stop signal; either way stop the messenger - - // TODO(jdef) a better implementation would attempt to re-listen; need to coordinate - // access to m.upid in that case. probably better off with a state machine instead of - // what we have now. - go func() { - select { - case err := <-errChan: - if err != nil { - //TODO(jdef) should the driver abort in this case? probably - //since this messenger will never attempt to re-establish the - //transport - log.Errorln("transport stopped unexpectedly:", err.Error()) - } - err = m.Stop() - if err != nil && err != errTerminal { - log.Errorln("failed to stop messenger cleanly: ", err.Error()) - } - case <-m.stop: - } - }() - return nil -} - -// Stop stops the messenger and clean up all the goroutines. -func (m *MesosMessenger) Stop() (err error) { - m.stopOnce.Do(func() { - select { - case <-m.stop: - default: - defer close(m.stop) - } - - log.Infof("stopping messenger %v..", m.upid) - - //TODO(jdef) don't hardcode the graceful flag here - if err2 := m.tr.Stop(true); err2 != nil && err2 != errTerminal { - log.Warningf("failed to stop the transporter: %v\n", err2) - err = err2 - } - }) - return -} - -// UPID returns the upid of the messenger. -func (m *MesosMessenger) UPID() upid.UPID { - return m.upid -} - -func (m *MesosMessenger) reportError(action string, msg *Message, err error) { - // log message transmission errors but don't shoot the messenger. - // this approach essentially drops all undelivered messages on the floor. - name := "" - if msg != nil { - name = msg.Name - } - log.Errorf("failed to %s message %q: %+v", action, name, err) -} - -func (m *MesosMessenger) sendLoop() { - for { - select { - case <-m.stop: - return - case f := <-m.sendingQueue: - f(errorHandlerFunc(func(ctx context.Context, msg *Message, err error) error { - if _, ok := err.(*networkError); ok { - // if transport reports a network error, then - // we're probably disconnected from the remote process? - pid := msg.UPID.String() - neterr := &mesos.InternalNetworkError{Pid: &pid} - sessionID, ok := sessionid.FromContext(ctx) - if ok { - neterr.Session = &sessionID - } - log.V(1).Infof("routing network error for pid %q session %q", pid, sessionID) - err2 := m.Route(ctx, &m.upid, neterr) - if err2 != nil { - log.Error(err2) - } else { - log.V(1).Infof("swallowing raw error because we're reporting a networkError: %v", err) - return nil - } - } - return err - })) - } - } -} - -// Since HTTPTransporter.Recv() is already buffered, so we don't need a 'recvLoop' here. -func (m *MesosMessenger) decodeLoop() { - for { - select { - case <-m.stop: - return - default: - } - msg, err := m.tr.Recv() - if err != nil { - if err == discardOnStopError { - log.V(1).Info("exiting decodeLoop, transport shutting down") - return - } else { - panic(fmt.Sprintf("unexpected transport error: %v", err)) - } - } - - log.V(2).Infof("Receiving message %v from %v\n", msg.Name, msg.UPID) - protoMessage, handler, found := m.messageBinding(msg.Name) - if !found { - log.Warningf("no message binding for message %q", msg.Name) - continue - } - - msg.ProtoMessage = protoMessage - if err := proto.Unmarshal(msg.Bytes, msg.ProtoMessage); err != nil { - log.Errorf("Failed to unmarshal message %v: %v\n", msg, err) - continue - } - - handler(msg.UPID, msg.ProtoMessage) - } -} - -func (m *MesosMessenger) messageBinding(name string) (proto.Message, MessageHandler, bool) { - m.guardHandlers.RLock() - defer m.guardHandlers.RUnlock() - - gotype, ok := m.installedMessages[name] - if !ok { - return nil, nil, false - } - - handler, ok := m.installedHandlers[name] - if !ok { - return nil, nil, false - } - - protoMessage := reflect.New(gotype).Interface().(proto.Message) - return protoMessage, handler, true -} - -// getMessageName returns the name of the message in the mesos manner. -func getMessageName(msg proto.Message) string { - var msgName string - - switch msg := msg.(type) { - case *scheduler.Call: - msgName = "scheduler" - default: - msgName = fmt.Sprintf("%v.%v", "mesos.internal", reflect.TypeOf(msg).Elem().Name()) - } - - return msgName -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/sessionid/sessionid.go b/vendor/github.com/mesos/mesos-go/messenger/sessionid/sessionid.go deleted file mode 100644 index ff48b7080a9..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/sessionid/sessionid.go +++ /dev/null @@ -1,18 +0,0 @@ -package sessionid - -import ( - "golang.org/x/net/context" -) - -type key int - -const sessionIDKey = 0 - -func NewContext(ctx context.Context, sessionID string) context.Context { - return context.WithValue(ctx, sessionIDKey, sessionID) -} - -func FromContext(ctx context.Context) (string, bool) { - sessionID, ok := ctx.Value(sessionIDKey).(string) - return sessionID, ok -} diff --git a/vendor/github.com/mesos/mesos-go/messenger/transporter.go b/vendor/github.com/mesos/mesos-go/messenger/transporter.go deleted file mode 100644 index efa1a10db6a..00000000000 --- a/vendor/github.com/mesos/mesos-go/messenger/transporter.go +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package messenger - -import ( - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -// Transporter defines methods for communicating with remote processes. -type Transporter interface { - //Send sends message to remote process. Must use context to determine - //cancelled requests. Will stop sending when transport is stopped. - Send(ctx context.Context, msg *Message) error - - //Rcvd receives and delegate message handling to installed handlers. - //Will stop receiving when transport is stopped. - Recv() (*Message, error) - - //Install mount an handler based on incoming message name. - Install(messageName string) - - //Start starts the transporter and returns immediately. The error chan - //is never nil. - Start() (upid.UPID, <-chan error) - - //Stop kills the transporter. - Stop(graceful bool) error - - //UPID returns the PID for transporter. - UPID() upid.UPID -} diff --git a/vendor/github.com/mesos/mesos-go/scheduler/doc.go b/vendor/github.com/mesos/mesos-go/scheduler/doc.go deleted file mode 100644 index 94cfbacd6af..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -/* -Package scheduler includes the interfaces for the mesos scheduler and -the mesos executor driver. It also contains as well as an implementation -of the driver that you can use in your code. -*/ -package scheduler diff --git a/vendor/github.com/mesos/mesos-go/scheduler/handler.go b/vendor/github.com/mesos/mesos-go/scheduler/handler.go deleted file mode 100644 index 9492ff818f0..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/handler.go +++ /dev/null @@ -1,29 +0,0 @@ -package scheduler - -import ( - "github.com/mesos/mesos-go/auth/callback" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/upid" -) - -type CredentialHandler struct { - pid *upid.UPID // the process to authenticate against (master) - client *upid.UPID // the process to be authenticated (slave / framework) - credential *mesos.Credential -} - -func (h *CredentialHandler) Handle(callbacks ...callback.Interface) error { - for _, cb := range callbacks { - switch cb := cb.(type) { - case *callback.Name: - cb.Set(h.credential.GetPrincipal()) - case *callback.Password: - cb.Set(([]byte)(h.credential.GetSecret())) - case *callback.Interprocess: - cb.Set(*(h.pid), *(h.client)) - default: - return &callback.Unsupported{Callback: cb} - } - } - return nil -} diff --git a/vendor/github.com/mesos/mesos-go/scheduler/plugins.go b/vendor/github.com/mesos/mesos-go/scheduler/plugins.go deleted file mode 100644 index 0054bbdd977..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/plugins.go +++ /dev/null @@ -1,7 +0,0 @@ -package scheduler - -import ( - _ "github.com/mesos/mesos-go/auth/sasl" - _ "github.com/mesos/mesos-go/auth/sasl/mech/crammd5" - _ "github.com/mesos/mesos-go/detector/zoo" -) diff --git a/vendor/github.com/mesos/mesos-go/scheduler/schedcache.go b/vendor/github.com/mesos/mesos-go/scheduler/schedcache.go deleted file mode 100644 index 5644623223b..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/schedcache.go +++ /dev/null @@ -1,96 +0,0 @@ -package scheduler - -import ( - log "github.com/golang/glog" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/upid" - "sync" -) - -type cachedOffer struct { - offer *mesos.Offer - slavePid *upid.UPID -} - -func newCachedOffer(offer *mesos.Offer, slavePid *upid.UPID) *cachedOffer { - return &cachedOffer{offer: offer, slavePid: slavePid} -} - -// schedCache a managed cache with backing maps to store offeres -// and tasked slaves. -type schedCache struct { - lock sync.RWMutex - savedOffers map[string]*cachedOffer // current offers key:OfferID - savedSlavePids map[string]*upid.UPID // Current saved slaves, key:slaveId -} - -func newSchedCache() *schedCache { - return &schedCache{ - savedOffers: make(map[string]*cachedOffer), - savedSlavePids: make(map[string]*upid.UPID), - } -} - -// putOffer stores an offer and the slavePID associated with offer. -func (cache *schedCache) putOffer(offer *mesos.Offer, pid *upid.UPID) { - if offer == nil || pid == nil { - log.V(3).Infoln("WARN: Offer not cached. The offer or pid cannot be nil") - return - } - log.V(3).Infoln("Caching offer ", offer.Id.GetValue(), " with slavePID ", pid.String()) - cache.lock.Lock() - cache.savedOffers[offer.Id.GetValue()] = &cachedOffer{offer: offer, slavePid: pid} - cache.lock.Unlock() -} - -// getOffer returns cached offer -func (cache *schedCache) getOffer(offerId *mesos.OfferID) *cachedOffer { - if offerId == nil { - log.V(3).Infoln("WARN: OfferId == nil, returning nil") - return nil - } - cache.lock.RLock() - defer cache.lock.RUnlock() - return cache.savedOffers[offerId.GetValue()] -} - -// containsOff test cache for offer(offerId) -func (cache *schedCache) containsOffer(offerId *mesos.OfferID) bool { - cache.lock.RLock() - defer cache.lock.RUnlock() - _, ok := cache.savedOffers[offerId.GetValue()] - return ok -} - -func (cache *schedCache) removeOffer(offerId *mesos.OfferID) { - cache.lock.Lock() - delete(cache.savedOffers, offerId.GetValue()) - cache.lock.Unlock() -} - -func (cache *schedCache) putSlavePid(slaveId *mesos.SlaveID, pid *upid.UPID) { - cache.lock.Lock() - cache.savedSlavePids[slaveId.GetValue()] = pid - cache.lock.Unlock() -} - -func (cache *schedCache) getSlavePid(slaveId *mesos.SlaveID) *upid.UPID { - if slaveId == nil { - log.V(3).Infoln("SlaveId == nil, returning empty UPID") - return nil - } - return cache.savedSlavePids[slaveId.GetValue()] -} - -func (cache *schedCache) containsSlavePid(slaveId *mesos.SlaveID) bool { - cache.lock.RLock() - defer cache.lock.RUnlock() - _, ok := cache.savedSlavePids[slaveId.GetValue()] - return ok -} - -func (cache *schedCache) removeSlavePid(slaveId *mesos.SlaveID) { - cache.lock.Lock() - delete(cache.savedSlavePids, slaveId.GetValue()) - cache.lock.Unlock() -} diff --git a/vendor/github.com/mesos/mesos-go/scheduler/schedtype.go b/vendor/github.com/mesos/mesos-go/scheduler/schedtype.go deleted file mode 100644 index 0e2c82343dc..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/schedtype.go +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package scheduler - -import ( - mesos "github.com/mesos/mesos-go/mesosproto" -) - -// Interface for connecting a scheduler to Mesos. This -// interface is used both to manage the scheduler's lifecycle (start -// it, stop it, or wait for it to finish) and to interact with Mesos -// (e.g., launch tasks, kill tasks, etc.). -// See the MesosSchedulerDriver type for a concrete -// impl of a SchedulerDriver. -type SchedulerDriver interface { - // Starts the scheduler driver. This needs to be called before any - // other driver calls are made. - Start() (mesos.Status, error) - - // Stops the scheduler driver. If the 'failover' flag is set to - // false then it is expected that this framework will never - // reconnect to Mesos and all of its executors and tasks can be - // terminated. Otherwise, all executors and tasks will remain - // running (for some framework specific failover timeout) allowing the - // scheduler to reconnect (possibly in the same process, or from a - // different process, for example, on a different machine). - Stop(failover bool) (mesos.Status, error) - - // Aborts the driver so that no more callbacks can be made to the - // scheduler. The semantics of abort and stop have deliberately been - // separated so that code can detect an aborted driver (i.e., via - // the return status of SchedulerDriver::join, see below), and - // instantiate and start another driver if desired (from within the - // same process). Note that 'Stop()' is not automatically called - // inside 'Abort()'. - Abort() (mesos.Status, error) - - // Waits for the driver to be stopped or aborted, possibly - // _blocking_ the current thread indefinitely. The return status of - // this function can be used to determine if the driver was aborted - // (see mesos.proto for a description of Status). - Join() (mesos.Status, error) - - // Starts and immediately joins (i.e., blocks on) the driver. - Run() (mesos.Status, error) - - // Requests resources from Mesos (see mesos.proto for a description - // of Request and how, for example, to request resources - // from specific slaves). Any resources available are offered to the - // framework via Scheduler.ResourceOffers callback, asynchronously. - RequestResources(requests []*mesos.Request) (mesos.Status, error) - - // AcceptOffers utilizes the new HTTP API to send a Scheduler Call Message - // to the Mesos Master. Valid operation types are LAUNCH, RESERVE, UNRESERVE, - // CREATE, DESTROY, and more. - AcceptOffers(offerIDs []*mesos.OfferID, operations []*mesos.Offer_Operation, filters *mesos.Filters) (mesos.Status, error) - - // Launches the given set of tasks. Any resources remaining (i.e., - // not used by the tasks or their executors) will be considered - // declined. The specified filters are applied on all unused - // resources (see mesos.proto for a description of Filters). - // Available resources are aggregated when mutiple offers are - // provided. Note that all offers must belong to the same slave. - // Invoking this function with an empty collection of tasks declines - // offers in their entirety (see Scheduler::declineOffer). - LaunchTasks(offerIDs []*mesos.OfferID, tasks []*mesos.TaskInfo, filters *mesos.Filters) (mesos.Status, error) - - // Kills the specified task. Note that attempting to kill a task is - // currently not reliable. If, for example, a scheduler fails over - // while it was attempting to kill a task it will need to retry in - // the future. Likewise, if unregistered / disconnected, the request - // will be dropped (these semantics may be changed in the future). - KillTask(taskID *mesos.TaskID) (mesos.Status, error) - - // Declines an offer in its entirety and applies the specified - // filters on the resources (see mesos.proto for a description of - // Filters). Note that this can be done at any time, it is not - // necessary to do this within the Scheduler::resourceOffers - // callback. - DeclineOffer(offerID *mesos.OfferID, filters *mesos.Filters) (mesos.Status, error) - - // Removes all filters previously set by the framework (via - // LaunchTasks()). This enables the framework to receive offers from - // those filtered slaves. - ReviveOffers() (mesos.Status, error) - - // Sends a message from the framework to one of its executors. These - // messages are best effort; do not expect a framework message to be - // retransmitted in any reliable fashion. - SendFrameworkMessage(executorID *mesos.ExecutorID, slaveID *mesos.SlaveID, data string) (mesos.Status, error) - - // Allows the framework to query the status for non-terminal tasks. - // This causes the master to send back the latest task status for - // each task in 'statuses', if possible. Tasks that are no longer - // known will result in a TASK_LOST update. If statuses is empty, - // then the master will send the latest status for each task - // currently known. - ReconcileTasks(statuses []*mesos.TaskStatus) (mesos.Status, error) -} - -// Scheduler a type with callback attributes to be provided by frameworks -// schedulers. -// -// Each callback includes a reference to the scheduler driver that was -// used to run this scheduler. The pointer will not change for the -// duration of a scheduler (i.e., from the point you do -// SchedulerDriver.Start() to the point that SchedulerDriver.Stop() -// returns). This is intended for convenience so that a scheduler -// doesn't need to store a reference to the driver itself. -type Scheduler interface { - - // Invoked when the scheduler successfully registers with a Mesos - // master. A unique ID (generated by the master) used for - // distinguishing this framework from others and MasterInfo - // with the ip and port of the current master are provided as arguments. - Registered(SchedulerDriver, *mesos.FrameworkID, *mesos.MasterInfo) - - // Invoked when the scheduler re-registers with a newly elected Mesos master. - // This is only called when the scheduler has previously been registered. - // MasterInfo containing the updated information about the elected master - // is provided as an argument. - Reregistered(SchedulerDriver, *mesos.MasterInfo) - - // Invoked when the scheduler becomes "disconnected" from the master - // (e.g., the master fails and another is taking over). - Disconnected(SchedulerDriver) - - // Invoked when resources have been offered to this framework. A - // single offer will only contain resources from a single slave. - // Resources associated with an offer will not be re-offered to - // _this_ framework until either (a) this framework has rejected - // those resources (see SchedulerDriver::launchTasks) or (b) those - // resources have been rescinded (see Scheduler::offerRescinded). - // Note that resources may be concurrently offered to more than one - // framework at a time (depending on the allocator being used). In - // that case, the first framework to launch tasks using those - // resources will be able to use them while the other frameworks - // will have those resources rescinded (or if a framework has - // already launched tasks with those resources then those tasks will - // fail with a TASK_LOST status and a message saying as much). - ResourceOffers(SchedulerDriver, []*mesos.Offer) - - // Invoked when an offer is no longer valid (e.g., the slave was - // lost or another framework used resources in the offer). If for - // whatever reason an offer is never rescinded (e.g., dropped - // message, failing over framework, etc.), a framwork that attempts - // to launch tasks using an invalid offer will receive TASK_LOST - // status updates for those tasks (see Scheduler::resourceOffers). - OfferRescinded(SchedulerDriver, *mesos.OfferID) - - // Invoked when the status of a task has changed (e.g., a slave is - // lost and so the task is lost, a task finishes and an executor - // sends a status update saying so, etc). Note that returning from - // this callback _acknowledges_ receipt of this status update! If - // for whatever reason the scheduler aborts during this callback (or - // the process exits) another status update will be delivered (note, - // however, that this is currently not true if the slave sending the - // status update is lost/fails during that time). - StatusUpdate(SchedulerDriver, *mesos.TaskStatus) - - // Invoked when an executor sends a message. These messages are best - // effort; do not expect a framework message to be retransmitted in - // any reliable fashion. - FrameworkMessage(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, string) - - // Invoked when a slave has been determined unreachable (e.g., - // machine failure, network partition). Most frameworks will need to - // reschedule any tasks launched on this slave on a new slave. - SlaveLost(SchedulerDriver, *mesos.SlaveID) - - // Invoked when an executor has exited/terminated. Note that any - // tasks running will have TASK_LOST status updates automagically - // generated. - ExecutorLost(SchedulerDriver, *mesos.ExecutorID, *mesos.SlaveID, int) - - // Invoked when there is an unrecoverable error in the scheduler or - // scheduler driver. The driver will be aborted BEFORE invoking this - // callback. - Error(SchedulerDriver, string) -} diff --git a/vendor/github.com/mesos/mesos-go/scheduler/scheduler.go b/vendor/github.com/mesos/mesos-go/scheduler/scheduler.go deleted file mode 100644 index e7ba706686b..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/scheduler.go +++ /dev/null @@ -1,1539 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package scheduler - -import ( - "errors" - "fmt" - "math" - "math/rand" - "net" - "os/user" - "sync" - "sync/atomic" - "time" - - "github.com/gogo/protobuf/proto" - log "github.com/golang/glog" - "github.com/mesos/mesos-go/auth" - "github.com/mesos/mesos-go/detector" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/mesosproto/scheduler" - util "github.com/mesos/mesos-go/mesosutil" - "github.com/mesos/mesos-go/mesosutil/process" - "github.com/mesos/mesos-go/messenger" - "github.com/mesos/mesos-go/messenger/sessionid" - "github.com/mesos/mesos-go/upid" - "github.com/pborman/uuid" - "golang.org/x/net/context" -) - -const ( - defaultAuthenticationTimeout = 30 * time.Second // timeout interval for an authentication attempt - registrationRetryIntervalMax = float64(1 * time.Minute) - registrationBackoffFactor = 2 * time.Second -) - -var ( - ErrDisconnected = errors.New("disconnected from mesos master") - errAuthenticationCanceled = errors.New("authentication canceled") -) - -type ErrDriverAborted struct { - Reason string -} - -func (err *ErrDriverAborted) Error() string { - if err.Reason != "" { - return err.Reason - } - return "driver-aborted" -} - -// helper to track authentication progress and to prevent multiple close() ops -// against a signalling chan. it's safe to invoke the func's of this struct -// even if the receiver pointer is nil. -type authenticationAttempt struct { - done chan struct{} - doneOnce sync.Once -} - -func (a *authenticationAttempt) cancel() { - if a != nil { - a.doneOnce.Do(func() { close(a.done) }) - } -} - -func (a *authenticationAttempt) inProgress() bool { - if a != nil { - select { - case <-a.done: - return false - default: - return true - } - } - return false -} - -type DriverConfig struct { - Scheduler Scheduler - Framework *mesos.FrameworkInfo - Master string - Credential *mesos.Credential // optional - WithAuthContext func(context.Context) context.Context // required when Credential != nil - HostnameOverride string // optional - BindingAddress net.IP // optional - BindingPort uint16 // optional - PublishedAddress net.IP // optional - NewMessenger func() (messenger.Messenger, error) // optional - NewDetector func() (detector.Master, error) // optional -} - -// Concrete implementation of a SchedulerDriver that connects a -// Scheduler with a Mesos master. The MesosSchedulerDriver is -// thread-safe. -// -// Note that scheduler failover is supported in Mesos. After a -// scheduler is registered with Mesos it may failover (to a new -// process on the same machine or across multiple machines) by -// creating a new driver with the ID given to it in -// Scheduler.Registered(). -// -// The driver is responsible for invoking the Scheduler callbacks as -// it communicates with the Mesos master. -// -// Note that blocking on the MesosSchedulerDriver (e.g., via -// MesosSchedulerDriver.Join) doesn't affect the scheduler callbacks -// in anyway because they are handled by a different thread. -// -// TODO(yifan): examples. -// See src/examples/test_framework.cpp for an example of using the -// MesosSchedulerDriver. -type MesosSchedulerDriver struct { - masterPid *upid.UPID - frameworkInfo *mesos.FrameworkInfo - self *upid.UPID - stopCh chan struct{} - status mesos.Status - messenger messenger.Messenger - masterDetector detector.Master - connected bool - connection uuid.UUID - failoverTimeout float64 - failover bool - cache *schedCache - updates map[string]*mesos.StatusUpdate // Key is a UUID string. - tasks map[string]*mesos.TaskInfo // Key is a UUID string. - credential *mesos.Credential - authenticated bool - authenticating *authenticationAttempt - reauthenticate bool - withAuthContext func(context.Context) context.Context - dispatch func(context.Context, *upid.UPID, proto.Message) error // send a message somewhere - started chan struct{} // signal chan that closes upon a successful call to Start() - eventLock sync.RWMutex // guard for all driver state - withScheduler func(f func(s Scheduler)) // execute some func with respect to the given scheduler; should be the last thing invoked in a handler (lock semantics) - done chan struct{} // signal chan that closes when no more events will be processed -} - -// Create a new mesos scheduler driver with the given -// scheduler, framework info, -// master address, and credential(optional) -func NewMesosSchedulerDriver(config DriverConfig) (initializedDriver *MesosSchedulerDriver, err error) { - if config.Scheduler == nil { - err = fmt.Errorf("Scheduler callbacks required.") - } else if config.Master == "" { - err = fmt.Errorf("Missing master location URL.") - } else if config.Framework == nil { - err = fmt.Errorf("FrameworkInfo must be provided.") - } else if config.Credential != nil && config.WithAuthContext == nil { - err = fmt.Errorf("WithAuthContext must be provided when Credential != nil") - } - if err != nil { - return - } - - framework := proto.Clone(config.Framework).(*mesos.FrameworkInfo) - - // set default userid - if framework.GetUser() == "" { - user, err := user.Current() - if err != nil || user == nil { - if err != nil { - log.Warningf("Failed to obtain username: %v\n", err) - } else { - log.Warningln("Failed to obtain username.") - } - framework.User = proto.String("") - } else { - framework.User = proto.String(user.Username) - } - } - - // default hostname - hostname := util.GetHostname(config.HostnameOverride) - if framework.GetHostname() == "" { - framework.Hostname = proto.String(hostname) - } - - driver := &MesosSchedulerDriver{ - frameworkInfo: framework, - stopCh: make(chan struct{}), - status: mesos.Status_DRIVER_NOT_STARTED, - cache: newSchedCache(), - credential: config.Credential, - failover: framework.Id != nil && len(framework.Id.GetValue()) > 0, - withAuthContext: config.WithAuthContext, - started: make(chan struct{}), - done: make(chan struct{}), - } - - driver.withScheduler = driver.makeWithScheduler(config.Scheduler) - - if framework.FailoverTimeout != nil && *framework.FailoverTimeout > 0 { - driver.failoverTimeout = *framework.FailoverTimeout * float64(time.Second) - log.V(1).Infof("found failover_timeout = %v", time.Duration(driver.failoverTimeout)) - } - - newDetector := config.NewDetector - if newDetector == nil { - newDetector = func() (detector.Master, error) { - return detector.New(config.Master) - } - } - newMessenger := config.NewMessenger - if newMessenger == nil { - newMessenger = func() (messenger.Messenger, error) { - process := process.New("scheduler") - return messenger.ForHostname(process, hostname, config.BindingAddress, config.BindingPort, config.PublishedAddress) - } - } - - // initialize new detector. - if driver.masterDetector, err = newDetector(); err != nil { - return - } else if driver.messenger, err = newMessenger(); err != nil { - return - } else if err = driver.init(); err != nil { - return - } else { - initializedDriver = driver - } - return -} - -func (driver *MesosSchedulerDriver) makeWithScheduler(cs Scheduler) func(func(Scheduler)) { - // mechanism that allows us to asynchronously invoke scheduler callbacks, but in a manner - // such that the callback invocations are serialized. useful because this will decouple the - // goroutine executing a messenger callback from the goroutine executing a scheduler callback, - // while preserving the serialization semantics for each type of callback handling. - // we use a chan to maintain the order of callback invocations; this is important for maintaining - // the order in which status updates are processed. - schedQueue := make(chan func(s Scheduler)) - go func() { - defer func() { - close(driver.done) - log.V(1).Infoln("finished processing scheduler events") - }() - for f := range schedQueue { - f(cs) - } - }() - - var schedLock sync.Mutex // synchronize write access to schedQueue - abort := int32(0) - - // assume that when withScheduler is invoked eventLock is locked - return func(f func(s Scheduler)) { - const timeout = 1 * time.Second - t := time.NewTimer(timeout) - defer t.Stop() - - trySend := func() (done bool) { - // don't block while attempting to enqueue a scheduler op; this could - // take a while depending upon the external scheduler implementation. - // also, it allows for multiple go-routines to re-compete for the lock - // every so often - this avoids indefinitely blocking a call to Abort(). - driver.eventLock.Unlock() - schedLock.Lock() - defer func() { - schedLock.Unlock() - driver.eventLock.Lock() - }() - - if atomic.LoadInt32(&abort) == 1 { - // can't send anymore - return true - } - - // try to write to event queue... - select { - case schedQueue <- f: - done = true - case <-driver.stopCh: - done = true - case <-t.C: - } - - // if stopping then close out the queue (keeping this check separate from - // the above on purpose! otherwise we could miss the close signal) - select { - case <-driver.stopCh: - if atomic.CompareAndSwapInt32(&abort, 0, 1) { - defer close(schedQueue) - log.V(1).Infoln("stopping scheduler event queue..") - - // one last attempt, before we run out of time - select { - case schedQueue <- f: - case <-t.C: - } - } - default: - } - return - } - for !trySend() { - t.Reset(timeout) // TODO(jdef) add jitter to this - } - // have to do this outside trySend because here we're guarded by eventLock; it's ok - // if this happens more then once. - if atomic.LoadInt32(&abort) == 1 { - driver.withScheduler = func(f func(_ Scheduler)) {} - } - } -} - -// ctx returns the current context.Context for the driver, expects to be invoked -// only when eventLock is locked. -func (driver *MesosSchedulerDriver) context() context.Context { - // set a "session" attribute so that the messenger can see it - // and use it for reporting delivery errors. - return sessionid.NewContext(context.TODO(), driver.connection.String()) -} - -// init initializes the driver. -func (driver *MesosSchedulerDriver) init() error { - log.Infof("Initializing mesos scheduler driver\n") - driver.dispatch = driver.messenger.Send - - // serialize all callbacks from the messenger - type messageHandler func(context.Context, *upid.UPID, proto.Message) - - guarded := func(h messageHandler) messenger.MessageHandler { - return messenger.MessageHandler(func(from *upid.UPID, msg proto.Message) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - h(driver.context(), from, msg) - }) - } - - // Install handlers. - driver.messenger.Install(guarded(driver.frameworkRegistered), &mesos.FrameworkRegisteredMessage{}) - driver.messenger.Install(guarded(driver.frameworkReregistered), &mesos.FrameworkReregisteredMessage{}) - driver.messenger.Install(guarded(driver.resourcesOffered), &mesos.ResourceOffersMessage{}) - driver.messenger.Install(guarded(driver.resourceOfferRescinded), &mesos.RescindResourceOfferMessage{}) - driver.messenger.Install(guarded(driver.statusUpdated), &mesos.StatusUpdateMessage{}) - driver.messenger.Install(guarded(driver.slaveLost), &mesos.LostSlaveMessage{}) - driver.messenger.Install(guarded(driver.frameworkMessageRcvd), &mesos.ExecutorToFrameworkMessage{}) - driver.messenger.Install(guarded(driver.frameworkErrorRcvd), &mesos.FrameworkErrorMessage{}) - driver.messenger.Install(guarded(driver.exitedExecutor), &mesos.ExitedExecutorMessage{}) - driver.messenger.Install(guarded(driver.handleMasterChanged), &mesos.InternalMasterChangeDetected{}) - driver.messenger.Install(guarded(driver.handleAuthenticationResult), &mesos.InternalAuthenticationResult{}) - driver.messenger.Install(guarded(driver.handleNetworkError), &mesos.InternalNetworkError{}) - return nil -} - -func (driver *MesosSchedulerDriver) handleNetworkError(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - msg := pbMsg.(*mesos.InternalNetworkError) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Info("ignoring network error because the driver is aborted.") - return - } else if !from.Equal(driver.self) { - log.Errorf("ignoring network error because message received from upid '%v'", from) - return - } else if !driver.connected { - log.V(1).Infof("ignoring network error since we're not currently connected") - return - } - - if driver.masterPid.String() == msg.GetPid() && driver.connection.String() == msg.GetSession() { - // fire a disconnection event - log.V(3).Info("Disconnecting scheduler.") - - // need to set all 3 of these at once, since withScheduler() temporarily releases the lock and we don't - // want inconsistent connection facts - driver.masterPid = nil - driver.connected = false - driver.authenticated = false - - driver.withScheduler(func(s Scheduler) { s.Disconnected(driver) }) - log.Info("master disconnected") - } -} - -// lead master detection callback. -func (driver *MesosSchedulerDriver) handleMasterChanged(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Info("Ignoring master change because the driver is aborted.") - return - } else if !from.Equal(driver.self) { - log.Errorf("ignoring master changed message received from upid '%v'", from) - return - } - - // Reconnect every time a master is detected. - wasConnected := driver.connected - driver.connected = false - driver.authenticated = false - - alertScheduler := false - if wasConnected { - log.V(3).Info("Disconnecting scheduler.") - driver.masterPid = nil - alertScheduler = true - } - - msg := pbMsg.(*mesos.InternalMasterChangeDetected) - master := msg.Master - - if master != nil { - log.Infof("New master %s detected\n", master.GetPid()) - - pid, err := upid.Parse(master.GetPid()) - if err != nil { - panic("Unable to parse Master's PID value.") // this should not happen. - } - - driver.masterPid = pid // save for downstream ops. - defer driver.tryAuthentication() - } else { - log.Infoln("No master detected.") - } - if alertScheduler { - driver.withScheduler(func(s Scheduler) { s.Disconnected(driver) }) - } -} - -// tryAuthentication expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) tryAuthentication() { - if driver.authenticated { - // programming error - panic("already authenticated") - } - - masterPid := driver.masterPid // save for referencing later in goroutine - if masterPid == nil { - log.Info("skipping authentication attempt because we lost the master") - return - } - - if driver.authenticating.inProgress() { - // authentication is in progress, try to cancel it (we may too late already) - driver.authenticating.cancel() - driver.reauthenticate = true - return - } - - if driver.credential != nil { - // authentication can block and we don't want to hold up the messenger loop - authenticating := &authenticationAttempt{done: make(chan struct{})} - go func() { - defer authenticating.cancel() - result := &mesos.InternalAuthenticationResult{ - //TODO(jdef): is this really needed? - Success: proto.Bool(false), - Completed: proto.Bool(false), - Pid: proto.String(masterPid.String()), - } - // don't reference driver.authenticating here since it may have changed - if err := driver.authenticate(masterPid, authenticating); err != nil { - log.Errorf("Scheduler failed to authenticate: %v\n", err) - if err == auth.AuthenticationFailed { - result.Completed = proto.Bool(true) - } - } else { - result.Completed = proto.Bool(true) - result.Success = proto.Bool(true) - } - pid := driver.messenger.UPID() - driver.messenger.Route(context.TODO(), &pid, result) - }() - driver.authenticating = authenticating - } else { - log.Infoln("No credentials were provided. " + - "Attempting to register scheduler without authentication.") - driver.authenticated = true - go driver.doReliableRegistration(float64(registrationBackoffFactor)) - } -} - -func (driver *MesosSchedulerDriver) handleAuthenticationResult(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - if driver.status != mesos.Status_DRIVER_RUNNING { - log.V(1).Info("ignoring authenticate because driver is not running") - return - } - if !from.Equal(driver.self) { - log.Errorf("ignoring authentication result message received from upid '%v'", from) - return - } - if driver.authenticated { - // programming error - panic("already authenticated") - } - if driver.masterPid == nil { - log.Infoln("ignoring authentication result because master is lost") - driver.authenticating.cancel() // cancel any in-progress background attempt - - // disable future retries until we get a new master - driver.reauthenticate = false - return - } - msg := pbMsg.(*mesos.InternalAuthenticationResult) - if driver.reauthenticate || !msg.GetCompleted() || driver.masterPid.String() != msg.GetPid() { - log.Infof("failed to authenticate with master %v: master changed", driver.masterPid) - driver.authenticating.cancel() // cancel any in-progress background authentication - driver.reauthenticate = false - driver.tryAuthentication() - return - } - if !msg.GetSuccess() { - log.Errorf("master %v refused authentication", driver.masterPid) - return - } - driver.authenticated = true - go driver.doReliableRegistration(float64(registrationBackoffFactor)) -} - -// ------------------------- Accessors ----------------------- // - -// Status returns the current driver status -func (driver *MesosSchedulerDriver) Status() mesos.Status { - driver.eventLock.RLock() - defer driver.eventLock.RUnlock() - return driver.status -} - -// Running returns true if the driver is in the DRIVER_RUNNING state -func (driver *MesosSchedulerDriver) Running() bool { - driver.eventLock.RLock() - defer driver.eventLock.RUnlock() - return driver.status == mesos.Status_DRIVER_RUNNING -} - -// Connected returns true if the driver has a registered (and authenticated, if enabled) -// connection to the leading mesos master -func (driver *MesosSchedulerDriver) Connected() bool { - driver.eventLock.RLock() - defer driver.eventLock.RUnlock() - return driver.connected -} - -// stopped returns true if the driver status != DRIVER_RUNNING; expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) stopped() bool { - return driver.status != mesos.Status_DRIVER_RUNNING -} - -// ---------------------- Handlers for Events from Master --------------- // -func (driver *MesosSchedulerDriver) frameworkRegistered(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(2).Infoln("Handling scheduler driver framework registered event.") - - msg := pbMsg.(*mesos.FrameworkRegisteredMessage) - masterInfo := msg.GetMasterInfo() - masterPid := masterInfo.GetPid() - frameworkId := msg.GetFrameworkId() - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Infof("ignoring FrameworkRegisteredMessage from master %s, driver is aborted", masterPid) - return - } - - if driver.connected { - log.Infoln("ignoring FrameworkRegisteredMessage from master, driver is already connected", masterPid) - return - } - - if driver.stopped() { - log.Infof("ignoring FrameworkRegisteredMessage from master %s, driver is stopped", masterPid) - return - } - if !driver.masterPid.Equal(from) { - log.Warningf("ignoring framework registered message because it was sent from '%v' instead of leading master '%v'", from, driver.masterPid) - return - } - - log.Infof("Framework registered with ID=%s\n", frameworkId.GetValue()) - driver.frameworkInfo.Id = frameworkId // generated by master. - - driver.connected = true - driver.failover = false - driver.connection = uuid.NewUUID() - driver.withScheduler(func(s Scheduler) { s.Registered(driver, frameworkId, masterInfo) }) -} - -func (driver *MesosSchedulerDriver) frameworkReregistered(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling Scheduler re-registered event.") - msg := pbMsg.(*mesos.FrameworkReregisteredMessage) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Infoln("Ignoring FrameworkReregisteredMessage from master, driver is aborted!") - return - } - if driver.connected { - log.Infoln("Ignoring FrameworkReregisteredMessage from master,driver is already connected!") - return - } - if !driver.masterPid.Equal(from) { - log.Warningf("ignoring framework re-registered message because it was sent from '%v' instead of leading master '%v'", from, driver.masterPid) - return - } - - // TODO(vv) detect if message was from leading-master (sched.cpp) - log.Infof("Framework re-registered with ID [%s] ", msg.GetFrameworkId().GetValue()) - driver.connected = true - driver.failover = false - driver.connection = uuid.NewUUID() - - driver.withScheduler(func(s Scheduler) { s.Reregistered(driver, msg.GetMasterInfo()) }) -} - -func (driver *MesosSchedulerDriver) resourcesOffered(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(2).Infoln("Handling resource offers.") - - msg := pbMsg.(*mesos.ResourceOffersMessage) - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Infoln("Ignoring ResourceOffersMessage, the driver is aborted!") - return - } - - if !driver.connected { - log.Infoln("Ignoring ResourceOffersMessage, the driver is not connected!") - return - } - - pidStrings := msg.GetPids() - if len(pidStrings) != len(msg.Offers) { - log.Errorln("Ignoring offers, Offer count does not match Slave PID count.") - return - } - - for i, offer := range msg.Offers { - if pid, err := upid.Parse(pidStrings[i]); err == nil { - driver.cache.putOffer(offer, pid) - log.V(2).Infof("Cached offer %s from SlavePID %s", offer.Id.GetValue(), pid) - } else { - log.Warningf("Failed to parse offer PID '%v': %v", pid, err) - } - } - - driver.withScheduler(func(s Scheduler) { s.ResourceOffers(driver, msg.Offers) }) -} - -func (driver *MesosSchedulerDriver) resourceOfferRescinded(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling resource offer rescinded.") - - msg := pbMsg.(*mesos.RescindResourceOfferMessage) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.Infoln("Ignoring RescindResourceOfferMessage, the driver is aborted!") - return - } - - if !driver.connected { - log.Infoln("Ignoring ResourceOffersMessage, the driver is not connected!") - return - } - - // TODO(vv) check for leading master (see sched.cpp) - - log.V(1).Infoln("Rescinding offer ", msg.OfferId.GetValue()) - driver.cache.removeOffer(msg.OfferId) - driver.withScheduler(func(s Scheduler) { s.OfferRescinded(driver, msg.OfferId) }) -} - -func (driver *MesosSchedulerDriver) send(ctx context.Context, upid *upid.UPID, msg proto.Message) error { - c := make(chan error, 1) - go func() { c <- driver.dispatch(ctx, upid, msg) }() - - select { - case <-ctx.Done(): - <-c // wait for Send(...) - return ctx.Err() - case err := <-c: - return err - } -} - -// statusUpdated expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) statusUpdated(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - msg := pbMsg.(*mesos.StatusUpdateMessage) - - if driver.status != mesos.Status_DRIVER_RUNNING { - log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not running!") - return - } - if !from.Equal(driver.self) { - if !driver.connected { - log.V(1).Infoln("Ignoring StatusUpdate message, the driver is not connected!") - return - } - if !driver.masterPid.Equal(from) { - log.Warningf("ignoring status message because it was sent from '%v' instead of leading master '%v'", from, driver.masterPid) - return - } - } - - log.V(2).Infof("Received status update from %q status source %q", from.String(), msg.GetPid()) - - status := msg.Update.GetStatus() - - // see https://github.com/apache/mesos/blob/master/src/sched/sched.cpp#L887 - // If the update does not have a 'uuid', it does not need - // acknowledging. However, prior to 0.23.0, the update uuid - // was required and always set. We also don't want to ACK updates - // that were internally generated. In 0.24.0, we can rely on the - // update uuid check here, until then we must still check for - // this being sent from the driver (from == UPID()) or from - // the master (pid == UPID()). - // TODO(vinod): Get rid of this logic in 0.25.0 because master - // and slave correctly set task status in 0.24.0. - if clearUUID := len(msg.Update.Uuid) == 0 || from.Equal(driver.self) || msg.GetPid() == driver.self.String(); clearUUID { - status.Uuid = nil - } else { - status.Uuid = msg.Update.Uuid - } - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.V(1).Infoln("Not sending StatusUpdate ACK, the driver is aborted!") - } else { - - // Send StatusUpdate Acknowledgement; see above for the rules. - // Only send ACK if udpate was not from this driver and spec'd a UUID; this is compat w/ 0.23+ - ackRequired := len(msg.Update.Uuid) > 0 && !from.Equal(driver.self) && msg.GetPid() != driver.self.String() - if ackRequired { - ackMsg := &mesos.StatusUpdateAcknowledgementMessage{ - SlaveId: msg.Update.SlaveId, - FrameworkId: driver.frameworkInfo.Id, - TaskId: msg.Update.Status.TaskId, - Uuid: msg.Update.Uuid, - } - - log.V(2).Infof("Sending ACK for status update %+v to %q", *msg.Update, from.String()) - if err := driver.send(ctx, driver.masterPid, ackMsg); err != nil { - log.Errorf("Failed to send StatusUpdate ACK message: %v", err) - } - } else { - log.V(2).Infof("Not sending ACK, update is not from slave %q", from.String()) - } - } - driver.withScheduler(func(s Scheduler) { s.StatusUpdate(driver, status) }) -} - -func (driver *MesosSchedulerDriver) exitedExecutor(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling ExitedExceutor event.") - msg := pbMsg.(*mesos.ExitedExecutorMessage) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.V(1).Infoln("Ignoring ExitedExecutor message, the driver is aborted!") - return - } - if !driver.connected { - log.V(1).Infoln("Ignoring ExitedExecutor message, the driver is not connected!") - return - } - status := msg.GetStatus() - log.V(2).Infoln("Lost executor %q from slave %q for framework %q with status %d", - msg.GetExecutorId().GetValue(), - msg.GetSlaveId().GetValue(), - msg.GetFrameworkId().GetValue(), - status) - driver.withScheduler(func(s Scheduler) { s.ExecutorLost(driver, msg.GetExecutorId(), msg.GetSlaveId(), int(status)) }) -} - -func (driver *MesosSchedulerDriver) slaveLost(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling LostSlave event.") - - msg := pbMsg.(*mesos.LostSlaveMessage) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.V(1).Infoln("Ignoring LostSlave message, the driver is aborted!") - return - } - - if !driver.connected { - log.V(1).Infoln("Ignoring LostSlave message, the driver is not connected!") - return - } - - // TODO(VV) - detect leading master (see sched.cpp) - - log.V(2).Infoln("Lost slave ", msg.SlaveId.GetValue()) - driver.cache.removeSlavePid(msg.SlaveId) - - driver.withScheduler(func(s Scheduler) { s.SlaveLost(driver, msg.SlaveId) }) -} - -func (driver *MesosSchedulerDriver) frameworkMessageRcvd(_ context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling framework message event.") - - msg := pbMsg.(*mesos.ExecutorToFrameworkMessage) - - if driver.status == mesos.Status_DRIVER_ABORTED { - log.V(1).Infoln("Ignoring framwork message, the driver is aborted!") - return - } - - log.V(1).Infoln("Received Framwork Message ", msg.String()) - - driver.withScheduler(func(s Scheduler) { s.FrameworkMessage(driver, msg.ExecutorId, msg.SlaveId, string(msg.Data)) }) -} - -func (driver *MesosSchedulerDriver) frameworkErrorRcvd(ctx context.Context, from *upid.UPID, pbMsg proto.Message) { - log.V(1).Infoln("Handling framework error event.") - msg := pbMsg.(*mesos.FrameworkErrorMessage) - driver.fatal(ctx, msg.GetMessage()) -} - -// ---------------------- Interface Methods ---------------------- // - -// Starts the scheduler driver. -// Returns immediately if an error occurs within start sequence. -func (driver *MesosSchedulerDriver) Start() (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - return driver.start() -} - -// start expected to be guarded by eventLock -func (driver *MesosSchedulerDriver) start() (mesos.Status, error) { - select { - case <-driver.started: - return driver.status, errors.New("Unable to Start: driver has already been started once.") - default: // proceed - } - - log.Infoln("Starting the scheduler driver...") - - if driver.status != mesos.Status_DRIVER_NOT_STARTED { - return driver.status, fmt.Errorf("Unable to Start, expecting driver status %s, but is %s:", mesos.Status_DRIVER_NOT_STARTED, driver.status) - } - - // Start the messenger. - if err := driver.messenger.Start(); err != nil { - log.Errorf("Scheduler failed to start the messenger: %v\n", err) - return driver.status, err - } - - pid := driver.messenger.UPID() - driver.self = &pid - driver.status = mesos.Status_DRIVER_RUNNING - close(driver.started) - - log.Infof("Mesos scheduler driver started with PID=%v", driver.self) - - listener := detector.OnMasterChanged(func(m *mesos.MasterInfo) { - driver.messenger.Route(context.TODO(), driver.self, &mesos.InternalMasterChangeDetected{ - Master: m, - }) - }) - - if driver.masterDetector != nil { - // register with Detect() AFTER we have a self pid from the messenger, otherwise things get ugly - // because our internal messaging depends on it. detector callbacks are routed over the messenger - // bus, maintaining serial (concurrency-safe) callback execution. - log.V(1).Infof("starting master detector %T: %+v", driver.masterDetector, driver.masterDetector) - driver.masterDetector.Detect(listener) - log.V(2).Infoln("master detector started") - } - return driver.status, nil -} - -// authenticate against the spec'd master pid using the configured authenticationProvider. -// the authentication process is canceled upon either cancelation of authenticating, or -// else because it timed out (see defaultAuthenticationTimeout, auth.Timeout). -// -// TODO(jdef) perhaps at some point in the future this will get pushed down into -// the messenger layer (e.g. to use HTTP-based authentication). We'd probably still -// specify the callback.Handler here, along with the user-selected authentication -// provider. Perhaps in the form of some messenger.AuthenticationConfig. -// -func (driver *MesosSchedulerDriver) authenticate(pid *upid.UPID, authenticating *authenticationAttempt) error { - log.Infof("authenticating with master %v", pid) - - var ( - authTimeout = defaultAuthenticationTimeout - ctx = driver.withAuthContext(context.TODO()) - handler = &CredentialHandler{ - pid: pid, - client: driver.self, - credential: driver.credential, - } - ) - - // check for authentication timeout override - if d, ok := auth.TimeoutFrom(ctx); ok { - authTimeout = d - } - - ctx, cancel := context.WithTimeout(ctx, authTimeout) - ctx = auth.WithParentUPID(ctx, *driver.self) - - ch := make(chan error, 1) - go func() { ch <- auth.Login(ctx, handler) }() - - select { - case <-ctx.Done(): - <-ch - return ctx.Err() - case <-authenticating.done: - cancel() - <-ch - return errAuthenticationCanceled - case e := <-ch: - cancel() - return e - } -} - -func (driver *MesosSchedulerDriver) doReliableRegistration(maxBackoff float64) { - for { - if !driver.registerOnce() { - return - } - maxBackoff = math.Min(maxBackoff, registrationRetryIntervalMax) - - // If failover timeout is present, bound the maximum backoff - // by 1/10th of the failover timeout. - if driver.failoverTimeout > 0 { - maxBackoff = math.Min(maxBackoff, driver.failoverTimeout/10.0) - } - - // Determine the delay for next attempt by picking a random - // duration between 0 and 'maxBackoff' (jitter). - delay := time.Duration(maxBackoff * rand.Float64()) - - log.V(1).Infof("will retry registration in %v if necessary", delay) - - t := time.NewTimer(delay) - defer t.Stop() - - select { - case <-driver.stopCh: - return - case <-t.C: - maxBackoff *= 2 - } - } -} - -// registerOnce returns true if we should attempt another registration later; it is *not* -// guarded by eventLock: all access to mutable members of MesosSchedulerDriver should be -// explicitly synchronized. -func (driver *MesosSchedulerDriver) registerOnce() bool { - var ( - failover bool - pid *upid.UPID - info *mesos.FrameworkInfo - ctx context.Context - ) - if func() bool { - driver.eventLock.RLock() - defer driver.eventLock.RUnlock() - - if driver.stopped() || driver.connected || driver.masterPid == nil || (driver.credential != nil && !driver.authenticated) { - log.V(1).Infof("skipping registration request: stopped=%v, connected=%v, authenticated=%v", - driver.stopped(), driver.connected, driver.authenticated) - return false - } - failover = driver.failover - pid = driver.masterPid - info = proto.Clone(driver.frameworkInfo).(*mesos.FrameworkInfo) - ctx = driver.context() - return true - }() { - // register framework - var message proto.Message - if len(info.GetId().GetValue()) > 0 { - // not the first time, or failing over - log.V(1).Infof("Reregistering with master: %v", pid) - message = &mesos.ReregisterFrameworkMessage{ - Framework: info, - Failover: proto.Bool(failover), - } - } else { - log.V(1).Infof("Registering with master: %v", pid) - message = &mesos.RegisterFrameworkMessage{ - Framework: info, - } - } - if err := driver.send(ctx, pid, message); err != nil { - log.Errorf("failed to send RegisterFramework message: %v", err) - if _, err = driver.Stop(failover); err != nil { - log.Errorf("failed to stop scheduler driver: %v", err) - } - } - return true - } - return false -} - -//Join blocks until the driver is stopped. -//Should follow a call to Start() -func (driver *MesosSchedulerDriver) Join() (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - return driver.join() -} - -// join expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) join() (stat mesos.Status, err error) { - if stat = driver.status; stat != mesos.Status_DRIVER_RUNNING { - err = fmt.Errorf("Unable to Join, expecting driver status %s, but is %s", mesos.Status_DRIVER_RUNNING, stat) - return - } - - timeout := 1 * time.Second - t := time.NewTimer(timeout) - defer t.Stop() - - driver.eventLock.Unlock() - defer func() { - driver.eventLock.Lock() - stat = driver.status - }() -waitForDeath: - for { - select { - case <-driver.done: - break waitForDeath - case <-t.C: - } - t.Reset(timeout) - } - return -} - -//Run starts and joins driver process and waits to be stopped or aborted. -func (driver *MesosSchedulerDriver) Run() (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - return driver.run(driver.context()) -} - -// run expected to be guarded by eventLock -func (driver *MesosSchedulerDriver) run(ctx context.Context) (mesos.Status, error) { - stat, err := driver.start() - - if err != nil { - return driver.stop(ctx, err, false) - } - - if stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to Run, expecting driver status %s, but is %s:", mesos.Status_DRIVER_RUNNING, driver.status) - } - - log.Infoln("Scheduler driver running. Waiting to be stopped.") - return driver.join() -} - -//Stop stops the driver. -func (driver *MesosSchedulerDriver) Stop(failover bool) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - return driver.stop(driver.context(), nil, failover) -} - -// stop expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) stop(ctx context.Context, cause error, failover bool) (mesos.Status, error) { - log.Infoln("Stopping the scheduler driver") - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to Stop, expected driver status %s, but is %s", mesos.Status_DRIVER_RUNNING, stat) - } - - if driver.connected && !failover { - // unregister the framework - log.Infoln("Unregistering the scheduler driver") - message := &mesos.UnregisterFrameworkMessage{ - FrameworkId: driver.frameworkInfo.Id, - } - //TODO(jdef) this is actually a little racy: we send an 'unregister' message but then - // immediately afterward the messenger is stopped in driver._stop(). so the unregister message - // may not actually end up being sent out. - if err := driver.send(ctx, driver.masterPid, message); err != nil { - log.Errorf("Failed to send UnregisterFramework message while stopping driver: %v\n", err) - if cause == nil { - cause = &ErrDriverAborted{} - } - return driver._stop(cause, mesos.Status_DRIVER_ABORTED) - } - time.Sleep(2 * time.Second) - } - - // stop messenger - return driver._stop(cause, mesos.Status_DRIVER_STOPPED) -} - -// stop expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) _stop(cause error, stopStatus mesos.Status) (mesos.Status, error) { - // stop messenger - defer func() { - select { - case <-driver.stopCh: - return - default: - } - close(driver.stopCh) - // decouple to avoid deadlock (avoid nested withScheduler() invocations) - go func() { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - if cause != nil { - log.V(1).Infof("Sending error via withScheduler: %v", cause) - driver.withScheduler(func(s Scheduler) { s.Error(driver, cause.Error()) }) - } else { - // send a noop func, withScheduler needs to see that stopCh is closed - log.V(1).Infof("Sending kill signal to withScheduler") - driver.withScheduler(func(_ Scheduler) {}) - } - }() - }() - driver.status = stopStatus - driver.connected = false - driver.connection = uuid.UUID{} - - log.Info("stopping messenger") - err := driver.messenger.Stop() - - log.Infof("Stop() complete with status %v error %v", stopStatus, err) - return stopStatus, err -} - -func (driver *MesosSchedulerDriver) Abort() (stat mesos.Status, err error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - return driver.abort(driver.context(), nil) -} - -// abort expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) abort(ctx context.Context, cause error) (stat mesos.Status, err error) { - if driver.masterDetector != nil { - defer driver.masterDetector.Cancel() - } - - log.Infof("Aborting framework [%+v]", driver.frameworkInfo.Id) - - if driver.connected { - _, err = driver.stop(ctx, cause, true) - } else { - driver._stop(cause, mesos.Status_DRIVER_ABORTED) - } - - stat = mesos.Status_DRIVER_ABORTED - driver.status = stat - return -} - -func (driver *MesosSchedulerDriver) AcceptOffers(offerIds []*mesos.OfferID, operations []*mesos.Offer_Operation, filters *mesos.Filters) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to AcceptOffers, expected driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - - ctx := driver.context() - if !driver.connected { - err := ErrDisconnected - for _, operation := range operations { - if *operation.Type == mesos.Offer_Operation_LAUNCH { - // decouple lost task processing to avoid deadlock (avoid nested withScheduler() invocations) - operation := operation - go func() { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - for _, task := range operation.Launch.TaskInfos { - driver.pushLostTask(ctx, task, err.Error()) - } - }() - } - } - log.Errorf("Failed to send LaunchTask message: %v\n", err) - return driver.status, err - } - - okOperations := make([]*mesos.Offer_Operation, 0, len(operations)) - - for _, offerId := range offerIds { - for _, operation := range operations { - // Keep only the slave PIDs where we run tasks so we can send - // framework messages directly. - if !driver.cache.containsOffer(offerId) { - log.Warningf("Attempting to accept offers with unknown offer %s\n", offerId.GetValue()) - continue - } - - // Validate - switch *operation.Type { - case mesos.Offer_Operation_LAUNCH: - tasks := []*mesos.TaskInfo{} - // Set TaskInfo.executor.framework_id, if it's missing. - for _, task := range operation.Launch.TaskInfos { - newTask := *task - if newTask.Executor != nil && newTask.Executor.FrameworkId == nil { - newTask.Executor.FrameworkId = driver.frameworkInfo.Id - } - tasks = append(tasks, &newTask) - } - for _, task := range tasks { - if driver.cache.getOffer(offerId).offer.SlaveId.Equal(task.SlaveId) { - // cache the tasked slave, for future communication - pid := driver.cache.getOffer(offerId).slavePid - driver.cache.putSlavePid(task.SlaveId, pid) - } else { - log.Warningf("Attempting to launch task %s with the wrong slaveId offer %s\n", task.TaskId.GetValue(), task.SlaveId.GetValue()) - } - } - operation.Launch.TaskInfos = tasks - okOperations = append(okOperations, operation) - case mesos.Offer_Operation_RESERVE: - // Only send reserved resources - filtered := util.FilterResources(operation.Reserve.Resources, func(res *mesos.Resource) bool { return res.Reservation != nil }) - operation.Reserve.Resources = filtered - okOperations = append(okOperations, operation) - case mesos.Offer_Operation_UNRESERVE: - // Only send reserved resources - filtered := util.FilterResources(operation.Unreserve.Resources, func(res *mesos.Resource) bool { return res.Reservation != nil }) - operation.Unreserve.Resources = filtered - okOperations = append(okOperations, operation) - case mesos.Offer_Operation_CREATE: - // Only send reserved resources disks with volumes - filtered := util.FilterResources(operation.Create.Volumes, func(res *mesos.Resource) bool { - return res.Reservation != nil && res.Disk != nil && res.GetName() == "disk" - }) - operation.Create.Volumes = filtered - okOperations = append(okOperations, operation) - case mesos.Offer_Operation_DESTROY: - // Only send reserved resources disks with volumes - filtered := util.FilterResources(operation.Destroy.Volumes, func(res *mesos.Resource) bool { - return res.Reservation != nil && res.Disk != nil && res.GetName() == "disk" - }) - operation.Destroy.Volumes = filtered - okOperations = append(okOperations, operation) - } - } - - driver.cache.removeOffer(offerId) // if offer - } - - // Accept Offers - message := &scheduler.Call{ - FrameworkId: driver.frameworkInfo.Id, - Type: scheduler.Call_ACCEPT.Enum(), - Accept: &scheduler.Call_Accept{ - OfferIds: offerIds, - Operations: okOperations, - Filters: filters, - }, - } - - if err := driver.send(ctx, driver.masterPid, message); err != nil { - for _, operation := range operations { - if *operation.Type == mesos.Offer_Operation_LAUNCH { - // decouple lost task processing to avoid deadlock (avoid nested withScheduler() invocations) - operation := operation - go func() { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - for _, task := range operation.Launch.TaskInfos { - driver.pushLostTask(ctx, task, "Unable to launch tasks: "+err.Error()) - } - }() - } - } - log.Errorf("Failed to send LaunchTask message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -func (driver *MesosSchedulerDriver) LaunchTasks(offerIds []*mesos.OfferID, tasks []*mesos.TaskInfo, filters *mesos.Filters) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to LaunchTasks, expected driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - - ctx := driver.context() - - // Launch tasks - if !driver.connected { - log.Infoln("Ignoring LaunchTasks message, disconnected from master.") - // decouple lost task processing to avoid deadlock (avoid nested withScheduler() invocations) - err := ErrDisconnected - go func() { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - // Send statusUpdate with status=TASK_LOST for each task. - // See sched.cpp L#823 - for _, task := range tasks { - driver.pushLostTask(ctx, task, err.Error()) - } - }() - return driver.status, err - } - - okTasks := make([]*mesos.TaskInfo, 0, len(tasks)) - - // Set TaskInfo.executor.framework_id, if it's missing. - for _, task := range tasks { - if task.Executor != nil && task.Executor.FrameworkId == nil { - task.Executor.FrameworkId = driver.frameworkInfo.Id - } - okTasks = append(okTasks, task) - } - - for _, offerId := range offerIds { - for _, task := range okTasks { - // Keep only the slave PIDs where we run tasks so we can send - // framework messages directly. - if driver.cache.containsOffer(offerId) { - if driver.cache.getOffer(offerId).offer.SlaveId.Equal(task.SlaveId) { - // cache the tasked slave, for future communication - pid := driver.cache.getOffer(offerId).slavePid - driver.cache.putSlavePid(task.SlaveId, pid) - } else { - log.Warningf("Attempting to launch task %s with the wrong slaveId offer %s\n", task.TaskId.GetValue(), task.SlaveId.GetValue()) - } - } else { - log.Warningf("Attempting to launch task %s with unknown offer %s\n", task.TaskId.GetValue(), offerId.GetValue()) - } - } - - driver.cache.removeOffer(offerId) // if offer - } - - // launch tasks - message := &mesos.LaunchTasksMessage{ - FrameworkId: driver.frameworkInfo.Id, - OfferIds: offerIds, - Tasks: okTasks, - Filters: filters, - } - - if err := driver.send(ctx, driver.masterPid, message); err != nil { - // decouple lost task processing to avoid deadlock (avoid nested withScheduler() invocations) - go func() { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - for _, task := range tasks { - driver.pushLostTask(ctx, task, "Unable to launch tasks: "+err.Error()) - } - }() - log.Errorf("Failed to send LaunchTask message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -// pushLostTask expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) pushLostTask(ctx context.Context, taskInfo *mesos.TaskInfo, why string) { - msg := &mesos.StatusUpdateMessage{ - Update: &mesos.StatusUpdate{ - FrameworkId: driver.frameworkInfo.Id, - Status: &mesos.TaskStatus{ - TaskId: taskInfo.TaskId, - State: mesos.TaskState_TASK_LOST.Enum(), - Source: mesos.TaskStatus_SOURCE_MASTER.Enum(), - Message: proto.String(why), - Reason: mesos.TaskStatus_REASON_MASTER_DISCONNECTED.Enum(), - }, - SlaveId: taskInfo.SlaveId, - ExecutorId: taskInfo.Executor.ExecutorId, - Timestamp: proto.Float64(float64(time.Now().Unix())), - }, - Pid: proto.String(driver.self.String()), - } - - // put it on internal chanel - // will cause handler to push to attached Scheduler - driver.statusUpdated(ctx, driver.self, msg) -} - -func (driver *MesosSchedulerDriver) KillTask(taskId *mesos.TaskID) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to KillTask, expecting driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - - if !driver.connected { - log.Infoln("Ignoring kill task message, disconnected from master.") - return driver.status, ErrDisconnected - } - - message := &mesos.KillTaskMessage{ - FrameworkId: driver.frameworkInfo.Id, - TaskId: taskId, - } - - if err := driver.send(driver.context(), driver.masterPid, message); err != nil { - log.Errorf("Failed to send KillTask message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -func (driver *MesosSchedulerDriver) RequestResources(requests []*mesos.Request) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to RequestResources, expecting driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - - if !driver.connected { - log.Infoln("Ignoring request resource message, disconnected from master.") - return driver.status, ErrDisconnected - } - - message := &mesos.ResourceRequestMessage{ - FrameworkId: driver.frameworkInfo.Id, - Requests: requests, - } - - if err := driver.send(driver.context(), driver.masterPid, message); err != nil { - log.Errorf("Failed to send ResourceRequest message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -func (driver *MesosSchedulerDriver) DeclineOffer(offerId *mesos.OfferID, filters *mesos.Filters) (mesos.Status, error) { - // NOTE: don't lock eventLock here because we're delegating to LaunchTasks() and that does it for us - // launching an empty task list will decline the offer - return driver.LaunchTasks([]*mesos.OfferID{offerId}, []*mesos.TaskInfo{}, filters) -} - -func (driver *MesosSchedulerDriver) ReviveOffers() (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to ReviveOffers, expecting driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - if !driver.connected { - log.Infoln("Ignoring revive offers message, disconnected from master.") - return driver.status, ErrDisconnected - } - - message := &mesos.ReviveOffersMessage{ - FrameworkId: driver.frameworkInfo.Id, - } - if err := driver.send(driver.context(), driver.masterPid, message); err != nil { - log.Errorf("Failed to send ReviveOffers message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -func (driver *MesosSchedulerDriver) SendFrameworkMessage(executorId *mesos.ExecutorID, slaveId *mesos.SlaveID, data string) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to SendFrameworkMessage, expecting driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - if !driver.connected { - log.Infoln("Ignoring send framework message, disconnected from master.") - return driver.status, ErrDisconnected - } - - message := &mesos.FrameworkToExecutorMessage{ - SlaveId: slaveId, - FrameworkId: driver.frameworkInfo.Id, - ExecutorId: executorId, - Data: []byte(data), - } - // Use list of cached slaveIds from previous offers. - // Send frameworkMessage directly to cached slave, otherwise to master. - if driver.cache.containsSlavePid(slaveId) { - slavePid := driver.cache.getSlavePid(slaveId) - if slavePid.Equal(driver.self) { - return driver.status, nil - } - if err := driver.send(driver.context(), slavePid, message); err != nil { - log.Errorf("Failed to send framework to executor message: %v\n", err) - return driver.status, err - } - } else { - // slavePid not cached, send to master. - if err := driver.send(driver.context(), driver.masterPid, message); err != nil { - log.Errorf("Failed to send framework to executor message: %v\n", err) - return driver.status, err - } - } - - return driver.status, nil -} - -func (driver *MesosSchedulerDriver) ReconcileTasks(statuses []*mesos.TaskStatus) (mesos.Status, error) { - driver.eventLock.Lock() - defer driver.eventLock.Unlock() - - if stat := driver.status; stat != mesos.Status_DRIVER_RUNNING { - return stat, fmt.Errorf("Unable to ReconcileTasks, expecting driver status %s, but got %s", mesos.Status_DRIVER_RUNNING, stat) - } - if !driver.connected { - log.Infoln("Ignoring send Reconcile Tasks message, disconnected from master.") - return driver.status, ErrDisconnected - } - - message := &mesos.ReconcileTasksMessage{ - FrameworkId: driver.frameworkInfo.Id, - Statuses: statuses, - } - if err := driver.send(driver.context(), driver.masterPid, message); err != nil { - log.Errorf("Failed to send reconcile tasks message: %v\n", err) - return driver.status, err - } - - return driver.status, nil -} - -// error expects to be guarded by eventLock -func (driver *MesosSchedulerDriver) fatal(ctx context.Context, err string) { - if driver.status == mesos.Status_DRIVER_ABORTED { - log.V(3).Infoln("Ignoring error message, the driver is aborted!") - return - } - driver.abort(ctx, &ErrDriverAborted{Reason: err}) -} diff --git a/vendor/github.com/mesos/mesos-go/scheduler/testing.go b/vendor/github.com/mesos/mesos-go/scheduler/testing.go deleted file mode 100644 index 46b584b39ab..00000000000 --- a/vendor/github.com/mesos/mesos-go/scheduler/testing.go +++ /dev/null @@ -1,78 +0,0 @@ -package scheduler - -import ( - "github.com/gogo/protobuf/proto" - mesos "github.com/mesos/mesos-go/mesosproto" - "github.com/mesos/mesos-go/upid" - "golang.org/x/net/context" -) - -type TestDriver struct { - *MesosSchedulerDriver -} - -func (t *TestDriver) SetConnected(b bool) { - t.eventLock.Lock() - defer t.eventLock.Unlock() - t.connected = b -} - -func (t *TestDriver) Started() <-chan struct{} { - return t.started -} - -func (t *TestDriver) Stopped() <-chan struct{} { - return t.stopCh -} - -func (t *TestDriver) Done() <-chan struct{} { - return t.done -} - -func (t *TestDriver) Framework() *mesos.FrameworkInfo { - return t.frameworkInfo -} - -func (t *TestDriver) UPID() *upid.UPID { - return t.self -} - -func (t *TestDriver) MasterPID() *upid.UPID { - return t.masterPid -} - -func (t *TestDriver) Fatal(ctx context.Context, msg string) { - t.eventLock.Lock() - defer t.eventLock.Unlock() - t.fatal(ctx, msg) -} - -func (t *TestDriver) OnDispatch(f func(ctx context.Context, upid *upid.UPID, msg proto.Message) error) { - t.dispatch = f -} - -func (t *TestDriver) HandleMasterChanged(ctx context.Context, from *upid.UPID, msg proto.Message) { - t.eventLock.Lock() - defer t.eventLock.Unlock() - t.handleMasterChanged(ctx, from, msg) -} - -func (t *TestDriver) CacheOffer(offer *mesos.Offer, pid *upid.UPID) { - t.cache.putOffer(offer, pid) -} - -func (t *TestDriver) Context() context.Context { - return t.context() -} - -func (t *TestDriver) FrameworkRegistered(ctx context.Context, from *upid.UPID, msg proto.Message) { - t.eventLock.Lock() - defer t.eventLock.Unlock() - t.frameworkRegistered(ctx, from, msg) -} - -func (t *TestDriver) FrameworkReregistered(ctx context.Context, from *upid.UPID, msg proto.Message) { - t.eventLock.Lock() - defer t.eventLock.Unlock() - t.frameworkReregistered(ctx, from, msg) -}