本文整理汇总了Golang中github.com/coreos/fleet/Godeps/_workspace/src/github.com/golang/glog.V函数的典型用法代码示例。如果您正苦于以下问题:Golang V函数的具体用法?Golang V怎么用?Golang V使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:34,代码来源:unload.go
示例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
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:32,代码来源:known_hosts.go
示例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)
}
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:27,代码来源:agent.go
示例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
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:28,代码来源:machine.go
示例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
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:27,代码来源:engine.go
示例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
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:27,代码来源:engine.go
示例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
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:31,代码来源:filepath.go
示例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
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:11,代码来源:client.go
示例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()
}
}
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:54,代码来源:engine.go
示例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)
}
}
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:17,代码来源:agent.go
示例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)
}
}
}
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:48,代码来源:event.go
示例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)
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:28,代码来源:event.go
示例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
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:18,代码来源:reconcile.go
示例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
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:25,代码来源:ssh.go
示例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
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:27,代码来源:monitor.go
示例16: globMatches
func globMatches(pattern, target string) bool {
matched, err := path.Match(pattern, target)
if err != nil {
log.V(1).Infof("Received error while matching pattern '%s': %v", pattern, err)
}
return matched
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:7,代码来源:state.go
示例17: NewCoreOSMachine
func NewCoreOSMachine(static MachineState, um unit.UnitManager) *CoreOSMachine {
log.V(1).Infof("Created CoreOSMachine with static state %s", static)
m := &CoreOSMachine{
staticState: static,
um: um,
}
return m
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:8,代码来源:coreos.go
示例18: Run
// Run periodically attempts to reconcile the provided Agent until the stop
// channel is closed. Run will also reconcile in reaction to calls to Trigger.
// While a reconciliation is being attempted, calls to Trigger are ignored.
func (ar *AgentReconciler) Run(a *Agent, stop chan bool) {
ticker := time.Tick(reconcileInterval)
reconcile := func() {
done := make(chan struct{})
defer close(done)
// While the reconciliation is running, flush the trigger channel in the background
go func() {
for {
select {
case <-done:
return
default:
select {
case <-ar.rTrigger:
case <-done:
return
}
}
}
}()
start := time.Now()
ar.Reconcile(a)
elapsed := time.Now().Sub(start)
msg := fmt.Sprintf("AgentReconciler 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("AgentReconciler exiting due to stop signal")
return
case <-ticker:
reconcile()
case <-ar.rTrigger:
reconcile()
}
}
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:49,代码来源:reconcile.go
示例19: calculateTasksForOffer
func (ar *AgentReconciler) calculateTasksForOffer(dState *agentState, ms *machine.MachineState, j *job.Job, bids pkg.Set, taskchan chan *task) {
if bids.Contains(ms.ID) {
log.V(1).Infof("Bid already submitted for unresolved JobOffer(%s)", j.Name)
return
}
if able, reason := ar.ableToRun(dState, ms, j); !able {
log.V(1).Infof("Not bidding on Job(%s): %s", j.Name, reason)
return
}
taskchan <- &task{
Type: taskTypeSubmitBid,
Job: j,
Reason: taskReasonAbleToResolveOffer,
}
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:17,代码来源:reconcile.go
示例20: ableToRun
// ableToRun determines if the Agent can run the provided Job, and returns a boolean indicating
// whether this is the case. There are five criteria for an Agent to be eligible to run a Job:
// - Job must pass signature verification
// - agent must have all of the Job's required metadata (if any)
// - agent must meet the Job's machine target requirement (if any)
// - agent must have all required Peers of the Job scheduled locally (if any)
// - Job must not conflict with any other Jobs scheduled to the agent
func (a *Agent) ableToRun(j *job.Job) bool {
if !a.verifyJobSignature(j) {
log.V(1).Infof("Failed to verify Job(%s)", j.Name)
return false
}
log.Infof("Job(%s) has requirements: %s", j.Name, j.Requirements())
metadata := j.RequiredTargetMetadata()
if len(metadata) == 0 {
log.V(1).Infof("Job(%s) has no required machine metadata", j.Name)
} else {
log.V(1).Infof("Job(%s) requires machine metadata: %v", j.Name, metadata)
ms := a.Machine.State()
if !machine.HasMetadata(&ms, metadata) {
log.Infof("Unable to run Job(%s): local Machine metadata insufficient", j.Name)
return false
}
}
if tgt, ok := j.RequiredTarget(); ok && !a.Machine.State().MatchID(tgt) {
log.Infof("Unable to run Job(%s): agent does not meet machine target requirement (%s)", j.Name, tgt)
return false
}
peers := j.Peers()
if len(peers) == 0 {
log.V(1).Infof("Job(%s) has no required peers", j.Name)
} else {
log.V(1).Infof("Job(%s) requires peers: %v", j.Name, peers)
for _, peer := range peers {
if !a.peerScheduledHere(j.Name, peer) {
log.Infof("Unable to run Job(%s): required Peer(%s) is not scheduled locally", j.Name, peer)
return false
}
}
}
if conflicted, conflictedJobName := a.HasConflict(j.Name, j.Conflicts()); conflicted {
log.Infof("Unable to run Job(%s): conflict with Job(%s)", j.Name, conflictedJobName)
return false
}
return true
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:52,代码来源:agent.go
注:本文中的github.com/coreos/fleet/Godeps/_workspace/src/github.com/golang/glog.V函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论