ConfigurableApplicationContext context = null;
try {
context = new ClassPathXmlApplicationContext("application-context.xml");
System.out.println("Submitting kill-application example");
YarnClient client = (YarnClient) context.getBean("yarnClient");
ApplicationId applicationId = client.submitApplication();
System.out.println("Submitted kill-application example");
System.out.println("Waiting 30 seconds before aborting the application");
Thread.sleep(30000);
System.out.println("Asking resource manager to abort application with applicationid=" + applicationId);
client.killApplication(applicationId);