- All Implemented Interfaces:
Closeable,AutoCloseable,ClusterStateApplier,LifecycleComponent,Releasable
RepositoryMetadata in the cluster state. The cluster
state update then goes out to the rest of the cluster nodes so that all nodes know how to access the new repository. This class contains
factory information to create new repositories, and provides access to and maintains the lifecycle of repositories. New nodes can easily
find all the repositories via the cluster state after joining a cluster.
repository(ProjectId, String) can be used to fetch a repository.
createRepository(ProjectId, RepositoryMetadata) does the heavy lifting of creation.
applyClusterState(ClusterChangedEvent) handles adding and removing repositories per cluster state updates.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTask class that extracts the 'execute' part of the functionality for registering repositories.static classTask class that extracts the 'execute' part of the functionality for unregistering repositories. -
Field Summary
FieldsFields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle -
Constructor Summary
ConstructorsConstructorDescriptionRepositoriesService(Settings settings, ClusterService clusterService, Map<String, Repository.Factory> typesRegistry, Map<String, Repository.Factory> internalTypesRegistry, ThreadPool threadPool, NodeClient client, List<BiConsumer<Snapshot, IndexVersion>> preRestoreChecks) -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if new repositories appeared in or disappeared from cluster metadata and updates current list of repositories accordingly.clearRepositoriesStatsArchive(long maxVersionToClear) createNonProjectRepository(RepositoryMetadata repositoryMetadata) Similar tocreateRepository(ProjectId, RepositoryMetadata), but repository is not associated with a project, i.e.createRepository(ProjectId projectId, RepositoryMetadata repositoryMetadata) Creates a repository holder.protected voiddoClose()Close this component.protected voiddoStart()Start this component.protected voiddoStop()Stop this component.getProjectRepositories(ProjectId projectId) voidgetRepositoryData(ProjectId projectId, String repositoryName, ActionListener<RepositoryData> listener) Gets theRepositoryDatafor the given repository.static booleanstatic booleanisReadOnly(Settings repositorySettings) voidregisterInternalRepository(ProjectId projectId, String name, String type) voidregisterRepository(ProjectId projectId, PutRepositoryRequest request, ActionListener<AcknowledgedResponse> responseListener) Registers new repository in the clusterrepository(String repositoryName) Deprecated, for removal: This API element is subject to removal in a future version.repository(ProjectId projectId, String repositoryName) Returns registered repository, either internal or externalrepositoryOrNull(ProjectId projectId, String repositoryName) Similar torepository(ProjectId, String), but returnsnullinstead of throw if the repository is not found.voidunregisterInternalRepository(ProjectId projectId, String name) voidunregisterRepository(ProjectId projectId, DeleteRepositoryRequest request, ActionListener<AcknowledgedResponse> listener) Unregisters repository in the clusterstatic voidupdateRepositoryUuidInMetadata(ClusterService clusterService, ProjectId projectId, String repositoryName, RepositoryData repositoryData, ActionListener<Void> listener) Set the repository UUID in the named repository'sRepositoryMetadatato match the UUID in itsRepositoryData, which may involve a cluster state update.voidvalidateRepositoryCanBeCreated(ProjectId projectId, PutRepositoryRequest request) Ensures that we can create the repository and that it's creation actually worksstatic voidvalidateRepositoryName(String repositoryName) voidverifyRepository(ProjectId projectId, String repositoryName, ActionListener<List<DiscoveryNode>> listener) Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, start, stop
-
Field Details
-
REPOSITORIES_STATS_ARCHIVE_RETENTION_PERIOD
-
REPOSITORIES_STATS_ARCHIVE_MAX_ARCHIVED_STATS
-
COUNT_USAGE_STATS_NAME
- See Also:
-
-
Constructor Details
-
RepositoriesService
public RepositoriesService(Settings settings, ClusterService clusterService, Map<String, Repository.Factory> typesRegistry, Map<String, Repository.Factory> internalTypesRegistry, ThreadPool threadPool, NodeClient client, List<BiConsumer<Snapshot, IndexVersion>> preRestoreChecks)
-
-
Method Details
-
registerRepository
public void registerRepository(ProjectId projectId, PutRepositoryRequest request, ActionListener<AcknowledgedResponse> responseListener) Registers new repository in the clusterThis 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 a new repository to cluster metadata.
- Parameters:
projectId- the project ID to which the repository belongs.request- register repository requestresponseListener- register repository listener
-
validateRepositoryCanBeCreated
Ensures that we can create the repository and that it's creation actually worksThis verification method will create and then close the repository we want to create.
- Parameters:
request-
-
updateRepositoryUuidInMetadata
public static void updateRepositoryUuidInMetadata(ClusterService clusterService, ProjectId projectId, String repositoryName, RepositoryData repositoryData, ActionListener<Void> listener) Set the repository UUID in the named repository'sRepositoryMetadatato match the UUID in itsRepositoryData, which may involve a cluster state update.- Parameters:
listener- notified when theRepositoryMetadatais updated, possibly on this thread or possibly on the master service thread
-
unregisterRepository
public void unregisterRepository(ProjectId projectId, DeleteRepositoryRequest request, ActionListener<AcknowledgedResponse> listener) Unregisters repository in the clusterThis method can be only called on the master node. It removes repository information from cluster metadata.
- Parameters:
projectId- project to look for the repositoryrequest- unregister repository requestlistener- unregister repository listener
-
verifyRepository
public void verifyRepository(ProjectId projectId, String repositoryName, ActionListener<List<DiscoveryNode>> listener) -
isDedicatedVotingOnlyNode
-
applyClusterState
Checks if new repositories appeared in or disappeared from cluster metadata and updates current list of repositories accordingly.- Specified by:
applyClusterStatein interfaceClusterStateApplier- Parameters:
event- cluster changed event
-
getRepositoryData
public void getRepositoryData(ProjectId projectId, String repositoryName, ActionListener<RepositoryData> listener) Gets theRepositoryDatafor the given repository.- Parameters:
projectId- project to look for the repositoryrepositoryName- repository namelistener- listener to passRepositoryDatato
-
repository
Deprecated, for removal: This API element is subject to removal in a future version.Returns registered repository, either internal or external- Parameters:
repositoryName- repository name- Returns:
- registered repository
- Throws:
RepositoryMissingException- if repository with such name isn't registered
-
repository
Returns registered repository, either internal or external- Parameters:
projectId- the project to look for the repositoryrepositoryName- repository name- Returns:
- registered repository
- Throws:
RepositoryMissingException- if repository with such name isn't registered
-
repositoryOrNull
Similar torepository(ProjectId, String), but returnsnullinstead of throw if the repository is not found. -
getRepositories
- Returns:
- the current collection of registered repositories from all projects.
-
getProjectRepositories
- Returns:
- the current collection of registered repositories for the given project, keyed by name.
-
repositoriesStats
-
getRepositoriesThrottlingStats
-
clearRepositoriesStatsArchive
-
registerInternalRepository
-
unregisterInternalRepository
-
createRepository
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:
projectId- the project that the repository is associated withrepositoryMetadata- the repository metadata- Returns:
- the started repository
- Throws:
RepositoryException- if repository type is not registered
-
createNonProjectRepository
Similar tocreateRepository(ProjectId, RepositoryMetadata), but repository is not associated with a project, i.e. the repository is at the cluster level. -
validateRepositoryName
-
isReadOnly
-
getPreRestoreVersionChecks
-
getUsageStats
-
doStart
protected void doStart()Description copied from class:AbstractLifecycleComponentStart 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:
doStartin classAbstractLifecycleComponent
-
doStop
protected void doStop()Description copied from class:AbstractLifecycleComponentStop this component. Typically that means doing the reverse of whateverAbstractLifecycleComponent.doStart()does.This method is called while synchronized on
AbstractLifecycleComponent.lifecycle. It is only called once in the lifetime of a component, after callingAbstractLifecycleComponent.doStart(), although it will not be called at all if this component did not successfully start.- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
Description copied from class:AbstractLifecycleComponentClose 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:
doClosein classAbstractLifecycleComponent- Throws:
IOException
-