Module org.elasticsearch.server
Class AbstractProjectResolver
java.lang.Object
org.elasticsearch.cluster.project.AbstractProjectResolver
- All Implemented Interfaces:
ProjectIdResolver,ProjectResolver
A
ProjectResolver that uses Task.X_ELASTIC_PROJECT_ID_HTTP_HEADER to find the active project-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleanallowAccessToAllProjects(ThreadContext threadContext) Returnstrueif the current request is permitted to perform operations on all projects,falseotherwise.<E extends Exception>
voidexecuteOnProject(ProjectId projectId, CheckedRunnable<E> body) Execute a block in the context of a specific project.protected static ProjectMetadatafindProject(Metadata metadata, String headerValue) protected abstract ProjectIdSubclasses should override this method to handle the case where no project id is specified in the thread context.Retrieve the project for the current request.protected StringgetProjectIds(ClusterState clusterState) Returns the identifiers of all projects on which this request should operate.booleanReturnsfalseif the cluster runs in a setup that always expects only a single default project (see alsoMetadata.DEFAULT_PROJECT_ID).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.ProjectResolver
getProjectMetadata, getProjectMetadata, getProjectState, hasProject, hasProject
-
Constructor Details
-
AbstractProjectResolver
-
-
Method Details
-
getFallbackProjectId
Subclasses should override this method to handle the case where no project id is specified in the thread context. This may return a default project id or throw an exception -
allowAccessToAllProjects
Returnstrueif the current request is permitted to perform operations on all projects,falseotherwise. -
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.
-
supportsMultipleProjects
public boolean supportsMultipleProjects()Description copied from interface:ProjectIdResolverReturnsfalseif the cluster runs in a setup that always expects only a single default project (see alsoMetadata.DEFAULT_PROJECT_ID). Otherwise, it should returntrueto indicate the cluster can accommodate multiple projects regardless how many project it current has.- Specified by:
supportsMultipleProjectsin interfaceProjectIdResolver
-
findProject
-
getProjectIdFromThreadContext
-