Annotation Type OMLayoutVersionValidator
An annotation to mark methods that do certain request validations based on the
server's layout version and capability to perform a certain operation.
The methods annotated with this annotation are collected by the
ValidatorRegistry class during the initialization of the server.
The conditions describe the specific use case in which the validator should be
applied to the request.
See VersionExtractor for getting all the supported different Versioned
component's actual version.
The validator method will be applied to the specified request type(s).
To help keep these methods simple and straightforward use inheritance and annotate
the override method that just calls the method defined in the parent instead of specifying
multiple request types.
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 is an
OzoneManagerProtocolProtos.OMRequest
- the second parameter is a 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 ElementDescriptionThe version before which the validator needs to 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.Type[]The type(s) of the request(s) handled by this validator method.
-
Element Details
-
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(s) of the request(s) handled by this validator method. In case you are considering to specify multiple request types, please read the note above on using multiple request types with this kind of validator method.- Returns:
- the requestType(s) onto which the validator should be applied
-
applyBefore
OMLayoutFeature applyBeforeThe version before which the validator needs to run. The validator will run only for requests having a version which precedes the specified version.
-