sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arv...@apache.org
Subject svn commit: r1180162 - in /incubator/sqoop/trunk/src/java/com/cloudera/sqoop: mapreduce/AsyncSqlRecordWriter.java mapreduce/db/DBRecordReader.java util/LoggingUtils.java
Date Fri, 07 Oct 2011 19:12:02 GMT
Author: arvind
Date: Fri Oct  7 19:12:01 2011
New Revision: 1180162

URL: http://svn.apache.org/viewvc?rev=1180162&view=rev
Log:
SQOOP-357. Debug logs should include chained exception trace.

(Bilung Lee via Arvind Prabhakar)

Added:
    incubator/sqoop/trunk/src/java/com/cloudera/sqoop/util/LoggingUtils.java
Modified:
    incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/AsyncSqlRecordWriter.java
    incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/db/DBRecordReader.java

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/AsyncSqlRecordWriter.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/AsyncSqlRecordWriter.java?rev=1180162&r1=1180161&r2=1180162&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/AsyncSqlRecordWriter.java
(original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/AsyncSqlRecordWriter.java
Fri Oct  7 19:12:01 2011
@@ -27,11 +27,13 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.RecordWriter;
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import com.cloudera.sqoop.mapreduce.db.DBConfiguration;
-
+import com.cloudera.sqoop.util.LoggingUtils;
 import com.cloudera.sqoop.lib.SqoopRecord;
 
 /**
@@ -47,6 +49,8 @@ import com.cloudera.sqoop.lib.SqoopRecor
 public abstract class AsyncSqlRecordWriter<K extends SqoopRecord, V>
     extends RecordWriter<K, V> {
 
+  private static final Log LOG = LogFactory.getLog(AsyncSqlRecordWriter.class);
+
   private Connection connection;
 
   private Configuration conf;
@@ -166,6 +170,7 @@ public abstract class AsyncSqlRecordWrit
     // Check for any previous SQLException. If one happened, rethrow it here.
     SQLException lastException = execThread.getLastError();
     if (null != lastException) {
+      LoggingUtils.logAll(LOG, lastException);
       throw lastException;
     }
   }

Modified: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/db/DBRecordReader.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/db/DBRecordReader.java?rev=1180162&r1=1180161&r2=1180162&view=diff
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/db/DBRecordReader.java (original)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/mapreduce/db/DBRecordReader.java Fri
Oct  7 19:12:01 2011
@@ -37,6 +37,8 @@ import org.apache.hadoop.mapreduce.lib.d
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.hadoop.conf.Configuration;
 
+import com.cloudera.sqoop.util.LoggingUtils;
+
 /**
  * A RecordReader that reads records from a SQL table.
  * Emits LongWritables containing the record number as
@@ -245,6 +247,7 @@ public class DBRecordReader<T extends DB
 
       pos++;
     } catch (SQLException e) {
+      LoggingUtils.logAll(LOG, e);
       throw new IOException("SQLException in nextKeyValue", e);
     }
     return true;

Added: incubator/sqoop/trunk/src/java/com/cloudera/sqoop/util/LoggingUtils.java
URL: http://svn.apache.org/viewvc/incubator/sqoop/trunk/src/java/com/cloudera/sqoop/util/LoggingUtils.java?rev=1180162&view=auto
==============================================================================
--- incubator/sqoop/trunk/src/java/com/cloudera/sqoop/util/LoggingUtils.java (added)
+++ incubator/sqoop/trunk/src/java/com/cloudera/sqoop/util/LoggingUtils.java Fri Oct  7 19:12:01
2011
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2011 The Apache Software Foundation
+ *
+ * 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 com.cloudera.sqoop.util;
+
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * A helper class for logging.
+ */
+public final class LoggingUtils {
+
+  /**
+   * Private constructor to prevent instantiation.
+   */
+  private LoggingUtils() {
+  }
+
+  /**
+   * Log every exception in the chain if
+   * the exception is a chain of exceptions.
+   */
+  public static void logAll(Log log, SQLException e) {
+    log.error("Top level exception: ", e);
+    e = e.getNextException();
+    int indx = 1;
+    while (e != null) {
+      log.error("Chained exception " + indx + ": ", e);
+      e = e.getNextException();
+      indx++;
+    }
+  }
+}
+



Mime
View raw message