@Test public void testWithHdfsDefaultFs() { MRLocalCluster mrLocalCluster = new MRLocalCluster.Builder() .setNumNodeManagers( Integer.parseInt(propertyParser.getProperty(ConfigVars.YARN_NUM_NODE_MANAGERS_KEY))) .setJobHistoryAddress(propertyParser.getProperty(ConfigVars.MR_JOB_HISTORY_ADDRESS_KEY)) .setResourceManagerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_ADDRESS_KEY)) .setResourceManagerHostname( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_HOSTNAME_KEY)) .setResourceManagerSchedulerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY)) .setResourceManagerResourceTrackerAddress( propertyParser.getProperty( ConfigVars.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY)) .setResourceManagerWebappAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY)) .setUseInJvmContainerExecutor( Boolean.parseBoolean( propertyParser.getProperty(ConfigVars.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY))) .setHdfsDefaultFs("hdfs://localhost:8020/") .setConfig(new Configuration()) .build(); assertEquals("hdfs://localhost:8020/", mrLocalCluster.getHdfsDefaultFs()); }
@Test public void testUseInJvmContainerExecutor() { assertEquals( Boolean.parseBoolean( propertyParser.getProperty(ConfigVars.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY)), mrLocalCluster.getUseInJvmContainerExecutor()); }
static { try { propertyParser = new PropertyParser(ConfigVars.DEFAULT_PROPS_FILE); propertyParser.parsePropsFile(); } catch (IOException e) { LOG.error( "Unable to load property file: " + propertyParser.getProperty(ConfigVars.DEFAULT_PROPS_FILE)); } }
@BeforeClass public static void setUp() throws IOException { mrLocalCluster = new MRLocalCluster.Builder() .setNumNodeManagers( Integer.parseInt(propertyParser.getProperty(ConfigVars.YARN_NUM_NODE_MANAGERS_KEY))) .setJobHistoryAddress(propertyParser.getProperty(ConfigVars.MR_JOB_HISTORY_ADDRESS_KEY)) .setResourceManagerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_ADDRESS_KEY)) .setResourceManagerHostname( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_HOSTNAME_KEY)) .setResourceManagerSchedulerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY)) .setResourceManagerResourceTrackerAddress( propertyParser.getProperty( ConfigVars.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY)) .setResourceManagerWebappAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY)) .setUseInJvmContainerExecutor( Boolean.parseBoolean( propertyParser.getProperty(ConfigVars.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY))) .setConfig(new Configuration()) .build(); }
@Test public void testMissingConf() { exception.expect(IllegalArgumentException.class); MRLocalCluster mrLocalCluster = new MRLocalCluster.Builder() .setNumNodeManagers( Integer.parseInt(propertyParser.getProperty(ConfigVars.YARN_NUM_NODE_MANAGERS_KEY))) .setJobHistoryAddress(propertyParser.getProperty(ConfigVars.MR_JOB_HISTORY_ADDRESS_KEY)) .setResourceManagerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_ADDRESS_KEY)) .setResourceManagerHostname( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_HOSTNAME_KEY)) .setResourceManagerSchedulerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY)) .setResourceManagerResourceTrackerAddress( propertyParser.getProperty( ConfigVars.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY)) .setResourceManagerWebappAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY)) .setUseInJvmContainerExecutor( Boolean.parseBoolean( propertyParser.getProperty(ConfigVars.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY))) .build(); }
@Test public void testWithInJvmContainerExecutor() throws Exception { MRLocalCluster mrLocalCluster = new MRLocalCluster.Builder() .setNumNodeManagers( Integer.parseInt(propertyParser.getProperty(ConfigVars.YARN_NUM_NODE_MANAGERS_KEY))) .setJobHistoryAddress(propertyParser.getProperty(ConfigVars.MR_JOB_HISTORY_ADDRESS_KEY)) .setResourceManagerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_ADDRESS_KEY)) .setResourceManagerHostname( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_HOSTNAME_KEY)) .setResourceManagerSchedulerAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY)) .setResourceManagerResourceTrackerAddress( propertyParser.getProperty( ConfigVars.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY)) .setResourceManagerWebappAddress( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY)) .setUseInJvmContainerExecutor(true) .setConfig(new Configuration()) .build(); mrLocalCluster.configure(); assertEquals(true, mrLocalCluster.getUseInJvmContainerExecutor()); }
@Test public void testNumNodeManagers() { assertEquals( Integer.parseInt(propertyParser.getProperty(ConfigVars.YARN_NUM_NODE_MANAGERS_KEY)), (int) mrLocalCluster.getNumNodeManagers()); }
@Test public void testResourceManagerWebAppAddress() { assertEquals( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY), mrLocalCluster.getResourceManagerWebappAddress()); }
@Test public void testResourceManagerResourceTrackerAddress() { assertEquals( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY), mrLocalCluster.getResourceManagerResourceTrackerAddress()); }
@Test public void testResourceManagerSchedulerAddress() { assertEquals( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY), mrLocalCluster.getResourceManagerSchedulerAddress()); }
@Test public void testResourceManagerHostname() { assertEquals( propertyParser.getProperty(ConfigVars.YARN_RESOURCE_MANAGER_HOSTNAME_KEY), mrLocalCluster.getResourceManagerHostname()); }
@Test public void testJobHistoryAddress() { assertEquals( propertyParser.getProperty(ConfigVars.MR_JOB_HISTORY_ADDRESS_KEY), mrLocalCluster.getJobHistoryAddress()); }