/** * Queries RM for the list of applications with the given tag that have started * after the given timestamp. */ private Set<ApplicationId> getYarnChildJobs(String tag, long timestamp) { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); LOG.info(String.format("Querying RM for tag = %s, starting with ts = %s", tag, timestamp)); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setStartRange(timestamp, System.currentTimeMillis()); gar.setApplicationTags(Collections.singleton(tag)); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } return childYarnJobs; } }
public static Set<ApplicationId> getChildYarnJobs(Configuration conf, String tag) throws IOException, YarnException { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setApplicationTags(Collections.singleton(tag)); ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { if (isAdmin() || appReport.getApplicationTags().contains(QueryState.USERID_TAG + "=" + SessionState.get() .getUserName())) { childYarnJobs.add(appReport.getApplicationId()); } } if (childYarnJobs.isEmpty()) { LOG.info("No child applications found"); } else { LOG.info("Found child YARN applications: " + StringUtils.join(childYarnJobs, ",")); } return childYarnJobs; }
@Override public List<ApplicationReport> getApplications(Set<String> applicationTypes, EnumSet<YarnApplicationState> applicationStates, Set<String> applicationTags) throws YarnException, IOException { GetApplicationsRequest request = GetApplicationsRequest.newInstance(applicationTypes, applicationStates); request.setApplicationTags(applicationTags); GetApplicationsResponse response = rmClient.getApplications(request); return response.getApplicationList(); }
final GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(scope); gar.setApplicationTags(Collections.singleton(tag)); long endTime = System.currentTimeMillis(); if (startTime > endTime) {
/** * Queries RM for the list of applications with the given tag that have started * after the given timestamp. */ private Set<ApplicationId> getYarnChildJobs(String tag, long timestamp) { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); LOG.info(String.format("Querying RM for tag = %s, starting with ts = %s", tag, timestamp)); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setStartRange(timestamp, System.currentTimeMillis()); gar.setApplicationTags(Collections.singleton(tag)); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } return childYarnJobs; } }
/** * Queries RM for the list of applications with the given tag that have started * after the given timestamp. */ private Set<ApplicationId> getYarnChildJobs(String tag, long timestamp) { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); LOG.info(String.format("Querying RM for tag = %s, starting with ts = %s", tag, timestamp)); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setStartRange(timestamp, System.currentTimeMillis()); gar.setApplicationTags(Collections.singleton(tag)); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } return childYarnJobs; } }
gar.setApplicationTags(Collections.singleton(tag)); long endTime = System.currentTimeMillis(); if (startTime > endTime) {
final GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(scope); gar.setApplicationTags(Collections.singleton(tag)); long endTime = System.currentTimeMillis(); if (startTime > endTime) {
/** * Queries RM for the list of applications with the given tag that have started * after the given timestamp. */ private Set<ApplicationId> getYarnChildJobs(String tag, long timestamp) { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); LOG.info(String.format("Querying RM for tag = %s, starting with ts = %s", tag, timestamp)); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setStartRange(timestamp, System.currentTimeMillis()); gar.setApplicationTags(Collections.singleton(tag)); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } return childYarnJobs; } }
/** * Queries RM for the list of applications with the given tag that have started * after the given timestamp. */ private Set<ApplicationId> getYarnChildJobs(String tag, long timestamp) { Set<ApplicationId> childYarnJobs = new HashSet<ApplicationId>(); LOG.info(String.format("Querying RM for tag = %s, starting with ts = %s", tag, timestamp)); GetApplicationsRequest gar = GetApplicationsRequest.newInstance(); gar.setScope(ApplicationsRequestScope.OWN); gar.setStartRange(timestamp, System.currentTimeMillis()); gar.setApplicationTags(Collections.singleton(tag)); try { ApplicationClientProtocol proxy = ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class); GetApplicationsResponse apps = proxy.getApplications(gar); List<ApplicationReport> appsList = apps.getApplicationList(); for(ApplicationReport appReport : appsList) { childYarnJobs.add(appReport.getApplicationId()); } } catch (IOException ioe) { throw new RuntimeException("Exception occurred while finding child jobs", ioe); } catch (YarnException ye) { throw new RuntimeException("Exception occurred while finding child jobs", ye); } return childYarnJobs; } }
public GetApplicationsRequest build() { validate(); GetApplicationsRequest request = GetApplicationsRequest.newInstance(); Set<String> appStates = parseQueries(statesQuery, true); if (!appStates.isEmpty()) { request.setApplicationStates(appStates); } if (!users.isEmpty()) { request.setUsers(users); } if (!queues.isEmpty()) { request.setQueues(queues); } if (limitNumber != null) { request.setLimit(limitNumber); } request.setStartRange(startedTimeBegin, startedTimeEnd); request.setFinishRange(finishTimeBegin, finishTimeEnd); if (!appTypes.isEmpty()) { request.setApplicationTypes(appTypes); } if (!appTags.isEmpty()) { request.setApplicationTags(appTags); } return request; } }
request.setApplicationTags(appTags);
@Test public void testRequestWithEmptyApplicationTagsQuery() { GetApplicationsRequest request = ApplicationsRequestBuilder.create() .withApplicationTags(Sets.newHashSet()).build(); GetApplicationsRequest expectedRequest = getDefaultRequest(); expectedRequest.setApplicationTags(Sets.newHashSet()); assertEquals(expectedRequest, request); }
@Test public void testRequestWithValidApplicationTagsQuery() { GetApplicationsRequest request = ApplicationsRequestBuilder.create() .withApplicationTags(Sets.newHashSet("tag1")).build(); GetApplicationsRequest expectedRequest = getDefaultRequest(); expectedRequest.setApplicationTags(Sets.newHashSet("tag1")); assertEquals(expectedRequest, request); } }
null, null); Set<String> tagSet = new HashSet<String>(); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 6, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 3, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 2, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 1, rmService.getApplications(request).getApplicationList().size());
null, null); Set<String> tagSet = new HashSet<String>(); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 6, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 3, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 2, rmService.getApplications(request).getApplicationList().size()); request.setApplicationTags(tagSet); assertEquals("Incorrect number of matching tags", 1, rmService.getApplications(request).getApplicationList().size());
request.setApplicationTags(tags);
request.setApplicationTags(tags);