Updated Branches: refs/heads/trunk a840f41fc -> 528f7a8bb
SQOOP-720: Improve error handling when exporting malformed text data (Jarek Jarcec Cecho via Cheolsoo Park) Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/528f7a8b Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/528f7a8b Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/528f7a8b Branch: refs/heads/trunk Commit: 528f7a8bb51863b328da4a81873daa5e87fe029c Parents: a840f41 Author: Cheolsoo Park <[email protected]> Authored: Fri Nov 30 16:13:44 2012 -0800 Committer: Cheolsoo Park <[email protected]> Committed: Fri Nov 30 16:13:44 2012 -0800 ---------------------------------------------------------------------- .../apache/sqoop/mapreduce/TextExportMapper.java | 39 +++++++++++++- 1 files changed, 36 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/sqoop/blob/528f7a8b/src/java/org/apache/sqoop/mapreduce/TextExportMapper.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/sqoop/mapreduce/TextExportMapper.java b/src/java/org/apache/sqoop/mapreduce/TextExportMapper.java index 7b7f331..fb1edfd 100644 --- a/src/java/org/apache/sqoop/mapreduce/TextExportMapper.java +++ b/src/java/org/apache/sqoop/mapreduce/TextExportMapper.java @@ -23,10 +23,13 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapreduce.InputSplit; +import org.apache.hadoop.mapreduce.lib.input.FileSplit; import org.apache.hadoop.util.ReflectionUtils; -import com.cloudera.sqoop.lib.RecordParser; import com.cloudera.sqoop.lib.SqoopRecord; import com.cloudera.sqoop.mapreduce.AutoProgressMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * Converts an input record from a string representation to a parsed Sqoop @@ -36,6 +39,9 @@ import com.cloudera.sqoop.mapreduce.AutoProgressMapper; public class TextExportMapper extends AutoProgressMapper<LongWritable, Text, SqoopRecord, NullWritable> { + public static final Log LOG = + LogFactory.getLog(TextExportMapper.class.getName()); + private SqoopRecord recordImpl; public TextExportMapper() { @@ -76,8 +82,35 @@ public class TextExportMapper try { recordImpl.parse(val); context.write(recordImpl, NullWritable.get()); - } catch (RecordParser.ParseError pe) { - throw new IOException("Could not parse record: " + val, pe); + } catch (Exception e) { + // Something bad has happened + LOG.error(""); + LOG.error("Exception raised during data export"); + LOG.error(""); + + LOG.error("Exception: ", e); + LOG.error("On input: " + val); + + InputSplit is = context.getInputSplit(); + if (is instanceof FileSplit) { + LOG.error("On input file: " + ((FileSplit)is).getPath()); + } else if (is instanceof CombineFileSplit) { + LOG.error("On input file: " + + context.getConfiguration().get("map.input.file")); + } + LOG.error("At position " + key); + + LOG.error(""); + LOG.error("Currently processing split:"); + LOG.error(is); + + LOG.error(""); + LOG.error("This issue might not necessarily be caused by current input"); + LOG.error("due to the batching nature of export."); + LOG.error(""); + + throw new IOException("Can't export data, please check task tracker logs", + e); } } }
