-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.etl.utils | ||
|
||
import java.util.Properties | ||
|
||
import com.twitter.scalding.{RichXHandler, Tool} | ||
import org.apache.hadoop | ||
|
||
/** | ||
* Created by renienj on 3/12/17. | ||
*/ | ||
class HadoopRunner(job: String, prop: Properties) { | ||
|
||
def run() { | ||
val args = prop.get("main.args").asInstanceOf[String] | ||
require(args != null, "unable to get main.args") | ||
try { | ||
hadoop.util.ToolRunner.run(new hadoop.conf.Configuration, new Tool, args.split(" ")) | ||
} catch { | ||
case t: Throwable => { | ||
//create the exception URL link in GitHub wiki | ||
val gitHubLink = RichXHandler.createXUrl(t) | ||
val extraInfo = (if (RichXHandler().handlers.exists(h => h(t))) { | ||
RichXHandler.mapping(t.getClass) + "\n" | ||
} | ||
else { | ||
"" | ||
}) + | ||
"If you know what exactly caused this error, please consider contributing to GitHub via following link.\n" + gitHubLink | ||
|
||
//re-throw the exception with extra info | ||
throw new Throwable(extraInfo, t) | ||
} | ||
} | ||
} | ||
} |