Adding dep files and dependencies.
This commit is contained in:
parent
45f9efa578
commit
b341c0a0e4
539 changed files with 313111 additions and 0 deletions
6
vendor/github.com/mesos/mesos-go/api/v0/scheduler/doc.go
generated
vendored
Normal file
6
vendor/github.com/mesos/mesos-go/api/v0/scheduler/doc.go
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
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
|
29
vendor/github.com/mesos/mesos-go/api/v0/scheduler/handler.go
generated
vendored
Normal file
29
vendor/github.com/mesos/mesos-go/api/v0/scheduler/handler.go
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/mesos/mesos-go/api/v0/auth/callback"
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
"github.com/mesos/mesos-go/api/v0/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
|
||||
}
|
7
vendor/github.com/mesos/mesos-go/api/v0/scheduler/plugins.go
generated
vendored
Normal file
7
vendor/github.com/mesos/mesos-go/api/v0/scheduler/plugins.go
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
_ "github.com/mesos/mesos-go/api/v0/auth/sasl"
|
||||
_ "github.com/mesos/mesos-go/api/v0/auth/sasl/mech/crammd5"
|
||||
_ "github.com/mesos/mesos-go/api/v0/detector/zoo"
|
||||
)
|
96
vendor/github.com/mesos/mesos-go/api/v0/scheduler/schedcache.go
generated
vendored
Normal file
96
vendor/github.com/mesos/mesos-go/api/v0/scheduler/schedcache.go
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
log "github.com/golang/glog"
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
"github.com/mesos/mesos-go/api/v0/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()
|
||||
}
|
196
vendor/github.com/mesos/mesos-go/api/v0/scheduler/schedtype.go
generated
vendored
Normal file
196
vendor/github.com/mesos/mesos-go/api/v0/scheduler/schedtype.go
generated
vendored
Normal file
|
@ -0,0 +1,196 @@
|
|||
/**
|
||||
* 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/api/v0/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)
|
||||
}
|
1539
vendor/github.com/mesos/mesos-go/api/v0/scheduler/scheduler.go
generated
vendored
Normal file
1539
vendor/github.com/mesos/mesos-go/api/v0/scheduler/scheduler.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
78
vendor/github.com/mesos/mesos-go/api/v0/scheduler/testing.go
generated
vendored
Normal file
78
vendor/github.com/mesos/mesos-go/api/v0/scheduler/testing.go
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
package scheduler
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
"github.com/mesos/mesos-go/api/v0/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)
|
||||
}
|
Reference in a new issue