/** * Constructs YarnSystemException from {@link YarnRuntimeException}. * * @param e the {@link YarnRuntimeException} */ public YarnSystemException(YarnRuntimeException e) { super(e.getMessage(), e); }
@Test public void testNMExpiryAndHeartbeatIntervalsValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setLong(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1000); conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 1001); try { resourceManager = new MockRM(conf); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith("Nodemanager expiry interval should be no" + " less than heartbeat interval")) { throw e; } } }
throw new NotFoundException(e.getMessage()); } catch (NumberFormatException ne) { throw new NotFoundException(ne.getMessage());
throw new NotFoundException(e.getMessage()); } catch (NumberFormatException ne) { throw new NotFoundException(ne.getMessage());
@Test public void testNMExpiryAndHeartbeatIntervalsValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setLong(YarnConfiguration.RM_NM_EXPIRY_INTERVAL_MS, 1000); conf.setLong(YarnConfiguration.RM_NM_HEARTBEAT_INTERVAL_MS, 1001); resourceManager = new ResourceManager();; try { resourceManager.init(conf); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith("Nodemanager expiry interval should be no" + " less than heartbeat interval")) { throw e; } } }
/** * convert a job id string to an actual job and handle all the error checking. */ public static Job getJobFromJobIdString(String jid, AppContext appCtx) throws NotFoundException { JobId jobId; Job job; try { jobId = MRApps.toJobID(jid); } catch (YarnRuntimeException e) { // TODO: after MAPREDUCE-2793 YarnRuntimeException is probably not expected here // anymore but keeping it for now just in case other stuff starts failing. // Also, the webservice should ideally return BadRequest (HTTP:400) when // the id is malformed instead of NotFound (HTTP:404). The webserver on // top of which AMWebServices is built seems to automatically do that for // unhandled exceptions throw new NotFoundException(e.getMessage()); } catch (IllegalArgumentException e) { throw new NotFoundException(e.getMessage()); } if (jobId == null) { throw new NotFoundException("job, " + jid + ", is not found"); } job = appCtx.getJob(jobId); if (job == null) { throw new NotFoundException("job, " + jid + ", is not found"); } return job; }
/** * convert a job id string to an actual job and handle all the error checking. */ public static Job getJobFromJobIdString(String jid, AppContext appCtx) throws NotFoundException { JobId jobId; Job job; try { jobId = MRApps.toJobID(jid); } catch (YarnRuntimeException e) { // TODO: after MAPREDUCE-2793 YarnRuntimeException is probably not expected here // anymore but keeping it for now just in case other stuff starts failing. // Also, the webservice should ideally return BadRequest (HTTP:400) when // the id is malformed instead of NotFound (HTTP:404). The webserver on // top of which AMWebServices is built seems to automatically do that for // unhandled exceptions throw new NotFoundException(e.getMessage()); } catch (IllegalArgumentException e) { throw new NotFoundException(e.getMessage()); } if (jobId == null) { throw new NotFoundException("job, " + jid + ", is not found"); } job = appCtx.getJob(jobId); if (job == null) { throw new NotFoundException("job, " + jid + ", is not found"); } return job; }
@Test (timeout = 30000) public void testResourceManagerInitConfigValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, -1); try { resourceManager = new MockRM(conf); fail("Exception is expected because the global max attempts" + " is negative."); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith( "Invalid global max attempts configuration")) throw e; } }
throw new NotFoundException(e.getMessage()); } catch (NumberFormatException ne) { throw new NotFoundException(ne.getMessage());
throw new NotFoundException(e.getMessage()); } catch (NumberFormatException ne) { throw new NotFoundException(ne.getMessage());
throw new NotFoundException(e.getMessage()); } catch (NumberFormatException ne) { throw new NotFoundException(ne.getMessage());
/** * convert a job id string to an actual job and handle all the error checking. */ public static Job getJobFromJobIdString(String jid, AppContext appCtx) throws NotFoundException { JobId jobId; Job job; try { jobId = MRApps.toJobID(jid); } catch (YarnRuntimeException e) { // TODO: after MAPREDUCE-2793 YarnRuntimeException is probably not expected here // anymore but keeping it for now just in case other stuff starts failing. // Also, the webservice should ideally return BadRequest (HTTP:400) when // the id is malformed instead of NotFound (HTTP:404). The webserver on // top of which AMWebServices is built seems to automatically do that for // unhandled exceptions throw new NotFoundException(e.getMessage()); } catch (IllegalArgumentException e) { throw new NotFoundException(e.getMessage()); } if (jobId == null) { throw new NotFoundException("job, " + jid + ", is not found"); } job = appCtx.getJob(jobId); if (job == null) { throw new NotFoundException("job, " + jid + ", is not found"); } return job; }
/** * This method initializes an RM with the given configuration and expects it * to fail with a configuration error. * * @param conf the {@link Configuration} to use */ private void checkBadConfiguration(Configuration conf) { MockRM rm1 = null; conf.set(YarnConfiguration.RM_HA_ID, "rm1"); try { rm1 = new MockRM(conf); rm1.init(conf); fail("The RM allowed an invalid configuration"); } catch (YarnRuntimeException e) { assertTrue("The RM initialization threw an unexpected exception", e.getMessage().startsWith(HAUtil.BAD_CONFIG_MESSAGE_PREFIX)); } }
@Test (timeout = 30000) public void testResourceManagerInitConfigValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_AM_MAX_ATTEMPTS, -1); resourceManager = new ResourceManager(); try { resourceManager.init(conf); fail("Exception is expected because the global max attempts" + " is negative."); } catch (YarnRuntimeException e) { // Exception is expected. if (!e.getMessage().startsWith( "Invalid global max attempts configuration")) throw e; } }
@Test(timeout = 30000) public void testConfValidation() throws Exception { FifoScheduler scheduler = new FifoScheduler(); Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 2048); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024); try { scheduler.serviceInit(conf); fail("Exception is expected because the min memory allocation is" + " larger than the max memory allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e .getMessage().startsWith("Invalid resource scheduler memory")); } }
@Test (timeout = 30000) public void testConfValidation() throws Exception { Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 2048); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024); try { scheduler.serviceInit(conf); fail("Exception is expected because the min memory allocation is" + " larger than the max memory allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e.getMessage().startsWith( "Invalid resource scheduler memory")); } conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 2); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, 1); try { scheduler.serviceInit(conf); fail("Exception is expected because the min vcores allocation is" + " larger than the max vcores allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e.getMessage().startsWith( "Invalid resource scheduler vcores")); } }
@Test (timeout = 30000) public void testConfValidation() throws Exception { FifoScheduler scheduler = new FifoScheduler(); Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 2048); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024); try { scheduler.serviceInit(conf); fail("Exception is expected because the min memory allocation is" + " larger than the max memory allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e.getMessage().startsWith( "Invalid resource scheduler memory")); } }
@Test (timeout = 30000) public void testConfValidation() throws Exception { scheduler = new FairScheduler(); Configuration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, 2048); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_MB, 1024); try { scheduler.serviceInit(conf); fail("Exception is expected because the min memory allocation is" + " larger than the max memory allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e.getMessage().startsWith( "Invalid resource scheduler memory")); } conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_VCORES, 2); conf.setInt(YarnConfiguration.RM_SCHEDULER_MAXIMUM_ALLOCATION_VCORES, 1); try { scheduler.serviceInit(conf); fail("Exception is expected because the min vcores allocation is" + " larger than the max vcores allocation."); } catch (YarnRuntimeException e) { // Exception is expected. assertTrue("The thrown exception is not the expected one.", e.getMessage().startsWith( "Invalid resource scheduler vcores")); } }
e.getMessage().startsWith( "Invalid resource scheduler memory")); e.getMessage().startsWith( "Invalid resource scheduler vcores"));
e.getMessage().startsWith( "Invalid resource scheduler memory")); e.getMessage().startsWith( "Invalid resource scheduler vcores"));