agent

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2014 License: Apache-2.0 Imports: 14 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 {
	// contains filtered or unexported fields
}

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

func New

func New(registry *registry.Registry, events *event.EventBus, machine *machine.Machine, ttl, unitPrefix string, verifier *sign.SignatureVerifier) (*Agent, error)

func (*Agent) AbleToRun

func (a *Agent) AbleToRun(j *job.Job) bool

Determine if the Agent can run the provided Job

func (*Agent) Bid

func (a *Agent) Bid(jobName string)

Submit a bid for the given Job

func (*Agent) BidForPossibleJobs

func (a *Agent) BidForPossibleJobs()

Submit all possible bids for unresolved offers

func (*Agent) BidForPossiblePeers

func (a *Agent) BidForPossiblePeers(jobName string)

Submit all possible bids for known peers of the provided job

func (*Agent) FetchJob

func (a *Agent) FetchJob(jobName string) *job.Job

Pull a Job and its payload from the Registry

func (*Agent) ForgetJob added in v0.2.0

func (a *Agent) ForgetJob(jobName string)

ForgetJob purges all state related to a given job from the local cache

func (*Agent) Heartbeat

func (a *Agent) Heartbeat(ttl time.Duration, stop chan bool)

Periodically report to the Registry at an interval equal to half of the provided ttl. Stop reporting when the provided channel is closed. Failed attempts to report state to the Registry are retried twice before moving on to the next reporting interval.

func (*Agent) Initialize added in v0.2.0

func (a *Agent) Initialize() uint64

Initialize pushes the local machine state to the Registry repeatedly until it succeeds. It returns the modification index of the first successful response received from etcd.

func (*Agent) Machine

func (a *Agent) Machine() *machine.Machine

Access Agent's machine field

func (*Agent) MarshalJSON added in v0.2.0

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

func (*Agent) OfferResolved

func (a *Agent) OfferResolved(jobName string)

Instruct the Agent that the given offer has been resolved and may be ignored in future conflict calculations

func (*Agent) Purge

func (a *Agent) Purge()

Clear any presence data from the Registry

func (*Agent) ReportJobState

func (a *Agent) ReportJobState(jobName string, jobState *job.JobState)

Persist the state of the given Job into the Registry

func (*Agent) RescheduleJob

func (a *Agent) RescheduleJob(j *job.Job)

Inform the Registry that a Job must be rescheduled

func (*Agent) Run

func (a *Agent) Run()

Trigger all async processes the Agent intends to run

func (*Agent) StartJob

func (a *Agent) StartJob(j *job.Job)

Instruct the Agent to start the provided Job

func (*Agent) Stop

func (a *Agent) Stop()

Stop all async processes the Agent is running

func (*Agent) StopJob

func (a *Agent) StopJob(jobName string)

Instruct the Agent to stop the provided Job and all of its peers

func (*Agent) TrackOffer

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

Instruct the Agent that an offer has been created and must be tracked until it is resolved

func (*Agent) UnresolvedJobOffers

func (a *Agent) UnresolvedJobOffers() []job.JobOffer

func (*Agent) VerifyJob added in v0.2.0

func (a *Agent) VerifyJob(j *job.Job) bool

Verify a Job through SignatureSet

type AgentState

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

func NewState

func NewState() *AgentState

func (*AgentState) DropBid

func (self *AgentState) DropBid(name string)

func (*AgentState) DropJobConflicts

func (self *AgentState) DropJobConflicts(jobName string)

Purge all tracked conflicts for a given Job

func (*AgentState) DropOffer

func (self *AgentState) DropOffer(name string)

func (*AgentState) DropPeersJob

func (self *AgentState) DropPeersJob(jobName string)

Remove all references to a given Job from all Peer indexes

func (*AgentState) GetJobsByPeer

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

Retrieve all Jobs that share a given Peer

func (*AgentState) GetOffer

func (self *AgentState) GetOffer(name string) (job.JobOffer, bool)

func (*AgentState) GetOffersWithoutBids added in v0.1.1

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

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

func (*AgentState) HasBid

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

func (*AgentState) HasConflict

func (self *AgentState) HasConflict(potentialJobName string, potentialConflicts []string) (bool, string)

Determine whether there are any known conflicts with the given argument

func (*AgentState) Lock

func (self *AgentState) Lock()

func (*AgentState) MarshalJSON added in v0.2.0

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

func (*AgentState) TrackBid

func (self *AgentState) TrackBid(name string)

func (*AgentState) TrackJobConflicts

func (self *AgentState) TrackJobConflicts(jobName string, conflicts []string)

Store a list of conflicts on behalf of a given Job

func (*AgentState) TrackJobPeers

func (self *AgentState) TrackJobPeers(jobName string, peers []string)

Store a relation of 1 Job -> N Peers

func (*AgentState) TrackOffer

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

func (*AgentState) Unlock

func (self *AgentState) Unlock()

type EventHandler

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

func NewEventHandler

func NewEventHandler(agent *Agent) *EventHandler

func (*EventHandler) HandleEventJobOffered

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

func (*EventHandler) HandleEventJobScheduled

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

func (*EventHandler) HandleEventJobStateUpdated

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

func (*EventHandler) HandleEventJobStopped

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

func (*EventHandler) HandleEventJobUpdated added in v0.2.0

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

func (*EventHandler) HandleEventMachineCreated

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

Jump to

Keyboard shortcuts

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