// PropagateChanges fills registered channels with the data.
166897
func (adapter *Registry) PropagateChanges(ctx context.Context, txData map[string]datasync.ChangeValue) error {
	var events []func(done chan error)

	for _, sub := range adapter.subscriptions {
		var changes []datasync.ProtoWatchResp

		for _, prefix := range sub.KeyPrefixes {
			for key, val := range txData {
				if !strings.HasPrefix(key, prefix) {
					continue
				}

				var (
					prev   datasync.KeyVal
					curRev int64
				)

				if val.GetChangeType() == datasync.Delete {
					if _, prev = adapter.lastRev.Del(key); prev != nil {
						curRev = prev.GetRevision() + 1
					} else {
						continue
					}
				} else {
					_, prev, curRev = adapter.lastRev.Put(key, val)
				}

				changes = append(changes, &ChangeResp{
					Key:        key,
					ChangeType: val.GetChangeType(),
					CurrVal:    val,
					CurrRev:    curRev,
					PrevVal:    prev,
				})
			}
		}

		if len(changes) > 0 {
			sendTo := func(sub *Subscription) func(done chan error) {
				return func(done chan error) {
					sub.ChangeChan <- &ChangeEvent{
						ctx:      ctx,
						Changes:  changes,
						delegate: &DoneChannel{done},
					}
				}
			}
			events = append(events, sendTo(sub))
		}
	}

	done := make(chan error, 1)
	go AggregateDone(events, done)

	select {
	case err := <-done:
		if err != nil {
			return err
		}
	case <-time.After(PropagateChangesTimeout):
		logrus.DefaultLogger().Warnf("Timeout of aggregated data-change callbacks (%v)",
			PropagateChangesTimeout)
	}

	return nil
}
96252
func (s *SeesawECU) BGPNeighbors(ctx *ipc.Context, reply *quagga.Neighbors) error {
	s.trace("BGPNeighbors", ctx)

	authConn, err := s.ecu.authConnect(ctx)
	if err != nil {
		return err
	}
	defer authConn.Close()

	neighbors, err := authConn.BGPNeighbors()
	if err != nil {
		return err
	}

	if reply != nil {
		reply.Neighbors = neighbors
	}
	return nil
}
839979
func GMapGet(key string) (interface{}, bool) {
	gmap.lock.Lock()
	defer gmap.lock.Unlock()

	if !checkGMap(false) {
		return nil, false
	}

	v, ok := gmap.gm[key]
	return v, ok
}
120987
func (s *StartTaskInput) SetPropagateTags(v string) *StartTaskInput {
	s.PropagateTags = &v
	return s
}
510312
func (topo *CPUTopology) CPUsPerSocket() int {
	if topo.NumSockets == 0 {
		return 0
	}
	return topo.NumCPUs / topo.NumSockets
}
730260
func (n *node) PropagateWatchError(err error) {
	for _, ch := range n.watches {
		ch <- &topo.WatchData{
			Err: err,
		}
	}

	for _, c := range n.children {
		c.PropagateWatchError(err)
	}
}
1081078
func (o *VPort) BGPNeighbors(info *bambou.FetchingInfo) (BGPNeighborsList, *bambou.Error) {

	var list BGPNeighborsList
	err := bambou.CurrentSession().FetchChildren(o, BGPNeighborIdentity, &list, info)
	return list, err
}
1304048
func (s *TagDescription) SetPropagateAtLaunch(v bool) *TagDescription {
	s.PropagateAtLaunch = &v
	return s
}
1342241
func (c *ChannelCond) Broadcast() {
	var old chan struct{}
	c.Lock()
	defer c.Unlock()
	c.c, old = make(chan struct{}), c.c
	close(old)
}
1314427
func (s *propagateConstantSolver) validPropagateCond(cond Expression, funNameMap map[string]bool) (*Column, *Constant) {
	if eq, ok := cond.(*ScalarFunction); ok {
		if _, ok := funNameMap[eq.FuncName.L]; !ok {
			return nil, nil
		}
		if col, colOk := eq.GetArgs()[0].(*Column); colOk {
			if con, conOk := eq.GetArgs()[1].(*Constant); conOk {
				return col, con
			}
		}
		if col, colOk := eq.GetArgs()[1].(*Column); colOk {
			if con, conOk := eq.GetArgs()[0].(*Constant); conOk {
				return col, con
			}
		}
	}
	return nil, nil
}
778535
func (t *TotalThroughput) updateMaps() {
	// make a local copy of the sample counters for calculation
	t.lock.Lock()
	tmpCounts := t.currentCounts
	t.currentCounts = make(map[string]int)
	t.lock.Unlock()
	// short circuit if no traffic
	numKeys := len(tmpCounts)
	if numKeys == 0 {
		// no traffic the last 30s. clear the result map
		t.lock.Lock()
		defer t.lock.Unlock()
		t.savedSampleRates = make(map[string]int)
		return
	}
	// figure out our target throughput per key over ClearFrequencySec
	totalGoalThroughput := t.GoalThroughputPerSec * t.ClearFrequencySec
	// floor the throughput but min should be 1 event per bucket per time period
	throughputPerKey := int(math.Max(1, float64(totalGoalThroughput)/float64(numKeys)))
	// for each key, calculate sample rate by dividing counted events by the
	// desired number of events
	newSavedSampleRates := make(map[string]int)
	for k, v := range tmpCounts {
		rate := int(math.Max(1, (float64(v) / float64(throughputPerKey))))
		newSavedSampleRates[k] = rate
	}
	// save newly calculated sample rates
	t.lock.Lock()
	defer t.lock.Unlock()
	t.savedSampleRates = newSavedSampleRates
}
140434
func DialProtocol(ctx context.Context, protocol string, address string) (*VTGateConn, error) {
	dialer, ok := dialers[protocol]
	if !ok {
		return nil, fmt.Errorf("no dialer registered for VTGate protocol %s", protocol)
	}
	impl, err := dialer(ctx, address)
	if err != nil {
		return nil, err
	}
	return &VTGateConn{
		impl: impl,
	}, nil
}
1093474
func GetFromPropagateCtx(ctx context.Context, key string) interface{} {
	propagate := ToMap(ctx)
	if val, ok := propagate[key]; ok {
		return val
	}
	return nil
}
57911
func FMSketchToProto(s *FMSketch) *tipb.FMSketch {
	protoSketch := new(tipb.FMSketch)
	protoSketch.Mask = s.mask
	for val := range s.hashset {
		protoSketch.Hashset = append(protoSketch.Hashset, val)
	}
	return protoSketch
}
613087
func GetFromPropagateCtx(ctx context.Context, key string) interface{} {
	return pcontext.GetFromPropagateCtx(ctx, key)
}
663907
func (s *propOuterJoinConstSolver) propagateConstantEQ() {
	s.eqList = make([]*Constant, len(s.columns))
	lenFilters := len(s.filterConds)
	visited := make([]bool, lenFilters+len(s.joinConds))
	for i := 0; i < MaxPropagateColsCnt; i++ {
		mapper := s.pickNewEQConds(visited)
		if len(mapper) == 0 {
			return
		}
		cols := make([]*Column, 0, len(mapper))
		cons := make([]Expression, 0, len(mapper))
		for id, con := range mapper {
			cols = append(cols, s.columns[id])
			cons = append(cons, con)
		}
		for i, cond := range s.joinConds {
			if !visited[i+lenFilters] {
				s.joinConds[i] = ColumnSubstitute(cond, NewSchema(cols...), cons)
			}
		}
	}
}
371851
func (vs *volumeSnapshotter) propagateVolumeSnapshotCondition(snapshotDataName string, condition *crdv1.VolumeSnapshotCondition) error {
	var snapshotDataObj crdv1.VolumeSnapshotData
	err := vs.restClient.Get().
		Name(snapshotDataName).
		Resource(crdv1.VolumeSnapshotDataResourcePlural).
		Do().Into(&snapshotDataObj)
	if err != nil {
		return err
	}

	newCondition := &crdv1.VolumeSnapshotDataCondition{
		Type:               (crdv1.VolumeSnapshotDataConditionType)(condition.Type),
		Status:             condition.Status,
		Message:            condition.Message,
		LastTransitionTime: condition.LastTransitionTime,
	}
	oldStatus := snapshotDataObj.Status.DeepCopy()

	status := snapshotDataObj.Status
	isEqual := false
	if oldStatus.Conditions == nil || len(oldStatus.Conditions) == 0 || newCondition.Type != oldStatus.Conditions[len(oldStatus.Conditions)-1].Type {
		status.Conditions = append(status.Conditions, *newCondition)
	} else {
		oldCondition := oldStatus.Conditions[len(oldStatus.Conditions)-1]
		if newCondition.Status == oldCondition.Status {
			newCondition.LastTransitionTime = oldCondition.LastTransitionTime
		}
		status.Conditions[len(status.Conditions)-1] = *newCondition
		isEqual = newCondition.Type == oldCondition.Type &&
			newCondition.Status == oldCondition.Status &&
			newCondition.Reason == oldCondition.Reason &&
			newCondition.Message == oldCondition.Message &&
			newCondition.LastTransitionTime.Equal(&oldCondition.LastTransitionTime)
	}
	if !isEqual {
		var newSnapshotDataObj crdv1.VolumeSnapshotData
		snapshotDataObj.Status = status
		if snapshotDataObj.Status.CreationTimestamp.IsZero() && newCondition.Type == crdv1.VolumeSnapshotDataConditionReady {
			snapshotDataObj.Status.CreationTimestamp = newCondition.LastTransitionTime
		}
		err = vs.restClient.Put().
			Name(snapshotDataName).
			Resource(crdv1.VolumeSnapshotDataResourcePlural).
			Body(&snapshotDataObj).
			Do().Into(&newSnapshotDataObj)
		if err != nil {
			return err
		}
		glog.Infof("VolumeSnapshot status propagated to VolumeSnapshotData")
		return nil
	}

	return nil
}