// Changed updates the allWatcher's idea of the current state
// in response to the given change.
772923
func (b *allWatcherStateBacking) Changed(all *multiwatcherStore, change watcher.Change) error {
	c, ok := b.collectionByName[change.C]
	if !ok {
		return errors.Errorf("unknown collection %q in fetch request", change.C)
	}
	col, closer := b.st.db().GetCollection(c.name)
	defer closer()
	doc := reflect.New(c.docType).Interface().(backingEntityDoc)

	id := b.st.localID(change.Id.(string))

	// TODO(rog) investigate ways that this can be made more efficient
	// than simply fetching each entity in turn.
	// TODO(rog) avoid fetching documents that we have no interest
	// in, such as settings changes to entities we don't care about.
	err := col.FindId(id).One(doc)
	if err == mgo.ErrNotFound {
		err := doc.removed(all, b.st.ModelUUID(), id, b.st)
		return errors.Trace(err)
	}
	if err != nil {
		return err
	}
	return doc.updated(b.st, all, id)
}
247651
func (w *collectionWatcher) loop() error {
	var (
		changes []string
		in      = (<-chan watcher.Change)(w.source)
		out     = (chan<- []string)(w.sink)
	)

	w.watcher.WatchCollectionWithFilter(w.col, w.source, w.filter)
	defer w.watcher.UnwatchCollection(w.col, w.source)

	changes, err := w.initial()
	if err != nil {
		return err
	}

	for {
		select {
		case <-w.tomb.Dying():
			return tomb.ErrDying
		case <-w.watcher.Dead():
			return stateWatcherDeadError(w.watcher.Err())
		case ch := <-in:
			updates, ok := collect(ch, in, w.tomb.Dying())
			if !ok {
				return tomb.ErrDying
			}
			if err := w.mergeIds(&changes, updates); err != nil {
				return err
			}
			if len(changes) > 0 {
				out = w.sink
			}
		case out <- changes:
			changes = []string{}
			out = nil
		}
	}
}
1109722
func (w *Watch) update(newRevision int64){
	w.rwl.Lock()
	defer w.rwl.Unlock()
	w.revision = newRevision
	close(w.cond)
	w.cond = make(chan struct{})
}
909872
func (prc *Processor) Change(params imageserver.Params) bool {
	if !params.Has(param) {
		return false
	}
	params, err := params.GetParams(param)
	if err != nil {
		return true
	}
	if params.Empty() {
		return false
	}
	if params.Has("width") {
		return true
	}
	if params.Has("height") {
		return true
	}
	return false
}
1124022
func VersionChange(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "versionchange", Listener: listener}
}
695746
func (t *DryRunTarget) Changes() (map[string]Task, map[string]Task) {
	creates := make(map[string]Task)
	updates := make(map[string]Task)
	for _, r := range t.changes {
		if r.aIsNil {
			creates[getTaskName(r.changes)] = r.changes
		} else {
			updates[getTaskName(r.changes)] = r.changes
		}
	}
	return creates, updates
}
56323
func (st *State) WatchControllerStatusChanges() StringsWatcher {
	return newCollectionWatcher(st, colWCfg{
		col:    statusesC,
		filter: makeControllerIdFilter(st),
	})
}
1197267
func (m *Meta) backend_C_r_S_changed(c *configs.Backend, cHash int, sMgr *state.LocalState, output bool) (backend.Backend, tfdiags.Diagnostics) {
	if output {
		// Notify the user
		m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
			"[reset]%s\n\n",
			strings.TrimSpace(outputBackendReconfigure))))
	}

	// Get the old state
	s := sMgr.State()

	// Get the backend
	b, configVal, diags := m.backendInitFromConfig(c)
	if diags.HasErrors() {
		return nil, diags
	}

	// no need to confuse the user if the backend types are the same
	if s.Backend.Type != c.Type {
		m.Ui.Output(strings.TrimSpace(fmt.Sprintf(outputBackendMigrateChange, s.Backend.Type, c.Type)))
	}

	// Grab the existing backend
	oldB, oldBDiags := m.backend_C_r_S_unchanged(c, cHash, sMgr)
	diags = diags.Append(oldBDiags)
	if oldBDiags.HasErrors() {
		return nil, diags
	}

	// Perform the migration
	err := m.backendMigrateState(&backendMigrateOpts{
		OneType: s.Backend.Type,
		TwoType: c.Type,
		One:     oldB,
		Two:     b,
	})
	if err != nil {
		diags = diags.Append(err)
		return nil, diags
	}

	if m.stateLock {
		stateLocker := clistate.NewLocker(context.Background(), m.stateLockTimeout, m.Ui, m.Colorize())
		if err := stateLocker.Lock(sMgr, "backend from plan"); err != nil {
			diags = diags.Append(fmt.Errorf("Error locking state: %s", err))
			return nil, diags
		}
		defer stateLocker.Unlock(nil)
	}

	configJSON, err := ctyjson.Marshal(configVal, b.ConfigSchema().ImpliedType())
	if err != nil {
		diags = diags.Append(fmt.Errorf("Can't serialize backend configuration as JSON: %s", err))
		return nil, diags
	}

	// Update the backend state
	s = sMgr.State()
	if s == nil {
		s = terraform.NewState()
	}
	s.Backend = &terraform.BackendState{
		Type:      c.Type,
		ConfigRaw: json.RawMessage(configJSON),
		Hash:      uint64(cHash),
	}

	if err := sMgr.WriteState(s); err != nil {
		diags = diags.Append(fmt.Errorf(errBackendWriteSaved, err))
		return nil, diags
	}
	if err := sMgr.PersistState(); err != nil {
		diags = diags.Append(fmt.Errorf(errBackendWriteSaved, err))
		return nil, diags
	}

	if output {
		m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
			"[reset][green]\n"+strings.TrimSpace(successBackendSet), s.Backend.Type)))
	}

	return b, diags
}
1097473
func (wi WorkItem) ChangeSet(older change.Detector) (change.Set, error) {
	if older == nil {
		// this is changeset for a new ChangeDetector, report all observed attributes to
		// the change set. This needs extension once we support more attributes.
		changeSet := change.Set{
			{
				AttributeName: SystemState,
				NewValue:      wi.Fields[SystemState],
				OldValue:      nil,
			},
		}
		if wi.Fields[SystemBoardcolumns] != nil && len(wi.Fields[SystemBoardcolumns].([]interface{})) != 0 {
			changeSet = append(changeSet, change.Change{
				AttributeName: SystemBoardcolumns,
				NewValue:      wi.Fields[SystemBoardcolumns],
				OldValue:      nil,
			})
		}
		return changeSet, nil
	}
	olderWorkItem, ok := older.(WorkItem)
	if !ok {
		return nil, errs.New("Other entity is not a WorkItem: " + reflect.TypeOf(older).String())
	}
	if wi.ID != olderWorkItem.ID {
		return nil, errs.New("Other entity has not the same ID: " + olderWorkItem.ID.String())
	}
	changes := []change.Change{}
	// CAUTION: we're only supporting changes to the system.state and to the
	// board position relationship for now. If we need to support more
	// attribute changes, this has to be added here. This will be likely
	// necessary when adding new Actions.
	// compare system.state
	if wi.Fields[SystemState] != olderWorkItem.Fields[SystemState] {
		changes = append(changes, change.Change{
			AttributeName: SystemState,
			NewValue:      wi.Fields[SystemState],
			OldValue:      olderWorkItem.Fields[SystemState],
		})
	}
	// compare system.boardcolumns
	// this field looks like this:
	// system.boardcolumns": ["43f9e838-3b4b-45e8-85eb-dd402e8324b5", "69699af8-cb28-4b90-b829-24c1aad12797"]
	if wi.Fields[SystemBoardcolumns] == nil && olderWorkItem.Fields[SystemBoardcolumns] == nil {
		return changes, nil
	}
	if wi.Fields[SystemBoardcolumns] == nil || olderWorkItem.Fields[SystemBoardcolumns] == nil {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	if len(wi.Fields[SystemBoardcolumns].([]interface{})) == 0 || len(olderWorkItem.Fields[SystemBoardcolumns].([]interface{})) == 0 {
		if len(wi.Fields[SystemBoardcolumns].([]interface{})) == 0 && len(olderWorkItem.Fields[SystemBoardcolumns].([]interface{})) == 0 {
			// both lists are empty, return no change.
			return changes, nil
		}
		// one of the lists is empty, do return a change.
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	bcThis, ok1 := wi.Fields[SystemBoardcolumns].([]interface{})
	bcOlder, ok2 := olderWorkItem.Fields[SystemBoardcolumns].([]interface{})
	if !ok1 || !ok2 {
		return nil, errs.New("Boardcolumn slice is not a interface{} slice")
	}
	if len(bcThis) != len(bcOlder) {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	// because of the handing of interface{}, we need to do manual conversion here.
	thisCopyStr := make([]string, len(bcThis))
	for i := range bcThis {
		thisCopyStr[i], ok = bcThis[i].(string)
		if !ok {
			return nil, errs.New("Boardcolumn slice values are not of type string")
		}
	}
	olderCopyStr := make([]string, len(bcOlder))
	for i := range bcOlder {
		olderCopyStr[i], ok = bcOlder[i].(string)
		if !ok {
			return nil, errs.New("Boardcolumn slice values are not of type string")
		}
	}
	sort.Strings(thisCopyStr)
	sort.Strings(olderCopyStr)
	if !reflect.DeepEqual(thisCopyStr, olderCopyStr) {
		changes = append(changes, change.Change{
			AttributeName: SystemBoardcolumns,
			NewValue:      wi.Fields[SystemBoardcolumns],
			OldValue:      olderWorkItem.Fields[SystemBoardcolumns],
		})
		return changes, nil
	}
	return changes, nil
}
1248451
func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) {
	f.lock.Lock()
	defer f.lock.Unlock()

	objMeta, err := api.ObjectMetaFor(e.Object)
	if err != nil {
		panic(err) // this is test code only
	}

	resourceVersion := len(f.changes) + 1
	objMeta.ResourceVersion = strconv.Itoa(resourceVersion)
	f.changes = append(f.changes, e)
	key := f.key(objMeta)
	switch e.Type {
	case watch.Added, watch.Modified:
		f.items[key] = e.Object
	case watch.Deleted:
		delete(f.items, key)
	}

	if rand.Float64() < watchProbability {
		f.broadcaster.Action(e.Type, e.Object)
	}
}
162087
func (m *MockStringsWatcher) Changes() <-chan []string {
	ret := m.ctrl.Call(m, "Changes")
	ret0, _ := ret[0].(<-chan []string)
	return ret0
}
1217615
func (s *Settings) changes() settings.ItemChanges {
	var changes settings.ItemChanges

	for key := range cacheKeys(s.disk, s.core) {
		old, onDisk := s.disk[key]
		live, inCore := s.core[key]
		if reflect.DeepEqual(live, old) {
			continue
		}

		var change settings.ItemChange
		switch {
		case inCore && onDisk:
			change = settings.MakeModification(key, old, live)
		case inCore && !onDisk:
			change = settings.MakeAddition(key, live)
		case onDisk && !inCore:
			change = settings.MakeDeletion(key, old)
		default:
			panic("unreachable")
		}
		changes = append(changes, change)
	}
	sort.Sort(changes)
	return changes
}
499391
func (c *Client) ChangeApplicationofBareMetalServer(id string, appID string) error {
	values := url.Values{
		"SUBID": {id},
		"APPID": {appID},
	}

	return c.post(`baremetal/app_change`, values, nil)
}
1220905
func (s *ClusterStatus) SetStateChangeReason(v *ClusterStateChangeReason) *ClusterStatus {
	s.StateChangeReason = v
	return s
}
107323
func (mr *MockAgentMockRecorder) ChangeConfig(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeConfig", reflect.TypeOf((*MockAgent)(nil).ChangeConfig), arg0)
}
162274
func (p *Project) Change(event fsnotify.Event) {
	if p.parent.Change != nil {
		p.parent.Change(Context{Project: p, Event: event})
		return
	}
	// file extension
	ext := ext(event.Name)
	if ext == "" {
		ext = "DIR"
	}
	// change message
	msg = fmt.Sprintln(p.pname(p.Name, 4), ":", Magenta.Bold(strings.ToUpper(ext)), "changed", Magenta.Bold(event.Name))
	out = BufferOut{Time: time.Now(), Text: ext + " changed " + event.Name}
	p.stamp("log", out, msg, "")
}
735108
func (r *reconcileResults) Changes() int {
	return len(r.place) + len(r.inplaceUpdate) + len(r.stop)
}