@Test public void testUpdateHBaseAdnClusterConfigs() throws Exception { setupIoCContext(); EasyMockSupport easyMockSupport = new EasyMockSupport(); final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class); final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class); final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class); final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class); final Map<String, String> propertiesHbaseSite = new HashMap<String, String>() { { put("hbase.bucketcache.size", "1024m"); } }; final Map<String, String> propertiesHbaseEnv = new HashMap<String, String>() { { put("override_hbase_uid", "false"); } }; final Config mockHbaseEnv = easyMockSupport.createNiceMock(Config.class); expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).once(); final Config mockHbaseSite = easyMockSupport.createNiceMock(Config.class); expect(mockHbaseSite.getProperties()).andReturn(propertiesHbaseSite).once(); final Config mockClusterEnv = easyMockSupport.createNiceMock(Config.class); final Map<String, String> propertiesExpectedHbaseEnv = new HashMap<String, String>(); final Map<String, String> propertiesExpectedClusterEnv = new HashMap<String, String>() {{ put("override_uid", "false"); }}; final Map<String, String> propertiesExpectedHbaseSite = new HashMap<String, String>() {{ put("hbase.bucketcache.size", "1024"); }}; final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AmbariManagementController.class).toInstance(mockAmbariManagementController); bind(ConfigHelper.class).toInstance(mockConfigHelper); bind(Clusters.class).toInstance(mockClusters); bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }); expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once(); expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{ put("normal", mockClusterExpected); }}).once(); expect(mockClusterExpected.getDesiredConfigByType("cluster-env")).andReturn(mockClusterEnv).atLeastOnce(); expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHbaseEnv).atLeastOnce(); expect(mockClusterExpected.getDesiredConfigByType("hbase-site")).andReturn(mockHbaseSite).atLeastOnce(); expect(mockClusterEnv.getProperties()).andReturn(propertiesExpectedClusterEnv).atLeastOnce(); expect(mockHbaseEnv.getProperties()).andReturn(propertiesExpectedHbaseEnv).atLeastOnce(); expect(mockHbaseSite.getProperties()).andReturn(propertiesExpectedHbaseSite).atLeastOnce(); easyMockSupport.replayAll(); mockInjector.getInstance(UpgradeCatalog212.class).updateHbaseAndClusterConfigurations(); easyMockSupport.verifyAll(); }
protected void updateHbaseAndClusterConfigurations() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if ((clusterMap != null) && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config hbaseEnvProps = cluster.getDesiredConfigByType(HBASE_ENV); Config hbaseSiteProps = cluster.getDesiredConfigByType(HBASE_SITE); if (hbaseEnvProps != null) { String value = hbaseEnvProps.getProperties().get("override_hbase_uid"); if (value != null) { Map<String, String> updates = new HashMap<String, String>(); Set<String> removes = new HashSet<String>(); updates.put("override_uid", value); removes.add("override_hbase_uid"); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String, String>(), removes, false, true); updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false); } } if (hbaseSiteProps != null) { String value = hbaseSiteProps.getProperties().get("hbase.bucketcache.size"); if (value != null) { if (value.endsWith("m")) { value = value.substring(0, value.length() - 1); Map<String, String> updates = new HashMap<String, String>(); updates.put("hbase.bucketcache.size", value); updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true, false); } } } } } } }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected void updateHbaseAndClusterConfigurations() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if ((clusterMap != null) && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config hbaseEnvProps = cluster.getDesiredConfigByType(HBASE_ENV); Config hbaseSiteProps = cluster.getDesiredConfigByType(HBASE_SITE); if (hbaseEnvProps != null) { String value = hbaseEnvProps.getProperties().get("override_hbase_uid"); if (value != null) { Map<String, String> updates = new HashMap<String, String>(); Set<String> removes = new HashSet<String>(); updates.put("override_uid", value); removes.add("override_hbase_uid"); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String, String>(), removes, false, true); updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false); } } if (hbaseSiteProps != null) { String value = hbaseSiteProps.getProperties().get("hbase.bucketcache.size"); if (value != null) { if (value.endsWith("m")) { value = value.substring(0, value.length() - 1); Map<String, String> updates = new HashMap<String, String>(); updates.put("hbase.bucketcache.size", value); updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true, false); } } } } } } } }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected void updateHbaseAndClusterConfigurations() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if ((clusterMap != null) && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config hbaseEnvProps = cluster.getDesiredConfigByType(HBASE_ENV); Config hbaseSiteProps = cluster.getDesiredConfigByType(HBASE_SITE); if (hbaseEnvProps != null) { String value = hbaseEnvProps.getProperties().get("override_hbase_uid"); if (value != null) { Map<String, String> updates = new HashMap<String, String>(); Set<String> removes = new HashSet<String>(); updates.put("override_uid", value); removes.add("override_hbase_uid"); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String, String>(), removes, false, true); updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false); } } if (hbaseSiteProps != null) { String value = hbaseSiteProps.getProperties().get("hbase.bucketcache.size"); if (value != null) { if (value.endsWith("m")) { value = value.substring(0, value.length() - 1); Map<String, String> updates = new HashMap<String, String>(); updates.put("hbase.bucketcache.size", value); updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true, false); } } } } } } } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected void updateHbaseAndClusterConfigurations() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if ((clusterMap != null) && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config hbaseEnvProps = cluster.getDesiredConfigByType(HBASE_ENV); Config hbaseSiteProps = cluster.getDesiredConfigByType(HBASE_SITE); if (hbaseEnvProps != null) { String value = hbaseEnvProps.getProperties().get("override_hbase_uid"); if (value != null) { Map<String, String> updates = new HashMap<String, String>(); Set<String> removes = new HashSet<String>(); updates.put("override_uid", value); removes.add("override_hbase_uid"); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String, String>(), removes, false, true); updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false); } } if (hbaseSiteProps != null) { String value = hbaseSiteProps.getProperties().get("hbase.bucketcache.size"); if (value != null) { if (value.endsWith("m")) { value = value.substring(0, value.length() - 1); Map<String, String> updates = new HashMap<String, String>(); updates.put("hbase.bucketcache.size", value); updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true, false); } } } } } } } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog212 extends AbstractUpgradeCatalog { protected void updateHbaseAndClusterConfigurations() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); Clusters clusters = ambariManagementController.getClusters(); if (clusters != null) { Map<String, Cluster> clusterMap = clusters.getClusters(); if ((clusterMap != null) && !clusterMap.isEmpty()) { for (final Cluster cluster : clusterMap.values()) { Config hbaseEnvProps = cluster.getDesiredConfigByType(HBASE_ENV); Config hbaseSiteProps = cluster.getDesiredConfigByType(HBASE_SITE); if (hbaseEnvProps != null) { String value = hbaseEnvProps.getProperties().get("override_hbase_uid"); if (value != null) { Map<String, String> updates = new HashMap<String, String>(); Set<String> removes = new HashSet<String>(); updates.put("override_uid", value); removes.add("override_hbase_uid"); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV, new HashMap<String, String>(), removes, false, true); updateConfigurationPropertiesForCluster(cluster, CLUSTER_ENV, updates, true, false); } } if (hbaseSiteProps != null) { String value = hbaseSiteProps.getProperties().get("hbase.bucketcache.size"); if (value != null) { if (value.endsWith("m")) { value = value.substring(0, value.length() - 1); Map<String, String> updates = new HashMap<String, String>(); updates.put("hbase.bucketcache.size", value); updateConfigurationPropertiesForCluster(cluster, HBASE_SITE, updates, true, false); } } } } } } } @Inject  UpgradeCatalog212(Injector injector); protected  UpgradeCatalog212(); @Override String getTargetVersion(); @Override String getSourceVersion();  }