Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bde95f7
HDDS-11149. Add a maximum client version in the RequestFeatureValidat…
swamirishi Jul 12, 2024
f1676be
HDDS-11149. Set conditions default value to {}
swamirishi Jul 12, 2024
b77d1bf
Merge remote-tracking branch 'origin/master' into HDDS-11149
adoroszlai Jul 12, 2024
561d010
HDDS-11149. Create Base validator for generic version validation
swamirishi Jul 15, 2024
363d9fa
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi Jul 15, 2024
e623fdb
HDDS-11149. Add register validator processor
swamirishi Jul 15, 2024
b270bf6
HDDS-11149. Fix checkstyle
swamirishi Jul 15, 2024
ca3746d
HDDS-11149. Fix findbugs & rat failures
swamirishi Jul 17, 2024
a84749b
HDDS-11149. Move to enum maps
swamirishi Jul 18, 2024
fc57929
HDDS-11149. Move validation to ozone-common and fix docs
swamirishi Jul 19, 2024
778229a
HDDS-11149. Fix typo while extracting version
swamirishi Jul 29, 2024
9cf34be
HDDS-11149. Address review comments
swamirishi Aug 12, 2024
66027c2
HDDS-11149. Change method name
swamirishi Dec 17, 2024
dc9f93b
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi Dec 17, 2024
c33f78e
Revert "HDDS-11132. Revert client version bump done as part of HDDS-1…
swamirishi Dec 18, 2024
a394670
HDDS-11149. Address review comments
swamirishi Dec 18, 2024
d024eb9
HDDS-11149. Address review comments
swamirishi Dec 18, 2024
889e081
HDDS-11149. Address review comments
swamirishi Dec 18, 2024
436dfbd
HDDS-11149. Fix findbugs
swamirishi Dec 18, 2024
c1b690d
HDDS-11149. Fix annotation processor
swamirishi Dec 18, 2024
b9ef7d0
HDDS-11149. Fix annotation processor
swamirishi Dec 18, 2024
ba133d2
HDDS-11149. Fix package scanner prefix
swamirishi Dec 18, 2024
df698f8
HDDS-11149. Fix package scanner prefix
swamirishi Dec 19, 2024
0b5ceb5
HDDS-11149. Fix version values
swamirishi Dec 19, 2024
db76527
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi Dec 19, 2024
49efb20
HDDS-11963. Unify client version and layout version under one interfa…
swamirishi Dec 19, 2024
b819b63
HDDS-11963. Fix rat failure
swamirishi Dec 19, 2024
bfa7618
HDDS-11963. Address review comments
swamirishi Dec 19, 2024
ded3450
HDDS-11963. Address review comments
swamirishi Dec 19, 2024
568603e
Merge remote-tracking branch 'origin/HDDS-11963' into HEAD
swamirishi Dec 19, 2024
2124f03
HDDS-11149. Merge with master
swamirishi Dec 19, 2024
4004663
HDDS-11149. Change validator key
swamirishi Dec 20, 2024
2337f72
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi Dec 20, 2024
56e95eb
HDDS-11149. Fix test case
swamirishi Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you have added the methods to validate the max version, but those methods are not used anywhere in the processor itself, therefore if an invalid value is present (FUTURE_VERSION), the processor does not emit an error message in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the annotation processor to validate all that? I would rather put this check someplace else. Probably in a place like https://github.com/swamirishi/ozone/blob/fc57929908cbb05a6304366e67f64317dbf9505d/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/request/validation/ValidatorRegistry.java#L85-L88 where instead of just a set of allowedVersionTypes. I would pass a Map of version class to the allowed values. What do you think of that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed this reply...

The goal of the annotation processor is to signal erroneously annotated methods at compile time, so if this is testable properly, then I would prefer to cause a compile time error, as runtime issues may or may not be detected in the future, especially if you look at our compat tests, that are not really testing whether the actual validators are properly applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need not validate versions. We should allow future version validators as well. In that case we should just execute future versions. When the version is negative we run validators which match exactly that version.

return req.getVersion() > ClientVersion.CURRENT_VERSION ?
ClientVersion.FUTURE_VERSION : ClientVersion.fromProtoValue(req.getVersion());

.map(indexedMethods -> requestVersion.version() < 0 ?
indexedMethods.getItemsEqualToIdx(requestVersion.version()) :
indexedMethods.getItemsGreaterThanIdx(requestVersion.version()))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of disagree here still...
In the actual codebase, you can not specify a version that is not part of the enum already as you use the enum.
To define a future version validator correctly, you need to see into the future, which does not seem to be possibile.

So, even though it is probably not something one would do, but I think we may validate that at compile time.
I accept if we don't, but the only invalid value that can be specified is the FUTURE_VERSION as of now, so why not?

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.SimpleAnnotationValueVisitor8;
import javax.tools.Diagnostic;
import java.util.Arrays;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
Expand All @@ -50,14 +51,11 @@
* META-INF/services/javax.annotation.processing.Processor file in the module's
* resources folder.
*/
@SupportedAnnotationTypes(
"org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator")
@SupportedAnnotationTypes({
"org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator",
"org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator"})
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class RequestFeatureValidatorProcessor extends AbstractProcessor {

public static final String ERROR_CONDITION_IS_EMPTY =
"RequestFeatureValidator has an empty condition list. Please define the"
+ " ValidationCondition in which the validator has to be applied.";
public class OmRequestFeatureValidatorProcessor extends AbstractProcessor {
public static final String ERROR_ANNOTATED_ELEMENT_IS_NOT_A_METHOD =
"RequestFeatureValidator annotation is not applied to a method.";
public static final String ERROR_VALIDATOR_METHOD_HAS_TO_BE_STATIC =
Expand Down Expand Up @@ -90,8 +88,8 @@ public class RequestFeatureValidatorProcessor extends AbstractProcessor {
public static final String VALIDATION_CONTEXT_CLASS_NAME =
"org.apache.hadoop.ozone.om.request.validation.ValidationContext";

public static final String ANNOTATION_SIMPLE_NAME = "RequestFeatureValidator";
public static final String ANNOTATION_CONDITIONS_PROPERTY_NAME = "conditions";
private static final List<String> ANNOTATION_SIMPLE_NAMES = Arrays.asList("OMClientVersionValidator",
"OMLayoutVersionValidator");
public static final String ANNOTATION_PROCESSING_PHASE_PROPERTY_NAME =
"processingPhase";

Expand All @@ -104,7 +102,7 @@ public class RequestFeatureValidatorProcessor extends AbstractProcessor {
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
if (!annotation.getSimpleName().contentEquals(ANNOTATION_SIMPLE_NAME)) {
if (!ANNOTATION_SIMPLE_NAMES.contains(annotation.getSimpleName().toString())) {
continue;
}
processElements(roundEnv.getElementsAnnotatedWith(annotation));
Expand Down Expand Up @@ -172,7 +170,7 @@ private void ensurePostProcessorReturnsOMResponse(
ExecutableElement elem, boolean isPreprocessor) {
if (!isPreprocessor && !elem.getReturnType().toString()
.equals(OM_RESPONSE_CLASS_NAME)) {
emitErrorMsg(ERROR_VALIDATOR_METHOD_HAS_TO_RETURN_OMRESPONSE);
emitErrorMsg(ERROR_VALIDATOR_METHOD_HAS_TO_RETURN_OMRESPONSE + " " + elem.getSimpleName());
}
}

Expand Down Expand Up @@ -201,10 +199,6 @@ private boolean checkAndEvaluateAnnotation(
boolean isPreprocessor = false;
for (Entry<? extends ExecutableElement, ? extends AnnotationValue>
entry : methodAnnotation.getElementValues().entrySet()) {

if (hasInvalidValidationCondition(entry)) {
emitErrorMsg(ERROR_CONDITION_IS_EMPTY);
}
if (isProcessingPhaseValue(entry)) {
isPreprocessor = evaluateProcessingPhase(entry);
}
Expand All @@ -228,11 +222,6 @@ private boolean isProcessingPhaseValue(
return isPropertyNamedAs(entry, ANNOTATION_PROCESSING_PHASE_PROPERTY_NAME);
}

private boolean hasInvalidValidationCondition(
Entry<? extends ExecutableElement, ? extends AnnotationValue> entry) {
return isPropertyNamedAs(entry, ANNOTATION_CONDITIONS_PROPERTY_NAME)
&& !visit(entry, new ConditionValidator());
}

private boolean isPropertyNamedAs(
Entry<? extends ExecutableElement, ? extends AnnotationValue> entry,
Expand All @@ -246,24 +235,6 @@ private <T> T visit(
return entry.getValue().accept(visitor, null);
}

private static class ConditionValidator
extends SimpleAnnotationValueVisitor8<Boolean, Void> {

ConditionValidator() {
super(Boolean.TRUE);
}

@Override
public Boolean visitArray(List<? extends AnnotationValue> vals,
Void unused) {
if (vals.isEmpty()) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}

}

private static class ProcessingPhaseVisitor
extends SimpleAnnotationValueVisitor8<String, Void> {

Expand Down
Original file line number Diff line number Diff line change
@@ -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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 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;
import java.util.Set;

/**
* 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
* else is compiled, and then javac picks this class up as an annotation
* processor from the classpath via a ServiceLoader, based on the
* META-INF/services/javax.annotation.processing.Processor file in the module's
* resources folder.
*/
@SupportedAnnotationTypes("org.apache.hadoop.ozone.request.validation.RegisterValidator")
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class RegisterValidatorProcessor extends AbstractProcessor {

public static final String ANNOTATION_SIMPLE_NAME = "RegisterValidator";
public static final String VERSION_CLASS_NAME = "org.apache.hadoop.ozone.Version";
public static final String REQUEST_PROCESSING_PHASE_CLASS_NAME = "org.apache.hadoop.ozone.om.request.validation" +
".RequestProcessingPhase";
public static final String APPLY_BEFORE_METHOD_NAME = "applyBefore";
public static final String REQUEST_TYPE_METHOD_NAME = "requestType";
public static final String PROCESSING_PHASE_METHOD_NAME = "processingPhase";

public static final String MAX_VERSION_NOT_FOUND_ERROR_MESSAGE = "Method " + APPLY_BEFORE_METHOD_NAME +
" returning an enum implementing " + VERSION_CLASS_NAME + " not found";
public static final String REQUEST_TYPE_NOT_FOUND_ERROR_MESSAGE = "Method " + REQUEST_TYPE_METHOD_NAME +
" returning an enum not found";
public static final String PROCESSING_PHASE_NOT_FOUND_ERROR_MESSAGE = "Method " + PROCESSING_PHASE_METHOD_NAME
+ " returning an enum implementing " + REQUEST_PROCESSING_PHASE_CLASS_NAME + " not found";

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
for (TypeElement annotation : annotations) {
if (!annotation.getSimpleName().contentEquals(ANNOTATION_SIMPLE_NAME)) {
continue;
}
processElements(roundEnv.getElementsAnnotatedWith(annotation));
}
return false;
}

private boolean validateArrayMethod(ExecutableElement method, String expectedMethodName,
ElementKind expectedReturnType,
String expectedReturnClass) {
Elements elementUtils = processingEnv.getElementUtils();
Types types = processingEnv.getTypeUtils();
TypeElement expectedReturnInterface = expectedReturnClass == null || expectedReturnClass.equals("") ? null :
elementUtils.getTypeElement(expectedReturnClass);
return method.getSimpleName().toString().equals(expectedMethodName) && (expectedReturnType == null ||
TypeKind.ARRAY.equals(method.getReturnType().getKind()) &&
types.asElement(((ArrayType)method.getReturnType()).getComponentType()).getKind() == expectedReturnType) &&
(expectedReturnInterface == null ||
types.isAssignable(types.asElement(method.getReturnType()).asType(), expectedReturnInterface.asType()));
}

private boolean validateMethod(ExecutableElement method, String expectedMethodName, ElementKind expectedReturnType,
String expectedReturnClass) {
Elements elementUtils = processingEnv.getElementUtils();
Types types = processingEnv.getTypeUtils();
TypeElement expectedReturnInterface = expectedReturnClass == null || expectedReturnClass.equals("") ? null :
elementUtils.getTypeElement(expectedReturnClass);
return method.getSimpleName().toString().equals(expectedMethodName) && (expectedReturnType == null ||
types.asElement(method.getReturnType()) != null &&
types.asElement(method.getReturnType()).getKind() == expectedReturnType) &&
(expectedReturnInterface == null ||
types.isAssignable(types.asElement(method.getReturnType()).asType(), expectedReturnInterface.asType()));
}

private void processElements(Set<? extends Element> annotatedElements) {
for (Element element : annotatedElements) {
if (element.getKind().equals(ElementKind.ANNOTATION_TYPE)) {
boolean hasApplyBeforeMethod = false;
boolean hasRequestType = false;
boolean hasRequestProcessPhase = false;
for (Element enclosedElement : element.getEnclosedElements()) {
// Check if the annotation has a method called "validatorName" returning a String
if (enclosedElement instanceof ExecutableElement) {
ExecutableElement method = (ExecutableElement) enclosedElement;
hasApplyBeforeMethod = hasApplyBeforeMethod || validateMethod(method, APPLY_BEFORE_METHOD_NAME,
ElementKind.ENUM, VERSION_CLASS_NAME);
hasRequestType = hasRequestType || validateArrayMethod(method, REQUEST_TYPE_METHOD_NAME, ElementKind.ENUM,
null);
hasRequestProcessPhase = hasRequestProcessPhase || validateMethod(method, PROCESSING_PHASE_METHOD_NAME,
ElementKind.ENUM, REQUEST_PROCESSING_PHASE_CLASS_NAME);
}
}
if (!hasApplyBeforeMethod) {
emitErrorMsg(MAX_VERSION_NOT_FOUND_ERROR_MESSAGE + " for " +
element.getSimpleName().toString());
}
if (!hasRequestType) {
emitErrorMsg(REQUEST_TYPE_NOT_FOUND_ERROR_MESSAGE + " for " +
element.getSimpleName().toString());
}
if (!hasRequestProcessPhase) {
emitErrorMsg(PROCESSING_PHASE_NOT_FOUND_ERROR_MESSAGE + " for " +
element.getSimpleName().toString());
}
}
}
}


private void emitErrorMsg(String s) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, s);
}
}
3 changes: 2 additions & 1 deletion hadoop-hdds/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<restrictImports>
<reason>Only selected annotation processors are enabled, see configuration of maven-compiler-plugin.</reason>
<bannedImports>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.hdds.scm.metadata.Replicate</bannedImport>
<bannedImport>org.kohsuke.MetaInfServices</bannedImport>
</bannedImports>
Expand Down
3 changes: 2 additions & 1 deletion hadoop-hdds/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<restrictImports>
<reason>Only selected annotation processors are enabled, see configuration of maven-compiler-plugin.</reason>
<bannedImports>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.hdds.scm.metadata.Replicate</bannedImport>
<bannedImport>org.kohsuke.MetaInfServices</bannedImport>
</bannedImports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public enum ClientVersion implements ComponentVersion {
"This client version has support for Object Store and File " +
"System Optimized Bucket Layouts."),

EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST(4,
"This client version enforces replica index is set for fixing read corruption that could occur when " +
"replicaIndex parameter is not validated before EC block reads."),

FUTURE_VERSION(-1, "Used internally when the server side is older and an"
+ " unknown client version has arrived from the client.");

Expand Down
3 changes: 2 additions & 1 deletion hadoop-hdds/container-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<restrictImports>
<reason>Only selected annotation processors are enabled, see configuration of maven-compiler-plugin.</reason>
<bannedImports>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.hdds.scm.metadata.Replicate</bannedImport>
<bannedImport>org.kohsuke.MetaInfServices</bannedImport>
</bannedImports>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import static org.apache.hadoop.hdds.scm.protocolPB.ContainerCommandResponseBuilders.putBlockResponseSuccess;
import static org.apache.hadoop.hdds.scm.protocolPB.ContainerCommandResponseBuilders.unsupportedRequest;
import static org.apache.hadoop.hdds.scm.utils.ClientCommandsUtils.getReadChunkVersion;
import static org.apache.hadoop.ozone.ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST;
import static org.apache.hadoop.ozone.OzoneConsts.INCREMENTAL_CHUNK_LIST;
import static org.apache.hadoop.ozone.container.common.interfaces.Container.ScanResult;

Expand Down Expand Up @@ -665,6 +666,15 @@ ContainerCommandResponseProto handleEcho(
return getEchoResponse(request);
}

/**
* Checks if a replicaIndex needs to be checked based on the client version for a request.
* @param request ContainerCommandRequest object.
* @return true if the validation is required for the client version else false.
*/
private boolean replicaIndexCheckRequired(ContainerCommandRequestProto request) {
return request.hasVersion() && request.getVersion() >= EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue();
}

/**
* Handle Get Block operation. Calls BlockManager to process the request.
*/
Expand All @@ -683,7 +693,9 @@ ContainerCommandResponseProto handleGetBlock(
try {
BlockID blockID = BlockID.getFromProtobuf(
request.getGetBlock().getBlockID());
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
if (replicaIndexCheckRequired(request)) {
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
}
responseData = blockManager.getBlock(kvContainer, blockID).getProtoBufMessage();
final long numBytes = responseData.getSerializedSize();
metrics.incContainerBytesStats(Type.GetBlock, numBytes);
Expand Down Expand Up @@ -806,7 +818,9 @@ ContainerCommandResponseProto handleReadChunk(
ChunkInfo chunkInfo = ChunkInfo.getFromProtoBuf(request.getReadChunk()
.getChunkData());
Preconditions.checkNotNull(chunkInfo);
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
if (replicaIndexCheckRequired(request)) {
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
}
BlockUtils.verifyBCSId(kvContainer, blockID);

if (dispatcherContext == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ public static void verifyBCSId(Container container, BlockID blockID)
public static void verifyReplicaIdx(Container container, BlockID blockID)
throws IOException {
Integer containerReplicaIndex = container.getContainerData().getReplicaIndex();
Integer blockReplicaIndex = blockID.getReplicaIndex();
if (containerReplicaIndex > 0 && blockReplicaIndex != null && blockReplicaIndex != 0 &&
!containerReplicaIndex.equals(blockReplicaIndex)) {
if (containerReplicaIndex > 0 && !containerReplicaIndex.equals(blockID.getReplicaIndex())) {
throw new StorageContainerException(
"Unable to find the Container with replicaIdx " + blockID.getReplicaIndex() + ". Container "
+ container.getContainerData().getContainerID() + " replicaIdx is "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ public void testGetBlockWithReplicaIndexMismatch(ClientVersion clientVersion, in
handler.handleGetBlock(
getDummyCommandRequestProto(clientVersion, ContainerProtos.Type.GetBlock, rid),
container);
assertEquals((replicaIndex > 0 && rid != 0 && rid != replicaIndex) ?
assertEquals((replicaIndex > 0 && rid != replicaIndex && clientVersion.toProtoValue() >=
ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue()) ?
ContainerProtos.Result.CONTAINER_NOT_FOUND : UNKNOWN_BCSID,
response.getResult());
}
Expand Down Expand Up @@ -166,7 +167,8 @@ public void testReadChunkWithReplicaIndexMismatch(ClientVersion clientVersion, i
ContainerProtos.ContainerCommandResponseProto response =
handler.handleReadChunk(getDummyCommandRequestProto(clientVersion, ContainerProtos.Type.ReadChunk, rid),
container, null);
assertEquals((replicaIndex > 0 && rid != 0 && rid != replicaIndex) ?
assertEquals((replicaIndex > 0 && rid != replicaIndex &&
clientVersion.toProtoValue() >= ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue()) ?
ContainerProtos.Result.CONTAINER_NOT_FOUND : UNKNOWN_BCSID,
response.getResult());
}
Expand Down
3 changes: 2 additions & 1 deletion hadoop-hdds/framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd">
<restrictImports>
<reason>Only selected annotation processors are enabled, see configuration of maven-compiler-plugin.</reason>
<bannedImports>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMLayoutVersionValidator</bannedImport>
<bannedImport>org.apache.hadoop.ozone.om.request.validation.OMClientVersionValidator</bannedImport>
<bannedImport>org.kohsuke.MetaInfServices</bannedImport>
</bannedImports>
</restrictImports>
Expand Down
Loading
Loading