Source:
public static void main(String[] args) { if (args.length < 2) { throw new IllegalArgumentException("The number of arguments is incorrect. Usage:\n" + " <configuration file (conf.xml) path> <job file (.analysis.xml) path> [properties file path]\n" + "Got: " + Arrays.toString(args)); } final SparkConf conf = new SparkConf().setAppName("DataCleaner-spark"); final JavaSparkContext sparkContext = new JavaSparkContext(conf); final String confXmlPath = args[0]; final String analysisJobXmlPath = args[1]; final String propertiesPath; if (args.length > 2) { propertiesPath = args[2]; } else { propertiesPath = null; } final SparkJobContext sparkJobContext = new SparkJobContext(sparkContext, confXmlPath, analysisJobXmlPath, propertiesPath); final SparkAnalysisRunner sparkAnalysisRunner = new SparkAnalysisRunner(sparkContext, sparkJobContext); try { final AnalysisResultFuture result = sparkAnalysisRunner.run(); if (result.isDone()) { final Map<ComponentJob, AnalyzerResult> resultMap = result.getResultMap(); final SimpleAnalysisResult simpleAnalysisResult = new SimpleAnalysisResult(resultMap, result.getCreationDate()); final String resultJobFilePath = getResultJobFilePath(sparkContext, sparkJobContext); if (resultJobFilePath != null) { final HdfsResource hdfsResource = new HdfsResource(resultJobFilePath); final OutputStream out = hdfsResource.write(); try { SerializationUtils.serialize(simpleAnalysisResult, out); } catch (SerializationException e) { throw e; } finally { FileHelper.safeClose(out); } } } } finally { sparkContext.stop(); } }

Target:
public static void main(String[] args) { if (args.length < 2) { throw new IllegalArgumentException("The number of arguments is incorrect. Usage:\n" + " <configuration file (conf.xml) path> <job file (.analysis.xml) path> [properties file path]\n" + "Got: " + Arrays.toString(args)); } final SparkConf conf = new SparkConf().setAppName("DataCleaner-spark"); final JavaSparkContext sparkContext = new JavaSparkContext(conf); final String confXmlPath = args[0]; final String analysisJobXmlPath = args[1]; final String propertiesPath; if (args.length > 2) { propertiesPath = args[2]; } else { propertiesPath = null; } final SparkJobContext sparkJobContext = new SparkJobContext(sparkContext, confXmlPath, analysisJobXmlPath, propertiesPath); final SparkAnalysisRunner sparkAnalysisRunner = new SparkAnalysisRunner(sparkContext, sparkJobContext); try { final AnalysisResultFuture result = sparkAnalysisRunner.run(); if (result.isDone()) { final Map<ComponentJob, AnalyzerResult> resultMap = result.getResultMap(); final SimpleAnalysisResult simpleAnalysisResult = new SimpleAnalysisResult(resultMap, result.getCreationDate()); final String resultJobFilePath = getResultJobFilePath(sparkContext, sparkJobContext); logger.info("The result of the job was written to " + resultJobFilePath); if (resultJobFilePath != null) { final HdfsResource hdfsResource = new HdfsResource(resultJobFilePath); final OutputStream out = hdfsResource.write(); try { SerializationUtils.serialize(simpleAnalysisResult, out); } catch (SerializationException e) { logger.error("Error while trying to serialize the job"); throw e; } finally { FileHelper.safeClose(out); } } } } catch (Exception e) { logger.error("Exception " + e.getStackTrace()); throw e; } finally { sparkContext.stop(); } }