-
Notifications
You must be signed in to change notification settings - Fork 593
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 all 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
43 changes: 43 additions & 0 deletions
43
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/ShortCodec.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,43 @@ | ||
| /** | ||
| * 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.hadoop.hdds.utils.db; | ||
|
|
||
| import java.io.IOException; | ||
| import com.google.common.primitives.Shorts; | ||
|
|
||
| /** | ||
| * Codec to convert Short to/from byte array. | ||
| */ | ||
| public class ShortCodec implements Codec<Short> { | ||
|
|
||
| @Override | ||
| public byte[] toPersistedFormat(Short object) throws IOException { | ||
| return Shorts.toByteArray(object); | ||
| } | ||
|
|
||
| @Override | ||
| public Short fromPersistedFormat(byte[] rawData) throws IOException { | ||
| return Shorts.fromByteArray(rawData); | ||
| } | ||
|
|
||
| @Override | ||
| public Short copyObject(Short object) { | ||
| return object; | ||
| } | ||
| } |
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
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
| /* | ||
| * 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.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; | ||
| this.fileSizeBucket = new int[ReconConstants.NUM_OF_BINS]; | ||
yuangu002 marked this conversation as resolved.
Show resolved
Hide 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 Arrays.copyOf(this.fileSizeBucket, ReconConstants.NUM_OF_BINS); | ||
| } | ||
|
|
||
| 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); | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
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,81 @@ | ||
| /* | ||
| * 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.hadoop.ozone.recon.codec; | ||
|
|
||
| import org.apache.hadoop.hdds.utils.db.IntegerCodec; | ||
| import org.apache.hadoop.hdds.utils.db.ShortCodec; | ||
| 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> { | ||
|
|
||
| private final Codec<Integer> integerCodec = new IntegerCodec(); | ||
| private final Codec<Short> shortCodec = new ShortCodec(); | ||
| // 2 int fields + 41-length int array | ||
| 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 + Short.BYTES; | ||
| ByteArrayOutputStream out = new ByteArrayOutputStream(sizeOfRes); | ||
| out.write(integerCodec.toPersistedFormat(object.getNumOfFiles())); | ||
| out.write(integerCodec.toPersistedFormat(object.getSizeOfFiles())); | ||
| out.write(shortCodec.toPersistedFormat((short)ReconConstants.NUM_OF_BINS)); | ||
| 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.
Show resolved
Hide resolved
|
||
| return out.toByteArray(); | ||
| } | ||
|
|
||
| @Override | ||
| public NSSummary fromPersistedFormat(byte[] rawData) throws IOException { | ||
| assert(rawData.length == NUM_OF_INTS * Integer.BYTES + Short.BYTES); | ||
| DataInputStream in = new DataInputStream(new ByteArrayInputStream(rawData)); | ||
| NSSummary res = new NSSummary(); | ||
| res.setNumOfFiles(in.readInt()); | ||
| res.setSizeOfFiles(in.readInt()); | ||
| short len = in.readShort(); | ||
yuangu002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert(len == (short) ReconConstants.NUM_OF_BINS); | ||
| int[] fileSizeBucket = new int[len]; | ||
| for (int i = 0; i < len; ++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; | ||
| } | ||
| } | ||
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.