-
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 5 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
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
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
80 changes: 80 additions & 0 deletions
80
...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,80 @@ | ||
| /* | ||
| * 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 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.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.om.helpers.OmKeyLocationInfo; | ||
|
|
||
| /** | ||
| * Verifies block existence by making getBlock calls to the datanode. | ||
| */ | ||
| public class BlockExistenceVerifier implements ReplicaVerifier { | ||
| private final ContainerOperationClient containerClient; | ||
| private final XceiverClientManager xceiverClientManager; | ||
| private static final String CHECK_TYPE = "blockExistence"; | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return CHECK_TYPE; | ||
| } | ||
|
|
||
| public BlockExistenceVerifier(OzoneConfiguration conf) throws IOException { | ||
| this.containerClient = new ContainerOperationClient(conf); | ||
| this.xceiverClientManager = containerClient.getXceiverClientManager(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVerificationResult verifyBlock(DatanodeDetails datanode, OmKeyLocationInfo keyLocation) { | ||
| try { | ||
| Pipeline pipeline = Pipeline.newBuilder(keyLocation.getPipeline()) | ||
| .setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE)) | ||
| .setNodes(Collections.singletonList(datanode)) | ||
| .build(); | ||
|
|
||
| XceiverClientSpi client = xceiverClientManager.acquireClientForReadData(pipeline); | ||
| ContainerProtos.GetBlockResponseProto response = ContainerProtocolCalls.getBlock( | ||
| client, | ||
| keyLocation.getBlockID(), | ||
| keyLocation.getToken(), | ||
| Collections.singletonMap(datanode, 1) | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
|
|
||
| boolean hasBlock = response != null && response.hasBlockData(); | ||
|
|
||
| if (hasBlock) { | ||
| return BlockVerificationResult.pass(); | ||
| } else { | ||
| return BlockVerificationResult.failCheck("Block does not exist on this replica"); | ||
| } | ||
| } catch (IOException e) { | ||
| return BlockVerificationResult.failIncomplete(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
83 changes: 83 additions & 0 deletions
83
...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,83 @@ | ||
| /* | ||
| * 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 java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Json structure for replicas to pass through each check and give output. | ||
| */ | ||
| public class BlockVerificationResult { | ||
|
|
||
| private final boolean pass; | ||
| private final List<FailureDetail> failures; | ||
|
|
||
| public BlockVerificationResult(boolean pass, List<FailureDetail> failures) { | ||
| this.pass = pass; | ||
| this.failures = failures; | ||
| } | ||
|
|
||
| public static BlockVerificationResult pass() { | ||
| return new BlockVerificationResult(true, null); | ||
| } | ||
|
|
||
| public static BlockVerificationResult failCheck(String message) { | ||
| return new BlockVerificationResult(false, | ||
| Collections.singletonList(new FailureDetail(true, message))); | ||
| } | ||
|
|
||
| public static BlockVerificationResult failIncomplete(String message) { | ||
| return new BlockVerificationResult(false, | ||
| Collections.singletonList(new FailureDetail(false, message))); | ||
| } | ||
|
|
||
| public boolean passed() { | ||
| return pass; | ||
| } | ||
|
|
||
| public Optional<List<FailureDetail>> getFailures() { | ||
| return Optional.ofNullable(failures); | ||
| } | ||
|
|
||
| /** | ||
| * Details about the check failure. | ||
| */ | ||
| public static class FailureDetail { | ||
| // indicates whether the check finished and failed, | ||
| // or it was unable to finish due to connection or other issues | ||
| private final boolean completed; | ||
| private final String message; | ||
|
|
||
| public FailureDetail(boolean completed, String message) { | ||
| this.completed = completed; | ||
sarvekshayr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.message = message; | ||
| } | ||
|
|
||
| public boolean isCompleted() { | ||
| return completed; | ||
| } | ||
|
|
||
| public String getFailureMessage() { | ||
| return message; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
85 changes: 85 additions & 0 deletions
85
...op-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/replicas/ChecksumVerifier.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,85 @@ | ||
| /* | ||
| * 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.io.InputStream; | ||
| import java.util.Collections; | ||
| import org.apache.commons.io.IOUtils; | ||
| import org.apache.commons.io.output.NullOutputStream; | ||
| 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.scm.OzoneClientConfig; | ||
| import org.apache.hadoop.hdds.scm.XceiverClientManager; | ||
| import org.apache.hadoop.hdds.scm.cli.ContainerOperationClient; | ||
| import org.apache.hadoop.hdds.scm.pipeline.Pipeline; | ||
| import org.apache.hadoop.ozone.client.io.BlockInputStreamFactoryImpl; | ||
| import org.apache.hadoop.ozone.common.OzoneChecksumException; | ||
| import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo; | ||
|
|
||
| /** | ||
| * Verifies the checksum of blocks by checking each replica associated | ||
| * with a given key. | ||
| */ | ||
| public class ChecksumVerifier implements ReplicaVerifier { | ||
| private final OzoneConfiguration conf; | ||
| private final ContainerOperationClient containerClient; | ||
| private final XceiverClientManager xceiverClientManager; | ||
| private static final String CHECK_TYPE = "checksum"; | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return CHECK_TYPE; | ||
| } | ||
|
|
||
| public ChecksumVerifier(OzoneConfiguration conf) throws IOException { | ||
| this.conf = conf; | ||
| this.containerClient = new ContainerOperationClient(conf); | ||
| this.xceiverClientManager = containerClient.getXceiverClientManager(); | ||
| } | ||
|
|
||
| @Override | ||
| public BlockVerificationResult verifyBlock(DatanodeDetails datanode, OmKeyLocationInfo keyLocation) { | ||
| Pipeline pipeline = Pipeline.newBuilder(keyLocation.getPipeline()) | ||
| .setReplicationConfig(StandaloneReplicationConfig.getInstance(ONE)) | ||
| .setNodes(Collections.singletonList(datanode)) | ||
| .build(); | ||
|
|
||
| try (InputStream is = new BlockInputStreamFactoryImpl().create( | ||
| keyLocation.getPipeline().getReplicationConfig(), | ||
| keyLocation, | ||
| pipeline, | ||
| keyLocation.getToken(), | ||
| xceiverClientManager, | ||
| null, | ||
| conf.getObject(OzoneClientConfig.class))) { | ||
| IOUtils.copyLarge(is, NullOutputStream.INSTANCE); | ||
| return BlockVerificationResult.pass(); | ||
| } catch (IOException e) { | ||
| Throwable cause = e.getCause() != null ? e.getCause() : e; | ||
| if (cause instanceof OzoneChecksumException) { | ||
| return BlockVerificationResult.failCheck(cause.getMessage()); | ||
| } else { | ||
| return BlockVerificationResult.failIncomplete(cause.getMessage()); | ||
| } | ||
| } | ||
| } | ||
| } |
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.