// EnableSnapshots allows the compactor to perform snapshots.
165059
func (c *Compactor) EnableSnapshots() {
	c.mu.Lock()
	c.snapshotsEnabled = true
	if c.snapshotsInterrupt == nil {
		c.snapshotsInterrupt = make(chan struct{})
	}
	c.mu.Unlock()
}
373097
func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanceParams) (*EnableStorageMaintenanceResponse, error) {
	resp, err := s.cs.newRequest("enableStorageMaintenance", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r EnableStorageMaintenanceResponse
	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
}
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
}
648282
func (c *Client) GetSnapshots() (snapshotList []Snapshot, err error) {
	var snapshotMap map[string]Snapshot
	if err := c.get(`snapshot/list`, &snapshotMap); err != nil {
		return nil, err
	}

	for _, snapshot := range snapshotMap {
		snapshotList = append(snapshotList, snapshot)
	}
	sort.Sort(snapshots(snapshotList))
	return snapshotList, nil
}
398471
func (s *Simulation) UploadSnapshot(ctx context.Context, snapshotFile string, opts ...AddNodeOption) error {
	f, err := os.Open(snapshotFile)
	if err != nil {
		return err
	}

	jsonbyte, err := ioutil.ReadAll(f)
	f.Close()
	if err != nil {
		return err
	}
	var snap simulations.Snapshot
	if err := json.Unmarshal(jsonbyte, &snap); err != nil {
		return err
	}

	//the snapshot probably has the property EnableMsgEvents not set
	//set it to true (we need this to wait for messages before uploading)
	for i := range snap.Nodes {
		snap.Nodes[i].Node.Config.EnableMsgEvents = true
		snap.Nodes[i].Node.Config.Services = s.serviceNames
		for _, o := range opts {
			o(snap.Nodes[i].Node.Config)
		}
	}

	if err := s.Net.Load(&snap); err != nil {
		return err
	}
	return s.WaitTillSnapshotRecreated(ctx, &snap)
}
557152
func (p *PoolDevice) CreateSnapshotDevice(ctx context.Context, deviceName string, snapshotName string, virtualSizeBytes uint64) (retErr error) {
	baseInfo, err := p.metadata.GetDevice(ctx, deviceName)
	if err != nil {
		return errors.Wrapf(err, "failed to query device metadata for %q", deviceName)
	}

	// Suspend thin device if it was activated previously to avoid corruptions
	isActivated := p.IsActivated(baseInfo.Name)
	if isActivated {
		if err := p.suspendDevice(ctx, baseInfo); err != nil {
			return err
		}

		// Resume back base thin device on exit
		defer func() {
			retErr = multierror.Append(retErr, p.resumeDevice(ctx, baseInfo)).ErrorOrNil()
		}()
	}

	snapInfo := &DeviceInfo{
		Name:       snapshotName,
		Size:       virtualSizeBytes,
		ParentName: deviceName,
		State:      Unknown,
	}

	// Save snapshot metadata and allocate new device ID
	if err := p.metadata.AddDevice(ctx, snapInfo); err != nil {
		return errors.Wrapf(err, "failed to save initial metadata for snapshot %q", snapshotName)
	}

	defer func() {
		if retErr == nil {
			return
		}

		// Rollback metadata
		retErr = multierror.Append(retErr, p.metadata.RemoveDevice(ctx, snapInfo.Name))
	}()

	// Create thin device snapshot
	if err := p.createSnapshot(ctx, baseInfo, snapInfo); err != nil {
		return err
	}

	defer func() {
		if retErr == nil {
			return
		}

		// Rollback snapshot creation
		retErr = multierror.Append(retErr, p.deleteDevice(ctx, snapInfo))
	}()

	// Activate snapshot device
	return p.activateDevice(ctx, snapInfo)
}
1071032
func (s *TableRestoreStatus) SetSnapshotIdentifier(v string) *TableRestoreStatus {
	s.SnapshotIdentifier = &v
	return s
}
1113740
func (c *Compactor) DisableCompactions() {
	c.mu.Lock()
	c.compactionsEnabled = false
	if c.compactionsInterrupt != nil {
		close(c.compactionsInterrupt)
		c.compactionsInterrupt = nil
	}
	c.mu.Unlock()
}
277067
func (c *Cloud) CreateSnapshot(snapshotOptions *SnapshotOptions) (snapshotID string, status string, err error) {
	request := &ec2.CreateSnapshotInput{}
	request.VolumeId = aws.String(snapshotOptions.VolumeID)
	request.DryRun = aws.Bool(false)
	descriptions := "Created by Kubernetes for volume " + snapshotOptions.VolumeID
	request.Description = aws.String(descriptions)
	res, err := c.ec2.CreateSnapshot(request)
	if err != nil {
		return "", "", err
	}
	if res == nil {
		return "", "", fmt.Errorf("nil CreateSnapshotResponse")
	}
	if snapshotOptions.Tags != nil {
		awsID := awsVolumeID(aws.StringValue(res.SnapshotId))
		// apply tags
		if err := c.tagging.createTags(c.ec2, string(awsID), ResourceLifecycleOwned, *snapshotOptions.Tags); err != nil {
			_, delerr := c.DeleteSnapshot(*res.SnapshotId)
			if delerr != nil {
				return "", "", fmt.Errorf("error tagging snapshot %s, could not delete the snapshot: %v", *res.SnapshotId, delerr)
			}
			return "", "", fmt.Errorf("error tagging snapshot %s: %v", *res.SnapshotId, err)
		}
	}
	return *res.SnapshotId, *res.State, nil

}
1192510
func (s *ListApplicationSnapshotsOutput) SetSnapshotSummaries(v []*SnapshotDetails) *ListApplicationSnapshotsOutput {
	s.SnapshotSummaries = v
	return s
}
122257
func (db *DB) EnableShouldClose() {
	db.mu.Lock()
	defer db.mu.Unlock()
	db.shouldClose = true
}
1081783
func (c *Host) CreateSnapshot(volumeID string) (*volume.Info, error) {
	var res volume.Info
	err := c.c.Put(fmt.Sprintf("/storage/volumes/%s/snapshot", volumeID), nil, &res)
	return &res, err
}
1186192
func (p *peer) ChannelSnapshots() []*channeldb.ChannelSnapshot {
	p.activeChanMtx.RLock()
	defer p.activeChanMtx.RUnlock()

	snapshots := make([]*channeldb.ChannelSnapshot, 0, len(p.activeChannels))
	for _, activeChan := range p.activeChannels {
		// We'll only return a snapshot for channels that are
		// *immedately* available for routing payments over.
		if activeChan.RemoteNextRevocation() == nil {
			continue
		}

		snapshot := activeChan.StateSnapshot()
		snapshots = append(snapshots, snapshot)
	}

	return snapshots
}
778593
func (db *DB) EnableCompactions() {
	db.autoCompactMtx.Lock()
	defer db.autoCompactMtx.Unlock()

	db.autoCompact = true
	level.Info(db.logger).Log("msg", "compactions enabled")
}
434002
func (c *Client) CreateSnapshot() (*Snapshot, error) {
	snap := &Snapshot{}
	return snap, c.Get("/snapshot", snap)
}
802909
func (vs *volumeSnapshotter) takeSnapshot(
	snapshot *crdv1.VolumeSnapshot,
	pv *v1.PersistentVolume,
	tags *map[string]string,
) (*crdv1.VolumeSnapshotDataSource, *[]crdv1.VolumeSnapshotCondition, error) {
	spec := &pv.Spec
	volumeType := crdv1.GetSupportedVolumeFromPVSpec(spec)
	if len(volumeType) == 0 {
		return nil, nil, fmt.Errorf("unsupported volume type found in PV %#v", spec)
	}
	plugin, ok := (*vs.volumePlugins)[volumeType]
	if !ok {
		return nil, nil, fmt.Errorf("%s is not supported volume for %#v", volumeType, spec)
	}

	snapDataSource, snapConditions, err := plugin.SnapshotCreate(snapshot, pv, tags)
	if err != nil {
		glog.Warningf("failed to snapshot %#v, err: %v", spec, err)
	} else {
		glog.Infof("snapshot created: %v. Conditions: %#v", snapDataSource, snapConditions)
		return snapDataSource, snapConditions, nil
	}
	return nil, nil, nil
}
335217
func (s *CreateElasticsearchDomainInput) SetSnapshotOptions(v *SnapshotOptions) *CreateElasticsearchDomainInput {
	s.SnapshotOptions = v
	return s
}