Skip to content

Instantly share code, notes, and snippets.

@juriad
Created March 15, 2017 14:02
Show Gist options
  • Select an option

  • Save juriad/8cc355bcbe381ccfaa658e6844c6e0d8 to your computer and use it in GitHub Desktop.

Select an option

Save juriad/8cc355bcbe381ccfaa658e6844c6e0d8 to your computer and use it in GitHub Desktop.
Start processing in yarn-cluster mode and await the end
public void run(String planFileOnHdfs) throws IOException, InterruptedException {
SparkLauncher sparkLauncher = new SparkLauncher();
SparkAppHandle handle = sparkLauncher
.setAppResource("cif.hadoop.boot.jar")
.setMainClass("com.ataccama.dqc.hadoop.launcher.HadoopClusterLauncher")
.setMaster("yarn-cluster")
.addAppArgs(planFileOnHdfs)
.startApplication();
CountDownLatch countDownLatch = new CountDownLatch(1);
handle.addListener(new SparkAppHandle.Listener() {
@Override
public void stateChanged(SparkAppHandle handle) {
if (handle.getState().isFinal()) {
countDownLatch.countDown();
}
}
@Override
public void infoChanged(SparkAppHandle handle) {
}
});
countDownLatch.await();
System.out.println(handle.getAppId() + " ended in state " + handle.getState());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment