Java Code Examples for org.apache.hadoop.yarn.conf.YarnConfiguration#getServiceAddressConfKeys()

The following examples show how to use org.apache.hadoop.yarn.conf.YarnConfiguration#getServiceAddressConfKeys() . 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 File: RMHATestBase.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
  configuration.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  configuration.set(YarnConfiguration.RM_STORE,
      ZKRMStateStore.class.getName());
  configuration.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
  configuration.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, ZK_TIMEOUT_MS);
  configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
  configuration.set(YarnConfiguration.RM_CLUSTER_ID, "test-yarn-cluster");
  int base = 100;
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, "rm1"), "0.0.0.0:"
        + (base + 20));
    configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:"
        + (base + 40));
    base = base * 2;
  }
  confForRM1 = new Configuration(configuration);
  confForRM1.set(YarnConfiguration.RM_HA_ID, "rm1");
  confForRM2 = new Configuration(configuration);
  confForRM2.set(YarnConfiguration.RM_HA_ID, "rm2");
}
 
Example 2
Source File: TestRMHA.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  configuration = new Configuration();
  UserGroupInformation.setConfiguration(configuration);
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + ","
      + RM2_NODE_ID);
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, RM1_NODE_ID), RM1_ADDRESS);
    configuration.set(HAUtil.addSuffix(confKey, RM2_NODE_ID), RM2_ADDRESS);
    configuration.set(HAUtil.addSuffix(confKey, RM3_NODE_ID), RM3_ADDRESS);
  }

  // Enable webapp to test web-services also
  configuration.setBoolean(MockRM.ENABLE_WEBAPP, true);
  configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  ClusterMetrics.destroy();
  QueueMetrics.clearQueueMetrics();
  DefaultMetricsSystem.shutdown();
}
 
Example 3
Source File: TestZKRMStateStore.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private Configuration createHARMConf(
    String rmIds, String rmId, int adminPort) {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  conf.set(YarnConfiguration.RM_HA_IDS, rmIds);
  conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  conf.set(YarnConfiguration.RM_STORE, ZKRMStateStore.class.getName());
  conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
  conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, ZK_TIMEOUT_MS);
  conf.set(YarnConfiguration.RM_HA_ID, rmId);
  conf.set(YarnConfiguration.RM_WEBAPP_ADDRESS, "localhost:0");

  for (String rpcAddress : YarnConfiguration.getServiceAddressConfKeys(conf)) {
    for (String id : HAUtil.getRMHAIds(conf)) {
      conf.set(HAUtil.addSuffix(rpcAddress, id), "localhost:0");
    }
  }
  conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADMIN_ADDRESS, rmId),
      "localhost:" + adminPort);
  return conf;
}
 
Example 4
Source File: RMHATestBase.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
  configuration.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  configuration.set(YarnConfiguration.RM_STORE,
      ZKRMStateStore.class.getName());
  configuration.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
  configuration.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, ZK_TIMEOUT_MS);
  configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
  configuration.set(YarnConfiguration.RM_CLUSTER_ID, "test-yarn-cluster");
  int base = 100;
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, "rm1"), "0.0.0.0:"
        + (base + 20));
    configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:"
        + (base + 40));
    base = base * 2;
  }
  confForRM1 = new Configuration(configuration);
  confForRM1.set(YarnConfiguration.RM_HA_ID, "rm1");
  confForRM2 = new Configuration(configuration);
  confForRM2.set(YarnConfiguration.RM_HA_ID, "rm2");
}
 
Example 5
Source File: TestRMHA.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  configuration = new Configuration();
  UserGroupInformation.setConfiguration(configuration);
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + ","
      + RM2_NODE_ID);
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, RM1_NODE_ID), RM1_ADDRESS);
    configuration.set(HAUtil.addSuffix(confKey, RM2_NODE_ID), RM2_ADDRESS);
    configuration.set(HAUtil.addSuffix(confKey, RM3_NODE_ID), RM3_ADDRESS);
  }

  // Enable webapp to test web-services also
  configuration.setBoolean(MockRM.ENABLE_WEBAPP, true);
  configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  ClusterMetrics.destroy();
  QueueMetrics.clearQueueMetrics();
  DefaultMetricsSystem.shutdown();
}
 
Example 6
Source File: TestZKRMStateStore.java    From big-c with Apache License 2.0 6 votes vote down vote up
private Configuration createHARMConf(
    String rmIds, String rmId, int adminPort) {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  conf.set(YarnConfiguration.RM_HA_IDS, rmIds);
  conf.setBoolean(YarnConfiguration.RECOVERY_ENABLED, true);
  conf.set(YarnConfiguration.RM_STORE, ZKRMStateStore.class.getName());
  conf.set(YarnConfiguration.RM_ZK_ADDRESS, hostPort);
  conf.setInt(YarnConfiguration.RM_ZK_TIMEOUT_MS, ZK_TIMEOUT_MS);
  conf.set(YarnConfiguration.RM_HA_ID, rmId);
  conf.set(YarnConfiguration.RM_WEBAPP_ADDRESS, "localhost:0");

  for (String rpcAddress : YarnConfiguration.getServiceAddressConfKeys(conf)) {
    for (String id : HAUtil.getRMHAIds(conf)) {
      conf.set(HAUtil.addSuffix(rpcAddress, id), "localhost:0");
    }
  }
  conf.set(HAUtil.addSuffix(YarnConfiguration.RM_ADMIN_ADDRESS, rmId),
      "localhost:" + adminPort);
  return conf;
}
 
Example 7
Source File: MiniYARNCluster.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void setHARMConfiguration(final int index, Configuration conf) {
  String hostname = MiniYARNCluster.getHostname();
  for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
    conf.set(HAUtil.addSuffix(confKey, rmIds[index]), hostname + ":0");
  }
}
 
Example 8
Source File: TestRMAdminService.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Test
public void testRMHAWithFileSystemBasedConfiguration() throws IOException,
    YarnException {
  StateChangeRequestInfo requestInfo = new StateChangeRequestInfo(
      HAServiceProtocol.RequestSource.REQUEST_BY_USER);
  configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
      "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
  configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
  int base = 100;
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, "rm1"), "0.0.0.0:"
        + (base + 20));
    configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:"
        + (base + 40));
    base = base * 2;
  }
  Configuration conf1 = new Configuration(configuration);
  conf1.set(YarnConfiguration.RM_HA_ID, "rm1");
  Configuration conf2 = new Configuration(configuration);
  conf2.set(YarnConfiguration.RM_HA_ID, "rm2");

  // upload default configurations
  uploadDefaultConfiguration();

  MockRM rm1 = null;
  MockRM rm2 = null;
  try {
    rm1 = new MockRM(conf1);
    rm1.init(conf1);
    rm1.start();
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);

    rm2 = new MockRM(conf2);
    rm2.init(conf1);
    rm2.start();
    Assert.assertTrue(rm2.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);

    rm1.adminService.transitionToActive(requestInfo);
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.ACTIVE);

    CapacitySchedulerConfiguration csConf =
        new CapacitySchedulerConfiguration();
    csConf.set("yarn.scheduler.capacity.maximum-applications", "5000");
    uploadConfiguration(csConf, "capacity-scheduler.xml");

    rm1.adminService.refreshQueues(RefreshQueuesRequest.newInstance());

    int maxApps =
        ((CapacityScheduler) rm1.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();
    Assert.assertEquals(maxApps, 5000);

    // Before failover happens, the maxApps is
    // still the default value on the standby rm : rm2
    int maxAppsBeforeFailOver =
        ((CapacityScheduler) rm2.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();
    Assert.assertEquals(maxAppsBeforeFailOver, 10000);

    // Do the failover
    rm1.adminService.transitionToStandby(requestInfo);
    rm2.adminService.transitionToActive(requestInfo);
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);
    Assert.assertTrue(rm2.getRMContext().getHAServiceState()
        == HAServiceState.ACTIVE);

    int maxAppsAfter =
        ((CapacityScheduler) rm2.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();

    Assert.assertEquals(maxAppsAfter, 5000);
  } finally {
    if (rm1 != null) {
      rm1.stop();
    }
    if (rm2 != null) {
      rm2.stop();
    }
  }
}
 
Example 9
Source File: MiniYARNCluster.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void setHARMConfiguration(final int index, Configuration conf) {
  String hostname = MiniYARNCluster.getHostname();
  for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
    conf.set(HAUtil.addSuffix(confKey, rmIds[index]), hostname + ":0");
  }
}
 
Example 10
Source File: TestRMAdminService.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testRMHAWithFileSystemBasedConfiguration() throws IOException,
    YarnException {
  StateChangeRequestInfo requestInfo = new StateChangeRequestInfo(
      HAServiceProtocol.RequestSource.REQUEST_BY_USER);
  configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS,
      "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider");
  configuration.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  configuration.setBoolean(YarnConfiguration.AUTO_FAILOVER_ENABLED, false);
  configuration.set(YarnConfiguration.RM_HA_IDS, "rm1,rm2");
  int base = 100;
  for (String confKey : YarnConfiguration
      .getServiceAddressConfKeys(configuration)) {
    configuration.set(HAUtil.addSuffix(confKey, "rm1"), "0.0.0.0:"
        + (base + 20));
    configuration.set(HAUtil.addSuffix(confKey, "rm2"), "0.0.0.0:"
        + (base + 40));
    base = base * 2;
  }
  Configuration conf1 = new Configuration(configuration);
  conf1.set(YarnConfiguration.RM_HA_ID, "rm1");
  Configuration conf2 = new Configuration(configuration);
  conf2.set(YarnConfiguration.RM_HA_ID, "rm2");

  // upload default configurations
  uploadDefaultConfiguration();

  MockRM rm1 = null;
  MockRM rm2 = null;
  try {
    rm1 = new MockRM(conf1);
    rm1.init(conf1);
    rm1.start();
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);

    rm2 = new MockRM(conf2);
    rm2.init(conf1);
    rm2.start();
    Assert.assertTrue(rm2.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);

    rm1.adminService.transitionToActive(requestInfo);
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.ACTIVE);

    CapacitySchedulerConfiguration csConf =
        new CapacitySchedulerConfiguration();
    csConf.set("yarn.scheduler.capacity.maximum-applications", "5000");
    uploadConfiguration(csConf, "capacity-scheduler.xml");

    rm1.adminService.refreshQueues(RefreshQueuesRequest.newInstance());

    int maxApps =
        ((CapacityScheduler) rm1.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();
    Assert.assertEquals(maxApps, 5000);

    // Before failover happens, the maxApps is
    // still the default value on the standby rm : rm2
    int maxAppsBeforeFailOver =
        ((CapacityScheduler) rm2.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();
    Assert.assertEquals(maxAppsBeforeFailOver, 10000);

    // Do the failover
    rm1.adminService.transitionToStandby(requestInfo);
    rm2.adminService.transitionToActive(requestInfo);
    Assert.assertTrue(rm1.getRMContext().getHAServiceState()
        == HAServiceState.STANDBY);
    Assert.assertTrue(rm2.getRMContext().getHAServiceState()
        == HAServiceState.ACTIVE);

    int maxAppsAfter =
        ((CapacityScheduler) rm2.getRMContext().getScheduler())
            .getConfiguration().getMaximumSystemApplications();

    Assert.assertEquals(maxAppsAfter, 5000);
  } finally {
    if (rm1 != null) {
      rm1.stop();
    }
    if (rm2 != null) {
      rm2.stop();
    }
  }
}
 
Example 11
Source File: MiniYARNClusterSplice.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
private void setHARMConfiguration(final int index, Configuration conf) {
    String hostname = MiniYARNClusterSplice.getHostname();
    for (String confKey : YarnConfiguration.getServiceAddressConfKeys(conf)) {
        conf.set(HAUtil.addSuffix(confKey, rmIds[index]), hostname + ":0");
    }
}