HDFS-12274. Ozone: Corona: move corona from test to tools package. Contributed by Nandakumar.

This commit is contained in:
Weiwei Yang 2017-08-10 17:25:14 +08:00 committed by Owen O'Malley
parent bb9a4793d3
commit 285d61cd8d
3 changed files with 31 additions and 6 deletions

View File

@ -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();

View File

@ -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.
*/

View File

@ -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;
/**