Module org.elasticsearch.server
Class DefaultProjectResolver
java.lang.Object
org.elasticsearch.cluster.project.DefaultProjectResolver
- All Implemented Interfaces:
ProjectIdResolver,ProjectResolver
This is the
ProjectResolver implementation that stateful uses.
It mainly ensures that there's a single and implicit project existing at all times.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E extends Exception>
voidexecuteOnProject(ProjectId projectId, CheckedRunnable<E> body) Execute a block in the context of a specific project.Retrieve the project for the current request.getProjectIds(ClusterState clusterState) Returns the identifiers of all projects on which this request should operate.getProjectMetadata(Metadata metadata) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.cluster.project.ProjectIdResolver
supportsMultipleProjectsMethods inherited from interface org.elasticsearch.cluster.project.ProjectResolver
getProjectMetadata, getProjectState, hasProject, hasProject
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
DefaultProjectResolver
public DefaultProjectResolver()
-
-
Method Details
-
getProjectMetadata
- Specified by:
getProjectMetadatain interfaceProjectResolver
-
getProjectId
Description copied from interface:ProjectIdResolverRetrieve the project for the current request.- Specified by:
getProjectIdin interfaceProjectIdResolver- Returns:
- The identifier of the current project.
-
getProjectIds
Description copied from interface:ProjectResolverReturns 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
- Specified by:
getProjectIdsin interfaceProjectResolver- Returns:
- A readonly collection of all the project ids on which this request should operate
- If the request is tied to a single project, then a collection with a single item that is the same as
-
executeOnProject
public <E extends Exception> void executeOnProject(ProjectId projectId, CheckedRunnable<E> body) throws E Description copied from interface:ProjectResolverExecute 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()orProjectResolver.getProjectMetadata(Metadata)) will return the project specified byprojectId. - Executes the
CheckedRunnable.run()method on the suppliedbody - Restores the context to its original state
- Specified by:
executeOnProjectin interfaceProjectResolver- Throws:
E
- Configures the execution (thread) context so that any calls to resolve a project (e.g.
-