Java源码示例:org.apache.hadoop.yarn.server.resourcemanager.scheduler.YarnScheduler

示例1
/**
 * Utility method to validate a list resource requests, by insuring that the
 * requested memory/vcore is non-negative and not greater than max
 */
public static void normalizeAndValidateRequests(List<ResourceRequest> ask,
    Resource maximumResource, String queueName, YarnScheduler scheduler,
    RMContext rmContext)
    throws InvalidResourceRequestException {

  QueueInfo queueInfo = null;
  try {
    queueInfo = scheduler.getQueueInfo(queueName, false, false);
  } catch (IOException e) {
  }

  for (ResourceRequest resReq : ask) {
    SchedulerUtils.normalizeAndvalidateRequest(resReq, maximumResource,
        queueName, scheduler, rmContext, queueInfo);
  }
}
 
示例2
public RMAppAttemptImpl(ApplicationAttemptId appAttemptId,
    RMContext rmContext, YarnScheduler scheduler,
    ApplicationMasterService masterService,
    ApplicationSubmissionContext submissionContext,
    Configuration conf, boolean maybeLastAttempt, ResourceRequest amReq) {
  this.conf = conf;
  this.applicationAttemptId = appAttemptId;
  this.rmContext = rmContext;
  this.eventHandler = rmContext.getDispatcher().getEventHandler();
  this.submissionContext = submissionContext;
  this.scheduler = scheduler;
  this.masterService = masterService;

  ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
  this.readLock = lock.readLock();
  this.writeLock = lock.writeLock();

  this.proxiedTrackingUrl = generateProxyUriWithScheme();
  this.maybeLastAttempt = maybeLastAttempt;
  this.stateMachine = stateMachineFactory.make(this);

  this.attemptMetrics =
      new RMAppAttemptMetrics(applicationAttemptId, rmContext);
  
  this.amReq = amReq;
}
 
示例3
public RMAppManager(RMContext context,
    YarnScheduler scheduler, ApplicationMasterService masterService,
    ApplicationACLsManager applicationACLsManager, Configuration conf) {
  this.rmContext = context;
  this.scheduler = scheduler;
  this.masterService = masterService;
  this.applicationACLsManager = applicationACLsManager;
  this.conf = conf;
  this.maxCompletedAppsInMemory = conf.getInt(
      YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS,
      YarnConfiguration.DEFAULT_RM_MAX_COMPLETED_APPLICATIONS);
  this.maxCompletedAppsInStateStore =
      conf.getInt(
        YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS,
        YarnConfiguration.DEFAULT_RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS);
  if (this.maxCompletedAppsInStateStore > this.maxCompletedAppsInMemory) {
    this.maxCompletedAppsInStateStore = this.maxCompletedAppsInMemory;
  }
}
 
示例4
@Test
public void testGetApplicationResourceUsageReportDummy() throws YarnException,
    IOException {
  ApplicationAttemptId attemptId = getApplicationAttemptId(1);
  YarnScheduler yarnScheduler = mockYarnScheduler();
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  when(rmContext.getDispatcher().getEventHandler()).thenReturn(
      new EventHandler<Event>() {
        public void handle(Event event) {
        }
      });
  ApplicationSubmissionContext asContext = 
      mock(ApplicationSubmissionContext.class);
  YarnConfiguration config = new YarnConfiguration();
  RMAppAttemptImpl rmAppAttemptImpl = new RMAppAttemptImpl(attemptId,
      rmContext, yarnScheduler, null, asContext, config, false, null);
  ApplicationResourceUsageReport report = rmAppAttemptImpl
      .getApplicationResourceUsageReport();
  assertEquals(report, RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
}
 
示例5
public ClientRMService createRMService() throws IOException {
  YarnScheduler yarnScheduler = mockYarnScheduler();
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ConcurrentHashMap<ApplicationId, RMApp> apps = getRMApps(rmContext,
      yarnScheduler);
  when(rmContext.getRMApps()).thenReturn(apps);
  when(rmContext.getYarnConfiguration()).thenReturn(new Configuration());
  RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, null,
      mock(ApplicationACLsManager.class), new Configuration());
  when(rmContext.getDispatcher().getEventHandler()).thenReturn(
      new EventHandler<Event>() {
        public void handle(Event event) {
        }
      });

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(
      mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
          any(QueueACL.class), anyString())).thenReturn(true);
  return new ClientRMService(rmContext, yarnScheduler, appManager,
      mockAclsManager, mockQueueACLsManager, null);
}
 
示例6
private void mockRMContext(YarnScheduler yarnScheduler, RMContext rmContext)
    throws IOException {
  Dispatcher dispatcher = mock(Dispatcher.class);
  when(rmContext.getDispatcher()).thenReturn(dispatcher);
  EventHandler eventHandler = mock(EventHandler.class);
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  QueueInfo queInfo = recordFactory.newRecordInstance(QueueInfo.class);
  queInfo.setQueueName("testqueue");
  when(yarnScheduler.getQueueInfo(eq("testqueue"), anyBoolean(), anyBoolean()))
      .thenReturn(queInfo);
  when(yarnScheduler.getQueueInfo(eq("nonexistentqueue"), anyBoolean(), anyBoolean()))
      .thenThrow(new IOException("queue does not exist"));
  RMApplicationHistoryWriter writer = mock(RMApplicationHistoryWriter.class);
  when(rmContext.getRMApplicationHistoryWriter()).thenReturn(writer);
  SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class);
  when(rmContext.getSystemMetricsPublisher()).thenReturn(publisher);
  ConcurrentHashMap<ApplicationId, RMApp> apps = getRMApps(rmContext,
      yarnScheduler);
  when(rmContext.getRMApps()).thenReturn(apps);
  when(yarnScheduler.getAppsInQueue(eq("testqueue"))).thenReturn(
      getSchedulerApps(apps));
   ResourceScheduler rs = mock(ResourceScheduler.class);
   when(rmContext.getScheduler()).thenReturn(rs);
}
 
示例7
private ConcurrentHashMap<ApplicationId, RMApp> getRMApps(
    RMContext rmContext, YarnScheduler yarnScheduler) {
  ConcurrentHashMap<ApplicationId, RMApp> apps = 
    new ConcurrentHashMap<ApplicationId, RMApp>();
  ApplicationId applicationId1 = getApplicationId(1);
  ApplicationId applicationId2 = getApplicationId(2);
  ApplicationId applicationId3 = getApplicationId(3);
  YarnConfiguration config = new YarnConfiguration();
  apps.put(applicationId1, getRMApp(rmContext, yarnScheduler, applicationId1,
      config, "testqueue", 10, 3, 3));
  apps.put(applicationId2, getRMApp(rmContext, yarnScheduler, applicationId2,
      config, "a", 20, 2, 2));
  apps.put(applicationId3, getRMApp(rmContext, yarnScheduler, applicationId3,
      config, "testqueue", 40, 5, 5));
  return apps;
}
 
示例8
private static YarnScheduler mockYarnScheduler() {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  when(yarnScheduler.getMinimumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  when(yarnScheduler.getMaximumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
  when(yarnScheduler.getAppsInQueue(QUEUE_1)).thenReturn(
      Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
  when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(
      Arrays.asList(getApplicationAttemptId(103)));
  ApplicationAttemptId attemptId = getApplicationAttemptId(1);
  when(yarnScheduler.getAppResourceUsageReport(attemptId)).thenReturn(null);
  ResourceCalculator rc = new DefaultResourceCalculator();
  when(yarnScheduler.getResourceCalculator()).thenReturn(rc);
  return yarnScheduler;
}
 
示例9
/**
 * Utility method to validate a list resource requests, by insuring that the
 * requested memory/vcore is non-negative and not greater than max
 */
public static void normalizeAndValidateRequests(List<ResourceRequest> ask,
    Resource maximumResource, String queueName, YarnScheduler scheduler,
    RMContext rmContext)
    throws InvalidResourceRequestException {

  QueueInfo queueInfo = null;
  try {
    queueInfo = scheduler.getQueueInfo(queueName, false, false);
  } catch (IOException e) {
  }

  for (ResourceRequest resReq : ask) {
    SchedulerUtils.normalizeAndvalidateRequest(resReq, maximumResource,
        queueName, scheduler, rmContext, queueInfo);
  }
}
 
示例10
public RMAppAttemptImpl(ApplicationAttemptId appAttemptId,
    RMContext rmContext, YarnScheduler scheduler,
    ApplicationMasterService masterService,
    ApplicationSubmissionContext submissionContext,
    Configuration conf, boolean maybeLastAttempt, ResourceRequest amReq) {
  this.conf = conf;
  this.applicationAttemptId = appAttemptId;
  this.rmContext = rmContext;
  this.eventHandler = rmContext.getDispatcher().getEventHandler();
  this.submissionContext = submissionContext;
  this.scheduler = scheduler;
  this.masterService = masterService;

  ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
  this.readLock = lock.readLock();
  this.writeLock = lock.writeLock();

  this.proxiedTrackingUrl = generateProxyUriWithScheme();
  this.maybeLastAttempt = maybeLastAttempt;
  this.stateMachine = stateMachineFactory.make(this);

  this.attemptMetrics =
      new RMAppAttemptMetrics(applicationAttemptId, rmContext);
  
  this.amReq = amReq;
}
 
示例11
public RMAppManager(RMContext context,
    YarnScheduler scheduler, ApplicationMasterService masterService,
    ApplicationACLsManager applicationACLsManager, Configuration conf) {
  this.rmContext = context;
  this.scheduler = scheduler;
  this.masterService = masterService;
  this.applicationACLsManager = applicationACLsManager;
  this.conf = conf;
  this.maxCompletedAppsInMemory = conf.getInt(
      YarnConfiguration.RM_MAX_COMPLETED_APPLICATIONS,
      YarnConfiguration.DEFAULT_RM_MAX_COMPLETED_APPLICATIONS);
  this.maxCompletedAppsInStateStore =
      conf.getInt(
        YarnConfiguration.RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS,
        YarnConfiguration.DEFAULT_RM_STATE_STORE_MAX_COMPLETED_APPLICATIONS);
  if (this.maxCompletedAppsInStateStore > this.maxCompletedAppsInMemory) {
    this.maxCompletedAppsInStateStore = this.maxCompletedAppsInMemory;
  }
}
 
示例12
@Test
public void testGetApplicationResourceUsageReportDummy() throws YarnException,
    IOException {
  ApplicationAttemptId attemptId = getApplicationAttemptId(1);
  YarnScheduler yarnScheduler = mockYarnScheduler();
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  when(rmContext.getDispatcher().getEventHandler()).thenReturn(
      new EventHandler<Event>() {
        public void handle(Event event) {
        }
      });
  ApplicationSubmissionContext asContext = 
      mock(ApplicationSubmissionContext.class);
  YarnConfiguration config = new YarnConfiguration();
  RMAppAttemptImpl rmAppAttemptImpl = new RMAppAttemptImpl(attemptId,
      rmContext, yarnScheduler, null, asContext, config, false, null);
  ApplicationResourceUsageReport report = rmAppAttemptImpl
      .getApplicationResourceUsageReport();
  assertEquals(report, RMServerUtils.DUMMY_APPLICATION_RESOURCE_USAGE_REPORT);
}
 
示例13
public ClientRMService createRMService() throws IOException {
  YarnScheduler yarnScheduler = mockYarnScheduler();
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);
  ConcurrentHashMap<ApplicationId, RMApp> apps = getRMApps(rmContext,
      yarnScheduler);
  when(rmContext.getRMApps()).thenReturn(apps);
  when(rmContext.getYarnConfiguration()).thenReturn(new Configuration());
  RMAppManager appManager = new RMAppManager(rmContext, yarnScheduler, null,
      mock(ApplicationACLsManager.class), new Configuration());
  when(rmContext.getDispatcher().getEventHandler()).thenReturn(
      new EventHandler<Event>() {
        public void handle(Event event) {
        }
      });

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
  when(
      mockQueueACLsManager.checkAccess(any(UserGroupInformation.class),
          any(QueueACL.class), anyString())).thenReturn(true);
  return new ClientRMService(rmContext, yarnScheduler, appManager,
      mockAclsManager, mockQueueACLsManager, null);
}
 
示例14
private void mockRMContext(YarnScheduler yarnScheduler, RMContext rmContext)
    throws IOException {
  Dispatcher dispatcher = mock(Dispatcher.class);
  when(rmContext.getDispatcher()).thenReturn(dispatcher);
  EventHandler eventHandler = mock(EventHandler.class);
  when(dispatcher.getEventHandler()).thenReturn(eventHandler);
  QueueInfo queInfo = recordFactory.newRecordInstance(QueueInfo.class);
  queInfo.setQueueName("testqueue");
  when(yarnScheduler.getQueueInfo(eq("testqueue"), anyBoolean(), anyBoolean()))
      .thenReturn(queInfo);
  when(yarnScheduler.getQueueInfo(eq("nonexistentqueue"), anyBoolean(), anyBoolean()))
      .thenThrow(new IOException("queue does not exist"));
  RMApplicationHistoryWriter writer = mock(RMApplicationHistoryWriter.class);
  when(rmContext.getRMApplicationHistoryWriter()).thenReturn(writer);
  SystemMetricsPublisher publisher = mock(SystemMetricsPublisher.class);
  when(rmContext.getSystemMetricsPublisher()).thenReturn(publisher);
  ConcurrentHashMap<ApplicationId, RMApp> apps = getRMApps(rmContext,
      yarnScheduler);
  when(rmContext.getRMApps()).thenReturn(apps);
  when(yarnScheduler.getAppsInQueue(eq("testqueue"))).thenReturn(
      getSchedulerApps(apps));
   ResourceScheduler rs = mock(ResourceScheduler.class);
   when(rmContext.getScheduler()).thenReturn(rs);
}
 
示例15
private ConcurrentHashMap<ApplicationId, RMApp> getRMApps(
    RMContext rmContext, YarnScheduler yarnScheduler) {
  ConcurrentHashMap<ApplicationId, RMApp> apps = 
    new ConcurrentHashMap<ApplicationId, RMApp>();
  ApplicationId applicationId1 = getApplicationId(1);
  ApplicationId applicationId2 = getApplicationId(2);
  ApplicationId applicationId3 = getApplicationId(3);
  YarnConfiguration config = new YarnConfiguration();
  apps.put(applicationId1, getRMApp(rmContext, yarnScheduler, applicationId1,
      config, "testqueue", 10, 3));
  apps.put(applicationId2, getRMApp(rmContext, yarnScheduler, applicationId2,
      config, "a", 20, 2));
  apps.put(applicationId3, getRMApp(rmContext, yarnScheduler, applicationId3,
      config, "testqueue", 40, 5));
  return apps;
}
 
示例16
private static YarnScheduler mockYarnScheduler() {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  when(yarnScheduler.getMinimumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  when(yarnScheduler.getMaximumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
  when(yarnScheduler.getAppsInQueue(QUEUE_1)).thenReturn(
      Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
  when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(
      Arrays.asList(getApplicationAttemptId(103)));
  ApplicationAttemptId attemptId = getApplicationAttemptId(1);
  when(yarnScheduler.getAppResourceUsageReport(attemptId)).thenReturn(null);
  ResourceCalculator rc = new DefaultResourceCalculator();
  when(yarnScheduler.getResourceCalculator()).thenReturn(rc);
  return yarnScheduler;
}
 
示例17
public ClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager) {
  this(rmContext, scheduler, rmAppManager, applicationACLsManager,
      queueACLsManager, rmDTSecretManager, new UTCClock());
}
 
示例18
public ClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager, Clock clock) {
  super(ClientRMService.class.getName());
  this.scheduler = scheduler;
  this.rmContext = rmContext;
  this.rmAppManager = rmAppManager;
  this.applicationsACLsManager = applicationACLsManager;
  this.queueACLsManager = queueACLsManager;
  this.rmDTSecretManager = rmDTSecretManager;
  this.reservationSystem = rmContext.getReservationSystem();
  this.clock = clock;
  this.rValidator = new ReservationInputValidator(clock);
}
 
示例19
protected RMApp createNewTestApp(ApplicationSubmissionContext submissionContext) {
  ApplicationId applicationId = MockApps.newAppID(appId++);
  String user = MockApps.newUserName();
  String name = MockApps.newAppName();
  String queue = MockApps.newQueue();
  // ensure max application attempts set to known value
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, maxAppAttempts);
  scheduler = mock(YarnScheduler.class);

  ApplicationMasterService masterService =
      new ApplicationMasterService(rmContext, scheduler);
  
  if(submissionContext == null) {
    submissionContext = new ApplicationSubmissionContextPBImpl();
  }
  // applicationId will not be used because RMStateStore is mocked,
  // but applicationId is still set for safety
  submissionContext.setApplicationId(applicationId);

  RMApp application =
      new RMAppImpl(applicationId, rmContext, conf, name, user, queue,
        submissionContext, scheduler, masterService,
        System.currentTimeMillis(), "YARN", null, null);

  testAppStartState(applicationId, user, name, queue, application);
  this.rmContext.getRMApps().putIfAbsent(application.getApplicationId(),
      application);
  return application;
}
 
示例20
private void checkTaskContainersHost(ApplicationAttemptId attemptId,
    ContainerId containerId, ResourceManager rm, String host) {
  YarnScheduler scheduler = rm.getRMContext().getScheduler();
  SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);

  Assert.assertTrue(appReport.getLiveContainers().size() > 0);
  for (RMContainer c : appReport.getLiveContainers()) {
    if (c.getContainerId().equals(containerId)) {
      Assert.assertEquals(host, c.getAllocatedNode().getHost());
    }
  }
}
 
示例21
public MyRMAppManager(RMContext context, YarnScheduler scheduler,
    ApplicationMasterService masterService,
    ApplicationACLsManager applicationACLsManager, Configuration conf) {
  super(context, scheduler, masterService, applicationACLsManager, conf);
  this.conf = conf;
  this.rmContext = context;
}
 
示例22
public MyClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager,
    ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager) {
  super(rmContext, scheduler, rmAppManager, applicationACLsManager,
      queueACLsManager, rmDTSecretManager);
  this.rmContext = rmContext;
}
 
示例23
@Test
public void testGetApplicationReport() throws Exception {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  RMContext rmContext = mock(RMContext.class);
  mockRMContext(yarnScheduler, rmContext);

  ApplicationId appId1 = getApplicationId(1);

  ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
  when(
      mockAclsManager.checkAccess(UserGroupInformation.getCurrentUser(),
          ApplicationAccessType.VIEW_APP, null, appId1)).thenReturn(true);

  ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler,
      null, mockAclsManager, null, null);
  try {
    RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
    GetApplicationReportRequest request = recordFactory
        .newRecordInstance(GetApplicationReportRequest.class);
    request.setApplicationId(appId1);
    GetApplicationReportResponse response = 
        rmService.getApplicationReport(request);
    ApplicationReport report = response.getApplicationReport();
    ApplicationResourceUsageReport usageReport = 
        report.getApplicationResourceUsageReport();
    Assert.assertEquals(10, usageReport.getMemorySeconds());
    Assert.assertEquals(3, usageReport.getVcoreSeconds());
    Assert.assertEquals(3, usageReport.getGcoreSeconds());
  } finally {
    rmService.close();
  }
}
 
示例24
public CustomedClientRMService(RMContext rmContext,
    YarnScheduler scheduler, RMAppManager rmAppManager,
    ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager) {
  super(rmContext, scheduler, rmAppManager, applicationACLsManager,
      queueACLsManager, rmDTSecretManager);
}
 
示例25
public ClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager) {
  this(rmContext, scheduler, rmAppManager, applicationACLsManager,
      queueACLsManager, rmDTSecretManager, new UTCClock());
}
 
示例26
public ClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager, Clock clock) {
  super(ClientRMService.class.getName());
  this.scheduler = scheduler;
  this.rmContext = rmContext;
  this.rmAppManager = rmAppManager;
  this.applicationsACLsManager = applicationACLsManager;
  this.queueACLsManager = queueACLsManager;
  this.rmDTSecretManager = rmDTSecretManager;
  this.reservationSystem = rmContext.getReservationSystem();
  this.clock = clock;
  this.rValidator = new ReservationInputValidator(clock);
}
 
示例27
protected RMApp createNewTestApp(ApplicationSubmissionContext submissionContext) {
  ApplicationId applicationId = MockApps.newAppID(appId++);
  String user = MockApps.newUserName();
  String name = MockApps.newAppName();
  String queue = MockApps.newQueue();
  // ensure max application attempts set to known value
  conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, maxAppAttempts);
  scheduler = mock(YarnScheduler.class);

  ApplicationMasterService masterService =
      new ApplicationMasterService(rmContext, scheduler);
  
  if(submissionContext == null) {
    submissionContext = new ApplicationSubmissionContextPBImpl();
  }
  // applicationId will not be used because RMStateStore is mocked,
  // but applicationId is still set for safety
  submissionContext.setApplicationId(applicationId);

  RMApp application =
      new RMAppImpl(applicationId, rmContext, conf, name, user, queue,
        submissionContext, scheduler, masterService,
        System.currentTimeMillis(), "YARN", null, null);

  testAppStartState(applicationId, user, name, queue, application);
  this.rmContext.getRMApps().putIfAbsent(application.getApplicationId(),
      application);
  return application;
}
 
示例28
private void checkTaskContainersHost(ApplicationAttemptId attemptId,
    ContainerId containerId, ResourceManager rm, String host) {
  YarnScheduler scheduler = rm.getRMContext().getScheduler();
  SchedulerAppReport appReport = scheduler.getSchedulerAppInfo(attemptId);

  Assert.assertTrue(appReport.getLiveContainers().size() > 0);
  for (RMContainer c : appReport.getLiveContainers()) {
    if (c.getContainerId().equals(containerId)) {
      Assert.assertEquals(host, c.getAllocatedNode().getHost());
    }
  }
}
 
示例29
public MyRMAppManager(RMContext context, YarnScheduler scheduler,
    ApplicationMasterService masterService,
    ApplicationACLsManager applicationACLsManager, Configuration conf) {
  super(context, scheduler, masterService, applicationACLsManager, conf);
  this.conf = conf;
  this.rmContext = context;
}
 
示例30
public MyClientRMService(RMContext rmContext, YarnScheduler scheduler,
    RMAppManager rmAppManager,
    ApplicationACLsManager applicationACLsManager,
    QueueACLsManager queueACLsManager,
    RMDelegationTokenSecretManager rmDTSecretManager) {
  super(rmContext, scheduler, rmAppManager, applicationACLsManager,
      queueACLsManager, rmDTSecretManager);
  this.rmContext = rmContext;
}