// AddIfNotPresent adds a pod to the active queue if it is not present in any of
// the queues. If it is present in any, it doesn't do any thing.
4020
func (p *PriorityQueue) AddIfNotPresent(pod *v1.Pod) error {
	p.lock.Lock()
	defer p.lock.Unlock()
	if p.unschedulableQ.get(pod) != nil {
		return nil
	}

	pInfo := p.newPodInfo(pod)
	if _, exists, _ := p.activeQ.Get(pInfo); exists {
		return nil
	}
	if _, exists, _ := p.podBackoffQ.Get(pInfo); exists {
		return nil
	}
	err := p.activeQ.Add(pInfo)
	if err != nil {
		klog.Errorf("Error adding pod %v/%v to the scheduling queue: %v", pod.Namespace, pod.Name, err)
	} else {
		p.nominatedPods.add(pod, "")
		p.cond.Broadcast()
	}
	return err
}
855042
func ValidatePodPresetUpdate(pip, oldPip *settings.PodPreset) field.ErrorList {
	allErrs := apivalidation.ValidateObjectMetaUpdate(&pip.ObjectMeta, &oldPip.ObjectMeta, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidatePodPresetSpec(&pip.Spec, field.NewPath("spec"))...)

	return allErrs
}
117335
func addNominatedPods(pod *v1.Pod, meta predicates.PredicateMetadata,
	nodeInfo *schedulernodeinfo.NodeInfo, queue internalqueue.SchedulingQueue) (bool, predicates.PredicateMetadata,
	*schedulernodeinfo.NodeInfo) {
	if queue == nil || nodeInfo == nil || nodeInfo.Node() == nil {
		// This may happen only in tests.
		return false, meta, nodeInfo
	}
	nominatedPods := queue.NominatedPodsForNode(nodeInfo.Node().Name)
	if nominatedPods == nil || len(nominatedPods) == 0 {
		return false, meta, nodeInfo
	}
	var metaOut predicates.PredicateMetadata
	if meta != nil {
		metaOut = meta.ShallowCopy()
	}
	nodeInfoOut := nodeInfo.Clone()
	for _, p := range nominatedPods {
		if util.GetPodPriority(p) >= util.GetPodPriority(pod) && p.UID != pod.UID {
			nodeInfoOut.AddPod(p)
			if metaOut != nil {
				metaOut.AddPod(p, nodeInfoOut)
			}
		}
	}
	return true, metaOut, nodeInfoOut
}
926630
func (c *LRUCache) GetIFPresent(key interface{}) (interface{}, error) {
	v, err := c.get(key, false)
	if err == KeyNotFoundError {
		return c.getWithLoader(key, false)
	}
	return v, err
}
514899
func WaitNotPresent(sel interface{}, opts ...QueryOption) Action {
	return Query(sel, append(opts, NodeNotPresent)...)
}
682231
func (a *StorageAPI) AddToUnit(args params.StoragesAddParams) (params.AddStorageResults, error) {
	return a.addToUnit(args)
}
898814
func (builder *StoreValueCommandBuilder) WithIfNotModified(ifNotModified bool) *StoreValueCommandBuilder {
	builder.protobuf.IfNotModified = &ifNotModified
	return builder
}
1074815
func (v *Validator) SetNotBefore(nbf time.Time) {
	v.expect()
	v.Expected.Set("nbf", nbf)
}
1105347
func (p *propDistantFrom) AddDistantFrom(id int64) {
	p.DistantFrom = append(p.DistantFrom, id)
}
903385
func (q *UniqueQueue) AddFunc(id interface{}, fn func()) {
	if q.Exist(id) {
		return
	}

	idStr := com.ToStr(id)
	q.table.Lock()
	q.table.pool[idStr] = true
	if fn != nil {
		fn()
	}
	q.table.Unlock()
	q.queue <- idStr
}
360
func (f *fieldHolder) AddFunc(fn func() (string, interface{}, error)) error {
	for {
		key, rawVal, err := fn()
		if err != nil {
			// fn is done giving us data
			break
		}
		f.AddField(key, rawVal)
	}
	return nil
}
333218
func (w *Window) JoystickPresent(js Joystick) bool {
	return w.currJoy.connected[js]
}
1187644
func (p *PodContainer) AddArtifact(artifact *PodArtifact) *PodContainer {
	p.Artifacts = append(p.Artifacts, artifact)
	return p
}
569307
func AddNewOutputFunc(name string, f NewOutputFunc) bool {
	updateMutex.Lock()
	defer updateMutex.Unlock()
	return lockedAddNewOutputFunc(name, f)
}
1110666
func (kva *KvAlert) raiseIfNotExist(a *api.Alert) error {
	kv := kva.GetKvdbInstance()
	if a.Resource == api.ResourceType_RESOURCE_TYPE_NONE {
		return ErrResourceNotFound
	}

	// Acquire resource lock: lockKey/resouceId.uniqueTag.lock.
	// This ensures only one raiseIfNotExists operation for a given resource
	// is able to proceed.
	kvp, err := kv.Lock(getLockId(a.ResourceId, a.UniqueTag))
	if err != nil {
		logrus.Errorf("Failed to get lock for resource %s, err: %s",
			a.ResourceId, err.Error())
		return err
	}
	defer kv.Unlock(kvp)

	alerts, err := kva.getResourceSpecificAlerts(a.Resource, kv)
	if err != nil {
		logrus.Infof("Failed to get alerts of type %s, error: %s",
			a.Resource, err.Error())
		return err
	}
	for _, alert := range alerts {
		if alert.ResourceId == a.ResourceId && alert.UniqueTag == a.UniqueTag {
			a.Id = alert.Id
			return nil
		}
	}

	// Alert does ot exist, raise a new one
	return kva.raise(a)
}
714332
func (b *Base) AddFuncIf(p Predicate, key string, f ValueConverter) Serializer {
	b.modifiers = append(b.modifiers, func(m jsonMap) jsonMap {
		if p(b.raw) {
			m[key] = f(b.raw)
		}
		return m
	})
	return b
}
284331
func (fp *formatParser) addStatic(b []byte) {
	if b == nil {
		return
	} else if len(fp.lastStatic) == 0 {
		fp.lastStatic = b
	} else {
		fp.lastStatic = append(fp.lastStatic, b...)
	}
}