HADOOP-16129. Misc. bug fixes for KMS Benchmark. Contributed by George Huang.
Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
This commit is contained in:
parent
05bce33d6e
commit
9daf43c6fa
@ -17,12 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.crypto.key.kms.server;
|
package org.apache.hadoop.crypto.key.kms.server;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.crypto.key.KeyProvider;
|
import org.apache.hadoop.crypto.key.KeyProvider;
|
||||||
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
|
||||||
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||||
import org.apache.hadoop.util.ExitUtil;
|
import org.apache.hadoop.util.ExitUtil;
|
||||||
import org.apache.hadoop.util.GenericOptionsParser;
|
import org.apache.hadoop.util.GenericOptionsParser;
|
||||||
import org.apache.hadoop.util.KMSUtil;
|
import org.apache.hadoop.util.KMSUtil;
|
||||||
@ -30,7 +28,8 @@
|
|||||||
import org.apache.hadoop.util.Time;
|
import org.apache.hadoop.util.Time;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
import org.apache.hadoop.util.ToolRunner;
|
import org.apache.hadoop.util.ToolRunner;
|
||||||
import org.apache.log4j.Level;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
@ -59,7 +58,8 @@ public class KMSBenchmark implements Tool {
|
|||||||
private static final Logger LOG =
|
private static final Logger LOG =
|
||||||
LoggerFactory.getLogger(KMSBenchmark.class);
|
LoggerFactory.getLogger(KMSBenchmark.class);
|
||||||
|
|
||||||
private static final String GENERAL_OPTIONS_USAGE = "[-logLevel L] |";
|
private static final String GENERAL_OPTIONS_USAGE = "[-threads int] |" +
|
||||||
|
" [-numops int] | [{-warmup (true|false)}]";
|
||||||
|
|
||||||
private static Configuration config;
|
private static Configuration config;
|
||||||
|
|
||||||
@ -74,6 +74,11 @@ public class KMSBenchmark implements Tool {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
config = conf;
|
config = conf;
|
||||||
kp = createKeyProviderCryptoExtension(config);
|
kp = createKeyProviderCryptoExtension(config);
|
||||||
|
try {
|
||||||
|
eek = kp.generateEncryptedKey(encryptionKeyName);
|
||||||
|
} catch (GeneralSecurityException e) {
|
||||||
|
LOG.warn("failed to generate key", e);
|
||||||
|
}
|
||||||
// create key and/or warm up
|
// create key and/or warm up
|
||||||
for (int i = 2; i < args.length; i++) {
|
for (int i = 2; i < args.length; i++) {
|
||||||
if (args[i].equals("-warmup")) {
|
if (args[i].equals("-warmup")) {
|
||||||
@ -126,9 +131,6 @@ abstract class OperationStatsBase {
|
|||||||
// time from start to finish
|
// time from start to finish
|
||||||
private long elapsedTime = 0;
|
private long elapsedTime = 0;
|
||||||
|
|
||||||
// logging level, ERROR by default
|
|
||||||
private Level logLevel;
|
|
||||||
|
|
||||||
private List<StatsDaemon> daemons;
|
private List<StatsDaemon> daemons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -174,7 +176,6 @@ abstract long executeOp(int daemonId, int inputIdx, String arg1)
|
|||||||
OperationStatsBase() {
|
OperationStatsBase() {
|
||||||
numOpsRequired = 10000;
|
numOpsRequired = 10000;
|
||||||
numThreads = 3;
|
numThreads = 3;
|
||||||
logLevel = Level.ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void benchmark() throws IOException {
|
void benchmark() throws IOException {
|
||||||
@ -301,16 +302,6 @@ protected boolean verifyOpArgument(List<String> args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// process common options
|
// process common options
|
||||||
int llIndex = args.indexOf("-logLevel");
|
|
||||||
if (llIndex >= 0) {
|
|
||||||
if (args.size() <= llIndex + 1) {
|
|
||||||
printUsage();
|
|
||||||
}
|
|
||||||
logLevel = Level.toLevel(args.get(llIndex+1), Level.ERROR);
|
|
||||||
args.remove(llIndex+1);
|
|
||||||
args.remove(llIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
String type = args.get(1);
|
String type = args.get(1);
|
||||||
if (OP_ALL_NAME.equals(type)) {
|
if (OP_ALL_NAME.equals(type)) {
|
||||||
type = getOpName();
|
type = getOpName();
|
||||||
@ -511,7 +502,6 @@ long executeOp(int daemonId, int inputIdx, String clientName)
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
long start = Time.now();
|
long start = Time.now();
|
||||||
try {
|
try {
|
||||||
eek = kp.generateEncryptedKey(encryptionKeyName);
|
|
||||||
kp.decryptEncryptedKey(eek);
|
kp.decryptEncryptedKey(eek);
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
LOG.warn("failed to generate and/or decrypt key", e);
|
LOG.warn("failed to generate and/or decrypt key", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user