/** * Kill a submitted application by sending a call to the ASM * * @param appId Application Id to be killed. * @throws YarnException * @throws IOException */ private void forceKillApplication(ApplicationId appId) throws YarnException, IOException { jstormClientContext.yarnClient.killApplication(appId); }
@Override public void killCluster(ApplicationId applicationId) throws FlinkException { try { yarnClient.killApplication(applicationId); Utils.deleteApplicationFiles(Collections.singletonMap( YarnConfigKeys.FLINK_YARN_FILES, getYarnFilesDir(applicationId).toUri().toString())); } catch (YarnException | IOException e) { throw new FlinkException("Could not kill the Yarn Flink cluster with id " + applicationId + '.', e); } }
/** * Kills YARN application and stops YARN client. * * <p>Use this method to kill the App before it has been properly deployed */ private void failSessionDuringDeployment(YarnClient yarnClient, YarnClientApplication yarnApplication) { LOG.info("Killing YARN application"); try { yarnClient.killApplication(yarnApplication.getNewApplicationResponse().getApplicationId()); } catch (Exception e) { // we only log a debug message here because the "killApplication" call is a best-effort // call (we don't know if the application has been deployed when the error occured). LOG.debug("Error while killing YARN application", e); } yarnClient.stop(); }
public void killApplication() throws YarnClientException { try { yarnClient.killApplication(appId); } catch (YarnException | IOException e) { throw new YarnClientException( "Kill failed for application: " + appId.toString()); } } }
/** * Kills all jobs tagged with the given tag that have been started after the * given timestamp. */ @Override public void killJobs(String tag, long timestamp) { try { LOG.info("Looking for jobs to kill..."); Set<ApplicationId> childJobs = getYarnChildJobs(tag, timestamp); if (childJobs.isEmpty()) { LOG.info("No jobs found from"); return; } else { LOG.info(String.format("Found MR jobs count: %d", childJobs.size())); LOG.info("Killing all found jobs"); YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf); yarnClient.start(); for (ApplicationId app: childJobs) { LOG.info(String.format("Killing job: %s ...", app)); yarnClient.killApplication(app); LOG.info(String.format("Job %s killed", app)); } } } catch (YarnException ye) { throw new RuntimeException("Exception occurred while killing child job(s)", ye); } catch (IOException ioe) { throw new RuntimeException("Exception occurred while killing child job(s)", ioe); } }
public static void killChildYarnJobs(Configuration conf, String tag) { try { if (tag == null) { return; } LOG.info("Killing yarn jobs using query tag:" + tag); Set<ApplicationId> childYarnJobs = getChildYarnJobs(conf, tag); if (!childYarnJobs.isEmpty()) { YarnClient yarnClient = YarnClient.createYarnClient(); yarnClient.init(conf); yarnClient.start(); for (ApplicationId app : childYarnJobs) { yarnClient.killApplication(app); } } } catch (IOException | YarnException ye) { LOG.warn("Exception occurred while killing child job({})", ye); } }
@Test(enabled=false, groups = { "disabledOnTravis" }, dependsOnMethods = "testSetupAndSubmitApplication") public void testGetReconnectableApplicationId() throws Exception { Assert.assertEquals(this.gobblinYarnAppLauncher.getReconnectableApplicationId().get(), this.applicationId); this.yarnClient.killApplication(this.applicationId); Assert.assertEquals(yarnClient.getApplicationReport(applicationId).getYarnApplicationState(), YarnApplicationState.KILLED, "Application not killed"); // takes some time for kill to take effect and app master to go down Thread.sleep(5000); }
private void killApplicationAndWait(final ApplicationId id) throws Exception { final YarnClient yarnClient = getYarnClient(); checkState(yarnClient != null, "yarnClient must be initialized"); yarnClient.killApplication(id); waitUntilCondition(() -> !yarnClient.getApplications(EnumSet.of(YarnApplicationState.KILLED, YarnApplicationState.FINISHED)).isEmpty(), Deadline.fromNow(TIMEOUT)); }
/** * Kill a submitted application by sending a call to the ASM * @param appId Application Id to be killed. * @throws YarnException * @throws IOException */ private void forceKillApplication(ApplicationId appId) throws YarnException, IOException { // TODO clarify whether multiple jobs with the same app id can be submitted and be running at // the same time. // If yes, can we kill a particular attempt only? // Response can be ignored as it is non-null on success or // throws an exception in case of failures yarnClient.killApplication(appId); }
public void killYarnApplication(String clusterName, ApplicationId appId) throws IOException, YarnException { ClusterInfo cluster = clusters.get(clusterName); if (cluster == null) { throw new IllegalArgumentException("Invalid cluster name " + clusterName); } cluster.client().killApplication(appId); }
public void changeState(UUID uuid, InstanceState desiredState) throws IOException, YarnException { if (desiredState == null || desiredState.getState() != InstanceState.StateEnum.KILLED) { throw new UnsupportedOperationException(); } InstanceInfo info = instances().get(uuid); if (info == null) { return; } ClusterInfo cluster = clusters.get(info.clusterName()); Preconditions.checkNotNull(cluster); cluster.client().killApplication(info.appId()); }
} catch (ExecutionException e) { LOG.warn("Failed to deploy {}, cause: {}", appId.toString(), e.getCause()); yarnClient.killApplication(appId); throw (Exception) e.getCause();
@Test public void testChangeState() throws Exception { YarnClient client = mock(YarnClient.class); YarnClusterConfiguration conf = mock(YarnClusterConfiguration.class); ClusterInfo clusterInfo = new ClusterInfo("foo", conf, client); UUID app = UUID.randomUUID(); ApplicationId yarnAppId = mock(ApplicationId.class); try (InstanceManager manager = new InstanceManager( Collections.singletonMap("foo", clusterInfo), mock(InstanceStateUpdateListener.class), mock(ScheduledExecutorService.class), AthenaXExtraConfigOptions.INSTANCE_MANAGER_RESCAN_INTERVAL.defaultValue())) { InstanceInfo instance = new InstanceInfo("foo", yarnAppId, mock(InstanceMetadata.class), mock(InstanceStatus.class)); manager.instances().put(app, instance); manager.changeState(app, new InstanceState().state(InstanceState.StateEnum.KILLED)); verify(client).killApplication(eq(yarnAppId)); } } }
/** * Kill a submitted application by sending a call to the ASM * @param appId Application Id to be killed. * @throws YarnException * @throws java.io.IOException */ private void forceKillApplication(ApplicationId appId) throws YarnException, IOException { yarnClient.killApplication(appId); }
@Override public void killApplication(ApplicationId applicationId) throws YarnException, IOException { client.killApplication(applicationId); }
@Override public void killApplication(ApplicationId appId, String diagnostics) throws YarnException, IOException { client.killApplication(appId, diagnostics); }
/** * This function kills an application given the applicationId * * @param applicationId the application Id of the job to be killed * @throws IOException Throws IO exception * @throws YarnException in case of errors or if YARN rejects the request due to * access-control restrictions. */ public void killApplication(String applicationId) throws IOException, YarnException { log.info("killing job with application id: " + applicationId); yarnClient.killApplication(getApplicationIDFromString(applicationId)); }
@Override public void killCluster(ApplicationId applicationId) throws FlinkException { try { yarnClient.killApplication(applicationId); Utils.deleteApplicationFiles(Collections.singletonMap( YarnConfigKeys.FLINK_YARN_FILES, getYarnFilesDir(applicationId).toUri().toString())); } catch (YarnException | IOException e) { throw new FlinkException("Could not kill the Yarn Flink cluster with id " + applicationId + '.', e); } }
@Override public void killCluster(ApplicationId applicationId) throws FlinkException { try { yarnClient.killApplication(applicationId); Utils.deleteApplicationFiles(Collections.singletonMap( YarnConfigKeys.FLINK_YARN_FILES, getYarnFilesDir(applicationId).toUri().toString())); } catch (YarnException | IOException e) { throw new FlinkException("Could not kill the Yarn Flink cluster with id " + applicationId + '.', e); } }