// Snapshot is part of the raft.FSM interface.
553327
func (fsm *SimpleFSM) Snapshot() (raft.FSMSnapshot, error) {
	fsm.mu.Lock()
	defer fsm.mu.Unlock()
	copied := make([][]byte, len(fsm.logs))
	copy(copied, fsm.logs)
	return &SimpleSnapshot{copied, len(copied)}, nil
}
810611
func (db *MemDB) Snapshot() *MemDB {
	clone := &MemDB{
		schema:  db.schema,
		root:    unsafe.Pointer(db.getRoot()),
		primary: false,
	}
	return clone
}
69423
func (r *AllocationBitmap) Snapshot() (string, []byte) {
	r.lock.Lock()
	defer r.lock.Unlock()

	return r.rangeSpec, r.allocated.Bytes()
}
941096
func (db *DB) newSnapshot() *Snapshot {
	snap := &Snapshot{
		db:   db,
		elem: db.acquireSnapshot(),
	}
	atomic.AddInt32(&db.aliveSnaps, 1)
	runtime.SetFinalizer(snap, (*Snapshot).Release)
	return snap
}
1021687
func (rs *RaftStorage) TakeSnapshot(i uint64, cs raftpb.ConfState, data []byte) error {
	rs.lg.Debugf("Creating snapshot at index %d from MemoryStorage", i)
	snap, err := rs.ram.CreateSnapshot(i, &cs, data)
	if err != nil {
		return errors.Errorf("failed to create snapshot from MemoryStorage: %s", err)
	}

	if err = rs.saveSnap(snap); err != nil {
		return err
	}

	rs.snapshotIndex = append(rs.snapshotIndex, snap.Metadata.Index)

	// Keep some entries in memory for slow followers to catchup
	if i > rs.SnapshotCatchUpEntries {
		compacti := i - rs.SnapshotCatchUpEntries
		rs.lg.Debugf("Purging in-memory raft entries prior to %d", compacti)
		if err = rs.ram.Compact(compacti); err != nil {
			if err == raft.ErrCompacted {
				rs.lg.Warnf("Raft entries prior to %d are already purged", compacti)
			} else {
				rs.lg.Fatalf("Failed to purge raft entries: %s", err)
			}
		}
	}

	rs.lg.Infof("Snapshot is taken at index %d", i)

	rs.gc()
	return nil
}
806530
func (s *ExpDecaySample) Snapshot() Sample {
	s.mutex.Lock()
	defer s.mutex.Unlock()
	vals := s.values.Values()
	values := make([]int64, len(vals))
	for i, v := range vals {
		values[i] = v.v
	}
	return &SampleSnapshot{
		count:  s.count,
		values: values,
	}
}
42170
func (p *PolicyAuthorizer) Snapshot() bool {
	if allow, recurse := enforce(p.aclRule, PolicyWrite); !recurse {
		return allow
	}
	return p.parent.Snapshot()
}
627847
func (d *Lepton3) Snapshot() (*RawFrame, error) {
	if err := d.Open(); err != nil {
		return nil, err
	}
	defer d.Close()
	frame := new(RawFrame)
	if err := d.NextFrame(frame); err != nil {
		return nil, err
	}
	return frame, nil
}
612522
func (f *fragment) Snapshot() error {
	f.mu.Lock()
	defer f.mu.Unlock()
	return f.snapshot()
}
860528
func (d *destination) snapshot() *seesaw.Destination {
	return &seesaw.Destination{
		Backend:     d.backend,
		Name:        d.name(),
		VserverName: d.service.vserver.String(),
		Stats:       d.stats,
		Enabled:     d.backend.Enabled,
		Weight:      d.weight,
		Healthy:     d.healthy,
		Active:      d.active,
	}
}
127849
func (v *RsyncVolume) Snapshot(label, message string, tags []string) (err error) {
	v.Lock()
	defer v.Unlock()
	// does the snapshot already exist
	label = v.rawSnapshotLabel(label)
	dest := v.snapshotPath(label)
	if exists, err := volume.IsDir(dest); exists || err != nil {
		if exists {
			glog.Errorf("Snapshot exists: %s", v.rawSnapshotLabel(label))
			return volume.ErrSnapshotExists
		}
		return err
	}
	// check the tags for duplicates
	for _, tagName := range tags {
		if tagInfo, err := v.getSnapshotWithTag(tagName, false); err != volume.ErrSnapshotDoesNotExist {
			if err != nil {
				glog.Errorf("Could not look up snapshot for tag %s: %s", tagName, err)
				return err
			} else {
				glog.Errorf("Tag '%s' is already in use by snapshot %s", tagName, tagInfo.Name)
				return volume.ErrTagAlreadyExists
			}
		}
	}
	// write snapshot info
	info := volume.SnapshotInfo{
		Name:     v.rawSnapshotLabel(label),
		TenantID: v.Tenant(),
		Label:    v.prettySnapshotLabel(label),
		Tags:     tags,
		Message:  message,
		Created:  time.Now(),
	}
	if err := v.writeSnapshotInfo(label, &info); err != nil {
		return err
	}
	exe, err := exec.LookPath("rsync")
	if err != nil {
		return err
	}
	argv := []string{"-a", v.Path() + "/", dest + "/"}
	glog.Infof("Performing snapshot rsync command: %s %s", exe, argv)
	if err := os.MkdirAll(filepath.Join(v.driver.MetadataDir(), label), 0755); err != nil && !os.IsExist(err) {
		return err
	}
	var output []byte
	for i := 0; i < 3; i++ {
		rsync := exec.Command(exe, argv...)
		done := make(chan interface{})
		go func() {
			defer close(done)
			output, err = rsync.CombinedOutput()
		}()

		select {
		case <-time.After(v.timeout):
			glog.V(2).Infof("Received signal to kill rsync")
			rsync.Process.Kill()
			<-done
		case <-done:
		}
		if err == nil {
			return nil
		}
		if exitStatus, ok := utils.GetExitStatus(err); !ok || exitStatus != 24 {
			glog.Errorf("Could not perform rsync: %s", string(output))
			return err
		}
		glog.Infof("trying snapshot again: %s", label)
	}
	if exitStatus, _ := utils.GetExitStatus(err); exitStatus == 24 {
		glog.Warningf("snapshot completed with errors: Partial transfer due to vanished source files")
		return nil
	}
	glog.Errorf("Could not perform rsync: %s", string(output))
	return err
}
1207519
func (ds *Dataset) Snapshot(name string) (*Snapshot, error) {
	sn := fmt.Sprintf("%v@%v", ds.Name, name)
	err := exec.Command("zfs", "snapshot", sn).Run()
	if err != nil {
		return nil, err
	}
	return GetSnapshot(sn)
}
840463
func (s *SnapshotDeleteService) Snapshot(snapshot string) *SnapshotDeleteService {
	s.snapshot = snapshot
	return s
}
982885
func Snapshot() (c map[string]uint64, g map[string]int64) {
	hm.Lock()
	defer hm.Unlock()

	gm.Lock()
	defer gm.Unlock()

	cm.Lock()
	defer cm.Unlock()

	for _, init := range inits {
		init()
	}

	c = make(map[string]uint64, len(counters)+len(counterFuncs))
	for n, v := range counters {
		c[n] = v
	}

	for n, f := range counterFuncs {
		c[n] = f()
	}

	g = make(map[string]int64, len(gauges))
	for n, f := range gauges {
		g[n] = f()
	}

	return
}
775903
func (v *vserver) snapshot() *seesaw.Vserver {
	if v.config == nil {
		return nil
	}
	sv := &seesaw.Vserver{
		Name:    v.config.Name,
		Entries: make([]*seesaw.VserverEntry, 0, len(v.config.Entries)),
		Host: seesaw.Host{
			Hostname: v.config.Hostname,
			IPv4Addr: v.config.IPv4Addr,
			IPv4Mask: v.config.IPv4Mask,
			IPv6Addr: v.config.IPv6Addr,
			IPv6Mask: v.config.IPv6Mask,
		},
		FWM:           make(map[seesaw.AF]uint32),
		Services:      make(map[seesaw.ServiceKey]*seesaw.Service, len(v.services)),
		OverrideState: v.vserverOverride.State(),
		Enabled:       v.enabled,
		ConfigEnabled: v.config.Enabled,
		Warnings:      v.config.Warnings,
	}
	for _, ve := range v.config.Entries {
		sv.Entries = append(sv.Entries, ve.Snapshot())
	}
	sv.FWM[seesaw.IPv4] = v.fwm[seesaw.IPv4]
	sv.FWM[seesaw.IPv6] = v.fwm[seesaw.IPv6]
	for _, s := range v.services {
		ss := s.snapshot()
		sv.Services[ss.ServiceKey] = ss
	}
	return sv
}
158961
func (lc *LightningChannel) StateSnapshot() *channeldb.ChannelSnapshot {
	lc.RLock()
	defer lc.RUnlock()

	return lc.channelState.Snapshot()
}
111432
func (d *driver) VolumeSnapshot(
	ctx types.Context,
	volumeID, snapshotName string,
	opts types.Store) (*types.Snapshot, error) {
	// TODO Snapshots are not implemented yet
	return nil, types.ErrNotImplemented
}