@Test public void testUpdateYarnSite() throws Exception { EasyMockSupport easyMockSupport = new EasyMockSupport(); final String propertyToRemove = "yarn.nodemanager.linux-container-executor.cgroups.mount-path"; final AmbariManagementController ambariManagementController = createNiceMock(AmbariManagementController.class); Config mockYarnEnv = easyMockSupport.createNiceMock(Config.class); Config mockYarnSite = easyMockSupport.createNiceMock(Config.class); HashMap<String, String> yarnEnv = new HashMap<String, String>() {{ put("yarn_cgroups_enabled", "false"); }}; HashMap<String, String> yarnSite = new HashMap<String, String>() {{ put(propertyToRemove, ""); }}; reset(clusters, cluster, injector); expect(injector.getInstance(AmbariManagementController.class)).andReturn(ambariManagementController).atLeastOnce(); expect(ambariManagementController.getClusters()).andReturn(clusters).atLeastOnce(); expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{ put("normal", cluster); }}).once(); expect(cluster.getDesiredConfigByType("yarn-env")).andReturn(mockYarnEnv).atLeastOnce(); expect(mockYarnEnv.getProperties()).andReturn(yarnEnv).anyTimes(); expect(cluster.getDesiredConfigByType("yarn-site")).andReturn(mockYarnSite).atLeastOnce(); expect(mockYarnSite.getProperties()).andReturn(yarnSite).anyTimes(); replay(clusters, cluster, injector, ambariManagementController, mockYarnEnv, mockYarnSite); UpgradeCatalog250 upgradeCatalog250 = createMockBuilder(UpgradeCatalog250.class) .addMockedMethod("removeConfigurationPropertiesFromCluster") .withConstructor(injector) .createNiceMock(); Capture<HashSet<String>> removeConfigName = EasyMock.newCapture(); upgradeCatalog250.removeConfigurationPropertiesFromCluster(anyObject(Cluster.class), eq("yarn-site"), capture(removeConfigName)); EasyMock.expectLastCall(); replay(upgradeCatalog250); upgradeCatalog250.updateYarnSite(); easyMockSupport.verifyAll(); Set<String> updatedProperties = removeConfigName.getValue(); assertTrue(updatedProperties.contains(propertyToRemove)); reset(injector); }
protected void updateYarnSite() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { Config yarnEnvConfig = cluster.getDesiredConfigByType(YARN_ENV_CONFIG); Config yarnSiteConfig = cluster.getDesiredConfigByType(YARN_SITE_CONFIG); if (yarnEnvConfig != null && yarnSiteConfig != null) { String cgroupEnabled = yarnEnvConfig.getProperties().get(YARN_CGROUPS_ENABLED); String mountPath = yarnSiteConfig.getProperties().get(YARN_LCE_CGROUPS_MOUNT_PATH); if (StringUtils.isEmpty(mountPath) && cgroupEnabled != null && cgroupEnabled.trim().equalsIgnoreCase("false")){ removeConfigurationPropertiesFromCluster(cluster, YARN_SITE_CONFIG, new HashSet<String>(){{ add(YARN_LCE_CGROUPS_MOUNT_PATH); }}); } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateYarnSite() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { Config yarnEnvConfig = cluster.getDesiredConfigByType(YARN_ENV_CONFIG); Config yarnSiteConfig = cluster.getDesiredConfigByType(YARN_SITE_CONFIG); if (yarnEnvConfig != null && yarnSiteConfig != null) { String cgroupEnabled = yarnEnvConfig.getProperties().get(YARN_CGROUPS_ENABLED); String mountPath = yarnSiteConfig.getProperties().get(YARN_LCE_CGROUPS_MOUNT_PATH); if (StringUtils.isEmpty(mountPath) && cgroupEnabled != null && cgroupEnabled.trim().equalsIgnoreCase("false")){ removeConfigurationPropertiesFromCluster(cluster, YARN_SITE_CONFIG, new HashSet<String>(){{ add(YARN_LCE_CGROUPS_MOUNT_PATH); }}); } } } } }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateYarnSite() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { Config yarnEnvConfig = cluster.getDesiredConfigByType(YARN_ENV_CONFIG); Config yarnSiteConfig = cluster.getDesiredConfigByType(YARN_SITE_CONFIG); if (yarnEnvConfig != null && yarnSiteConfig != null) { String cgroupEnabled = yarnEnvConfig.getProperties().get(YARN_CGROUPS_ENABLED); String mountPath = yarnSiteConfig.getProperties().get(YARN_LCE_CGROUPS_MOUNT_PATH); if (StringUtils.isEmpty(mountPath) && cgroupEnabled != null && cgroupEnabled.trim().equalsIgnoreCase("false")){ removeConfigurationPropertiesFromCluster(cluster, YARN_SITE_CONFIG, new HashSet<String>(){{ add(YARN_LCE_CGROUPS_MOUNT_PATH); }}); } } } } @Inject  UpgradeCatalog250(Injector injector); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateYarnSite() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { Config yarnEnvConfig = cluster.getDesiredConfigByType(YARN_ENV_CONFIG); Config yarnSiteConfig = cluster.getDesiredConfigByType(YARN_SITE_CONFIG); if (yarnEnvConfig != null && yarnSiteConfig != null) { String cgroupEnabled = yarnEnvConfig.getProperties().get(YARN_CGROUPS_ENABLED); String mountPath = yarnSiteConfig.getProperties().get(YARN_LCE_CGROUPS_MOUNT_PATH); if (StringUtils.isEmpty(mountPath) && cgroupEnabled != null && cgroupEnabled.trim().equalsIgnoreCase("false")){ removeConfigurationPropertiesFromCluster(cluster, YARN_SITE_CONFIG, new HashSet<String>(){{ add(YARN_LCE_CGROUPS_MOUNT_PATH); }}); } } } } @Inject  UpgradeCatalog250(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog250 extends AbstractUpgradeCatalog { protected void updateYarnSite() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { Config yarnEnvConfig = cluster.getDesiredConfigByType(YARN_ENV_CONFIG); Config yarnSiteConfig = cluster.getDesiredConfigByType(YARN_SITE_CONFIG); if (yarnEnvConfig != null && yarnSiteConfig != null) { String cgroupEnabled = yarnEnvConfig.getProperties().get(YARN_CGROUPS_ENABLED); String mountPath = yarnSiteConfig.getProperties().get(YARN_LCE_CGROUPS_MOUNT_PATH); if (StringUtils.isEmpty(mountPath) && cgroupEnabled != null && cgroupEnabled.trim().equalsIgnoreCase("false")){ removeConfigurationPropertiesFromCluster(cluster, YARN_SITE_CONFIG, new HashSet<String>(){{ add(YARN_LCE_CGROUPS_MOUNT_PATH); }}); } } } } @Inject  UpgradeCatalog250(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); static final String COMPONENT_TABLE; static final String COMPONENT_VERSION_TABLE; static final String COMPONENT_VERSION_PK; static final String COMPONENT_VERSION_FK_COMPONENT; static final String COMPONENT_VERSION_FK_REPO_VERSION; }