sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject svn commit: r1375399 - in /sqoop/trunk/src/java/org/apache/sqoop/mapreduce: ExportJobBase.java ImportJobBase.java
Date Tue, 21 Aug 2012 06:56:20 GMT
Author: jarcec
Date: Tue Aug 21 06:56:19 2012
New Revision: 1375399

URL: http://svn.apache.org/viewvc?rev=1375399&view=rev
Log:
SQOOP-580. Add Open-ended "teardown" routine that is called after the job execution for cleanup.

(Seetharam Venkatesh via Jarek Jarcec Cecho)

Modified:
    sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ExportJobBase.java
    sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ImportJobBase.java

Modified: sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ExportJobBase.java
URL: http://svn.apache.org/viewvc/sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ExportJobBase.java?rev=1375399&r1=1375398&r2=1375399&view=diff
==============================================================================
--- sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ExportJobBase.java (original)
+++ sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ExportJobBase.java Tue Aug 21 06:56:19
2012
@@ -353,9 +353,8 @@ public class ExportJobBase extends JobBa
       }
     }
 
+    Job job = new Job(conf);
     try {
-      Job job = new Job(conf);
-
       // Set the external jar to use for the job.
       job.getConfiguration().set("mapred.jar", ormJarFile);
 
@@ -365,6 +364,8 @@ public class ExportJobBase extends JobBa
       configureMapper(job, tableName, tableClassName);
       configureNumTasks(job);
       cacheJars(job, context.getConnManager());
+
+      jobSetup(job);
       setJob(job);
       boolean success = runJob(job);
       if (!success) {
@@ -376,6 +377,7 @@ public class ExportJobBase extends JobBa
       throw new IOException(cnfe);
     } finally {
       unloadJars();
+      jobTeardown(job);
     }
 
     // Unstage the data if needed
@@ -416,4 +418,19 @@ public class ExportJobBase extends JobBa
       return FileType.UNKNOWN;
     }
   }
+
+  /**
+   * Open-ended "setup" routine that is called after the job is configured
+   * but just before it is submitted to MapReduce. Subclasses may override
+   * if necessary.
+   */
+  protected void jobSetup(Job job) throws IOException, ExportException {
+  }
+
+  /**
+   * Open-ended "teardown" routine that is called after the job is executed.
+   * Subclasses may override if necessary.
+   */
+  protected void jobTeardown(Job job) throws IOException, ExportException {
+  }
 }

Modified: sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ImportJobBase.java
URL: http://svn.apache.org/viewvc/sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ImportJobBase.java?rev=1375399&r1=1375398&r2=1375399&view=diff
==============================================================================
--- sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ImportJobBase.java (original)
+++ sqoop/trunk/src/java/org/apache/sqoop/mapreduce/ImportJobBase.java Tue Aug 21 06:56:19
2012
@@ -191,9 +191,8 @@ public class ImportJobBase extends JobBa
         new TableClassName(options).getClassForTable(tableName);
     loadJars(conf, ormJarFile, tableClassName);
 
+    Job job = new Job(conf);
     try {
-      Job job = new Job(conf);
-
       // Set the external jar to use for the job.
       job.getConfiguration().set("mapred.jar", ormJarFile);
 
@@ -216,6 +215,7 @@ public class ImportJobBase extends JobBa
       throw new IOException(cnfe);
     } finally {
       unloadJars();
+      jobTeardown(job);
     }
   }
 
@@ -227,6 +227,13 @@ public class ImportJobBase extends JobBa
   protected void jobSetup(Job job) throws IOException, ImportException {
   }
 
+  /**
+   * Open-ended "teardown" routine that is called after the job is executed.
+   * Subclasses may override if necessary.
+   */
+  protected void jobTeardown(Job job) throws IOException, ImportException {
+  }
+
   protected ImportJobContext getContext() {
     return context;
   }



Mime
View raw message