// update attempts to update the cached statistics from the Seesaw Engine.
337271
func (e *ecuStats) update() error {
	// TODO(jsing): Make this untrusted.
	ctx := ipc.NewTrustedContext(seesaw.SCECU)
	seesawConn, err := conn.NewSeesawIPC(ctx)
	if err != nil {
		return fmt.Errorf("Failed to connect to engine: %v", err)
	}
	if err := seesawConn.Dial(e.ecu.cfg.EngineSocket); err != nil {
		return fmt.Errorf("Failed to connect to engine: %v", err)
	}
	defer seesawConn.Close()

	clusterStatus, err := seesawConn.ClusterStatus()
	if err != nil {
		return fmt.Errorf("Failed to get cluster status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.ClusterStatus = *clusterStatus
	e.stats.lock.Unlock()

	configStatus, err := seesawConn.ConfigStatus()
	if err != nil {
		return fmt.Errorf("Failed to get config status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.ConfigStatus = *configStatus
	e.stats.lock.Unlock()

	ha, err := seesawConn.HAStatus()
	if err != nil {
		return fmt.Errorf("Failed to get HA status: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.HAStatus = *ha
	e.stats.lock.Unlock()

	neighbors, err := seesawConn.BGPNeighbors()
	if err != nil {
		return fmt.Errorf("Failed to get BGP neighbors: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.neighbors = neighbors
	e.stats.lock.Unlock()

	vlans, err := seesawConn.VLANs()
	if err != nil {
		return fmt.Errorf("Failed to get VLANs: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.vlans = vlans.VLANs
	e.stats.lock.Unlock()

	vservers, err := seesawConn.Vservers()
	if err != nil {
		return fmt.Errorf("Failed to get vservers: %v", err)
	}
	e.stats.lock.Lock()
	e.stats.vservers = vservers
	e.stats.lock.Unlock()

	return nil
}
340880
func (gvc *GlobalVariableCache) Update(rows []chunk.Row, fields []*ast.ResultField) {
	gvc.Lock()
	gvc.lastModify = time.Now()
	gvc.rows = rows
	gvc.fields = fields
	gvc.Unlock()
}
939821
func (ar *allocRunner) update(update *structs.Allocation) error {
	if ar.logger.IsTrace() {
		start := time.Now()
		ar.logger.Trace("running update hooks", "start", start)
		defer func() {
			end := time.Now()
			ar.logger.Trace("finished update hooks", "end", end, "duration", end.Sub(start))
		}()
	}

	req := &interfaces.RunnerUpdateRequest{
		Alloc: update,
	}

	var merr multierror.Error
	for _, hook := range ar.runnerHooks {
		h, ok := hook.(interfaces.RunnerUpdateHook)
		if !ok {
			continue
		}

		name := h.Name()
		var start time.Time
		if ar.logger.IsTrace() {
			start = time.Now()
			ar.logger.Trace("running pre-run hook", "name", name, "start", start)
		}

		if err := h.Update(req); err != nil {
			merr.Errors = append(merr.Errors, fmt.Errorf("update hook %q failed: %v", name, err))
		}

		if ar.logger.IsTrace() {
			end := time.Now()
			ar.logger.Trace("finished update hooks", "name", name, "end", end, "duration", end.Sub(start))
		}
	}

	return merr.ErrorOrNil()
}
847328
func (c *Cache) Update(event sd.Event) {
	c.mtx.Lock()
	defer c.mtx.Unlock()

	sort.Strings(event.Instances)
	if reflect.DeepEqual(c.state, event) {
		return // no need to broadcast the same instances
	}

	c.state = event
	c.reg.broadcast(event)
}
1016057
func (s *BuildStore) Update(ctx context.Context, build chronograf.BuildInfo) error {
	if err := s.client.db.Update(func(tx *bolt.Tx) error {
		return s.update(ctx, build, tx)
	}); err != nil {
		return err
	}

	return nil
}
153675
func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
	var fieldsCount = 5
	cpuTimes, err := getDragonFlyCPUTimes()
	if err != nil {
		return err
	}

	// Export order: user nice sys intr idle
	cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
	for i, value := range cpuTimes {
		cpux := fmt.Sprintf("%d", i/fieldsCount)
		ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount])
	}

	return nil
}
148217
func (p *Init) Update(ctx context.Context, r *google_protobuf.Any) error {
	p.mu.Lock()
	defer p.mu.Unlock()

	return p.initState.Update(ctx, r)
}
819429
func (s *Simple) Update(key string) {
	atomic.AddInt64(&s.stats.Updates, 1)
	atv := s.getOrCreateAtomicTimedValue(key)
	s.update(key, atv)
}
56494
func (s *service) Update(ctx context.Context, r *taskAPI.UpdateTaskRequest) (*ptypes.Empty, error) {
	return nil, errdefs.ErrNotImplemented
}
682062
func (tu *thresholdUpdater) Update(status error) {
	tu.mu.Lock()
	defer tu.mu.Unlock()

	if status == nil {
		tu.count = 0
	} else if tu.count < tu.threshold {
		tu.count++
	}

	tu.status = status
}
1157361
func (c *meminfoCollector) Update(ch chan<- prometheus.Metric) error {
	var metricType prometheus.ValueType
	memInfo, err := c.getMemInfo()
	if err != nil {
		return fmt.Errorf("couldn't get meminfo: %s", err)
	}
	log.Debugf("Set node_mem: %#v", memInfo)
	for k, v := range memInfo {
		if strings.HasSuffix(k, "_total") {
			metricType = prometheus.CounterValue
		} else {
			metricType = prometheus.GaugeValue
		}
		ch <- prometheus.MustNewConstMetric(
			prometheus.NewDesc(
				prometheus.BuildFQName(namespace, memInfoSubsystem, k),
				fmt.Sprintf("Memory information field %s.", k),
				nil, nil,
			),
			metricType, v,
		)
	}
	return nil
}
1195370
func (c *FakeFlunders) Update(flunder *v1beta1.Flunder) (result *v1beta1.Flunder, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewUpdateAction(flundersResource, c.ns, flunder), &v1beta1.Flunder{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1beta1.Flunder), err
}
954138
func (t *StandardTimer) Update(d time.Duration) {
	t.mutex.Lock()
	defer t.mutex.Unlock()
	t.histogram.Update(int64(d))
	t.meter.Mark(1)
}
411719
func (mem *Memory) Update(key string, rls *rspb.Release) error {
	defer unlock(mem.wlock())

	if rs, ok := mem.cache[rls.Name]; ok && rs.Exists(key) {
		rs.Replace(key, newRecord(key, rls))
		return nil
	}
	return storageerrors.ErrReleaseNotFound(rls.Name)
}
172447
func (r *Reservoir) Update(v int64) {
	r.m.Lock()
	defer r.m.Unlock()
	s := atomic.AddInt64(&r.size, 1)
	if int(s) <= len(r.values) {
		// Not full
		r.values[s-1] = v
	} else {
		// Full
		l := rand.Int63n(s)
		if int(l) < len(r.values) {
			r.values[l] = v
		}
	}
}
1185269
func (c *Cache) Update(u interface{}, value interface{}) (err error) {

	var timer *time.Timer
	if c.lifetime != -1 {
		timer = time.AfterFunc(c.lifetime, func() {
			if err := c.removeNotify(u, true); err != nil {
				zap.L().Warn("Failed to remove item", zap.String("key", fmt.Sprintf("%v", u)))
			}
		})
	}

	t := time.Now()

	c.Lock()
	defer c.Unlock()

	if _, ok := c.data[u]; ok {

		if c.data[u].timer != nil {
			c.data[u].timer.Stop()
		}

		c.data[u] = entry{
			value:     value,
			timestamp: t,
			timer:     timer,
			expirer:   c.expirer,
		}

		return nil
	}

	return errors.New("cannot update item: not found")
}
1301305
func (s *Statistics) Update(samples ...float64) {
	s.Lock()
	defer s.Unlock()

	for _, sample := range samples {
		s.samples++
		s.total += sample
		s.squares += (sample * sample)

		// If this is our first sample then this value is both our maximum and
		// our minimum value. Otherwise, perform comparisions.
		if s.samples == 1 {
			s.maximum = sample
			s.minimum = sample
		} else {
			if sample > s.maximum {
				s.maximum = sample
			}

			if sample < s.minimum {
				s.minimum = sample
			}
		}
	}
}