// AcquireUchiwa returns an uchiwa url for the node alerting
352300
func (e EnvDetails) AcquireUchiwa(h string, c string) string {

	tags := e.Sensu.Consul.Tags
	dc := e.Sensu.Consul.Datacenter

	url := "<https://" + tags + ".uchiwa.service" + "." + dc + ".consul/#/client/" + dc + "/" + h + "?check=" + c + "|" + c + ">"
	return url
}
1330140
func (r *RepositoryComment) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
918772
func (device *Device) Acquire() error {
	ret := Status(C.cairo_device_acquire(device.Ptr)).toError()
	if err := device.status(); err != nil {
		panic(err)
	}
	return ret
}
620849
func (r *Repository) GetStargazersURL() string {
	if r == nil || r.StargazersURL == nil {
		return ""
	}
	return *r.StargazersURL
}
559421
func (p *GzipPool) AcquireGzipWriter(w io.Writer) *gzip.Writer {
	v := p.Get()
	if v == nil {
		gzipWriter, err := gzip.NewWriterLevel(w, p.Level)
		if err != nil {
			return nil
		}
		return gzipWriter
	}
	gzipWriter := v.(*gzip.Writer)
	gzipWriter.Reset(w)
	return gzipWriter
}
828426
func (env *maasEnviron) acquireNode(
	ctx context.ProviderCallContext,
	nodeName, zoneName, systemId string,
	cons constraints.Value,
	interfaces []interfaceBinding,
	volumes []volumeInfo,
) (gomaasapi.MAASObject, error) {

	// TODO(axw) 2014-08-18 #1358219
	// We should be requesting preferred architectures if unspecified,
	// like in the other providers.
	//
	// This is slightly complicated in MAAS as there are a finite
	// number of each architecture; preference may also conflict with
	// other constraints, such as tags. Thus, a preference becomes a
	// demand (which may fail) if not handled properly.

	acquireParams := convertConstraints(cons)
	positiveSpaceNames, negativeSpaceNames := convertSpacesFromConstraints(cons.Spaces)
	positiveSpaces, negativeSpaces, err := env.spaceNamesToSpaceInfo(ctx, positiveSpaceNames, negativeSpaceNames)
	// If spaces aren't supported the constraints should be empty anyway.
	if err != nil && !errors.IsNotSupported(err) {
		return gomaasapi.MAASObject{}, errors.Trace(err)
	}
	err = addInterfaces(acquireParams, interfaces, positiveSpaces, negativeSpaces)
	if err != nil {
		return gomaasapi.MAASObject{}, errors.Trace(err)
	}
	addStorage(acquireParams, volumes)
	acquireParams.Add("agent_name", env.uuid)
	if zoneName != "" {
		acquireParams.Add("zone", zoneName)
	}
	if nodeName != "" {
		acquireParams.Add("name", nodeName)
	}
	if systemId != "" {
		acquireParams.Add("system_id", systemId)
	}

	var result gomaasapi.JSONObject
	for a := shortAttempt.Start(); a.Next(); {
		client := env.getMAASClient().GetSubObject("nodes/")
		logger.Tracef("calling acquire with params: %+v", acquireParams)
		result, err = client.CallPost("acquire", acquireParams)
		if err == nil {
			break
		}
	}
	if err != nil {
		return gomaasapi.MAASObject{}, err
	}
	node, err := result.GetMAASObject()
	if err != nil {
		err := errors.Annotate(err, "unexpected result from 'acquire' on MAAS API")
		return gomaasapi.MAASObject{}, err
	}
	return node, nil
}
1352314
func (c *CommitsComparison) GetURL() string {
	if c == nil || c.URL == nil {
		return ""
	}
	return *c.URL
}
27643
func (s *Semaphore) Acquire() {
	s.aMutex.Lock()
	defer s.aMutex.Unlock()

	s.pMutex.Lock()
	s.avail--
	s.pMutex.Unlock()

	<-s.channel
}
850076
func (w *hookRunner) acquireExecutionLock(action string, interrupt <-chan struct{}) (func(), error) {
	spec := machinelock.Spec{
		Cancel:  interrupt,
		Worker:  "meterstatus",
		Comment: action,
	}
	releaser, err := w.machineLock.Acquire(spec)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return releaser, nil
}
1030341
func (c *Pool) Acquire(w http.ResponseWriter, r *http.Request) Context {
	ctx := c.pool.Get().(Context)
	ctx.BeginRequest(w, r)
	return ctx
}
635332
func (r *RepositoryContent) GetGitURL() string {
	if r == nil || r.GitURL == nil {
		return ""
	}
	return *r.GitURL
}
1059096
func (r *lockRepositoryImpl) AcquireLock(ctx context.Context, owner, name string, opts ...pglock.ClientOption) (*pglock.Lock, error) {
	log.Info(ctx, map[string]interface{}{
		"lock":  name,
		"owner": owner,
	}, "acquiring lock...")
	// obtain a lock to prevent other pods to perform this task
	var clnOpts []pglock.ClientOption
	if opts != nil {
		// Useful for testing
		clnOpts = opts
	} else {
		// Use default
		clnOpts = []pglock.ClientOption{
			pglock.WithCustomTable("worker_lock"),
			pglock.WithLeaseDuration(30 * time.Second),
			pglock.WithHeartbeatFrequency(10 * time.Second),
			pglock.WithLogger(log.Logger()),
		}
	}
	if owner != "" {
		// use a specific owner name, otherwise it will be a random value (default behaviour)
		clnOpts = append(clnOpts, pglock.WithOwner(owner))
	}
	c, err := pglock.New(r.db, clnOpts...)
	if err != nil {
		return nil, errs.Wrap(err, "cannot create worker lock client")
	}
	l, err := c.Acquire(name) // will wait until it succeeds
	if err != nil {
		// Try to get the name of the owner who holds the lock if any
		var holdByOwner string
		existingLock, nerr := c.Get(name)
		if nerr != nil {
			log.Error(ctx, map[string]interface{}{
				"err":   nerr,
				"lock":  name,
				"owner": owner,
			}, "cannot obtain the existing lock when trying to acquire a new one")
		} else {
			holdByOwner = existingLock.Owner()
		}
		return nil, errs.Wrapf(err, "cannot acquire worker lock '%s' which is currently hold by '%s'", name, holdByOwner)
	}
	log.Info(ctx, map[string]interface{}{
		"lock":  name,
		"owner": owner,
	}, "acquired lock")
	return l, nil
}
661339
func (r *EtcdRegistry) getUnitFromObjectNode(node *etcd.Node, unitHashLookupFunc func(unit.Hash) *unit.UnitFile) (*job.Unit, error) {
	var err error
	var jm jobModel
	if err = unmarshal(node.Value, &jm); err != nil {
		return nil, err
	}

	var unit *unit.UnitFile

	unit = unitHashLookupFunc(jm.UnitHash)
	if unit == nil {
		log.Warningf("No Unit found in Registry for Job(%s)", jm.Name)
		return nil, nil
	}

	ju := &job.Unit{
		Name: jm.Name,
		Unit: *unit,
	}
	return ju, nil

}
1041091
func (r *Repository) GetAssigneesURL() string {
	if r == nil || r.AssigneesURL == nil {
		return ""
	}
	return *r.AssigneesURL
}
784330
func (c *Connection) GetW(path string, node client.Node, cancel <-chan struct{}) (<-chan client.Event, error) {
	c.RLock()
	defer c.RUnlock()
	if err := c.isClosed(); err != nil {
		return nil, err
	}
	return c.getW(path, node, cancel)
}
170796
func (p *PUContext) GetJWT() (string, error) {
	p.RLock()
	defer p.RUnlock()

	if p.jwtExpiration.After(time.Now()) && len(p.jwt) > 0 {
		return p.jwt, nil
	}

	return "", fmt.Errorf("expired token")
}
410938
func (s *SQLStore) acquireDBLock(steal bool) (bool, string, uint64, error) {
	s.dbLock.Lock()
	defer s.dbLock.Unlock()
	var (
		lockID  string
		tick    uint64
		hasLock bool
	)
	tx, err := s.dbLock.db.Begin()
	if err != nil {
		return false, "", 0, err
	}
	defer func() {
		if tx != nil {
			tx.Rollback()
		}
	}()
	r := tx.QueryRow(sqlStmts[sqlDBLockSelect])
	err = r.Scan(&lockID, &tick)
	if err != nil && err != sql.ErrNoRows {
		return false, "", 0, sqlStmtError(sqlDBLockSelect, err)
	}
	if err == sql.ErrNoRows || steal || lockID == "" || lockID == s.dbLock.id {
		// If we are stealing, reset tick to 0 (so it will become 1 in update statement)
		if steal {
			tick = 0
		}
		stmt := sqlStmts[sqlDBLockUpdate]
		if err == sql.ErrNoRows {
			stmt = sqlStmts[sqlDBLockInsert]
		}
		if _, err := tx.Exec(stmt, s.dbLock.id, tick+1); err != nil {
			return false, "", 0, sqlStmtError(sqlDBLockUpdate, err)
		}
		hasLock = true
	}
	if err := tx.Commit(); err != nil {
		return false, "", 0, err
	}
	tx = nil
	return hasLock, lockID, tick, nil
}