-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-10928. Implement container comparison logic within datanodes. #7293
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
errose28
merged 12 commits into
apache:HDDS-10239-container-reconciliation
from
aswinshakil:HDDS-10928
Nov 22, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ed10b64
HDDS-10928. Implement container comparison and repair logic within da…
aswinshakil 1d89262
HDDS-10928. Change implementation and update tests.
aswinshakil 6c59ee0
HDDS-10928. Update implementation and address review comments.
aswinshakil 11a256a
Address review comments
aswinshakil 1fdd3a5
Update deleted blocks logic
aswinshakil 9fc13b6
Update tests.
aswinshakil 9ada3f5
Address review comments.
aswinshakil 82b3d59
Address tests for deleted blocks.
aswinshakil 9d025f3
Merging HDDS-10239-container-reconciliation into HDDS- HDDS-10928
aswinshakil f1679ce
Address review comments.
aswinshakil a5ff097
Address review comments.
aswinshakil 5dba34c
Update exception and other review comments.
aswinshakil 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
86 changes: 86 additions & 0 deletions
86
...service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerDiffReport.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.container.checksum; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * This class represents the difference between our replica of a container and a peer's replica of a container. | ||
| * It summarizes the operations we need to do to reconcile our replica with the peer replica it was compared to. | ||
| */ | ||
| public class ContainerDiffReport { | ||
| private final List<ContainerProtos.BlockMerkleTree> missingBlocks; | ||
| private final Map<Long, List<ContainerProtos.ChunkMerkleTree>> missingChunks; | ||
| private final Map<Long, List<ContainerProtos.ChunkMerkleTree>> corruptChunks; | ||
|
|
||
| public ContainerDiffReport() { | ||
| this.missingBlocks = new ArrayList<>(); | ||
| this.missingChunks = new HashMap<>(); | ||
| this.corruptChunks = new HashMap<>(); | ||
| } | ||
|
|
||
| public void addMissingBlock(ContainerProtos.BlockMerkleTree missingBlockMerkleTree) { | ||
| this.missingBlocks.add(missingBlockMerkleTree); | ||
| } | ||
|
|
||
| public void addMissingChunk(long blockId, ContainerProtos.ChunkMerkleTree missingChunkMerkleTree) { | ||
| this.missingChunks.computeIfAbsent(blockId, any -> new ArrayList<>()).add(missingChunkMerkleTree); | ||
| } | ||
|
|
||
| public void addCorruptChunk(long blockId, ContainerProtos.ChunkMerkleTree corruptChunk) { | ||
| this.corruptChunks.computeIfAbsent(blockId, any -> new ArrayList<>()).add(corruptChunk); | ||
| } | ||
|
|
||
| public List<ContainerProtos.BlockMerkleTree> getMissingBlocks() { | ||
| return missingBlocks; | ||
| } | ||
|
|
||
| public Map<Long, List<ContainerProtos.ChunkMerkleTree>> getMissingChunks() { | ||
| return missingChunks; | ||
| } | ||
|
|
||
| public Map<Long, List<ContainerProtos.ChunkMerkleTree>> getCorruptChunks() { | ||
| return corruptChunks; | ||
| } | ||
|
|
||
| /** | ||
| * If needRepair is true, It means current replica needs blocks/chunks from the peer to repair | ||
| * its container replica. The peer replica still may have corruption, which it will fix when | ||
| * it reconciles with other peers. | ||
| */ | ||
| public boolean needsRepair() { | ||
| return !missingBlocks.isEmpty() || !missingChunks.isEmpty() || !corruptChunks.isEmpty(); | ||
| } | ||
|
|
||
| // TODO: HDDS-11763 - Add metrics for missing blocks, missing chunks, corrupt chunks. | ||
| @Override | ||
| public String toString() { | ||
| return "ContainerDiffReport:" + | ||
| " MissingBlocks= " + missingBlocks.size() + " blocks" + | ||
| ", MissingChunks= " + missingChunks.values().stream().mapToInt(List::size).sum() | ||
| + " chunks from " + missingChunks.size() + " blocks" + | ||
| ", CorruptChunks= " + corruptChunks.values().stream().mapToInt(List::size).sum() | ||
| + " chunks from " + corruptChunks.size() + " blocks"; | ||
| } | ||
| } |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using the same result code for this case and the legitimate IO exception case. This might be okay because we could want the caller to queue the scanner for on demand scanning in both cases. We can leave it for now and revisit in the follow up patch that needs to handle this if required.