-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HDFS-17496. DataNode supports more fine-grained dataset lock based on blockid. #6764
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
Changes from 9 commits
fcf8021
db36a2b
dc09713
89ca2cd
c723265
3d579ae
94d6660
4751846
263a5ca
d4f9eb1
9eb153c
226cd5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ | |
| import java.io.FileInputStream; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| import org.apache.hadoop.classification.InterfaceAudience; | ||
| import org.apache.hadoop.hdfs.protocol.Block; | ||
|
|
@@ -127,6 +129,31 @@ public static File idToBlockDir(File root, long blockId) { | |
| return new File(root, path); | ||
| } | ||
|
|
||
| /** | ||
| * Take an example. We hava a block with blockid mapping to: | ||
| * "/data1/hadoop/hdfs/datanode/current/BP-xxxx/current/finalized/subdir0/subdir0" | ||
| * We return "subdir0/subdir0" | ||
| * @param blockId blockId | ||
| * @return The two-level subdir name | ||
| */ | ||
| public static String idToBlockDirSuffixName(long blockId) { | ||
|
||
| int d1 = (int) ((blockId >> 16) & 0x1F); | ||
| int d2 = (int) ((blockId >> 8) & 0x1F); | ||
| return DataStorage.BLOCK_SUBDIR_PREFIX + d1 + SEP + | ||
| DataStorage.BLOCK_SUBDIR_PREFIX + d2; | ||
| } | ||
|
|
||
| public static List<String> getAllSubDirNameForDataSetLock() { | ||
|
||
| List<String> res = new ArrayList<>(); | ||
| for (int d1 = 0; d1 <= 0x1F; d1++) { | ||
| for (int d2 = 0; d2 <= 0x1F; d2++) { | ||
| res.add(DataStorage.BLOCK_SUBDIR_PREFIX + d1 + SEP + | ||
| DataStorage.BLOCK_SUBDIR_PREFIX + d2); | ||
| } | ||
| } | ||
| return res; | ||
| } | ||
|
|
||
| /** | ||
| * @return the FileInputStream for the meta data of the given block. | ||
| * @throws FileNotFoundException | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.