Class SnapshotsService

    • Method Detail

      • getRepositoryData

        public RepositoryData getRepositoryData​(String repositoryName)
        Gets the RepositoryData for the given repository.
        Parameters:
        repositoryName - repository name
        Returns:
        repository data
      • snapshot

        public SnapshotInfo snapshot​(String repositoryName,
                                     SnapshotId snapshotId)
        Retrieves snapshot from repository
        Parameters:
        repositoryName - repository name
        snapshotId - snapshot id
        Returns:
        snapshot
        Throws:
        SnapshotMissingException - if snapshot is not found
      • snapshots

        public List<SnapshotInfo> snapshots​(String repositoryName,
                                            List<SnapshotId> snapshotIds,
                                            boolean ignoreUnavailable)
        Returns a list of snapshots from repository sorted by snapshot creation date
        Parameters:
        repositoryName - repository name
        snapshotIds - snapshots for which to fetch snapshot information
        ignoreUnavailable - if true, snapshots that could not be read will only be logged with a warning, if false, they will throw an error
        Returns:
        list of snapshots
      • currentSnapshots

        public List<SnapshotInfo> currentSnapshots​(String repositoryName)
        Returns a list of currently running snapshots from repository sorted by snapshot creation date
        Parameters:
        repositoryName - repository name
        Returns:
        list of snapshots
      • createSnapshot

        public void createSnapshot​(CreateSnapshotRequest request,
                                   ActionListener<Snapshot> listener)
        Initializes the snapshotting process.

        This method is used by clients to start snapshot. It makes sure that there is no snapshots are currently running and creates a snapshot record in cluster state metadata.

        Parameters:
        request - snapshot request
        listener - snapshot creation listener
      • currentSnapshots

        public List<SnapshotsInProgress.Entry> currentSnapshots​(String repository,
                                                                List<String> snapshots)
        Returns status of the currently running snapshots

        This method is executed on master node

        Parameters:
        repository - repository id
        snapshots - list of snapshots that will be used as a filter, empty list means no snapshots are filtered
        Returns:
        list of metadata for currently running snapshots
      • applyClusterState

        public void applyClusterState​(ClusterChangedEvent event)
        Description copied from interface: ClusterStateApplier
        Called when a new cluster state (ClusterChangedEvent.state() needs to be applied. The cluster state to be applied is already committed when this method is called, so an applier must therefore be prepared to deal with any state it receives without throwing an exception. Throwing an exception from an applier is very bad because it will stop the application of this state before it has reached all the other appliers, and will likely result in another attempt to apply the same (or very similar) cluster state which might continue until this node is removed from the cluster.
        Specified by:
        applyClusterState in interface ClusterStateApplier
      • deleteSnapshot

        public void deleteSnapshot​(String repositoryName,
                                   String snapshotName,
                                   ActionListener<Void> listener,
                                   boolean immediatePriority)
        Deletes a snapshot from the repository, looking up the Snapshot reference before deleting. If the snapshot is still running cancels the snapshot first and then deletes it from the repository.
        Parameters:
        repositoryName - repositoryName
        snapshotName - snapshotName
        listener - listener
      • isRepositoryInUse

        public static boolean isRepositoryInUse​(ClusterState clusterState,
                                                String repository)
        Checks if a repository is currently in use by one of the snapshots
        Parameters:
        clusterState - cluster state
        repository - repository id
        Returns:
        true if repository is currently in use by one of the running snapshots
      • snapshottingIndices

        public static Set<Index> snapshottingIndices​(ClusterState currentState,
                                                     Set<Index> indicesToCheck)
        Returns the indices that are currently being snapshotted (with partial == false) and that are contained in the indices-to-check set.