You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2017/09/18 21:47:10 UTC
hadoop git commit: HDFS-12481. Ozone: Corona: Support for variable
key length in offline mode. Contributed by Nandakumar.
Repository: hadoop
Updated Branches:
refs/heads/HDFS-7240 1caf63789 -> 44d086733
HDFS-12481. Ozone: Corona: Support for variable key length in offline mode. Contributed by Nandakumar.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/44d08673
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/44d08673
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/44d08673
Branch: refs/heads/HDFS-7240
Commit: 44d086733a3e6ee0ad23a5b7572eaa7b29b837ff
Parents: 1caf637
Author: Anu Engineer <ae...@apache.org>
Authored: Mon Sep 18 14:43:35 2017 -0700
Committer: Anu Engineer <ae...@apache.org>
Committed: Mon Sep 18 14:43:35 2017 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/ozone/tools/Corona.java | 30 ++++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/44d08673/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java
index 6ed3344..be8a191 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java
@@ -91,6 +91,7 @@ public final class Corona extends Configured implements Tool {
private static final String NUM_OF_VOLUMES = "numOfVolumes";
private static final String NUM_OF_BUCKETS = "numOfBuckets";
private static final String NUM_OF_KEYS = "numOfKeys";
+ private static final String KEY_SIZE = "keySize";
private static final String MODE_DEFAULT = "offline";
private static final String SOURCE_DEFAULT =
@@ -101,6 +102,8 @@ public final class Corona extends Configured implements Tool {
private static final String NUM_OF_BUCKETS_DEFAULT = "1000";
private static final String NUM_OF_KEYS_DEFAULT = "500000";
+ private static final int KEY_SIZE_DEFAULT = 10240;
+
private static final Logger LOG =
LoggerFactory.getLogger(Corona.class);
@@ -115,6 +118,8 @@ public final class Corona extends Configured implements Tool {
private String numOfBuckets;
private String numOfKeys;
+ private int keySize;
+
private boolean validateWrites;
private OzoneClient ozoneClient;
@@ -157,8 +162,8 @@ public final class Corona extends Configured implements Tool {
@Override
public int run(String[] args) throws Exception {
GenericOptionsParser parser = new GenericOptionsParser(getConf(),
- getOzonePetaGenOptions(), args);
- parseOzonePetaGenOptions(parser.getCommandLine());
+ getOptions(), args);
+ parseOptions(parser.getCommandLine());
if(printUsage) {
usage();
return 0;
@@ -174,6 +179,7 @@ public final class Corona extends Configured implements Tool {
LOG.info("Number of Volumes: {}.", numOfVolumes);
LOG.info("Number of Buckets per Volume: {}.", numOfBuckets);
LOG.info("Number of Keys per Bucket: {}.", numOfKeys);
+ LOG.info("Key size: {} bytes", keySize);
for (int i = 0; i < Integer.parseInt(numOfVolumes); i++) {
String volume = "vol-" + i + "-" +
RandomStringUtils.randomNumeric(5);
@@ -205,7 +211,7 @@ public final class Corona extends Configured implements Tool {
return 0;
}
- private Options getOzonePetaGenOptions() {
+ private Options getOptions() {
Options options = new Options();
OptionBuilder.withDescription("prints usage.");
@@ -251,6 +257,12 @@ public final class Corona extends Configured implements Tool {
"created per Bucket in offline mode");
Option optNumOfKeys = OptionBuilder.create(NUM_OF_KEYS);
+ OptionBuilder.withArgName("value");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("specifies the size of Key in bytes to be " +
+ "created in offline mode");
+ Option optKeySize = OptionBuilder.create(KEY_SIZE);
+
options.addOption(optHelp);
options.addOption(optMode);
options.addOption(optSource);
@@ -259,10 +271,11 @@ public final class Corona extends Configured implements Tool {
options.addOption(optNumOfVolumes);
options.addOption(optNumOfBuckets);
options.addOption(optNumOfKeys);
+ options.addOption(optKeySize);
return options;
}
- private void parseOzonePetaGenOptions(CommandLine cmdLine) {
+ private void parseOptions(CommandLine cmdLine) {
printUsage = cmdLine.hasOption(HELP);
mode = cmdLine.hasOption(MODE) ?
@@ -284,6 +297,10 @@ public final class Corona extends Configured implements Tool {
numOfKeys = cmdLine.hasOption(NUM_OF_KEYS) ?
cmdLine.getOptionValue(NUM_OF_KEYS) : NUM_OF_KEYS_DEFAULT;
+
+ keySize = cmdLine.hasOption(KEY_SIZE) ?
+ Integer.parseInt(cmdLine.getOptionValue(KEY_SIZE)) : KEY_SIZE_DEFAULT;
+
}
private void usage() {
@@ -306,6 +323,8 @@ public final class Corona extends Configured implements Tool {
System.out.println("-numOfKeys <value> "
+ "specifies number of Keys to be created per Bucket " +
"in offline mode");
+ System.out.println("-keySize <value> "
+ + "specifies the size of Key in bytes to be created in offline mode");
System.out.println("-help "
+ "prints usage.");
System.out.println();
@@ -343,8 +362,7 @@ public final class Corona extends Configured implements Tool {
String key = "key-" + k + "-" +
RandomStringUtils.randomNumeric(5);
byte[] value = DFSUtil.string2Bytes(
- RandomStringUtils.randomAscii(10240));
-
+ RandomStringUtils.randomAscii(keySize));
try {
LOG.trace("Adding key: {} in bucket: {} of volume: {}",
key, bucket, volume);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org