From 54e760511a2e2f8e5ecf1eb8762434fcd041f4d6 Mon Sep 17 00:00:00 2001 From: Takanobu Asanuma Date: Wed, 4 Dec 2019 11:28:50 +0900 Subject: [PATCH] HDFS-14825. [Dynamometer] Workload doesn't start unless an absolute path of Mapper class given. (#1693) --- .../workloadgenerator/WorkloadDriver.java | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/WorkloadDriver.java b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/WorkloadDriver.java index 8b170c12ac..a2717cf8e4 100644 --- a/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/WorkloadDriver.java +++ b/hadoop-tools/hadoop-dynamometer/hadoop-dynamometer-workload/src/main/java/org/apache/hadoop/tools/dynamometer/workloadgenerator/WorkloadDriver.java @@ -168,16 +168,27 @@ public static void main(String[] args) throws Exception { // recognize this @SuppressWarnings("unchecked") private Class> getMapperClass( - String className) throws ClassNotFoundException { - if (!className.contains(".")) { - className = WorkloadDriver.class.getPackage().getName() + "." + className; + String className) { + String[] potentialQualifiedClassNames = { + WorkloadDriver.class.getPackage().getName() + "." + className, + AuditReplayMapper.class.getPackage().getName() + "." + className, + className + }; + for (String qualifiedClassName : potentialQualifiedClassNames) { + Class mapperClass; + try { + mapperClass = getConf().getClassByName(qualifiedClassName); + } catch (ClassNotFoundException cnfe) { + continue; + } + if (!WorkloadMapper.class.isAssignableFrom(mapperClass)) { + throw new IllegalArgumentException(className + " is not a subclass of " + + WorkloadMapper.class.getCanonicalName()); + } + return (Class>) mapperClass; } - Class mapperClass = getConf().getClassByName(className); - if (!WorkloadMapper.class.isAssignableFrom(mapperClass)) { - throw new IllegalArgumentException(className + " is not a subclass of " - + WorkloadMapper.class.getCanonicalName()); - } - return (Class>) mapperClass; + throw new IllegalArgumentException("Unable to find workload mapper class: " + + className); } private String getMapperUsageInfo(String mapperClassName)