agent

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2014 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TTL to use with all state pushed to Registry
	DefaultTTL = "30s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Machine machine.Machine
	// contains filtered or unexported fields
}

The Agent owns all of the coordination between the Registry, the local Machine, and the local UnitManager.

func New

func New(mgr unit.UnitManager, reg registry.Registry, mach machine.Machine, ttl string, verifier *sign.SignatureVerifier) (*Agent, error)

func (*Agent) HasConflict added in v0.3.0

func (a *Agent) HasConflict(potentialJobName string, potentialConflicts []string) (bool, string)

HasConflict determines whether there are any known conflicts with the given argument

func (*Agent) Heartbeat

func (a *Agent) Heartbeat(stop chan bool)

Heartbeat updates the Registry periodically with this Agent's presence information as well as an acknowledgement of the jobs it is expected to be running.

func (*Agent) Initialize added in v0.2.0

func (a *Agent) Initialize() uint64

Initialize prepares the Agent for normal operation by doing three things: 1. Announce presence to the Registry, tracking the etcd index of the operation 2. Discover any jobs that are scheduled locally, loading/starting them if they can run locally 3. Cache all unresolved job offers and bid for any that can be run locally The returned value is the etcd index at which the agent's presence was announced.

func (*Agent) JobScheduledElsewhere added in v0.4.0

func (a *Agent) JobScheduledElsewhere(jobName string)

JobScheduledElsewhere clears all state related to the indicated job before bidding for all oustanding jobs that can be run locally.

func (*Agent) JobScheduledLocally added in v0.4.0

func (a *Agent) JobScheduledLocally(jobName string)

JobScheduledLocally clears all state related to the indicated job's offers/bids before attempting to load and possibly start the job. The ability to run the job will be revalidated before loading, and unscheduled if such validation fails.

func (*Agent) JobUnscheduled added in v0.4.0

func (a *Agent) JobUnscheduled(jobName string)

JobUnscheduled attempts to unload the indicated job only if it were scheduled here in the first place, otherwise the event is ignored. If unloading is necessary, all jobs that can be run locally will also be bid upon.

func (*Agent) MarshalJSON added in v0.2.0

func (a *Agent) MarshalJSON() ([]byte, error)

func (*Agent) MaybeBid added in v0.4.0

func (a *Agent) MaybeBid(jo job.JobOffer)

MaybeBid determines bids for the given JobOffer only if it the Agent determines that it is able to run the JobOffer's Job

func (*Agent) Purge

func (a *Agent) Purge()

Purge removes the Agent's state from the Registry

func (*Agent) ReportUnitState added in v0.3.0

func (a *Agent) ReportUnitState(jobName string, us *unit.UnitState)

ReportUnitState attaches the current state of the Agent's Machine to the given unit.UnitState object, then persists that state in the Registry

func (*Agent) StartJob

func (a *Agent) StartJob(jobName string)

StartJob starts the indicated Job after first acquiring the state mutex

func (*Agent) StopJob

func (a *Agent) StopJob(jobName string)

StopJob stops the indicated Job after first acquiring the state mutex

type AgentState

type AgentState struct {

	// index of local payload conflicts to the job they belong to
	Conflicts map[string][]string
	// contains filtered or unexported fields
}

func NewState

func NewState() *AgentState

func (*AgentState) GetJobsByPeer

func (as *AgentState) GetJobsByPeer(peerName string) []string

Retrieve all Jobs that share a given Peer

func (*AgentState) GetOffersWithoutBids added in v0.1.1

func (as *AgentState) GetOffersWithoutBids() []job.JobOffer

GetOffersWithoutBids returns all tracked JobOffers that have no corresponding JobBid tracked in the same AgentState object.

func (*AgentState) HasBid

func (as *AgentState) HasBid(name string) bool

func (*AgentState) LaunchedJobs added in v0.3.0

func (as *AgentState) LaunchedJobs() []string

func (*AgentState) Lock

func (as *AgentState) Lock()

func (*AgentState) MarshalJSON added in v0.2.0

func (as *AgentState) MarshalJSON() ([]byte, error)

func (*AgentState) PurgeJob added in v0.3.0

func (as *AgentState) PurgeJob(jobName string)

PurgeJob removes all state tracked on behalf of a given job

func (*AgentState) PurgeOffer added in v0.3.0

func (as *AgentState) PurgeOffer(name string)

func (*AgentState) ScheduledHere added in v0.3.0

func (as *AgentState) ScheduledHere(jobName string) bool

func (*AgentState) ScheduledJobs added in v0.3.0

func (as *AgentState) ScheduledJobs() []string

func (*AgentState) SetTargetState added in v0.3.0

func (as *AgentState) SetTargetState(jobName string, state job.JobState)

func (*AgentState) TrackBid

func (as *AgentState) TrackBid(name string)

func (*AgentState) TrackJob added in v0.3.0

func (as *AgentState) TrackJob(j *job.Job)

TrackJob extracts and stores information about the given job for later reference

func (*AgentState) TrackOffer

func (as *AgentState) TrackOffer(offer job.JobOffer)

func (*AgentState) Unlock

func (as *AgentState) Unlock()

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

func NewEventHandler

func NewEventHandler(agent *Agent) *EventHandler

func (*EventHandler) HandleCommandStartJob added in v0.3.0

func (eh *EventHandler) HandleCommandStartJob(ev event.Event)

func (*EventHandler) HandleCommandStopJob added in v0.3.0

func (eh *EventHandler) HandleCommandStopJob(ev event.Event)

func (*EventHandler) HandleEventJobDestroyed added in v0.3.0

func (eh *EventHandler) HandleEventJobDestroyed(ev event.Event)

func (*EventHandler) HandleEventJobOffered

func (eh *EventHandler) HandleEventJobOffered(ev event.Event)

func (*EventHandler) HandleEventJobScheduled

func (eh *EventHandler) HandleEventJobScheduled(ev event.Event)

func (*EventHandler) HandleEventJobUnscheduled added in v0.3.0

func (eh *EventHandler) HandleEventJobUnscheduled(ev event.Event)

func (*EventHandler) HandleEventUnitStateUpdated added in v0.3.0

func (eh *EventHandler) HandleEventUnitStateUpdated(ev event.Event)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL