fapifta commented on code in PR #7603:
URL: https://github.com/apache/ozone/pull/7603#discussion_r1987196252


##########
hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/RegisterValidatorProcessor.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ozone.annotations;
+
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.ArrayType;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.util.Elements;
+import javax.lang.model.util.Types;
+import javax.tools.Diagnostic;
+
+/**
+ * This class is an annotation processor that is hooked into the java compiler
+ * and is used to validate the RegisterValidator annotations in the
+ * codebase, to ensure that the annotated classes have the proper methods 
returning appropriate object types.
+ *
+ * The module is compiled in a different execution via Maven before anything

Review Comment:
   The preprocessor apidoc change for the OmRequestFeatureValidatorProcessor 
should be applied here also.



##########
hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/OmRequestFeatureValidatorProcessor.java:
##########


Review Comment:
   This is not related to this PR directly, but as we adding a new annotation 
preprocessor and the second part of the class api doc is copied to the new 
class, let's address the earlier change in the build in the class' api doc 
please.
   
   In the current build, the annotation processors are directly specified to 
only those modules where the annotation is intended to be used, and it happens 
with the general build. This is also visible in the 
hadoop-ozone/ozone-manager/pom.xml change. So there is no ServiceLoader in 
action anymore, and these annotation preprocessors along with the actual 
enablement of the use of the related annotation is controlled by the pom.xml of 
all individual modules, while in the project pom it is disabled for all modules 
that does not enable it.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types

Review Comment:
   ```suggestion
    * The validator method will be applied to the specified request type(s).
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.
+ *
+ * The annotated methods have to have a fixed signature.
+ * A {@link 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

Review Comment:
   ```suggestion
    * - the first parameter is an
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.

Review Comment:
   ```suggestion
    * To help keep these methods simple and straightforward, use one method for 
multiple requests only If
    *  you use the same validation code for different requests like bulk 
reject, in this case specify all the
    * request types to which the validation applies in an array.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.
+ *
+ * The annotated methods have to have a fixed signature.
+ * A {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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
+ * - similarly 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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMClientVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied

Review Comment:
   ```suggestion
      * The type(s) of the request(s) handled by this validator method.
      * @return the requestType(s) onto which the validator should be applied
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied to just one specific request type

Review Comment:
   ```suggestion
    * The validator method will be applied to the specified request type(s).
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link ValidatorRegistry} class during the initialization of the server.
+ *
+ * The conditions specify the specific use case in which the validator should 
be

Review Comment:
   ```suggestion
    * The conditions describe the specific use case in which the validator 
should be
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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 {@link 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

Review Comment:
   ```suggestion
    * - the first parameter is an
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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 {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link ValidationContext}

Review Comment:
   ```suggestion
    * - the second parameter is a {@link ValidationContext}
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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 {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMLayoutVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied
+   */
+  Type[] requestType();
+
+  /**
+   * The max version for which the validator would run. The validator would 
run for the request
+   * where the version is older than the excluding of the specified version.
+   * @returns the max layout version until which the validator runs excluding 
the specified version itself.

Review Comment:
   ```suggestion
      * @returns the exclusive upper bound of the request's version under which 
the validator is applicable.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.
+ *
+ * The annotated methods have to have a fixed signature.
+ * A {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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
+ * - similarly 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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMClientVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied
+   */
+  Type[] requestType();
+
+  /**
+   * The max version for which the validator would run. The validator would 
run for the request
+   * where the version is older than the excluding of the specified version.

Review Comment:
   ```suggestion
      * The version before which the validator needs to run. The validator will 
run only for requests
      * having a version which precedes the specified version.
   ```



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/request/validation/package-info.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Request's validation handling.
+ *
+ * This package holds facilities to add new situation specific behaviour to
+ * request handling without cluttering the basic logic of the request handler
+ * code for any server.
+ * {@link org.apache.hadoop.ozone.request.validation.RegisterValidator}
+ * is used to register any validator which has the following methods:
+ * - applyBefore : Returns an enum which implement {@link 
org.apache.hadoop.ozone.Versioned}
+ * - requestType: Returns an Enum value.
+ * - processingPhase: Returns {@link 
org.apache.hadoop.ozone.request.validation.RequestProcessingPhase}
+ *
+ * The system uses a reflection based discovery to find methods that are
+ * annotated with the
+ * {@link org.apache.hadoop.ozone.request.validation.RegisterValidator}
+ * annotation.
+ * This annotation is used to register a particular annotation which inturn 
would be used to specify conditions in
+ * which a certain validator has to be used, the request type to which the 
validation should be applied,
+ * and the request processing phase in which we apply the validation and the 
maxVersion corresponding to which this
+ * is supposed to run.

Review Comment:
   ```suggestion
    * The system uses a reflection based discovery to find methods that are
    * annotated with an annotation annotated with the
    * {@link org.apache.hadoop.ozone.request.validation.RegisterValidator}
    * annotation.
    * The RegisterValidator annotation is used to register a particular 
annotation which in turn would be used
    * to specify conditions in which a certain validator has to be used:
    * - the request type onto which the validation should be applied,
    * - the request processing phase in which the validation should be applied
    * - and the layout version before which the validation should be applied.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link ValidatorRegistry} class during the initialization of the server.
+ *
+ * The conditions specify the specific use case in which the validator should 
be

Review Comment:
   ```suggestion
    * The conditions describe the specific use case in which the validator 
should be
   ```



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/request/validation/package-info.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Request's validation handling.
+ *
+ * This package holds facilities to add new situation specific behaviour to
+ * request handling without cluttering the basic logic of the request handler
+ * code for any server.
+ * {@link org.apache.hadoop.ozone.request.validation.RegisterValidator}
+ * is used to register any validator which has the following methods:
+ * - applyBefore : Returns an enum which implement {@link 
org.apache.hadoop.ozone.Versioned}

Review Comment:
   ```suggestion
    * - applyBefore : Returns an enum which implements {@link 
org.apache.hadoop.ozone.Versioned}
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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.

Review Comment:
   ```suggestion
    * 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.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.
+ *
+ * The annotated methods have to have a fixed signature.
+ * A {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link ValidationContext}

Review Comment:
   ```suggestion
    * - the second parameter is a {@link ValidationContext}
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.

Review Comment:
   ```suggestion
    * applied to the request.
    * See {@link VersionExtractor} for getting all the supported different 
{@link org.apache.hadoop.ozone.Versioned} component's actual version.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.

Review Comment:
   ```suggestion
    * applied to the request.
    * See {@link VersionExtractor} for getting all the supported different 
{@link org.apache.hadoop.ozone.Versioned} component's actual version.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMClientVersionValidator.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * An annotation to mark methods that do certain request validations based on 
the
+ * request protocol's client version.
+ *
+ * The methods annotated with this annotation are collected by the
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * The validator method should be applied the specified request types
+ * to help keep these methods simple and straightforward. If you want to use
+ * the same validation for different requests just put it as part of the lists 
of request types.
+ *
+ * The annotated methods have to have a fixed signature.
+ * A {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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
+ * - similarly 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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMClientVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied
+   */
+  Type[] requestType();
+
+  /**
+   * The max version for which the validator would run. The validator would 
run for the request
+   * where the version is older than the excluding of the specified version.
+   * @returns the max client version until which the validator runs excluding 
the specified version itself.

Review Comment:
   ```suggestion
      * @returns the exclusive upper bound of the request's version under which 
the validator is applicable.
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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 {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMLayoutVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied

Review Comment:
   ```suggestion
      * The 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.
      * @return the requestType(s) onto which the validator should be applied
   ```



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/validation/OMLayoutVersionValidator.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.om.request.validation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type;
+import org.apache.hadoop.ozone.request.validation.RegisterValidator;
+import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase;
+
+/**
+ * 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
+ * {@link 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 {@link VersionExtractor} for getting all the 
supported different
+ * {@link org.apache.hadoop.ozone.Versioned}.
+ * 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 {@link 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
+ * {@link
+ * org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest}
+ * - the second parameter of type {@link 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 {@link RequestProcessingPhase#POST_PROCESS} phase method is running once
+ * the
+ * {@link
+ * 
org.apache.hadoop.ozone.protocol.proto.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.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@RegisterValidator
+public @interface OMLayoutVersionValidator {
+
+  /**
+   * Defines if the validation has to run before or after the general request
+   * processing.
+   * @return if this is a pre or post processing validator
+   */
+  RequestProcessingPhase processingPhase();
+
+  /**
+   * The type of the request handled by this validator method.
+   * @return the requestType to whihc the validator should be applied
+   */
+  Type[] requestType();
+
+  /**
+   * The max version for which the validator would run. The validator would 
run for the request
+   * where the version is older than the excluding of the specified version.

Review Comment:
   ```suggestion
      * The version before which the validator needs to run. The validator will 
run only for requests
      * having a version which precedes the specified version.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to