void startTimelineClient(final Configuration conf) throws YarnException, IOException, InterruptedException { try { appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) { // Creating the Timeline Client timelineClient = TimelineClient.createTimelineClient(); timelineClient.init(conf); timelineClient.start(); } else { timelineClient = null; LOG.warn("Timeline service is not enabled"); } return null; } }); } catch (UndeclaredThrowableException e) { throw new YarnException(e.getCause()); } }
/** * Constructs YarnSystemException from {@link YarnException}. * * @param e the {@link YarnException} */ public YarnSystemException(YarnException e) { super(e.getMessage(), e); }
private void submitAppToRMWithInValidAcl(String submitter, ApplicationSubmissionContext appSubmissionContext) throws YarnException, IOException, InterruptedException { ApplicationClientProtocol submitterClient = getRMClientForUser(submitter); SubmitApplicationRequest submitRequest = SubmitApplicationRequest .newInstance(appSubmissionContext); try { submitterClient.submitApplication(submitRequest); } catch (YarnException ex) { Assert.assertTrue(ex.getCause() instanceof RemoteException); } }
@Override public SubmitApplicationResponse run() { try { return client.submitApplication(req); } catch (YarnException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } PrivilegedAction<SubmitApplicationResponse> setClientReq(
@Test public void testExceptionCalls() throws Exception { client.setThrowYarnException(true); try { client.putEntitiesAsync(generateEntity("1")); } catch (YarnException e) { Assert.fail("Async calls are not expected to throw exception"); } try { client.putEntities(generateEntity("2")); Assert.fail("Sync calls are expected to throw exception"); } catch (YarnException e) { Assert.assertEquals("Same exception needs to be thrown", "ActualException", e.getCause().getMessage()); } }
@Override protected ApplicationHistoryProtocol getAHSProxy(Configuration conf) throws IOException { GetApplicationReportResponse resp = Mockito. mock(GetApplicationReportResponse.class); historyManager = Mockito.mock(ApplicationHistoryProtocol.class); try { Mockito.when(historyManager.getApplicationReport(Mockito .any(GetApplicationReportRequest.class))).thenReturn(resp); } catch (YarnException e) { // TODO Auto-generated catch block e.printStackTrace(); } return historyManager; } }
@VisibleForTesting void startTimelineClient(final Configuration conf) throws YarnException, IOException, InterruptedException { try { appSubmitterUgi.doAs(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws Exception { if (conf.getBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED)) { // Creating the Timeline Client timelineClient = TimelineClient.createTimelineClient(); timelineClient.init(conf); timelineClient.start(); } else { timelineClient = null; LOG.warn("Timeline service is not enabled"); } return null; } }); } catch (UndeclaredThrowableException e) { throw new YarnException(e.getCause()); } }
@POST @Path("/delegation-token") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postDelegationToken(DelegationToken tokenData, @Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, Exception { init(); UserGroupInformation callerUGI; try { callerUGI = createKerberosUserGroupInformation(hsr); } catch (YarnException ye) { return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build(); } return createDelegationToken(tokenData, hsr, callerUGI); }
@Override protected ApplicationHistoryProtocol getAHSProxy(Configuration conf) throws IOException { GetApplicationReportResponse resp = Mockito. mock(GetApplicationReportResponse.class); historyManager = Mockito.mock(ApplicationHistoryProtocol.class); try { Mockito.when(historyManager.getApplicationReport(Mockito .any(GetApplicationReportRequest.class))).thenReturn(resp); } catch (YarnException e) { // TODO Auto-generated catch block e.printStackTrace(); } return historyManager; } }
/** * Returns an instance of {@link YarnException} */ public static YarnException getRemoteException(Throwable t) { return new YarnException(t); }
@POST @Path("/delegation-token") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) public Response postDelegationToken(DelegationToken tokenData, @Context HttpServletRequest hsr) throws AuthorizationException, IOException, InterruptedException, Exception { init(); UserGroupInformation callerUGI; try { callerUGI = createKerberosUserGroupInformation(hsr); } catch (YarnException ye) { return Response.status(Status.FORBIDDEN).entity(ye.getMessage()).build(); } return createDelegationToken(tokenData, hsr, callerUGI); }
/** * Returns an instance of {@link YarnException} */ public static YarnException getRemoteException(String message) { return new YarnException(message); }
@Override public Void run() throws Exception { try { checkTokenRenewal(owner, other); return null; } catch (YarnException ex) { Assert.assertTrue(ex.getMessage().contains(owner.getUserName() + " tries to renew a token with renewer " + other.getUserName())); throw ex; } } });
/** * Returns an instance of {@link YarnException} */ public static YarnException getRemoteException(Throwable t) { return new YarnException(t); }
@Override public Void run() throws Exception { try { checkTokenRenewal(owner, other); return null; } catch (YarnException ex) { Assert.assertTrue(ex.getMessage().contains( owner.getUserName() + " tries to renew a token")); Assert.assertTrue(ex.getMessage().contains( "with non-matching renewer " + other.getUserName())); throw ex; } } });
/** * Returns an instance of {@link YarnException} */ public static YarnException getRemoteException(String message) { return new YarnException(message); }
@Override public Void run() throws Exception { try { checkTokenCancellation(rmService, tokOwner, tokRenewer); Assert.fail("We should not reach here; token owner = " + tokOwner.getUserName() + ", renewer = " + tokRenewer.getUserName()); return null; } catch (YarnException e) { Assert.assertTrue(e.getMessage().contains( testerKerb.getUserName() + " is not authorized to cancel the token")); return null; } } });
/** * Returns an instance of {@link YarnException} */ public static YarnException getRemoteException(String message) { return new YarnException(message); }
@Override public Void run() throws Exception { try { checkTokenCancellation(tokOwner, tokRenewer); Assert.fail("We should not reach here; token owner = " + tokOwner.getUserName() + ", renewer = " + tokRenewer.getUserName()); return null; } catch (YarnException ex) { Assert.assertTrue(ex.getMessage().contains( tester.getUserName() + " is not authorized to cancel the token")); return null; } } });
private void validateConfOrThrowException() throws YarnException { if (conf == null) { throw new YarnException("Please initialize (call initialize) before use " + GpuDiscoverer.class.getSimpleName()); } }