org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope Java Examples

The following examples show how to use org.apache.hadoop.yarn.api.protocolrecords.ApplicationsRequestScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GetApplicationsRequestPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void setScope(ApplicationsRequestScope scope) {
  maybeInitBuilder();
  if (scope == null) {
    builder.clearScope();
  }
  this.scope = scope;
}
 
Example #2
Source File: GetApplicationsRequestPBImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void setScope(ApplicationsRequestScope scope) {
  maybeInitBuilder();
  if (scope == null) {
    builder.clearScope();
  }
  this.scope = scope;
}
 
Example #3
Source File: RMCommunicator.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Get list of all applications known to RM according to time range provided.
 *@param set of application types
 * @return list of application report
 * @throws YarnException the yarn exception
 * @throws IOException Signals that an I/O exception has occurred.
 */

public List<ApplicationReport> getApplications(ApplicationsRequestScope scope, Set<String> users,
		Set<String> queues, Set<String> applicationTypes, Set<String> applicationTags,
		EnumSet<YarnApplicationState> applicationStates, Long finishFrom, Long finishTo, Long limit)
				throws YarnException, IOException {
	return proxy
			.getApplications(GetApplicationsRequest.newInstance(scope, users, queues, applicationTypes,
					applicationTags, applicationStates, null, new LongRange(finishFrom, finishTo), limit))
			.getApplicationList();
}
 
Example #4
Source File: GetApplicationsRequestPBImpl.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationsRequestScope getScope() {
  initScope();
  return this.scope;
}
 
Example #5
Source File: ProtoUtils.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static YarnServiceProtos.ApplicationsRequestScopeProto
    convertToProtoFormat(ApplicationsRequestScope e) {
  return YarnServiceProtos.ApplicationsRequestScopeProto.valueOf(e.name());
}
 
Example #6
Source File: ProtoUtils.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static ApplicationsRequestScope convertFromProtoFormat
    (YarnServiceProtos.ApplicationsRequestScopeProto e) {
  return ApplicationsRequestScope.valueOf(e.name());
}
 
Example #7
Source File: TestGetApplicationsRequest.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetApplicationsRequest(){
  GetApplicationsRequest request = GetApplicationsRequest.newInstance();
  
  EnumSet<YarnApplicationState> appStates = 
    EnumSet.of(YarnApplicationState.ACCEPTED);
  request.setApplicationStates(appStates);
  
  Set<String> tags = new HashSet<String>();
  tags.add("tag1");
  request.setApplicationTags(tags);
  
  Set<String> types = new HashSet<String>();
  types.add("type1");
  request.setApplicationTypes(types);
  
  long startBegin = System.currentTimeMillis();
  long startEnd = System.currentTimeMillis() + 1;
  request.setStartRange(startBegin, startEnd);
  long finishBegin = System.currentTimeMillis() + 2;
  long finishEnd = System.currentTimeMillis() + 3;
  request.setFinishRange(finishBegin, finishEnd);
  
  long limit = 100L;
  request.setLimit(limit);
  
  Set<String> queues = new HashSet<String>();
  queues.add("queue1");
  request.setQueues(queues);
  
  
  Set<String> users = new HashSet<String>();
  users.add("user1");
  request.setUsers(users);
  
  ApplicationsRequestScope scope = ApplicationsRequestScope.ALL;
  request.setScope(scope);
  
  GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(
      ((GetApplicationsRequestPBImpl)request).getProto());
  
  // verify the whole record equals with original record
  Assert.assertEquals(requestFromProto, request);

  // verify all properties are the same as original request
  Assert.assertEquals(
      "ApplicationStates from proto is not the same with original request",
      requestFromProto.getApplicationStates(), appStates);
  
  Assert.assertEquals(
      "ApplicationTags from proto is not the same with original request",
      requestFromProto.getApplicationTags(), tags);
  
  Assert.assertEquals(
      "ApplicationTypes from proto is not the same with original request",
      requestFromProto.getApplicationTypes(), types);
  
  Assert.assertEquals(
      "StartRange from proto is not the same with original request",
      requestFromProto.getStartRange(), new LongRange(startBegin, startEnd));
  
  Assert.assertEquals(
      "FinishRange from proto is not the same with original request",
      requestFromProto.getFinishRange(), new LongRange(finishBegin, finishEnd));
  
  Assert.assertEquals(
      "Limit from proto is not the same with original request",
      requestFromProto.getLimit(), limit);
  
  Assert.assertEquals(
      "Queues from proto is not the same with original request",
      requestFromProto.getQueues(), queues);
  
  Assert.assertEquals(
      "Users from proto is not the same with original request",
      requestFromProto.getUsers(), users);
}
 
Example #8
Source File: GetApplicationsRequestPBImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationsRequestScope getScope() {
  initScope();
  return this.scope;
}
 
Example #9
Source File: ProtoUtils.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static YarnServiceProtos.ApplicationsRequestScopeProto
    convertToProtoFormat(ApplicationsRequestScope e) {
  return YarnServiceProtos.ApplicationsRequestScopeProto.valueOf(e.name());
}
 
Example #10
Source File: ProtoUtils.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static ApplicationsRequestScope convertFromProtoFormat
    (YarnServiceProtos.ApplicationsRequestScopeProto e) {
  return ApplicationsRequestScope.valueOf(e.name());
}
 
Example #11
Source File: TestGetApplicationsRequest.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetApplicationsRequest(){
  GetApplicationsRequest request = GetApplicationsRequest.newInstance();
  
  EnumSet<YarnApplicationState> appStates = 
    EnumSet.of(YarnApplicationState.ACCEPTED);
  request.setApplicationStates(appStates);
  
  Set<String> tags = new HashSet<String>();
  tags.add("tag1");
  request.setApplicationTags(tags);
  
  Set<String> types = new HashSet<String>();
  types.add("type1");
  request.setApplicationTypes(types);
  
  long startBegin = System.currentTimeMillis();
  long startEnd = System.currentTimeMillis() + 1;
  request.setStartRange(startBegin, startEnd);
  long finishBegin = System.currentTimeMillis() + 2;
  long finishEnd = System.currentTimeMillis() + 3;
  request.setFinishRange(finishBegin, finishEnd);
  
  long limit = 100L;
  request.setLimit(limit);
  
  Set<String> queues = new HashSet<String>();
  queues.add("queue1");
  request.setQueues(queues);
  
  
  Set<String> users = new HashSet<String>();
  users.add("user1");
  request.setUsers(users);
  
  ApplicationsRequestScope scope = ApplicationsRequestScope.ALL;
  request.setScope(scope);
  
  GetApplicationsRequest requestFromProto = new GetApplicationsRequestPBImpl(
      ((GetApplicationsRequestPBImpl)request).getProto());
  
  // verify the whole record equals with original record
  Assert.assertEquals(requestFromProto, request);

  // verify all properties are the same as original request
  Assert.assertEquals(
      "ApplicationStates from proto is not the same with original request",
      requestFromProto.getApplicationStates(), appStates);
  
  Assert.assertEquals(
      "ApplicationTags from proto is not the same with original request",
      requestFromProto.getApplicationTags(), tags);
  
  Assert.assertEquals(
      "ApplicationTypes from proto is not the same with original request",
      requestFromProto.getApplicationTypes(), types);
  
  Assert.assertEquals(
      "StartRange from proto is not the same with original request",
      requestFromProto.getStartRange(), new LongRange(startBegin, startEnd));
  
  Assert.assertEquals(
      "FinishRange from proto is not the same with original request",
      requestFromProto.getFinishRange(), new LongRange(finishBegin, finishEnd));
  
  Assert.assertEquals(
      "Limit from proto is not the same with original request",
      requestFromProto.getLimit(), limit);
  
  Assert.assertEquals(
      "Queues from proto is not the same with original request",
      requestFromProto.getQueues(), queues);
  
  Assert.assertEquals(
      "Users from proto is not the same with original request",
      requestFromProto.getUsers(), users);
}