Java Code Examples for org.apache.hadoop.yarn.exceptions.YarnException

The following examples show how to use org.apache.hadoop.yarn.exceptions.YarnException. These examples are extracted from open source projects. 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 Project: submarine   Source File: YarnServiceJobMonitor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public JobStatus getTrainingJobStatus(String jobName)
    throws IOException, YarnException {
  if (this.serviceClient == null) {
    synchronized (this) {
      if (this.serviceClient == null) {
        this.serviceClient = YarnServiceUtils.createServiceClient(
            clientContext.getYarnConfig());
      }
    }
  }
  String appStatus = serviceClient.getStatusString(jobName);
  Service serviceSpec = ServiceApiUtil.jsonSerDeser.fromJson(appStatus);
  JobStatus jobStatus = JobStatusBuilder.fromServiceSpec(serviceSpec);
  return jobStatus;
}
 
Example 2
Source Project: submarine   Source File: YarnServiceJobSubmitter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ApplicationId submitJob(Parameter paramsHolder)
    throws IOException, YarnException {
  Framework framework = paramsHolder.getFramework();
  RunJobParameters parameters =
      (RunJobParameters) paramsHolder.getParameters();

  if (framework == Framework.TENSORFLOW) {
    return submitTensorFlowJob((TensorFlowRunJobParameters) parameters);
  } else if (framework == Framework.PYTORCH) {
    return submitPyTorchJob((PyTorchRunJobParameters) parameters);
  } else {
    throw new UnsupportedOperationException(SUPPORTED_FRAMEWORKS_MESSAGE);
  }
}
 
Example 3
Source Project: big-c   Source File: TestYarnClient.java    License: Apache License 2.0 6 votes vote down vote up
private ContainerReport getContainer(
    ContainerId containerId,
    HashMap<ApplicationAttemptId, List<ContainerReport>> containersToAppAttemptMapping)
    throws YarnException, IOException {
  List<ContainerReport> containersForAppAttempt =
      containersToAppAttemptMapping.get(containerId
          .getApplicationAttemptId());
  if (containersForAppAttempt == null) {
    throw new ApplicationNotFoundException(containerId
        .getApplicationAttemptId().getApplicationId() + " is not found ");
  }
  Iterator<ContainerReport> iterator = containersForAppAttempt.iterator();
  while (iterator.hasNext()) {
    ContainerReport next = iterator.next();
    if (next.getContainerId().equals(containerId)) {
      return next;
    }
  }
  throw new ContainerNotFoundException(containerId + " is not found ");
}
 
Example 4
Source Project: hadoop   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  NodeId nodeId = request.getNodeId();
  Resource resource = request.getResource();
  LOG.info("Registering " + nodeId.toString());
  // NOTE: this really should be checking against the config value
  InetSocketAddress expected = NetUtils.getConnectAddress(
      conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
  Assert.assertEquals(NetUtils.getHostPortString(expected), nodeId.toString());
  Assert.assertEquals(5 * 1024, resource.getMemory());
  registeredNodes.add(nodeId);

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 5
Source Project: big-c   Source File: TestResourceTrackerPBClientImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test the method registerNodeManager. Method should return a not null
 * result.
 * 
 */
@Test
public void testResourceTrackerPBClientImpl() throws Exception {
  RegisterNodeManagerRequest request = recordFactory
      .newRecordInstance(RegisterNodeManagerRequest.class);
  assertNotNull(client.registerNodeManager(request));
  
  ResourceTrackerTestImpl.exception = true;
  try {
    client.registerNodeManager(request);
    fail("there  should be YarnException");
  } catch (YarnException e) {
    assertTrue(e.getMessage().startsWith("testMessage"));
  }finally{
    ResourceTrackerTestImpl.exception = false;
  }

}
 
Example 6
Source Project: hadoop   Source File: AbstractYarnScheduler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void killAllAppsInQueue(String queueName)
    throws YarnException {
  // check if queue is a valid
  List<ApplicationAttemptId> apps = getAppsInQueue(queueName);
  if (apps == null) {
    String errMsg = "The specified Queue: " + queueName + " doesn't exist";
    LOG.warn(errMsg);
    throw new YarnException(errMsg);
  }
  // generate kill events for each pending/running app
  for (ApplicationAttemptId app : apps) {
    this.rmContext
        .getDispatcher()
        .getEventHandler()
        .handle(new RMAppEvent(app.getApplicationId(), RMAppEventType.KILL));
  }
}
 
Example 7
Source Project: big-c   Source File: TimelineDataManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add or update an domain. If the domain already exists, only the owner
 * and the admin can update it.
 */
public void putDomain(TimelineDomain domain,
    UserGroupInformation callerUGI) throws YarnException, IOException {
  TimelineDomain existingDomain =
      store.getDomain(domain.getId());
  if (existingDomain != null) {
    if (!timelineACLsManager.checkAccess(callerUGI, existingDomain)) {
      throw new YarnException(callerUGI.getShortUserName() +
          " is not allowed to override an existing domain " +
          existingDomain.getId());
    }
    // Set it again in case ACLs are not enabled: The domain can be
    // modified by every body, but the owner is not changed.
    domain.setOwner(existingDomain.getOwner());
  }
  store.put(domain);
  // If the domain exists already, it is likely to be in the cache.
  // We need to invalidate it.
  if (existingDomain != null) {
    timelineACLsManager.replaceIfExist(domain);
  }
}
 
Example 8
Source Project: big-c   Source File: SCMAdminProtocolService.java    License: Apache License 2.0 6 votes vote down vote up
private void checkAcls(String method) throws YarnException {
  UserGroupInformation user;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    LOG.warn("Couldn't get current user", ioe);
    throw RPCUtil.getRemoteException(ioe);
  }

  if (!authorizer.isAdmin(user)) {
    LOG.warn("User " + user.getShortUserName() + " doesn't have permission" +
        " to call '" + method + "'");

    throw RPCUtil.getRemoteException(
        new AccessControlException("User " + user.getShortUserName() +
        " doesn't have permission" + " to call '" + method + "'"));
  }
  LOG.info("SCM Admin: " + method + " invoked by user " +
      user.getShortUserName());
}
 
Example 9
Source Project: hadoop   Source File: TestReservationInputValidator.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteReservationNoID() {
  ReservationDeleteRequest request = new ReservationDeleteRequestPBImpl();
  Plan plan = null;
  try {
    plan = rrValidator.validateReservationDeleteRequest(rSystem, request);
    Assert.fail();
  } catch (YarnException e) {
    Assert.assertNull(plan);
    String message = e.getMessage();
    Assert
        .assertTrue(message
            .startsWith("Missing reservation id. Please try again by specifying a reservation id."));
    LOG.info(message);
  }
}
 
Example 10
Source Project: flink   Source File: YarnClusterDescriptor.java    License: Apache License 2.0 6 votes vote down vote up
private ClusterResourceDescription getCurrentFreeClusterResources(YarnClient yarnClient) throws YarnException, IOException {
	List<NodeReport> nodes = yarnClient.getNodeReports(NodeState.RUNNING);

	int totalFreeMemory = 0;
	int containerLimit = 0;
	int[] nodeManagersFree = new int[nodes.size()];

	for (int i = 0; i < nodes.size(); i++) {
		NodeReport rep = nodes.get(i);
		int free = rep.getCapability().getMemory() - (rep.getUsed() != null ? rep.getUsed().getMemory() : 0);
		nodeManagersFree[i] = free;
		totalFreeMemory += free;
		if (free > containerLimit) {
			containerLimit = free;
		}
	}
	return new ClusterResourceDescription(totalFreeMemory, containerLimit, nodeManagersFree);
}
 
Example 11
Source Project: big-c   Source File: ClientRMService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException {
  try {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be renewed only with kerberos authentication");
    }
    
    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(
        protoToken.getIdentifier().array(), protoToken.getPassword().array(),
        new Text(protoToken.getKind()), new Text(protoToken.getService()));

    String user = getRenewerForToken(token);
    long nextExpTime = rmDTSecretManager.renewToken(token, user);
    RenewDelegationTokenResponse renewResponse = Records
        .newRecord(RenewDelegationTokenResponse.class);
    renewResponse.setNextExpirationTime(nextExpTime);
    return renewResponse;
  } catch (IOException e) {
    throw RPCUtil.getRemoteException(e);
  }
}
 
Example 12
Source Project: hadoop   Source File: SCMStore.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Clean all resource references to a cache resource that contain application
 * ids pointing to finished applications. If the resource key does not exist,
 * do nothing.
 *
 * @param key a unique identifier for a resource
 * @throws YarnException
 */
@Private
public void cleanResourceReferences(String key) throws YarnException {
  Collection<SharedCacheResourceReference> refs = getResourceReferences(key);
  if (!refs.isEmpty()) {
    Set<SharedCacheResourceReference> refsToRemove =
        new HashSet<SharedCacheResourceReference>();
    for (SharedCacheResourceReference r : refs) {
      if (!appChecker.isApplicationActive(r.getAppId())) {
        // application in resource reference is dead, it is safe to remove the
        // reference
        refsToRemove.add(r);
      }
    }
    if (refsToRemove.size() > 0) {
      removeResourceReferences(key, refsToRemove, false);
    }
  }
}
 
Example 13
Source Project: big-c   Source File: TestAHSClient.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetContainers() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  List<ContainerReport> reports = client.getContainers(appAttemptId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getContainerId(),
    (ContainerId.newContainerId(appAttemptId, 1)));
  Assert.assertEquals(reports.get(1).getContainerId(),
    (ContainerId.newContainerId(appAttemptId, 2)));
  client.stop();
}
 
Example 14
@Override
public Map<ApplicationId, ApplicationReport> getAllApplications()
    throws YarnException, IOException {
  TimelineEntities entities = timelineDataManager.getEntities(
      ApplicationMetricsConstants.ENTITY_TYPE, null, null, null, null,
      null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class),
      UserGroupInformation.getLoginUser());
  Map<ApplicationId, ApplicationReport> apps =
      new LinkedHashMap<ApplicationId, ApplicationReport>();
  if (entities != null && entities.getEntities() != null) {
    for (TimelineEntity entity : entities.getEntities()) {
      try {
        ApplicationReportExt app =
            generateApplicationReport(entity, ApplicationReportField.ALL);
        apps.put(app.appReport.getApplicationId(), app.appReport);
      } catch (Exception e) {
        LOG.error("Error on generating application report for " +
            entity.getEntityId(), e);
      }
    }
  }
  return apps;
}
 
Example 15
Source Project: big-c   Source File: AdminService.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
    RefreshUserToGroupsMappingsRequest request)
    throws YarnException, IOException {
  String argName = "refreshUserToGroupsMappings";
  UserGroupInformation user = checkAcls(argName);

  checkRMStatus(user.getShortUserName(), argName, "refresh user-groups.");

  Groups.getUserToGroupsMappingService(
      getConfiguration(new Configuration(false),
          YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();

  RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");

  return recordFactory.newRecordInstance(
      RefreshUserToGroupsMappingsResponse.class);
}
 
Example 16
Source Project: Bats   Source File: YarnAppLauncherImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isFinished()
{
  try {
    ApplicationReport appReport = yarnClient.getApplicationReport(appId);
    if (appReport != null) {
      if (appReport.getFinalApplicationStatus() == null
          || appReport.getFinalApplicationStatus() == FinalApplicationStatus.UNDEFINED) {
        return false;
      }
    }
    return true;
  } catch (YarnException | IOException e) {
    throw Throwables.propagate(e);
  }
}
 
Example 17
Source Project: hadoop   Source File: TestReservationInputValidator.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSubmitReservationEmptyRR() {
  ReservationSubmissionRequest request =
      createSimpleReservationSubmissionRequest(1, 0, 1, 5, 3);
  Plan plan = null;
  try {
    plan =
        rrValidator.validateReservationSubmissionRequest(rSystem, request,
            ReservationSystemTestUtil.getNewReservationId());
    Assert.fail();
  } catch (YarnException e) {
    Assert.assertNull(plan);
    String message = e.getMessage();
    Assert.assertTrue(message
        .startsWith("No resources have been specified to reserve"));
    LOG.info(message);
  }
}
 
Example 18
Source Project: big-c   Source File: TestAHSClient.java    License: Apache License 2.0 6 votes vote down vote up
@Test(timeout = 10000)
public void testGetApplications() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  List<ApplicationReport> reports = client.getApplications();
  Assert.assertEquals(reports, expectedReports);

  reports = client.getApplications();
  Assert.assertEquals(reports.size(), 4);
  client.stop();
}
 
Example 19
Source Project: big-c   Source File: TestNodeStatusUpdater.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  NodeId nodeId = request.getNodeId();
  Resource resource = request.getResource();
  LOG.info("Registering " + nodeId.toString());
  // NOTE: this really should be checking against the config value
  InetSocketAddress expected = NetUtils.getConnectAddress(
      conf.getSocketAddr(YarnConfiguration.NM_ADDRESS, null, -1));
  Assert.assertEquals(NetUtils.getHostPortString(expected), nodeId.toString());
  Assert.assertEquals(5 * 1024, resource.getMemory());
  registeredNodes.add(nodeId);

  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  response.setContainerTokenMasterKey(createMasterKey());
  response.setNMTokenMasterKey(createMasterKey());
  return response;
}
 
Example 20
/**
 * Get the max possible containers available in cluster.
 * @param cluster 
 * @param rmCommunicator 
 *
 * @return the max possible containers available in cluster
 * @throws YarnException the yarn exception
 * @throws IOException Signals that an I/O exception has occurred.
 */
private int getMaxPossibleContainersAvailableInCluster(Cluster cluster, RMCommunicator rmCommunicator) throws YarnException, IOException{
	int containersBasedOnVcores=0;
	int containersBasedOnMemory=0;
	int finalContainers=0;
	containersBasedOnVcores = getAvailableVCoresInCluster(rmCommunicator)/getMinimumParameterMandatoryForContainer(YARN_CONTAINER_MINIMUM_VCORE, 1, cluster);
	containersBasedOnMemory=getTotalMemoryAvailableInCluster(rmCommunicator)/getMinimumParameterMandatoryForContainer(YARN_CONTAINER_MINIMUM_MEMORY, 1024, cluster);
	finalContainers = Math.min(containersBasedOnVcores, containersBasedOnMemory);
	if(finalContainers<0){
		finalContainers =0;
	}
	return finalContainers;

}
 
Example 21
@Override
public GetApplicationAttemptsResponse getApplicationAttempts(
    GetApplicationAttemptsRequest request) throws YarnException, IOException {
  GetApplicationAttemptsRequestProto requestProto =
      ((GetApplicationAttemptsRequestPBImpl) request).getProto();
  try {
    return new GetApplicationAttemptsResponsePBImpl(
      proxy.getApplicationAttempts(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 22
Source Project: hadoop   Source File: TestFairScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Test (expected = YarnException.class)
public void testMoveToNonexistentQueue() throws Exception {
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  scheduler.getQueueManager().getLeafQueue("queue1", true);
  
  ApplicationAttemptId appAttId =
      createSchedulingRequest(1024, 1, 1, "queue1", "user1", 3);
  scheduler.moveApplication(appAttId.getApplicationId(), "queue2");
}
 
Example 23
Source Project: hadoop   Source File: ClientRMService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetApplicationAttemptsResponse getApplicationAttempts(
    GetApplicationAttemptsRequest request) throws YarnException, IOException {
  ApplicationId appId = request.getApplicationId();
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    LOG.info("Error getting UGI ", ie);
    throw RPCUtil.getRemoteException(ie);
  }
  RMApp application = this.rmContext.getRMApps().get(appId);
  if (application == null) {
    // If the RM doesn't have the application, throw
    // ApplicationNotFoundException and let client to handle.
    throw new ApplicationNotFoundException("Application with id '" + appId
        + "' doesn't exist in RM.");
  }
  boolean allowAccess = checkAccess(callerUGI, application.getUser(),
      ApplicationAccessType.VIEW_APP, application);
  GetApplicationAttemptsResponse response = null;
  if (allowAccess) {
    Map<ApplicationAttemptId, RMAppAttempt> attempts = application
        .getAppAttempts();
    List<ApplicationAttemptReport> listAttempts = 
      new ArrayList<ApplicationAttemptReport>();
    Iterator<Map.Entry<ApplicationAttemptId, RMAppAttempt>> iter = attempts
        .entrySet().iterator();
    while (iter.hasNext()) {
      listAttempts.add(iter.next().getValue()
          .createApplicationAttemptReport());
    }
    response = GetApplicationAttemptsResponse.newInstance(listAttempts);
  } else {
    throw new YarnException("User " + callerUGI.getShortUserName()
        + " does not have privilage to see this aplication " + appId);
  }
  return response;
}
 
Example 24
Source Project: hadoop   Source File: SharedCacheUploaderService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SCMUploaderCanUploadResponse canUpload(
    SCMUploaderCanUploadRequest request) throws YarnException, IOException {
  // TODO (YARN-2781): we may want to have a more flexible policy of
  // instructing the node manager to upload only if it meets a certain
  // criteria
  // until then we return true for now
  SCMUploaderCanUploadResponse response =
      recordFactory.newRecordInstance(SCMUploaderCanUploadResponse.class);
  response.setUploadable(true);
  return response;
}
 
Example 25
Source Project: AthenaX   Source File: AthenaXYarnClusterDescriptor.java    License: Apache License 2.0 5 votes vote down vote up
private ApplicationReport poll() throws IOException, YarnException {
  ApplicationReport report;
  report = yarnClient.getApplicationReport(appId);
  YarnApplicationState appState = report.getYarnApplicationState();
  LOG.debug("Application State: {}", appState);

  switch (appState) {
    case FAILED:
    case FINISHED:
      //TODO: the finished state may be valid in flip-6
    case KILLED:
      throw new IOException("The YARN application unexpectedly switched to state "
          + appState + " during deployment. \n"
          + "Diagnostics from YARN: " + report.getDiagnostics() + "\n"
          + "If log aggregation is enabled on your cluster, use this command to further investigate the issue:\n"
          + "yarn logs -applicationId " + appId);
      //break ..
    case RUNNING:
      LOG.info("YARN application has been deployed successfully.");
      break;
    default:
      if (appState != lastAppState) {
        LOG.info("Deploying cluster, current state " + appState);
      }
      lastAppState = appState;
      if (System.currentTimeMillis() - startTime > DEPLOY_TIMEOUT_MS) {
        throw new RuntimeException(String.format("Deployment took more than %d seconds. "
            + "Please check if the requested resources are available in the YARN cluster", DEPLOY_TIMEOUT_MS));
      }
      return null;
  }
  return report;
}
 
Example 26
Source Project: big-c   Source File: RMAppManager.java    License: Apache License 2.0 5 votes vote down vote up
private RMAppImpl createAndPopulateNewRMApp(
    ApplicationSubmissionContext submissionContext, long submitTime,
    String user, boolean isRecovery) throws YarnException {
  ApplicationId applicationId = submissionContext.getApplicationId();
  ResourceRequest amReq =
      validateAndCreateResourceRequest(submissionContext, isRecovery);

  // Create RMApp
  RMAppImpl application =
      new RMAppImpl(applicationId, rmContext, this.conf,
          submissionContext.getApplicationName(), user,
          submissionContext.getQueue(),
          submissionContext, this.scheduler, this.masterService,
          submitTime, submissionContext.getApplicationType(),
          submissionContext.getApplicationTags(), amReq);

  // Concurrent app submissions with same applicationId will fail here
  // Concurrent app submissions with different applicationIds will not
  // influence each other
  if (rmContext.getRMApps().putIfAbsent(applicationId, application) !=
      null) {
    String message = "Application with id " + applicationId
        + " is already present! Cannot add a duplicate!";
    LOG.warn(message);
    throw new YarnException(message);
  }
  // Inform the ACLs Manager
  this.applicationACLsManager.addApplication(applicationId,
      submissionContext.getAMContainerSpec().getApplicationACLs());
  String appViewACLs = submissionContext.getAMContainerSpec()
      .getApplicationACLs().get(ApplicationAccessType.VIEW_APP);
  rmContext.getSystemMetricsPublisher().appACLsUpdated(
      application, appViewACLs, System.currentTimeMillis());
  return application;
}
 
Example 27
Source Project: datacollector   Source File: EmrClusterJob.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void terminateJob(Properties jobProps) throws IOException {
  String appIdStr = Utils.checkNotNull(jobProps.getProperty("appId"), null);
  if (appIdStr == null) {
    throw new IOException("appId not present in jobProps");
  }
  YarnClient yarnClient = getYarnClient(new EMRJobConfig(jobProps).getClusterId(), emrClusterConfig);
  ApplicationId appId = ApplicationId.fromString(appIdStr);
  try {
    yarnClient.killApplication(appId);
  } catch (YarnException ex) {
    throw new IOException("Failed to terminate yarn job " + ex);
  }
}
 
Example 28
Source Project: big-c   Source File: TestAHSClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public ApplicationAttemptReport getApplicationAttemptReport(
    ApplicationAttemptId appAttemptId) throws YarnException, IOException {
  when(mockAttemptResponse.getApplicationAttemptReport()).thenReturn(
    getAttempt(appAttemptId));
  return super.getApplicationAttemptReport(appAttemptId);
}
 
Example 29
Source Project: big-c   Source File: LocalRMInterface.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerResponse response = recordFactory.newRecordInstance(RegisterNodeManagerResponse.class);
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { new Integer(123)
    .byteValue() }));
  response.setContainerTokenMasterKey(masterKey);
  response.setNMTokenMasterKey(masterKey);
  return response;
}
 
Example 30
Source Project: hadoop   Source File: TestRMFailover.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWebAppProxyInStandAloneMode() throws YarnException,
    InterruptedException, IOException {
  conf.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
  WebAppProxyServer webAppProxyServer = new WebAppProxyServer();
  try {
    conf.set(YarnConfiguration.PROXY_ADDRESS, "0.0.0.0:9099");
    cluster.init(conf);
    cluster.start();
    getAdminService(0).transitionToActive(req);
    assertFalse("RM never turned active", -1 == cluster.getActiveRMIndex());
    verifyConnections();
    webAppProxyServer.init(conf);

    // Start webAppProxyServer
    Assert.assertEquals(STATE.INITED, webAppProxyServer.getServiceState());
    webAppProxyServer.start();
    Assert.assertEquals(STATE.STARTED, webAppProxyServer.getServiceState());

    // send httpRequest with fakeApplicationId
    // expect to get "Not Found" response and 404 response code
    URL wrongUrl = new URL("http://0.0.0.0:9099/proxy/" + fakeAppId);
    HttpURLConnection proxyConn = (HttpURLConnection) wrongUrl
        .openConnection();

    proxyConn.connect();
    verifyResponse(proxyConn);

    explicitFailover();
    verifyConnections();
    proxyConn.connect();
    verifyResponse(proxyConn);
  } finally {
    webAppProxyServer.stop();
  }
}