diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs index c34471ffe74..914635e6210 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs @@ -104,7 +104,7 @@ function hdfscmd_case hadoop_do_classpath_subcommand HADOOP_CLASSNAME "$@" ;; corona) - HADOOP_CLASSNAME=org.apache.hadoop.ozone.Corona + HADOOP_CLASSNAME=org.apache.hadoop.ozone.tools.Corona ;; crypto) HADOOP_CLASSNAME=org.apache.hadoop.hdfs.tools.CryptoAdmin diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/Corona.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java similarity index 98% rename from hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/Corona.java rename to hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java index 4d69ba9f340..971fdd6a1d6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/Corona.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/Corona.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package org.apache.hadoop.ozone; +package org.apache.hadoop.ozone.tools; import org.apache.commons.cli.CommandLine; @@ -26,9 +26,11 @@ import org.apache.commons.cli.Options; import org.apache.commons.lang.RandomStringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; +import org.apache.hadoop.hdfs.DFSUtil; import org.apache.hadoop.ozone.client.OzoneClient; import org.apache.hadoop.ozone.client.OzoneClientFactory; import org.apache.hadoop.ozone.client.io.OzoneOutputStream; +import org.apache.hadoop.ozone.OzoneConfiguration; import org.apache.hadoop.util.GenericOptionsParser; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; @@ -144,7 +146,7 @@ public final class Corona extends Configured implements Tool { parseOzonePetaGenOptions(parser.getCommandLine()); if(printUsage) { usage(); - System.exit(0); + return 0; } LOG.info("Number of Threads: " + numOfThreads); processor = Executors.newFixedThreadPool(Integer.parseInt(numOfThreads)); @@ -300,7 +302,8 @@ public final class Corona extends Configured implements Tool { for (int k = 0; k < totalKeys; k++) { String key = "key-" + k + "-" + RandomStringUtils.randomNumeric(5); - byte[] value = RandomStringUtils.randomAscii(10240).getBytes(); + byte[] value = DFSUtil.string2Bytes( + RandomStringUtils.randomAscii(10240)); try { LOG.trace("Adding key: {} in bucket: {} of volume: {}", key, bucket, volume); @@ -349,7 +352,7 @@ public final class Corona extends Configured implements Tool { private class ProgressBar implements Runnable { - private final long refreshInterval = 1000L; + private static final long REFRESH_INTERVAL = 1000L; private PrintStream stream; private long maxValue; @@ -369,7 +372,7 @@ public final class Corona extends Configured implements Tool { if(completed) { break; } - Thread.sleep(refreshInterval); + Thread.sleep(REFRESH_INTERVAL); } if(exception) { stream.println(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/package-info.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/package-info.java new file mode 100644 index 00000000000..4d74f48b0be --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/ozone/tools/package-info.java @@ -0,0 +1,22 @@ +/** + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.tools; + +/** + This package contains class used for testing and benchmarking ozone cluster. + */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/test/OzoneTestDriver.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/test/OzoneTestDriver.java index ecb929d01a9..f7eb85d28b2 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/test/OzoneTestDriver.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/test/OzoneTestDriver.java @@ -18,7 +18,7 @@ package org.apache.hadoop.test; -import org.apache.hadoop.ozone.Corona; +import org.apache.hadoop.ozone.tools.Corona; import org.apache.hadoop.util.ProgramDriver; /**