- All Superinterfaces:
ProjectIdResolver
- All Known Implementing Classes:
AbstractProjectResolver
,DefaultProjectResolver
This exposes methods for accessing project-scoped data from the global one.
The project in question is implied from the thread context.
-
Method Summary
Modifier and TypeMethodDescription<E extends Exception>
voidexecuteOnProject
(ProjectId projectId, CheckedRunnable<E> body) Execute a block in the context of a specific project.default Collection
<ProjectId> getProjectIds
(ClusterState clusterState) Returns the identifiers of all projects on which this request should operate.default ProjectMetadata
getProjectMetadata
(ClusterState clusterState) default ProjectMetadata
getProjectMetadata
(Metadata metadata) default ProjectState
getProjectState
(ClusterState clusterState) default boolean
hasProject
(ClusterState clusterState) default boolean
hasProject
(Metadata metadata) Methods inherited from interface org.elasticsearch.cluster.project.ProjectIdResolver
getProjectId, supportsMultipleProjects
-
Method Details
-
getProjectMetadata
-
getProjectMetadata
-
hasProject
-
hasProject
-
getProjectState
-
getProjectIds
Returns the identifiers of all projects on which this request should operate. In practice, this will either be:- If the request is tied to a single project, then a collection with a single item that is the same as
ProjectIdResolver.getProjectId()
if the project exists in the cluster state - If the request is not tied to a single project and it is allowed to access all projects, then a collection of all the project ids in the cluster
- Otherwise an exception is thrown
- Returns:
- A readonly collection of all the project ids on which this request should operate
- Throws:
SecurityException
- if this request is required to provide a project id, but none was provided
- If the request is tied to a single project, then a collection with a single item that is the same as
-
executeOnProject
Execute a block in the context of a specific project. This method:- Configures the execution (thread) context so that any calls to resolve a project (e.g.
ProjectIdResolver.getProjectId()
orgetProjectMetadata(Metadata)
) will return the project specified byprojectId
. - Executes the
CheckedRunnable.run()
method on the suppliedbody
- Restores the context to its original state
- Throws:
IllegalStateException
- If there is already a project-id set in the execution context. It is an error to attempt to override the active project-idE
- Configures the execution (thread) context so that any calls to resolve a project (e.g.
-