本文整理汇总了Golang中github.com/coreos/fleet/third_party/github.com/golang/glog.Errorf函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorf函数的具体用法?Golang Errorf怎么用?Golang Errorf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ResolveJobOffer
func (self *Engine) ResolveJobOffer(jobName string, machBootId string) error {
log.V(2).Infof("Attempting to lock JobOffer(%s)", jobName)
mutex := self.lockJobOffer(jobName)
if mutex == nil {
log.V(2).Infof("Could not lock JobOffer(%s)", jobName)
return errors.New("Could not lock JobOffer")
}
defer mutex.Unlock()
log.V(2).Infof("Claimed JobOffer(%s)", jobName)
log.V(2).Infof("Resolving JobOffer(%s), scheduling to Machine(%s)", jobName, machBootId)
err := self.registry.ResolveJobOffer(jobName)
if err != nil {
log.Errorf("Failed resolving JobOffer(%s): %v", jobName, err)
return err
}
err = self.registry.ScheduleJob(jobName, machBootId)
if err != nil {
log.Errorf("Failed scheduling Job(%s): %v", jobName, err)
return err
}
log.Infof("Scheduled Job(%s) to Machine(%s)", jobName, machBootId)
return nil
}
开发者ID:vidyacraghav,项目名称:fleet,代码行数:28,代码来源:engine.go
示例2: 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
}
开发者ID:rswart,项目名称:fleet,代码行数:27,代码来源:engine.go
示例3: UpdateLoggingFlagsFromConfig
func UpdateLoggingFlagsFromConfig(conf *Config) {
err := flag.Lookup("v").Value.Set(strconv.Itoa(conf.Verbosity))
if err != nil {
glog.Errorf("Failed to apply config.Verbosity to flag.v: %v", err)
}
err = flag.Lookup("logtostderr").Value.Set("true")
if err != nil {
glog.Errorf("Failed to set flag.logtostderr to true: %v", err)
}
}
开发者ID:shaunstanislaus,项目名称:fleet,代码行数:11,代码来源:config.go
示例4: HandleEventJobScheduled
func (eh *EventHandler) HandleEventJobScheduled(ev event.Event) {
jobName := ev.Payload.(string)
target := ev.Context.(string)
eh.agent.state.Lock()
defer eh.agent.state.Unlock()
log.V(1).Infof("EventJobScheduled(%s): Dropping outstanding offers and bids", jobName)
eh.agent.state.PurgeOffer(jobName)
if target != eh.agent.Machine().State().ID {
log.Infof("EventJobScheduled(%s): Job not scheduled to this Agent, purging related data from cache", jobName)
eh.agent.state.PurgeJob(jobName)
log.Infof("EventJobScheduled(%s): Checking outstanding job offers", jobName)
eh.agent.BidForPossibleJobs()
return
}
log.Infof("EventJobScheduled(%s): Job scheduled to this Agent", jobName)
j := eh.agent.FetchJob(jobName)
if j == nil {
log.Errorf("EventJobScheduled(%s): Failed to fetch Job", jobName)
return
}
if !eh.agent.VerifyJob(j) {
log.Errorf("EventJobScheduled(%s): Failed to verify Job", j.Name)
return
}
if !eh.agent.AbleToRun(j) {
log.Infof("EventJobScheduled(%s): Unable to run scheduled Job, unscheduling.", jobName)
eh.agent.registry.ClearJobTarget(jobName, target)
eh.agent.state.PurgeJob(jobName)
return
}
log.Infof("EventJobScheduled(%s): Loading Job", j.Name)
eh.agent.LoadJob(j)
log.Infof("EventJobScheduled(%s): Bidding for all possible peers of Job", j.Name)
eh.agent.BidForPossiblePeers(j.Name)
ts := eh.agent.registry.GetJobTargetState(j.Name)
if ts == nil || *ts != job.JobStateLaunched {
return
}
log.Infof("EventJobScheduled(%s): Starting Job", j.Name)
eh.agent.StartJob(j.Name)
}
开发者ID:rswart,项目名称:fleet,代码行数:53,代码来源:event.go
示例5: Heartbeat
// 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 (a *Agent) Heartbeat(ttl time.Duration, stop chan bool) {
attempt := func(attempts int, f func() error) (err error) {
if attempts < 1 {
return fmt.Errorf("attempts argument must be 1 or greater, got %d", attempts)
}
// The amount of time the retry mechanism waits after a failed attempt
// doubles following each failure. This is a simple exponential backoff.
sleep := time.Second
for i := 1; i <= attempts; i++ {
err = f()
if err == nil || i == attempts {
break
}
sleep = sleep * 2
log.V(2).Infof("function returned err, retrying in %v: %v", sleep, err)
time.Sleep(sleep)
}
return err
}
heartbeat := func() error {
return a.registry.SetMachineState(a.machine.State(), ttl)
}
// Explicitly heartbeat immediately to push state to the
// Registry as quickly as possible
a.machine.RefreshState()
if err := attempt(3, heartbeat); err != nil {
log.Errorf("Failed heartbeat after 3 attempts: %v", err)
}
interval := ttl / refreshInterval
ticker := time.Tick(interval)
for {
select {
case <-stop:
log.V(2).Info("MachineHeartbeat exiting due to stop signal")
return
case <-ticker:
log.V(2).Info("MachineHeartbeat tick")
a.machine.RefreshState()
if err := attempt(3, heartbeat); err != nil {
log.Errorf("Failed heartbeat after 3 attempts: %v", err)
}
}
}
}
开发者ID:nullstyle,项目名称:fleet,代码行数:56,代码来源:agent.go
示例6: HandleEventJobScheduled
func (eh *EventHandler) HandleEventJobScheduled(ev event.Event) {
jobName := ev.Payload.(string)
log.V(1).Infof("EventJobScheduled(%s): Dropping outstanding offers and bids", jobName)
eh.agent.OfferResolved(jobName)
if ev.Context.(machine.MachineState).BootId != eh.agent.Machine().State().BootId {
log.V(1).Infof("EventJobScheduled(%s): Job not scheduled to this Agent, checking unbade offers", jobName)
eh.agent.BidForPossibleJobs()
return
}
log.V(1).Infof("EventJobScheduled(%s): Job scheduled to this Agent", jobName)
j := eh.agent.FetchJob(jobName)
if j == nil {
log.Errorf("EventJobScheduled(%s): Failed to fetch Job")
return
}
if !eh.agent.AbleToRun(j) {
log.V(1).Infof("EventJobScheduled(%s): Unable to run scheduled Job, rescheduling.", jobName)
eh.agent.RescheduleJob(j)
return
}
log.V(1).Infof("EventJobScheduled(%s): Starting Job", j.Name)
eh.agent.StartJob(j)
log.V(1).Infof("EventJobScheduled(%s): Bidding for all possible peers of Job", j.Name)
eh.agent.BidForPossiblePeers(j.Name)
}
开发者ID:RandomStuffs22,项目名称:fleet,代码行数:32,代码来源:event.go
示例7: 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
}
开发者ID:rswart,项目名称:fleet,代码行数:27,代码来源:engine.go
示例8: Publish
// Publish is a long-running function that streams dbus events through
// a translation layer and on to the EventBus
func (m *SystemdManager) Publish(bus *event.EventBus, stopchan chan bool) {
m.Systemd.Subscribe()
changechan, errchan := m.subscriptions.Subscribe()
stream := NewEventStream()
stream.Stream(changechan, bus.Channel)
for true {
select {
case <-stopchan:
break
case err := <-errchan:
var errString string
if err != nil {
errString = err.Error()
} else {
errString = "N/A"
}
log.Errorf("Received error from dbus: err=%s", errString)
}
}
stream.Close()
m.Systemd.Unsubscribe()
}
开发者ID:rswart,项目名称:fleet,代码行数:28,代码来源:manager.go
示例9: 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)
}
开发者ID:paulczar,项目名称:fleet,代码行数:37,代码来源:agent.go
示例10: stopUnit
func (m *SystemdManager) stopUnit(name string) {
if stat, err := m.Systemd.StopUnit(name, "replace"); err != nil {
log.Errorf("Failed to stop systemd unit %s: %v", name, err)
} else {
log.Infof("Stopped systemd unit %s(%s)", name, stat)
}
}
开发者ID:rswart,项目名称:fleet,代码行数:7,代码来源:manager.go
示例11: GetAllPayloads
func (r *Registry) GetAllPayloads() []job.JobPayload {
var payloads []job.JobPayload
key := path.Join(keyPrefix, payloadPrefix)
resp, err := r.etcd.Get(key, true, true)
if err != nil {
return payloads
}
for _, node := range resp.Node.Nodes {
var jp job.JobPayload
//TODO: Handle the error generated by unmarshal
unmarshal(node.Value, &jp)
if err != nil {
log.Errorf(err.Error())
continue
}
payloads = append(payloads, jp)
}
return payloads
}
开发者ID:natacado,项目名称:fleet,代码行数:25,代码来源:job.go
示例12: 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
}
开发者ID:vidyacraghav,项目名称:fleet,代码行数:26,代码来源:engine.go
示例13: 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())
}
}
开发者ID:paulczar,项目名称:fleet,代码行数:27,代码来源:agent.go
示例14: UnresolvedJobOffers
func (r *Registry) UnresolvedJobOffers() []job.JobOffer {
var offers []job.JobOffer
key := path.Join(keyPrefix, offerPrefix)
resp, err := r.etcd.Get(key, true, true)
if err != nil {
return offers
}
for _, node := range resp.Node.Nodes {
key := path.Join(node.Key, "object")
resp, err := r.etcd.Get(key, true, true)
// The object was probably handled between when we attempted to
// start resolving offers and when we actually tried to get it
if err != nil {
continue
}
var jo job.JobOffer
err = unmarshal(resp.Node.Value, &jo)
if err != nil {
log.Errorf(err.Error())
continue
}
offers = append(offers, jo)
}
return offers
}
开发者ID:nullstyle,项目名称:fleet,代码行数:32,代码来源:offer.go
示例15: 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)
}
开发者ID:paulczar,项目名称:fleet,代码行数:28,代码来源:event.go
示例16: startUnit
func (m *SystemdManager) startUnit(name string) {
log.V(1).Infof("Starting systemd unit %s", name)
files := []string{name}
if ok, _, err := m.Systemd.EnableUnitFiles(files, true, false); !ok {
log.Errorf("Failed to enable systemd unit %s: %v", name, err)
return
} else {
log.V(1).Infof("Enabled systemd unit %s", name)
}
if stat, err := m.Systemd.StartUnit(name, "replace"); err != nil {
log.Errorf("Failed to start systemd unit %s: %v", name, err)
} else {
log.Infof("Started systemd unit %s(%s)", name, stat)
}
}
开发者ID:jsdir,项目名称:fleet,代码行数:17,代码来源:manager.go
示例17: UpdateLoggingFlagsFromConfig
// UpdateLoggingFlagsFromConfig extracts the logging-related options from
// the provided config and sets flags in the given flagset
func UpdateLoggingFlagsFromConfig(flagset *flag.FlagSet, conf *Config) {
err := flagset.Lookup("v").Value.Set(strconv.Itoa(conf.Verbosity))
if err != nil {
glog.Errorf("Failed to apply config.Verbosity to flag.v: %v", err)
}
err = flagset.Lookup("logtostderr").Value.Set("true")
if err != nil {
glog.Errorf("Failed to set flag.logtostderr to true: %v", err)
}
if conf.Verbosity > 2 {
etcd.EnableDebugLogging()
} else {
etcd.DisableDebugLogging()
}
}
开发者ID:johnmontero,项目名称:fleet,代码行数:19,代码来源:config.go
示例18: UpdateLoggingFlagsFromConfig
// UpdateLoggingFlagsFromConfig extracts the logging-related options from
// the provided config and sets flags in the given flagset
func UpdateLoggingFlagsFromConfig(flagset *flag.FlagSet, conf *Config) {
err := flagset.Lookup("v").Value.Set(strconv.Itoa(conf.Verbosity))
if err != nil {
glog.Errorf("Failed to apply config.Verbosity to flag.v: %v", err)
}
err = flagset.Lookup("logtostderr").Value.Set("true")
if err != nil {
glog.Errorf("Failed to set flag.logtostderr to true: %v", err)
}
if conf.Verbosity > 2 {
etcd.SetLogger(log.New(os.Stdout, "go-etcd", log.LstdFlags))
} else {
etcd.SetLogger(log.New(ioutil.Discard, "go-etcd", log.LstdFlags))
}
}
开发者ID:jsdir,项目名称:fleet,代码行数:19,代码来源:config.go
示例19: CreateJobOffer
func (r *Registry) CreateJobOffer(jo *job.JobOffer) {
key := path.Join(keyPrefix, offerPrefix, jo.Job.Name, "object")
json, err := marshal(jo)
if err != nil {
log.Errorf(err.Error())
return
}
r.etcd.Set(key, json, 0)
}
开发者ID:nullstyle,项目名称:fleet,代码行数:9,代码来源:offer.go
示例20: checkVersion
// checkVersion makes a best-effort attempt to verify that fleetctl is at least as new as the
// latest fleet version found registered in the cluster. If any errors are encountered or fleetctl
// is >= the latest version found, it returns true. If it is < the latest found version, it returns
// false and a scary warning to the user.
func checkVersion() (string, bool) {
fv := version.SemVersion
lv, err := registryCtl.GetLatestVersion()
if err != nil {
log.Errorf("error attempting to check latest fleet version in Registry: %v", err)
} else if lv != nil && fv.LessThan(*lv) {
return fmt.Sprintf(oldVersionWarning, fv.String(), lv.String()), false
}
return "", true
}
开发者ID:paulczar,项目名称:fleet,代码行数:14,代码来源:fleetctl.go
注:本文中的github.com/coreos/fleet/third_party/github.com/golang/glog.Errorf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论