@VisibleForTesting Optional<ApplicationId> getReconnectableApplicationId() throws YarnException, IOException { List<ApplicationReport> applicationReports = this.yarnClient.getApplications(APPLICATION_TYPES, RECONNECTABLE_APPLICATION_STATES); if (applicationReports == null || applicationReports.isEmpty()) { return Optional.absent(); } // Try to find an application with a matching application name for (ApplicationReport applicationReport : applicationReports) { if (this.applicationName.equals(applicationReport.getName())) { return Optional.of(applicationReport.getApplicationId()); } } return Optional.absent(); }
private ApplicationReport getOnlyApplicationReport() throws IOException, YarnException { final YarnClient yarnClient = getYarnClient(); checkState(yarnClient != null); final List<ApplicationReport> apps = yarnClient.getApplications(EnumSet.of(YarnApplicationState.RUNNING)); assertEquals(1, apps.size()); // Only one running return apps.get(0); }
/** * Sleep a bit between the tests (we are re-using the YARN cluster for the tests). */ @After public void sleep() throws IOException, YarnException { Deadline deadline = Deadline.now().plus(Duration.ofSeconds(10)); boolean isAnyJobRunning = yarnClient.getApplications().stream() .anyMatch(YarnTestBase::isApplicationRunning); while (deadline.hasTimeLeft() && isAnyJobRunning) { try { Thread.sleep(500); } catch (InterruptedException e) { Assert.fail("Should not happen"); } isAnyJobRunning = yarnClient.getApplications().stream() .anyMatch(YarnTestBase::isApplicationRunning); } if (isAnyJobRunning) { final List<String> runningApps = yarnClient.getApplications().stream() .filter(YarnTestBase::isApplicationRunning) .map(app -> "App " + app.getApplicationId() + " is in state " + app.getYarnApplicationState() + '.') .collect(Collectors.toList()); if (!runningApps.isEmpty()) { Assert.fail("There is at least one application on the cluster that is not finished." + runningApps); } } }
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)); }
yc.init(YARN_CONFIGURATION); yc.start(); List<ApplicationReport> apps = yc.getApplications(EnumSet.of(YarnApplicationState.RUNNING)); Assert.assertEquals(1, apps.size()); // Only one running ApplicationReport app = apps.get(0); yc.killApplication(id); while (yc.getApplications(EnumSet.of(YarnApplicationState.KILLED)).size() == 0 && yc.getApplications(EnumSet.of(YarnApplicationState.FINISHED)).size() == 0) { sleep(500);
/** * Scan all clusters to recover the soft state. */ @VisibleForTesting void scanAll() throws IOException, YarnException { ConcurrentHashMap<UUID, InstanceInfo> newInstances = new ConcurrentHashMap<>(); for (ClusterInfo cluster : clusters.values()) { List<ApplicationReport> reports = cluster.client() .getApplications(Collections.singleton(ATHENAX_APPLICATION_TYPE)); for (ApplicationReport report : reports) { InstanceInfo instance = Utils.extractInstanceInfo(cluster.name(), report); if (instance == null) { LOG.warn("Failed to retrieve instance info for {}:{}", cluster.name(), report.getApplicationId()); } else { newInstances.put(instance.metadata().uuid(), instance); } } } LOG.info("Inspected {} active instances", newInstances.size()); instances.set(newInstances); listener.onUpdatedInstances(newInstances); } }
@Override public List<ApplicationReport> getApplications( Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates) throws YarnException, IOException { return client.getApplications(applicationTypes, applicationStates); }
@Override public List<ApplicationReport> getApplications() throws YarnException, IOException { return client.getApplications(); }
@Override public List<ApplicationReport> getApplications(Set<String> applicationTypes) throws YarnException, IOException { return client.getApplications(applicationTypes); }
@Override public List<ApplicationReport> getApplications( Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates, Set<String> applicationTags) throws YarnException, IOException { return client.getApplications( applicationTypes, applicationStates, applicationTags); }
@Override public List<ApplicationReport> getApplications( EnumSet<YarnApplicationState> applicationStates) throws YarnException, IOException { return client.getApplications(applicationStates); }
@Override public List<ApplicationReport> getApplications( EnumSet<YarnApplicationState> applicationStates) throws YarnException, IOException { return client.getApplications(applicationStates); }
@Override public List<ApplicationReport> getApplications(Set<String> queues, Set<String> users, Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates) throws YarnException, IOException { return client.getApplications(queues, users, applicationTypes, applicationStates); }
@Override public List<ApplicationReport> getApplications(Set<String> applicationTypes) throws YarnException, IOException { return client.getApplications(applicationTypes); }
private List<ApplicationReport> getYarnApplications(Set<String> hdfsUsers, YarnClient yarnClient) throws YarnException, IOException { List<ApplicationReport> projectApplications = yarnClient.getApplications(null, hdfsUsers, null, EnumSet.of( YarnApplicationState.ACCEPTED, YarnApplicationState.NEW, YarnApplicationState.NEW_SAVING, YarnApplicationState.RUNNING, YarnApplicationState.SUBMITTED)); return projectApplications; }
String errorMessage = ""; while(!verified) { List<ApplicationReport> apps = yarnClient.getApplications(); if (apps.size() == 0 ) { Thread.sleep(10);
public JobStatus[] getAllJobs() throws IOException, InterruptedException { try { Set<String> appTypes = new HashSet<String>(1); appTypes.add(MRJobConfig.MR_APPLICATION_TYPE); EnumSet<YarnApplicationState> appStates = EnumSet.noneOf(YarnApplicationState.class); return TypeConverter.fromYarnApps( client.getApplications(appTypes, appStates), this.conf); } catch (YarnException e) { throw new IOException(e); } }
public JobStatus[] getAllJobs() throws IOException, InterruptedException { try { Set<String> appTypes = new HashSet<String>(1); appTypes.add(MRJobConfig.MR_APPLICATION_TYPE); EnumSet<YarnApplicationState> appStates = EnumSet.noneOf(YarnApplicationState.class); return TypeConverter.fromYarnApps( client.getApplications(appTypes, appStates), this.conf); } catch (YarnException e) { throw new IOException(e); } }
public JobStatus[] getAllJobs() throws IOException, InterruptedException { try { Set<String> appTypes = new HashSet<String>(1); appTypes.add(TezConstants.TEZ_APPLICATION_TYPE); return TypeConverter.fromYarnApps(client.getApplications(appTypes), this.conf); } catch (YarnException e) { throw new IOException(e); } }
@Override public Void run() throws Exception { List<ApplicationReport> apps = yarnClient.getApplications(Collections.singleton(appType), EnumSet.of(YarnApplicationState.RUNNING)); for (ApplicationReport app : apps) { yarnClient.killApplication(app.getApplicationId()); } return null; } });