本文整理汇总了Golang中github.com/coreos/fleet/third_party/github.com/golang/glog.Infof函数的典型用法代码示例。如果您正苦于以下问题:Golang Infof函数的具体用法?Golang Infof怎么用?Golang Infof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Purge
// Purge removes the Agent's state from the Registry
func (a *Agent) Purge() {
// Continue heartbeating the agent's machine state while attempting to
// stop all the locally-running jobs
purged := make(chan bool)
go a.heartbeatAgent(a.ttl, purged)
a.state.Lock()
scheduled := a.state.ScheduledJobs()
a.state.Unlock()
machID := a.Machine.State().ID
for _, jobName := range scheduled {
log.Infof("Unloading Job(%s) from local machine", jobName)
a.unloadJob(jobName)
log.Infof("Unscheduling Job(%s) from local machine", jobName)
a.registry.ClearJobTarget(jobName, machID)
}
// Jobs have been stopped, the heartbeat can stop
close(purged)
log.Info("Removing Agent from Registry")
if err := a.registry.RemoveMachineState(machID); err != nil {
log.Errorf("Failed to remove Machine %s from Registry: %s", machID, err.Error())
}
}
示例2: HandleEventJobOffered
func (eh *EventHandler) HandleEventJobOffered(ev event.Event) {
jo := ev.Payload.(job.JobOffer)
log.Infof("EventJobOffered(%s): verifying ability to run Job", jo.Job.Name)
if !jo.OfferedTo(eh.agent.Machine().State().ID) {
log.Infof("EventJobOffered(%s): not offered to this machine", jo.Job.Name)
return
}
eh.agent.state.Lock()
defer eh.agent.state.Unlock()
// Everything we check against could change over time, so we track all
// offers starting here for future bidding even if we can't bid now
eh.agent.state.TrackOffer(jo)
eh.agent.state.TrackJob(&jo.Job)
if !eh.agent.AbleToRun(&jo.Job) {
log.Infof("EventJobOffered(%s): not all criteria met, not bidding", jo.Job.Name)
return
}
log.Infof("EventJobOffered(%s): passed all criteria, submitting JobBid", jo.Job.Name)
eh.agent.Bid(jo.Job.Name)
}
示例3: HandleEventMachineRemoved
func (eh *EventHandler) HandleEventMachineRemoved(ev event.Event) {
machID := ev.Payload.(string)
mutex := eh.engine.registry.LockMachine(machID, eh.engine.machine.State().ID)
if mutex == nil {
log.V(1).Infof("EventMachineRemoved(%s): failed to lock Machine, ignoring event", machID)
return
}
defer mutex.Unlock()
jobs := getJobsScheduledToMachine(eh.engine.registry, machID)
for _, j := range jobs {
log.Infof("EventMachineRemoved(%s): clearing UnitState(%s)", machID, j.Name)
err := eh.engine.registry.RemoveUnitState(j.Name)
if err != nil {
log.Errorf("Failed removing UnitState(%s) from Registry: %v", j.Name, err)
}
log.Infof("EventMachineRemoved(%s): unscheduling Job(%s)", machID, j.Name)
eh.engine.registry.ClearJobTarget(j.Name, machID)
}
for _, j := range jobs {
log.Infof("EventMachineRemoved(%s): re-publishing JobOffer(%s)", machID, j.Name)
eh.engine.OfferJob(j)
}
eh.engine.clust.machineRemoved(machID)
}
示例4: JobScheduledLocally
// 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 (a *Agent) JobScheduledLocally(jobName string) {
a.state.Lock()
defer a.state.Unlock()
log.Infof("Dropping offer and bid for Job(%s) from cache", jobName)
a.state.PurgeOffer(jobName)
j := a.fetchJob(jobName)
if j == nil {
log.Errorf("Failed to fetch Job(%s)", jobName)
return
}
if !a.ableToRun(j) {
log.Infof("Unable to run locally-scheduled Job(%s), unscheduling", jobName)
a.registry.ClearJobTarget(jobName, a.Machine.State().ID)
a.state.PurgeJob(jobName)
return
}
a.loadJob(j)
log.Infof("Bidding for all possible peers of Job(%s)", j.Name)
a.bidForPossiblePeers(j.Name)
ts, _ := a.registry.GetJobTargetState(j.Name)
if ts == nil || *ts != job.JobStateLaunched {
return
}
log.Infof("Job(%s) loaded, now starting it", j.Name)
a.startJobUnlocked(j.Name)
}
示例5: removeUnit
func (m *SystemdManager) removeUnit(name string) {
log.Infof("Unlinking systemd unit %s from target %s", name, m.Target.Name())
link := m.getLocalPath(path.Join(m.Target.Name()+".wants", name))
syscall.Unlink(link)
file := m.getLocalPath(name)
log.Infof("Removing systemd unit file %s", file)
syscall.Unlink(file)
}
示例6: HandleEventJobBidSubmitted
func (eh *EventHandler) HandleEventJobBidSubmitted(ev event.Event) {
jb := ev.Payload.(job.JobBid)
err := eh.engine.ResolveJobOffer(jb.JobName, jb.MachineID)
if err == nil {
log.Infof("EventJobBidSubmitted(%s): successfully scheduled Job to Machine(%s)", jb.JobName, jb.MachineID)
} else {
log.Infof("EventJobBidSubmitted(%s): failed to schedule Job to Machine(%s)", jb.JobName, jb.MachineID)
}
}
示例7: HandleCommandLoadJob
func (eh *EventHandler) HandleCommandLoadJob(ev event.Event) {
jobName := ev.Payload.(string)
j := eh.engine.registry.GetJob(jobName)
if j == nil {
log.Infof("CommandLoadJob(%s): asked to offer job that could not be found")
return
}
log.Infof("CommandLoadJob(%s): publishing JobOffer", jobName)
eh.engine.OfferJob(*j)
}
示例8: HandleEventJobScheduled
func (eh *EventHandler) HandleEventJobScheduled(ev event.Event) {
jobName := ev.Payload.(string)
target := ev.Context.(string)
if target != eh.agent.Machine.State().ID {
log.Infof("EventJobScheduled(%s): Job scheduled to other Machine(%s), informing Agent", jobName, target)
eh.agent.JobScheduledElsewhere(jobName)
} else {
log.Infof("EventJobScheduled(%s): Job scheduled here, informing Agent", jobName)
eh.agent.JobScheduledLocally(jobName)
}
}
示例9: JobScheduledElsewhere
// JobScheduledElsewhere clears all state related to the indicated
// job before bidding for all oustanding jobs that can be run locally.
func (a *Agent) JobScheduledElsewhere(jobName string) {
a.state.Lock()
defer a.state.Unlock()
log.Infof("Dropping offer and bid for Job(%s) from cache", jobName)
a.state.PurgeOffer(jobName)
log.Infof("Purging Job(%s) data from cache", jobName)
a.state.PurgeJob(jobName)
log.Infof("Checking outstanding job offers")
a.bidForPossibleJobs()
}
示例10: JobUnscheduled
// 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 (a *Agent) JobUnscheduled(jobName string) {
a.state.Lock()
defer a.state.Unlock()
if !a.state.ScheduledHere(jobName) {
log.V(1).Infof("Job(%s) not scheduled here, ignoring", jobName)
return
}
log.Infof("Unloading Job(%s)", jobName)
a.unloadJob(jobName)
log.Infof("Checking outstanding JobOffers")
a.bidForPossibleJobs()
}
示例11: getConfig
func getConfig(flagset *flag.FlagSet, file string) (*config.Config, error) {
if _, err := os.Stat(file); err != nil {
glog.Infof("Config file %s does not appear to exist - ignoring")
file = ""
}
opts := globalconf.Options{
EnvPrefix: "FLEET_",
ConfigFile: file,
}
gconf, err := globalconf.NewWithOptions(opts)
if err != nil {
return nil, err
}
gconf.ParseSet("", flagset)
cfg := config.NewConfig()
cfg.Verbosity = (*flagset.Lookup("verbosity")).Value.(flag.Getter).Get().(int)
cfg.EtcdServers = (*flagset.Lookup("etcd_servers")).Value.(flag.Getter).Get().(stringSlice)
cfg.BootId = (*flagset.Lookup("boot_id")).Value.(flag.Getter).Get().(string)
cfg.PublicIP = (*flagset.Lookup("public_ip")).Value.(flag.Getter).Get().(string)
cfg.RawMetadata = (*flagset.Lookup("metadata")).Value.(flag.Getter).Get().(string)
cfg.UnitPrefix = (*flagset.Lookup("unit_prefix")).Value.(flag.Getter).Get().(string)
cfg.AgentTTL = (*flagset.Lookup("agent_ttl")).Value.(flag.Getter).Get().(string)
return cfg, nil
}
示例12: StopJob
// Instruct the Agent to stop the provided Job and
// all of its peers
func (a *Agent) StopJob(jobName string) {
log.Infof("Stopping Job(%s)", jobName)
a.systemd.StopJob(jobName)
a.ReportJobState(jobName, nil)
a.state.Lock()
reversePeers := a.state.GetJobsByPeer(jobName)
a.state.DropPeersJob(jobName)
a.state.DropJobConflicts(jobName)
a.state.Unlock()
for _, peer := range reversePeers {
log.Infof("Stopping Peer(%s) of Job(%s)", peer, jobName)
a.registry.StopJob(peer)
}
}
示例13: ResolveJobOffer
func (e *Engine) ResolveJobOffer(jobName string, machID string) error {
log.V(1).Infof("Attempting to lock JobOffer(%s)", jobName)
mutex := e.registry.LockJobOffer(jobName, e.machine.State().ID)
if mutex == nil {
log.V(1).Infof("Could not lock JobOffer(%s)", jobName)
return errors.New("Could not lock JobOffer")
}
defer mutex.Unlock()
log.V(1).Infof("Claimed JobOffer(%s)", jobName)
err := e.registry.ResolveJobOffer(jobName)
if err != nil {
log.Errorf("Failed resolving JobOffer(%s): %v", jobName, err)
return err
}
err = e.registry.ScheduleJob(jobName, machID)
if err != nil {
log.Errorf("Failed scheduling Job(%s): %v", jobName, err)
return err
}
log.Infof("Scheduled Job(%s) to Machine(%s)", jobName, machID)
return nil
}
示例14: OfferJob
func (e *Engine) OfferJob(j job.Job) error {
log.V(1).Infof("Attempting to lock Job(%s)", j.Name)
mutex := e.registry.LockJob(j.Name, e.machine.State().ID)
if mutex == nil {
log.V(1).Infof("Could not lock Job(%s)", j.Name)
return errors.New("Could not lock Job")
}
defer mutex.Unlock()
log.V(1).Infof("Claimed Job(%s)", j.Name)
machineIDs, err := e.partitionCluster(&j)
if err != nil {
log.Errorf("Failed partitioning cluster for Job(%s): %v", j.Name, err)
return err
}
offer := job.NewOfferFromJob(j, machineIDs)
err = e.registry.CreateJobOffer(offer)
if err == nil {
log.Infof("Published JobOffer(%s)", offer.Job.Name)
}
return err
}
示例15: OfferJob
func (self *Engine) OfferJob(j job.Job) error {
log.V(2).Infof("Attempting to lock Job(%s)", j.Name)
mutex := self.lockJob(j.Name)
if mutex == nil {
log.V(1).Infof("Could not lock Job(%s)", j.Name)
return errors.New("Could not lock Job")
}
defer mutex.Unlock()
log.V(1).Infof("Claimed Job", j.Name)
machineBootIds, err := self.partitionCluster(&j)
if err != nil {
log.Errorf("Failed partitioning cluster for Job(%s): %v", j.Name, err)
return err
}
offer := job.NewOfferFromJob(j, machineBootIds)
log.V(2).Infof("Publishing JobOffer(%s)", offer.Job.Name)
self.registry.CreateJobOffer(offer)
log.Infof("Published JobOffer(%s)", offer.Job.Name)
return nil
}