Annotation Type RequestFeatureValidator
An annotation to mark methods that do certain request validations.
The methods annotated with this annotation are collected by the
ValidatorRegistry class during the initialization of the server.
The conditions specify the specific use case in which the validator should be
applied to the request. See ValidationCondition for more details
on the specific conditions.
The validator method should be applied to just one specific request type
to help keep these methods simple and straightforward. If you want to use
the same validation for different request types, use inheritance, and
annotate the override method that just calls super.
Note that the aim is to have these validators together with the request
processing code, so the handling of these specific situations are easy to
find.
The annotated methods have to have a fixed signature.
A RequestProcessingPhase.PRE_PROCESS phase method is running before
the request is processed by the regular code.
Its signature has to be the following:
- it has to be static and idempotent
- it has to have two parameters
- the first parameter it is an
OzoneManagerProtocolProtos.OMRequest
- the second parameter of type ValidationContext
- the method has to return the modified request, or throw a ServiceException
in case the request is considered to be invalid
- the method does not need to care about preserving the request it gets,
the original request is captured and saved by the calling environment.
A RequestProcessingPhase.POST_PROCESS phase method is running once
the
OzoneManagerProtocolProtos.OMResponse
is calculated for a given request.
Its signature has to be the following:
- it has to be static and idempotent
- it has three parameters
- similalry to the pre-processing validators, first parameter is the
OMRequest, the second parameter is the OMResponse, and the third
parameter is a ValidationContext.
- the method has to return the modified OMResponse or throw a
ServiceException if the request is considered invalid based on response.
- the method gets the request object that was supplied for the general
request processing code, not the original request, while it gets a copy
of the original response object provided by the general request processing
code.-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionRuntime conditions in which a validator should run.org.apache.hadoop.ozone.request.validation.RequestProcessingPhaseDefines if the validation has to run before or after the general request processing.org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.TypeThe type of the request handled by this validator method.
-
Element Details
-
conditions
ValidationCondition[] conditionsRuntime conditions in which a validator should run.- Returns:
- a list of conditions when the validator should be applied
-
processingPhase
org.apache.hadoop.ozone.request.validation.RequestProcessingPhase processingPhaseDefines if the validation has to run before or after the general request processing.- Returns:
- if this is a pre or post processing validator
-
requestType
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type requestTypeThe type of the request handled by this validator method.- Returns:
- the requestType to whihc the validator shoudl be applied
-