// StateSnapshotMeta returns the metadata from the most recently persisted
// or refreshed persistent state snapshot.
//
// This is an implementation of statemgr.PersistentMeta.
550180
func (s *State) StateSnapshotMeta() statemgr.SnapshotMeta {
	return statemgr.SnapshotMeta{
		Lineage: s.lineage,
		Serial:  s.serial,
	}
}
1206703
func (s *state) CurrentSnapshot() *ConfigSnapshot {
	// Make a chan for the response to be sent on
	ch := make(chan *ConfigSnapshot, 1)
	s.reqCh <- ch
	// Wait for the response
	return <-ch
}
1151291
func (do *Domain) GetSnapshotMeta(startTS uint64) (*meta.Meta, error) {
	snapshot, err := do.store.GetSnapshot(kv.NewVersion(startTS))
	if err != nil {
		return nil, err
	}
	return meta.NewSnapshotMeta(snapshot), nil
}
819490
func GetSnapshot(name string) (*Snapshot, error) {
	if !SnapshotExists(name) {
		return nil, fmt.Errorf("Snapshot not found")
	}
	return &Snapshot{
		Name: name,
	}, nil
}
1371039
func stateStepsFor234() []Step {
	return []Step{
		&upgradeStep{
			description: "delete cloud image metadata cache",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().DeleteCloudImageMetadata()
			},
		},
	}
}
586541
func (d dynamicSystemView) ReplicationState() consts.ReplicationState {
	state := d.core.ReplicationState()
	if d.core.perfStandby {
		state |= consts.ReplicationPerformanceStandby
	}
	return state
}
210887
func (c *Client) NewSnapshot(opts *NewSnapshotOptions) (NewSnapshotResult, error) {
	req := xms.PostSnapshotsReq(*opts)
	return c.api.PostSnapshots(&req)
}
725644
func (s *State) PersistState() error {
	s.mu.Lock()
	defer s.mu.Unlock()

	if s.readState != nil {
		if !statefile.StatesMarshalEqual(s.state, s.readState) {
			s.serial++
		}
	} else {
		// We might be writing a new state altogether, but before we do that
		// we'll check to make sure there isn't already a snapshot present
		// that we ought to be updating.
		err := s.refreshState()
		if err != nil {
			return fmt.Errorf("failed checking for existing remote state: %s", err)
		}
		if s.lineage == "" { // indicates that no state snapshot is present yet
			lineage, err := uuid.GenerateUUID()
			if err != nil {
				return fmt.Errorf("failed to generate initial lineage: %v", err)
			}
			s.lineage = lineage
			s.serial = 0
		}
	}

	f := statefile.New(s.state, s.lineage, s.serial)

	var buf bytes.Buffer
	err := statefile.Write(f, &buf)
	if err != nil {
		return err
	}

	err = s.Client.Put(buf.Bytes())
	if err != nil {
		return err
	}

	// After we've successfully persisted, what we just wrote is our new
	// reference state until someone calls RefreshState again.
	s.readState = s.state.DeepCopy()
	return nil
}
421962
func (l *State) LoadMetadata(data map[string]string) error {
	l.Lock()
	defer l.Unlock()

	for k, v := range data {
		l.metadata[k] = v
	}
	l.TriggerSyncChanges()
	return nil
}
800996
func (s *SnapshotService) RevertToVMSnapshot(p *RevertToVMSnapshotParams) (*RevertToVMSnapshotResponse, error) {
	resp, err := s.cs.newRequest("revertToVMSnapshot", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r RevertToVMSnapshotResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
158961
func (lc *LightningChannel) StateSnapshot() *channeldb.ChannelSnapshot {
	lc.RLock()
	defer lc.RUnlock()

	return lc.channelState.Snapshot()
}
678473
func (v *DeviceMapperVolume) isInvalidSnapshot(rawLabel string) bool {
	reader, err := v.ReadMetadata(rawLabel, ".SNAPSHOTINFO")
	if err != nil {
		return true
	}
	reader.Close()
	return false
}
1259711
func (asw *actualStateOfWorld) DeleteSnapshot(snapshotName string) error {
	asw.Lock()
	defer asw.Unlock()

	glog.Infof("Deleting snapshot from actual state of world: %s", snapshotName)
	delete(asw.snapshots, snapshotName)
	return nil
}
1287706
func (s *Store) Snapshot() (raft.FSMSnapshot, error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	buf, err := json.Marshal(s.data)
	if err != nil {
		return nil, err
	}
	return &raftSnapshot{data: buf}, nil
}
796584
func (dsw *desiredStateOfWorld) GetSnapshots() map[string]*crdv1.VolumeSnapshot {
	dsw.RLock()
	defer dsw.RUnlock()

	snapshots := make(map[string]*crdv1.VolumeSnapshot)

	for snapName, snapshot := range dsw.snapshots {
		snapshots[snapName] = snapshot
	}

	return snapshots
}
961405
func BuildState(cb func(*SyncState)) *State {
	s := NewState()
	cb(s.SyncWrapper())
	return s
}
469878
func (asw *actualStateOfWorld) GetSnapshots() map[string]*crdv1.VolumeSnapshot {
	asw.RLock()
	defer asw.RUnlock()

	snapshots := make(map[string]*crdv1.VolumeSnapshot)

	for snapName, snapshot := range asw.snapshots {
		snapshots[snapName] = snapshot
	}

	return snapshots
}