本文整理汇总了Golang中github.com/coreos/fleet/Godeps/_workspace/src/github.com/golang/glog.V函数的典型用法代码示例。如果您正苦于以下问题:Golang V函数的具体用法?Golang V怎么用?Golang V使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runUnloadUnit
func runUnloadUnit(args []string) (exit int) {
jobs, err := findJobs(args)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return 1
}
wait := make([]string, 0)
for _, j := range jobs {
if j.State == nil {
fmt.Fprintf(os.Stderr, "Unable to determine state of %q\n", *(j.State))
return 1
}
if *(j.State) == job.JobStateInactive {
log.V(1).Infof("Job(%s) already %s, skipping.", j.Name, job.JobStateInactive)
continue
}
log.V(1).Infof("Unloading Job(%s)", j.Name)
cAPI.SetJobTargetState(j.Name, job.JobStateInactive)
wait = append(wait, j.Name)
}
if !sharedFlags.NoBlock {
errchan := waitForJobStates(wait, job.JobStateInactive, sharedFlags.BlockAttempts, os.Stdout)
for err := range errchan {
fmt.Fprintf(os.Stderr, "%v\n", err)
exit = 1
}
}
return
}
示例2: addrToHostPort
// addrToHostPort takes the given address and parses it into a string suitable
// for use in the 'hostnames' field in a known_hosts file. For more details,
// see the `SSH_KNOWN_HOSTS FILE FORMAT` section of `man 8 sshd`
func (kc *HostKeyChecker) addrToHostPort(a string) (string, error) {
if !strings.Contains(a, ":") {
// No port, so return unadulterated
return a, nil
}
host, p, err := net.SplitHostPort(a)
if err != nil {
log.V(1).Infof("Unable to parse addr %s: %v", a, err)
return "", err
}
port, err := strconv.Atoi(p)
if err != nil {
log.V(1).Infof("Error parsing port %s: %v", p, err)
return "", err
}
// Default port should be omitted from the entry.
// (see `put_host_port` in openssh/misc.c)
if port == 0 || port == sshDefaultPort {
// IPv6 addresses must be enclosed in square brackets
if strings.Contains(host, ":") {
host = fmt.Sprintf("[%s]", host)
}
return host, nil
}
return fmt.Sprintf("[%s]:%d", host, port), nil
}
示例3: bidForPossiblePeers
// bidForPossiblePeers submits bids for all known peers of the provided job that can
// be run locally
func (a *Agent) bidForPossiblePeers(jobName string) {
peers := a.state.GetJobsByPeer(jobName)
for _, peer := range peers {
log.V(1).Infof("Found unresolved offer for Peer(%s) of Job(%s)", peer, jobName)
peerJob, err := a.registry.Job(peer)
if err != nil {
log.Errorf("Failed fetching Job(%s) from Registry: %v", peer, err)
return
}
if peerJob == nil {
log.V(1).Infof("Unable to find Peer(%s) of Job(%s) in Registry", peer, jobName)
return
}
if !a.ableToRun(peerJob) {
log.V(1).Infof("Unable to run Peer(%s) of Job(%s), not bidding", peer, jobName)
return
}
a.bid(peer)
}
}
示例4: HasMetadata
// HasMetadata determine if the Metadata of a given MachineState
// matches the indicated values.
func HasMetadata(state *MachineState, metadata map[string][]string) bool {
for key, values := range metadata {
local, ok := state.Metadata[key]
if !ok {
log.V(1).Infof("No local values found for Metadata(%s)", key)
return false
}
log.V(1).Infof("Asserting local Metadata(%s) meets requirements", key)
var localMatch bool
for _, val := range values {
if local == val {
log.V(1).Infof("Local Metadata(%s) meets requirement", key)
localMatch = true
}
}
if !localMatch {
log.V(1).Infof("Local Metadata(%s) does not match requirement", key)
return false
}
}
return true
}
示例5: 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
}
示例6: 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
}
示例7: ParseFilepath
// ParseFilepath expands ~ and ~user constructions.
// If user or $HOME is unknown, do nothing.
func ParseFilepath(path string) string {
if !strings.HasPrefix(path, "~") {
return path
}
i := strings.Index(path, "/")
if i < 0 {
i = len(path)
}
var home string
if i == 1 {
if home = os.Getenv("HOME"); home == "" {
usr, err := user.Current()
if err != nil {
log.V(1).Infof("Failed to get current home directory: %v", err)
return path
}
home = usr.HomeDir
}
} else {
usr, err := user.Lookup(path[1:i])
if err != nil {
log.V(1).Infof("Failed to get %v's home directory: %v", path[1:i], err)
return path
}
home = usr.HomeDir
}
path = filepath.Join(home, path[i:])
return path
}
示例8: one
func (ar *actionResolver) one(req *http.Request, cancel <-chan bool) (resp *http.Response, body []byte, err error) {
log.V(1).Infof("etcd: sending HTTP request %s %s", req.Method, req.URL)
resp, body, err = ar.requestFunc(req, cancel)
if err != nil {
log.V(1).Infof("etcd: recv error response from %s %s: %v", req.Method, req.URL, err)
return
}
log.V(1).Infof("etcd: recv response from %s %s: %s", req.Method, req.URL, resp.Status)
return
}
示例9: Run
func (e *Engine) Run(stop chan bool) {
ticker := time.Tick(reconcileInterval)
machID := e.machine.State().ID
reconcile := func() {
done := make(chan struct{})
defer func() { close(done) }()
// While the reconciliation is running, flush the trigger channel in the background
go func() {
for {
select {
case <-done:
return
default:
select {
case <-e.trigger:
case <-done:
return
}
}
}
}()
e.lease = ensureLeader(e.lease, e.registry, machID)
if e.lease == nil {
return
}
start := time.Now()
e.rec.Reconcile(e)
elapsed := time.Now().Sub(start)
msg := fmt.Sprintf("Engine completed reconciliation in %s", elapsed)
if elapsed > reconcileInterval {
log.Warning(msg)
} else {
log.V(1).Info(msg)
}
}
for {
select {
case <-stop:
log.V(1).Info("Engine exiting due to stop signal")
return
case <-ticker:
log.V(1).Info("Engine tick")
reconcile()
case <-e.trigger:
log.V(1).Info("Engine reconcilation triggered by job state change")
reconcile()
}
}
}
示例10: bidForPossibleJobs
// bidForPossibleJobs submits bids for all unresolved offers whose Jobs
// can be run locally
func (a *Agent) bidForPossibleJobs() {
offers := a.state.GetOffersWithoutBids()
log.V(1).Infof("Checking %d unbade offers", len(offers))
for i := range offers {
offer := offers[i]
log.V(1).Infof("Checking ability to run Job(%s)", offer.Job.Name)
if a.ableToRun(&offer.Job) {
log.V(1).Infof("Able to run Job(%s), submitting bid", offer.Job.Name)
a.bid(offer.Job.Name)
} else {
log.V(1).Infof("Still unable to run Job(%s)", offer.Job.Name)
}
}
}
示例11: watch
func watch(client etcd.Client, idx uint64, etcdchan chan *etcd.Result, key string, stop chan bool) {
for {
select {
case <-stop:
log.V(1).Infof("Gracefully closing etcd watch loop: key=%s", key)
return
default:
req := &etcd.Watch{
Key: key,
WaitIndex: idx,
Recursive: true,
}
log.V(1).Infof("Creating etcd watcher: %v", req)
resp, err := client.Wait(req, stop)
if err == nil {
if resp.Node != nil {
idx = resp.Node.ModifiedIndex + 1
}
etcdchan <- resp
continue
}
log.Errorf("etcd watcher %v returned error: %v", req, err)
etcdError, ok := err.(etcd.Error)
if !ok {
// Let's not slam the etcd server in the event that we know
// an unexpected error occurred.
time.Sleep(time.Second)
continue
}
switch etcdError.ErrorCode {
case etcd.ErrorEventIndexCleared:
// This is racy, but adding one to the last known index
// will help get this watcher back into the range of
// etcd's internal event history
idx = idx + 1
default:
// Let's not slam the etcd server in the event that we know
// an unexpected error occurred.
time.Sleep(time.Second)
}
}
}
}
示例12: handleLossOfMachineEvents
func (eh *EventHandler) handleLossOfMachineEvents(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("%s(%s): failed to lock Machine, ignoring event", ev.Type, machID)
return
}
defer mutex.Unlock()
jobs := getJobsScheduledToMachine(eh.engine.registry, machID)
for _, j := range jobs {
log.Infof("%s(%s): clearing UnitState(%s)", ev.Type, 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("%s(%s): unscheduling Job(%s)", ev.Type, machID, j.Name)
eh.engine.registry.ClearJobTarget(j.Name, machID)
}
for _, j := range jobs {
log.Infof("%s(%s): re-publishing JobOffer(%s)", ev.Type, machID, j.Name)
eh.engine.OfferJob(j)
}
eh.engine.clust.machineRemoved(machID)
}
示例13: verifyJobSignature
// verifyJobSignature attempts to verify the integrity of the given Job by checking the
// signature against a SignatureSet stored in the Registry
func (ar *AgentReconciler) verifyJobSignature(j *job.Job) bool {
if ar.verifier == nil {
return true
}
ss, _ := ar.reg.JobSignatureSet(j.Name)
ok, err := ar.verifier.VerifyJob(j, ss)
if err != nil {
log.V(1).Infof("Error verifying signature of Job(%s): %v", j.Name, err)
return false
} else if !ok {
log.V(1).Infof("Job(%s) does not match signature", j.Name)
return false
}
return true
}
示例14: findAddressInMachineList
func findAddressInMachineList(lookup string) (string, bool) {
states, err := cAPI.Machines()
if err != nil {
log.V(1).Infof("Unable to retrieve list of active machines from the Registry: %v", err)
return "", false
}
var match *machine.MachineState
for i := range states {
machState := states[i]
if !strings.HasPrefix(machState.ID, lookup) {
continue
} else if match != nil {
fmt.Fprintln(os.Stderr, "Found more than one Machine, be more specific.")
os.Exit(1)
}
match = &machState
}
if match == nil {
return "", false
}
return match.PublicIP, true
}
示例15: check
// check attempts to beat a Heart several times within a timeout, returning the
// log index at which the beat succeeded or an error
func (m *Monitor) check(hrt Heart) (idx uint64, err error) {
// time out after a third of the machine presence TTL, attempting
// the heartbeat up to four times
timeout := m.TTL / 3
interval := timeout / 4
tchan := time.After(timeout)
next := time.After(0)
for idx == 0 {
select {
case <-tchan:
err = errors.New("Monitor timed out before successful heartbeat")
return
case <-next:
idx, err = hrt.Beat(m.TTL)
if err != nil {
log.V(1).Infof("Monitor heartbeat function returned err, retrying in %v: %v", interval, err)
}
next = time.After(interval)
}
}
return
}