Review Board 1.7.22


SQOOP-744: log4j configuration for generated mapreduce job

Review Request #13035 - Created July 29, 2013 and submitted

Raghav Gautam
SQOOP-744
Reviewers
Sqoop
sqoop-sqoop2
Adding log4j.properties for the generated job.
Manually tested.
execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
Revision f5f6d8e New Change
[20] 18 lines
[+20]
19

    
   
19

   
20
import org.apache.hadoop.conf.Configuration;
20
import org.apache.hadoop.conf.Configuration;
21
import org.apache.hadoop.io.Text;
21
import org.apache.hadoop.io.Text;
22
import org.apache.hadoop.mapred.JobConf;
22
import org.apache.hadoop.mapred.JobConf;
23
import org.apache.hadoop.mapreduce.Job;
23
import org.apache.hadoop.mapreduce.Job;

    
   
24
import org.apache.log4j.PropertyConfigurator;
24
import org.apache.sqoop.job.JobConstants;
25
import org.apache.sqoop.job.JobConstants;
25
import org.apache.sqoop.json.util.SchemaSerialization;
26
import org.apache.sqoop.json.util.SchemaSerialization;
26
import org.apache.sqoop.model.FormUtils;
27
import org.apache.sqoop.model.FormUtils;
27
import org.apache.sqoop.model.MJob;
28
import org.apache.sqoop.model.MJob;
28
import org.apache.sqoop.schema.Schema;
29
import org.apache.sqoop.schema.Schema;
29
import org.apache.sqoop.utils.ClassUtils;
30
import org.apache.sqoop.utils.ClassUtils;
30
import org.json.simple.JSONObject;
31
import org.json.simple.JSONObject;
31
import org.json.simple.JSONValue;
32
import org.json.simple.JSONValue;
32

    
   
33

   

    
   
34
import java.io.InputStream;

    
   
35
import java.util.Properties;

    
   
36

   
33
/**
37
/**
34
 * Helper class to store and load various information in/from MapReduce configuration
38
 * Helper class to store and load various information in/from MapReduce configuration
35
 * object and JobConf object.
39
 * object and JobConf object.
36
 */
40
 */
37
public final class ConfigurationUtils {
41
public final class ConfigurationUtils {
[+20] [20] 221 lines
[+20] [+] private static Object loadConfiguration(JobConf configuration, String classProperty, Text valueProperty) {
259
  }
263
  }
260

    
   
264

   
261
  private ConfigurationUtils() {
265
  private ConfigurationUtils() {
262
    // Instantiation is prohibited
266
    // Instantiation is prohibited
263
  }
267
  }

    
   
268

   

    
   
269
  public static void configureLogging() {

    
   
270
    try {

    
   
271
      Properties props = new Properties();

    
   
272
      InputStream resourceAsStream =

    
   
273
          SqoopMapper.class.getResourceAsStream("/META-INF/log4j.properties");

    
   
274
      props.load(resourceAsStream);

    
   
275
      PropertyConfigurator.configure(props);

    
   
276
    } catch (Exception e) {

    
   
277
      System.err.println("Encountered exception while configuring logging " +

    
   
278
        "for sqoop: " + e);

    
   
279
    }

    
   
280
  }
264
}
281
}
execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java
Revision 59cf391 New Change
 
execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java
Revision b31161c New Change
 
execution/mapreduce/src/main/resources/META-INF/log4j.properties
New File
 
  1. execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java: Loading...
  2. execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java: Loading...
  3. execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java: Loading...
  4. execution/mapreduce/src/main/resources/META-INF/log4j.properties: Loading...