-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-5332. Add a new column family and a service provider in Recon DB for Namespace Summaries #2366
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 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
056297c
set up basic file structure and renaming-related changes
web-flow 77ad2a5
rename container/NSSummary service providers, added a ReconRocksDB cl…
yuangu002 17dd31d
refactor ReconDBProvider to ReconRocksDB, added unit tests
yuangu002 62446f3
checkstyle fix
yuangu002 63d3544
fix license headers
yuangu002 f0cbfbb
renaming and nit
yuangu002 bfa2f94
use file size max upper bound to calculate num of bins, not hardcoded
yuangu002 33629ee
nit on init & truncate table
yuangu002 fb09152
Update hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon…
yuangu002 bb65535
Update hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon…
yuangu002 7fd9bec
Update hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon…
yuangu002 0cb9d60
codec length change
yuangu002 28985e5
codec length change, minor fix
yuangu002 ec1fadb
Update hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon…
yuangu002 4922315
assert fix
yuangu002 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
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
54 changes: 54 additions & 0 deletions
54
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/NSSummary.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,54 @@ | ||
| package org.apache.hadoop.ozone.recon.api.types; | ||
|
|
||
| import org.apache.hadoop.ozone.recon.ReconConstants; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| /** | ||
| * Class to encapsulate namespace metadata summaries from OM. | ||
| */ | ||
|
|
||
| public class NSSummary { | ||
| private int numOfFiles; | ||
| private int sizeOfFiles; | ||
| private int[] fileSizeBucket; | ||
|
|
||
| public NSSummary() { | ||
| this.numOfFiles = 0; | ||
| this.sizeOfFiles = 0; | ||
| // TODO: I read the min is 1024(2^10), max is 1PB(2^50), | ||
| // so the number of buckets should be 40? | ||
| this.fileSizeBucket = new int[ReconConstants.NUM_OF_BINS]; | ||
|
yuangu002 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| public NSSummary(int numOfFiles, int sizeOfFiles, int[] bucket) { | ||
| this.numOfFiles = numOfFiles; | ||
| this.sizeOfFiles = sizeOfFiles; | ||
| setFileSizeBucket(bucket); | ||
| } | ||
|
|
||
| public int getNumOfFiles() { | ||
| return numOfFiles; | ||
| } | ||
|
|
||
| public int getSizeOfFiles() { | ||
| return sizeOfFiles; | ||
| } | ||
|
|
||
| public int[] getFileSizeBucket() { | ||
| return fileSizeBucket; | ||
| } | ||
|
|
||
| public void setNumOfFiles(int numOfFiles) { | ||
| this.numOfFiles = numOfFiles; | ||
| } | ||
|
|
||
| public void setSizeOfFiles(int sizeOfFiles) { | ||
| this.sizeOfFiles = sizeOfFiles; | ||
| } | ||
|
|
||
| public void setFileSizeBucket(int[] fileSizeBucket) { | ||
| this.fileSizeBucket = Arrays.copyOf( | ||
| fileSizeBucket, ReconConstants.NUM_OF_BINS); | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/NSSummaryCodec.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,58 @@ | ||
| package org.apache.hadoop.ozone.recon.codec; | ||
|
|
||
| import org.apache.hadoop.hdds.utils.db.IntegerCodec; | ||
| import org.apache.hadoop.ozone.recon.ReconConstants; | ||
| import org.apache.hadoop.ozone.recon.api.types.NSSummary; | ||
| import org.apache.hadoop.hdds.utils.db.Codec; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.ByteArrayOutputStream; | ||
| import java.io.DataInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Codec for Namespace Summary. | ||
| */ | ||
| public class NSSummaryCodec implements Codec<NSSummary>{ | ||
|
yuangu002 marked this conversation as resolved.
Outdated
|
||
|
|
||
| private final Codec<Integer> integerCodec = new IntegerCodec(); | ||
| // 2 int fields + 40-length int array | ||
|
yuangu002 marked this conversation as resolved.
Outdated
|
||
| private static final int NUM_OF_INTS = 2 + ReconConstants.NUM_OF_BINS; | ||
|
|
||
| @Override | ||
| public byte[] toPersistedFormat(NSSummary object) throws IOException { | ||
| final int sizeOfRes = NUM_OF_INTS * Integer.BYTES; | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(sizeOfRes); | ||
| out.write(integerCodec.toPersistedFormat(object.getNumOfFiles())); | ||
| out.write(integerCodec.toPersistedFormat(object.getSizeOfFiles())); | ||
| int[] fileSizeBucket = object.getFileSizeBucket(); | ||
| for (int i = 0; i < ReconConstants.NUM_OF_BINS; ++i) { | ||
| out.write(integerCodec.toPersistedFormat(fileSizeBucket[i])); | ||
| } | ||
|
smengcl marked this conversation as resolved.
|
||
| return out.toByteArray(); | ||
| } | ||
|
|
||
| @Override | ||
| public NSSummary fromPersistedFormat(byte[] rawData) throws IOException { | ||
| assert(rawData.length == NUM_OF_INTS * Integer.BYTES); | ||
| DataInputStream in = new DataInputStream(new ByteArrayInputStream(rawData)); | ||
| NSSummary res = new NSSummary(); | ||
| res.setNumOfFiles(in.readInt()); | ||
| res.setSizeOfFiles(in.readInt()); | ||
| int[] fileSizeBucket = new int[ReconConstants.NUM_OF_BINS]; | ||
| for (int i = 0; i < ReconConstants.NUM_OF_BINS && in.available() > 0; ++i) { | ||
| fileSizeBucket[i] = in.readInt(); | ||
| } | ||
| res.setFileSizeBucket(fileSizeBucket); | ||
| return res; | ||
| } | ||
|
|
||
| @Override | ||
| public NSSummary copyObject(NSSummary object) { | ||
| NSSummary copy = new NSSummary(); | ||
| copy.setNumOfFiles(object.getNumOfFiles()); | ||
| copy.setSizeOfFiles(object.getSizeOfFiles()); | ||
| copy.setFileSizeBucket(object.getFileSizeBucket()); | ||
| return copy; | ||
| } | ||
| } | ||
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
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.