Skip to content

Commit 7772adc

Browse files
author
Costin Leau
committed
add more logging
1 parent 86475ad commit 7772adc

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/main/java/org/springframework/data/hadoop/mapreduce/JobGenericOptions.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
2224
import org.apache.hadoop.conf.Configuration;
2325
import org.apache.hadoop.util.GenericOptionsParser;
2426
import org.springframework.core.io.Resource;
@@ -31,6 +33,8 @@
3133
*/
3234
abstract class JobGenericOptions {
3335

36+
final Log log = LogFactory.getLog(getClass());
37+
3438
Resource[] files, libJars, archives;
3539
String user;
3640

@@ -85,7 +89,7 @@ void buildGenericOptions(Configuration cfg) {
8589
}
8690
}
8791

88-
static void addResource(Resource[] args, String name, List<String> list) throws IOException {
92+
void addResource(Resource[] args, String name, List<String> list) throws IOException {
8993
if (!ObjectUtils.isEmpty(args)) {
9094
int count = args.length;
9195
list.add(name);
@@ -98,6 +102,10 @@ static void addResource(Resource[] args, String name, List<String> list) throws
98102
}
99103
}
100104
list.add(sb.toString());
105+
106+
if (log.isTraceEnabled()) {
107+
log.trace("Adding to generic option arg [" + name + "], resources " + sb.toString());
108+
}
101109
}
102110
}
103111

src/main/java/org/springframework/data/hadoop/mapreduce/ParentLastURLClassLoader.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.net.URL;
2020
import java.net.URLClassLoader;
2121
import java.util.ArrayList;
22+
import java.util.Arrays;
2223
import java.util.Collections;
2324
import java.util.Enumeration;
2425
import java.util.List;
@@ -103,4 +104,16 @@ public Enumeration<URL> getResources(String name) throws IOException {
103104

104105
return Collections.enumeration(urls);
105106
}
107+
108+
@Override
109+
public String toString() {
110+
StringBuilder sb = new StringBuilder("ParentLastURLCL\r\nURLs: ");
111+
sb.append(Arrays.asList(getURLs()));
112+
sb.append("\nParent CL: ");
113+
sb.append(getParent());
114+
sb.append("\nSystem CL: ");
115+
sb.append(system);
116+
sb.append("\n");
117+
return (sb.toString());
118+
}
106119
}

src/main/java/org/springframework/data/hadoop/mapreduce/ToolExecutor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.springframework.data.hadoop.mapreduce;
1717

1818
import java.security.PrivilegedExceptionAction;
19+
import java.util.Arrays;
1920
import java.util.Properties;
2021

2122
import org.apache.hadoop.conf.Configuration;
@@ -53,6 +54,11 @@ int runTool() throws Exception {
5354

5455
if (t == null) {
5556
cl = ClassLoadingUtils.createParentLastClassLoader(jar, beanClassLoader, cfg);
57+
58+
if (log.isTraceEnabled()) {
59+
log.trace("Creating Tool custom classloader " + cl);
60+
}
61+
5662
cfg.setClassLoader(cl);
5763

5864
// fall-back to main
@@ -62,6 +68,10 @@ int runTool() throws Exception {
6268
throw new IllegalArgumentException("no Tool class specified and no Main-Class available");
6369
}
6470
toolClassName = mainClass;
71+
72+
if (log.isTraceEnabled()) {
73+
log.trace("Discovered MainClass as Tool [" + mainClass + "]");
74+
}
6575
}
6676

6777
t = loadTool(toolClassName, cl);
@@ -72,6 +82,10 @@ int runTool() throws Exception {
7282

7383
final Tool ft = t;
7484

85+
if (log.isDebugEnabled()) {
86+
log.debug("Invoking tool [" + t + "] with args " + Arrays.toString(arguments));
87+
}
88+
7589
try {
7690
th.setContextClassLoader(cl);
7791

0 commit comments

Comments
 (0)