-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-12207. Unify output of ozone debug replicas verify checks
#8248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
52f8721
HDDS-12207. Unify output of checks
sarvekshayr c617555
Findbugs addressed
sarvekshayr 726af03
Modified the verifiers
sarvekshayr 3671a2a
Fixed pmd errors
sarvekshayr 7606334
Removed unused imports
sarvekshayr 5175151
Added a test and restructured some methods
sarvekshayr aecdc77
PMD failure added Override annotation
sarvekshayr 7b4f472
Added a robot test and inclued replicaIndex in verifyBlock()
sarvekshayr 8e5da41
Specified the key path to run the command in robot test
sarvekshayr 7a72f5b
Merge remote-tracking branch 'origin/master' into HDDS-12207
sarvekshayr 33fc833
Delete Checksums and close client in BlockExistenceVerifier
sarvekshayr 10c7bcb
Fixed checkstyle errors
sarvekshayr 474d397
Used AtomicBoolean and fixed the test
sarvekshayr 1bbf68c
Changed ozonefs-obs.robot volume name
sarvekshayr a27367f
Merge remote-tracking branch 'origin' into HDDS-12207
sarvekshayr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
...ne/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/BlockExistenceVerifier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * 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.debug.replicas; | ||
|
|
||
| import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import org.apache.hadoop.hdds.client.StandaloneReplicationConfig; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos; | ||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
| import org.apache.hadoop.hdds.scm.XceiverClientManager; | ||
| import org.apache.hadoop.hdds.scm.XceiverClientSpi; | ||
| import org.apache.hadoop.hdds.scm.cli.ContainerOperationClient; | ||
| import org.apache.hadoop.hdds.scm.pipeline.Pipeline; | ||
| import org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls; | ||
| import org.apache.hadoop.ozone.client.io.OzoneInputStream; | ||
| import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo; | ||
|
|
||
| /** | ||
| * Checks block existence using GetBlock calls to the Datanodes. | ||
| */ | ||
| public class BlockExistenceVerifier implements ReplicaVerifier { | ||
|
|
||
| private OzoneConfiguration conf; | ||
| private static final String CHECKTYPE = "blockExistence"; | ||
|
|
||
| public BlockExistenceVerifier(OzoneConfiguration conf) { | ||
| this.conf = conf; | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVerificationResult verifyBlock(DatanodeDetails datanode, OzoneInputStream stream, | ||
| OmKeyLocationInfo keyLocation) { | ||
| try (ContainerOperationClient containerClient = new ContainerOperationClient(conf); | ||
| XceiverClientManager xceiverClientManager = containerClient.getXceiverClientManager()) { | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Pipeline keyPipeline = keyLocation.getPipeline(); | ||
| boolean isECKey = keyPipeline.getReplicationConfig().getReplicationType() == HddsProtos.ReplicationType.EC; | ||
| Pipeline pipeline = isECKey ? keyPipeline : | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Pipeline.newBuilder(keyPipeline) | ||
| .setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE)) | ||
| .build(); | ||
|
|
||
| try (XceiverClientSpi client = xceiverClientManager.acquireClientForReadData(pipeline)) { | ||
|
|
||
| Map<DatanodeDetails, ContainerProtos.GetBlockResponseProto> responses = | ||
| ContainerProtocolCalls.getBlockFromAllNodes( | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| client, | ||
| keyLocation.getBlockID().getDatanodeBlockIDProtobuf(), | ||
| keyLocation.getToken() | ||
| ); | ||
|
|
||
| ContainerProtos.GetBlockResponseProto response = responses.get(datanode); | ||
| boolean hasBlock = response != null && response.hasBlockData(); | ||
|
|
||
| return new BlockVerificationResult(CHECKTYPE, hasBlock, hasBlock ? Collections.emptyList() : | ||
| Collections.singletonList(new BlockVerificationResult.FailureDetail( | ||
| true, "Block does not exist on this replica"))); | ||
| } | ||
|
|
||
| } catch (IOException | InterruptedException e) { | ||
| BlockVerificationResult.FailureDetail failure = new BlockVerificationResult.FailureDetail(true, e.getMessage()); | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return new BlockVerificationResult(CHECKTYPE, false, Collections.singletonList(failure)); | ||
| } | ||
| } | ||
|
|
||
| } | ||
91 changes: 91 additions & 0 deletions
91
...e/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/BlockVerificationResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * 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.debug.replicas; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.node.ArrayNode; | ||
| import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Json structure for replicas to pass through each check and give output. | ||
| */ | ||
| public class BlockVerificationResult { | ||
|
|
||
| private final String type; | ||
| private final boolean pass; | ||
| private final List<FailureDetail> failures; | ||
|
|
||
| public BlockVerificationResult(String type, boolean pass, List<FailureDetail> failures) { | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.type = type; | ||
| this.pass = pass; | ||
| this.failures = failures; | ||
| } | ||
|
|
||
| public String getType() { | ||
| return type; | ||
| } | ||
|
|
||
| public boolean isPass() { | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return pass; | ||
| } | ||
|
|
||
| public List<FailureDetail> getFailures() { | ||
| return failures; | ||
| } | ||
|
|
||
| /** | ||
| * Details about the check failure. | ||
| */ | ||
| public static class FailureDetail { | ||
| private final boolean present; | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| private final String message; | ||
|
|
||
| public FailureDetail(boolean present, String message) { | ||
| this.present = present; | ||
| this.message = message; | ||
| } | ||
|
|
||
| public boolean isPresent() { | ||
| return present; | ||
| } | ||
|
|
||
| public String getFailureMessage() { | ||
| return message; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public ObjectNode toJson(ObjectMapper mapper) { | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ObjectNode resultNode = mapper.createObjectNode(); | ||
| resultNode.put("type", type); | ||
| resultNode.put("pass", pass); | ||
|
|
||
| ArrayNode failuresArray = mapper.createArrayNode(); | ||
| for (FailureDetail failure : failures) { | ||
| ObjectNode failureNode = mapper.createObjectNode(); | ||
| failureNode.put("present", failure.isPresent()); | ||
| failureNode.put("message", failure.getFailureMessage()); | ||
| failuresArray.add(failureNode); | ||
| } | ||
|
|
||
| resultNode.set("failures", failuresArray); | ||
| return resultNode; | ||
| } | ||
|
|
||
| } | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.