HDFS-12481. Ozone: Corona: Support for variable key length in offline mode. Contributed by Nandakumar.
This commit is contained in:
parent
d9c3d9a5ef
commit
b984e903f3
|
@ -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_VOLUMES = "numOfVolumes";
|
||||||
private static final String NUM_OF_BUCKETS = "numOfBuckets";
|
private static final String NUM_OF_BUCKETS = "numOfBuckets";
|
||||||
private static final String NUM_OF_KEYS = "numOfKeys";
|
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 MODE_DEFAULT = "offline";
|
||||||
private static final String SOURCE_DEFAULT =
|
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_BUCKETS_DEFAULT = "1000";
|
||||||
private static final String NUM_OF_KEYS_DEFAULT = "500000";
|
private static final String NUM_OF_KEYS_DEFAULT = "500000";
|
||||||
|
|
||||||
|
private static final int KEY_SIZE_DEFAULT = 10240;
|
||||||
|
|
||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(Corona.class);
|
LoggerFactory.getLogger(Corona.class);
|
||||||
|
|
||||||
|
@ -115,6 +118,8 @@ public final class Corona extends Configured implements Tool {
|
||||||
private String numOfBuckets;
|
private String numOfBuckets;
|
||||||
private String numOfKeys;
|
private String numOfKeys;
|
||||||
|
|
||||||
|
private int keySize;
|
||||||
|
|
||||||
private boolean validateWrites;
|
private boolean validateWrites;
|
||||||
|
|
||||||
private OzoneClient ozoneClient;
|
private OzoneClient ozoneClient;
|
||||||
|
@ -157,8 +162,8 @@ public final class Corona extends Configured implements Tool {
|
||||||
@Override
|
@Override
|
||||||
public int run(String[] args) throws Exception {
|
public int run(String[] args) throws Exception {
|
||||||
GenericOptionsParser parser = new GenericOptionsParser(getConf(),
|
GenericOptionsParser parser = new GenericOptionsParser(getConf(),
|
||||||
getOzonePetaGenOptions(), args);
|
getOptions(), args);
|
||||||
parseOzonePetaGenOptions(parser.getCommandLine());
|
parseOptions(parser.getCommandLine());
|
||||||
if(printUsage) {
|
if(printUsage) {
|
||||||
usage();
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -174,6 +179,7 @@ public final class Corona extends Configured implements Tool {
|
||||||
LOG.info("Number of Volumes: {}.", numOfVolumes);
|
LOG.info("Number of Volumes: {}.", numOfVolumes);
|
||||||
LOG.info("Number of Buckets per Volume: {}.", numOfBuckets);
|
LOG.info("Number of Buckets per Volume: {}.", numOfBuckets);
|
||||||
LOG.info("Number of Keys per Bucket: {}.", numOfKeys);
|
LOG.info("Number of Keys per Bucket: {}.", numOfKeys);
|
||||||
|
LOG.info("Key size: {} bytes", keySize);
|
||||||
for (int i = 0; i < Integer.parseInt(numOfVolumes); i++) {
|
for (int i = 0; i < Integer.parseInt(numOfVolumes); i++) {
|
||||||
String volume = "vol-" + i + "-" +
|
String volume = "vol-" + i + "-" +
|
||||||
RandomStringUtils.randomNumeric(5);
|
RandomStringUtils.randomNumeric(5);
|
||||||
|
@ -205,7 +211,7 @@ public final class Corona extends Configured implements Tool {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Options getOzonePetaGenOptions() {
|
private Options getOptions() {
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
OptionBuilder.withDescription("prints usage.");
|
OptionBuilder.withDescription("prints usage.");
|
||||||
|
@ -251,6 +257,12 @@ public final class Corona extends Configured implements Tool {
|
||||||
"created per Bucket in offline mode");
|
"created per Bucket in offline mode");
|
||||||
Option optNumOfKeys = OptionBuilder.create(NUM_OF_KEYS);
|
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(optHelp);
|
||||||
options.addOption(optMode);
|
options.addOption(optMode);
|
||||||
options.addOption(optSource);
|
options.addOption(optSource);
|
||||||
|
@ -259,10 +271,11 @@ public final class Corona extends Configured implements Tool {
|
||||||
options.addOption(optNumOfVolumes);
|
options.addOption(optNumOfVolumes);
|
||||||
options.addOption(optNumOfBuckets);
|
options.addOption(optNumOfBuckets);
|
||||||
options.addOption(optNumOfKeys);
|
options.addOption(optNumOfKeys);
|
||||||
|
options.addOption(optKeySize);
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseOzonePetaGenOptions(CommandLine cmdLine) {
|
private void parseOptions(CommandLine cmdLine) {
|
||||||
printUsage = cmdLine.hasOption(HELP);
|
printUsage = cmdLine.hasOption(HELP);
|
||||||
|
|
||||||
mode = cmdLine.hasOption(MODE) ?
|
mode = cmdLine.hasOption(MODE) ?
|
||||||
|
@ -284,6 +297,10 @@ public final class Corona extends Configured implements Tool {
|
||||||
|
|
||||||
numOfKeys = cmdLine.hasOption(NUM_OF_KEYS) ?
|
numOfKeys = cmdLine.hasOption(NUM_OF_KEYS) ?
|
||||||
cmdLine.getOptionValue(NUM_OF_KEYS) : NUM_OF_KEYS_DEFAULT;
|
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() {
|
private void usage() {
|
||||||
|
@ -306,6 +323,8 @@ public final class Corona extends Configured implements Tool {
|
||||||
System.out.println("-numOfKeys <value> "
|
System.out.println("-numOfKeys <value> "
|
||||||
+ "specifies number of Keys to be created per Bucket " +
|
+ "specifies number of Keys to be created per Bucket " +
|
||||||
"in offline mode");
|
"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 "
|
System.out.println("-help "
|
||||||
+ "prints usage.");
|
+ "prints usage.");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
@ -343,8 +362,7 @@ public final class Corona extends Configured implements Tool {
|
||||||
String key = "key-" + k + "-" +
|
String key = "key-" + k + "-" +
|
||||||
RandomStringUtils.randomNumeric(5);
|
RandomStringUtils.randomNumeric(5);
|
||||||
byte[] value = DFSUtil.string2Bytes(
|
byte[] value = DFSUtil.string2Bytes(
|
||||||
RandomStringUtils.randomAscii(10240));
|
RandomStringUtils.randomAscii(keySize));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOG.trace("Adding key: {} in bucket: {} of volume: {}",
|
LOG.trace("Adding key: {} in bucket: {} of volume: {}",
|
||||||
key, bucket, volume);
|
key, bucket, volume);
|
||||||
|
|
Loading…
Reference in New Issue