Class RepositoriesService

java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.repositories.RepositoriesService
All Implemented Interfaces:
Closeable, AutoCloseable, ClusterStateApplier, LifecycleComponent, Releasable

public class RepositoriesService extends AbstractLifecycleComponent implements ClusterStateApplier
Service responsible for maintaining and providing access to snapshot repositories on nodes.
  • Field Details

    • REPOSITORIES_STATS_ARCHIVE_RETENTION_PERIOD

      public static final Setting<TimeValue> REPOSITORIES_STATS_ARCHIVE_RETENTION_PERIOD
    • REPOSITORIES_STATS_ARCHIVE_MAX_ARCHIVED_STATS

      public static final Setting<Integer> REPOSITORIES_STATS_ARCHIVE_MAX_ARCHIVED_STATS
  • Constructor Details

  • Method Details

    • registerRepository

      public void registerRepository(PutRepositoryRequest request, ActionListener<AcknowledgedResponse> listener)
      Registers new repository in the cluster

      This method can be only called on the master node. It tries to create a new repository on the master and if it was successful it adds new repository to cluster metadata.

      Parameters:
      request - register repository request
      listener - register repository listener
    • validateRepositoryCanBeCreated

      public void validateRepositoryCanBeCreated(PutRepositoryRequest request)
      Ensures that we can create the repository and that it's creation actually works

      This verification method will create and then close the repository we want to create.

      Parameters:
      request -
    • updateRepositoryUuidInMetadata

      public static void updateRepositoryUuidInMetadata(ClusterService clusterService, String repositoryName, RepositoryData repositoryData, ActionListener<Void> listener)
      Set the repository UUID in the named repository's RepositoryMetadata to match the UUID in its RepositoryData, which may involve a cluster state update.
      Parameters:
      listener - notified when the RepositoryMetadata is updated, possibly on this thread or possibly on the master service thread
    • unregisterRepository

      public void unregisterRepository(DeleteRepositoryRequest request, ActionListener<AcknowledgedResponse> listener)
      Unregisters repository in the cluster

      This method can be only called on the master node. It removes repository information from cluster metadata.

      Parameters:
      request - unregister repository request
      listener - unregister repository listener
    • verifyRepository

      public void verifyRepository(String repositoryName, ActionListener<List<DiscoveryNode>> listener)
    • isDedicatedVotingOnlyNode

      public static boolean isDedicatedVotingOnlyNode(Set<DiscoveryNodeRole> roles)
    • applyClusterState

      public void applyClusterState(ClusterChangedEvent event)
      Checks if new repositories appeared in or disappeared from cluster metadata and updates current list of repositories accordingly.
      Specified by:
      applyClusterState in interface ClusterStateApplier
      Parameters:
      event - cluster changed event
    • getRepositoryData

      public void getRepositoryData(String repositoryName, ActionListener<RepositoryData> listener)
      Gets the RepositoryData for the given repository.
      Parameters:
      repositoryName - repository name
      listener - listener to pass RepositoryData to
    • repository

      public Repository repository(String repositoryName)
      Returns registered repository
      Parameters:
      repositoryName - repository name
      Returns:
      registered repository
      Throws:
      RepositoryMissingException - if repository with such name isn't registered
    • getRepositories

      public Map<String,Repository> getRepositories()
      Returns:
      the current collection of registered repositories, keyed by name.
    • repositoriesStats

      public List<RepositoryStatsSnapshot> repositoriesStats()
    • getRepositoriesThrottlingStats

      public RepositoriesStats getRepositoriesThrottlingStats()
    • clearRepositoriesStatsArchive

      public List<RepositoryStatsSnapshot> clearRepositoriesStatsArchive(long maxVersionToClear)
    • registerInternalRepository

      public void registerInternalRepository(String name, String type)
    • unregisterInternalRepository

      public void unregisterInternalRepository(String name)
    • createRepository

      public Repository createRepository(RepositoryMetadata repositoryMetadata)
      Creates a repository holder.

      WARNING: This method is intended for expert only usage mainly in plugins/modules. Please take note of the following:

      • This method does not register the repository (e.g., in the cluster state).
      • This method starts the repository. The repository should be closed after use.
      • The repository metadata should be associated to an already registered non-internal repository type and factory pair.
      Parameters:
      repositoryMetadata - the repository metadata
      Returns:
      the started repository
      Throws:
      RepositoryException - if repository type is not registered
    • validateRepositoryName

      public static void validateRepositoryName(String repositoryName)
    • getPreRestoreVersionChecks

      public List<BiConsumer<Snapshot,IndexVersion>> getPreRestoreVersionChecks()
    • doStart

      protected void doStart()
      Description copied from class: AbstractLifecycleComponent
      Start this component. Typically that means doing things like launching background processes and registering listeners on other components. Other components have been initialized by this point, but may not yet be started.

      If this method throws an exception then the startup process will fail, but this component will not be stopped before it is closed.

      This method is called while synchronized on AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, although it may not be called at all if the startup process encountered some kind of fatal error, such as the failure of some other component to initialize or start.

      Specified by:
      doStart in class AbstractLifecycleComponent
    • doStop

      protected void doStop()
      Description copied from class: AbstractLifecycleComponent
      Stop this component. Typically that means doing the reverse of whatever AbstractLifecycleComponent.doStart() does.

      This method is called while synchronized on AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, after calling AbstractLifecycleComponent.doStart(), although it will not be called at all if this component did not successfully start.

      Specified by:
      doStop in class AbstractLifecycleComponent
    • doClose

      protected void doClose() throws IOException
      Description copied from class: AbstractLifecycleComponent
      Close this component. Typically that means doing the reverse of whatever happened during initialization, such as releasing resources acquired there.

      This method is called while synchronized on AbstractLifecycleComponent.lifecycle. It is called once in the lifetime of a component. If the component was started then it will be stopped before it is closed, and once it is closed it will not be started or stopped.

      Specified by:
      doClose in class AbstractLifecycleComponent
      Throws:
      IOException