@Test public void testUpdateHBaseConfiguration() throws Exception { 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 Host mockHost = easyMockSupport.createNiceMock(Host.class); final Config mockHBaseSite = easyMockSupport.createNiceMock(Config.class); final Config mockHBaseEnv = easyMockSupport.createNiceMock(Config.class); final Map<String, String> propertiesExpectedHBaseSite = new HashMap<String, String>(); propertiesExpectedHBaseSite.put("hbase.region.server.rpc.scheduler.factory.class", "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory"); propertiesExpectedHBaseSite.put("hbase.security.authorization", "true"); final Map<String, String> propertiesExpectedHBaseEnv = new HashMap<String, String>(); propertiesExpectedHBaseEnv.put("phoenix_sql_enabled", "false"); 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("hbase-site")).andReturn(mockHBaseSite).atLeastOnce(); expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHBaseEnv).atLeastOnce(); expect(mockHBaseSite.getProperties()).andReturn(propertiesExpectedHBaseSite).anyTimes(); expect(mockHBaseEnv.getProperties()).andReturn(propertiesExpectedHBaseEnv).anyTimes(); Capture<String> configType = EasyMock.newCapture(); Capture<String> configTag = EasyMock.newCapture(); expect(mockClusterExpected.getConfig(capture(configType), capture(configTag))). andReturn(mockHBaseSite).atLeastOnce(); easyMockSupport.replayAll(); mockInjector.getInstance(UpgradeCatalog210.class).updateHBaseConfigs(); easyMockSupport.verifyAll(); }
protected void updateHBaseConfigs() 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()) { if (cluster.getDesiredConfigByType("hbase-site") != null && cluster.getDesiredConfigByType("hbase-env") != null) { Map<String, String> hbaseEnvProps = new HashMap<String, String>(); Map<String, String> hbaseSiteProps = new HashMap<String, String>(); Set<String> hbaseEnvRemoveProps = new HashSet<String>(); Set<String> hbaseSiteRemoveProps = new HashSet<String>(); if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.region.server.rpc.scheduler.factory.class") && "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory".equals(cluster.getDesiredConfigByType("hbase-site").getProperties().get( "hbase.region.server.rpc.scheduler.factory.class"))) { hbaseEnvProps.put("phoenix_sql_enabled", "true"); } if (cluster.getDesiredConfigByType("hbase-env").getProperties().containsKey("phoenix_sql_enabled") && "true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-env").getProperties().get("phoenix_sql_enabled"))) { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); hbaseSiteProps.put("phoenix.functions.allowUserDefinedFunctions", "true"); } else { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.WALCellCodec"); hbaseSiteRemoveProps.add("hbase.rpc.controllerfactory.class"); hbaseSiteRemoveProps.add("phoenix.functions.allowUserDefinedFunctions"); } if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.security.authorization")) { if("true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-site").getProperties().get("hbase.security.authorization"))) { hbaseSiteProps.put("hbase.coprocessor.master.classes", "org.apache.hadoop.hbase.security.access.AccessController"); hbaseSiteProps.put("hbase.coprocessor.regionserver.classes", "org.apache.hadoop.hbase.security.access.AccessController"); } else { hbaseSiteProps.put("hbase.coprocessor.master.classes", ""); hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } } else { hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } updateConfigurationPropertiesForCluster(cluster, "hbase-site", hbaseSiteProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-env", hbaseEnvProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-site", new HashMap<String, String>(), hbaseSiteRemoveProps, false, true); updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String, String>(), hbaseEnvRemoveProps, false, true); } } } } }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void updateHBaseConfigs() 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()) { if (cluster.getDesiredConfigByType("hbase-site") != null && cluster.getDesiredConfigByType("hbase-env") != null) { Map<String, String> hbaseEnvProps = new HashMap<String, String>(); Map<String, String> hbaseSiteProps = new HashMap<String, String>(); Set<String> hbaseEnvRemoveProps = new HashSet<String>(); Set<String> hbaseSiteRemoveProps = new HashSet<String>(); if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.region.server.rpc.scheduler.factory.class") && "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory".equals(cluster.getDesiredConfigByType("hbase-site").getProperties().get( "hbase.region.server.rpc.scheduler.factory.class"))) { hbaseEnvProps.put("phoenix_sql_enabled", "true"); } if (cluster.getDesiredConfigByType("hbase-env").getProperties().containsKey("phoenix_sql_enabled") && "true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-env").getProperties().get("phoenix_sql_enabled"))) { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); hbaseSiteProps.put("phoenix.functions.allowUserDefinedFunctions", "true"); } else { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.WALCellCodec"); hbaseSiteRemoveProps.add("hbase.rpc.controllerfactory.class"); hbaseSiteRemoveProps.add("phoenix.functions.allowUserDefinedFunctions"); } if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.security.authorization")) { if("true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-site").getProperties().get("hbase.security.authorization"))) { hbaseSiteProps.put("hbase.coprocessor.master.classes", "org.apache.hadoop.hbase.security.access.AccessController"); hbaseSiteProps.put("hbase.coprocessor.regionserver.classes", "org.apache.hadoop.hbase.security.access.AccessController"); } else { hbaseSiteProps.put("hbase.coprocessor.master.classes", ""); hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } } else { hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } updateConfigurationPropertiesForCluster(cluster, "hbase-site", hbaseSiteProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-env", hbaseEnvProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-site", new HashMap<String, String>(), hbaseSiteRemoveProps, false, true); updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String, String>(), hbaseEnvRemoveProps, false, true); } } } } } }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void updateHBaseConfigs() 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()) { if (cluster.getDesiredConfigByType("hbase-site") != null && cluster.getDesiredConfigByType("hbase-env") != null) { Map<String, String> hbaseEnvProps = new HashMap<String, String>(); Map<String, String> hbaseSiteProps = new HashMap<String, String>(); Set<String> hbaseEnvRemoveProps = new HashSet<String>(); Set<String> hbaseSiteRemoveProps = new HashSet<String>(); if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.region.server.rpc.scheduler.factory.class") && "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory".equals(cluster.getDesiredConfigByType("hbase-site").getProperties().get( "hbase.region.server.rpc.scheduler.factory.class"))) { hbaseEnvProps.put("phoenix_sql_enabled", "true"); } if (cluster.getDesiredConfigByType("hbase-env").getProperties().containsKey("phoenix_sql_enabled") && "true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-env").getProperties().get("phoenix_sql_enabled"))) { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); hbaseSiteProps.put("phoenix.functions.allowUserDefinedFunctions", "true"); } else { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.WALCellCodec"); hbaseSiteRemoveProps.add("hbase.rpc.controllerfactory.class"); hbaseSiteRemoveProps.add("phoenix.functions.allowUserDefinedFunctions"); } if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.security.authorization")) { if("true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-site").getProperties().get("hbase.security.authorization"))) { hbaseSiteProps.put("hbase.coprocessor.master.classes", "org.apache.hadoop.hbase.security.access.AccessController"); hbaseSiteProps.put("hbase.coprocessor.regionserver.classes", "org.apache.hadoop.hbase.security.access.AccessController"); } else { hbaseSiteProps.put("hbase.coprocessor.master.classes", ""); hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } } else { hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } updateConfigurationPropertiesForCluster(cluster, "hbase-site", hbaseSiteProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-env", hbaseEnvProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-site", new HashMap<String, String>(), hbaseSiteRemoveProps, false, true); updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String, String>(), hbaseEnvRemoveProps, false, true); } } } } } @Inject  UpgradeCatalog210(Injector injector); }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void updateHBaseConfigs() 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()) { if (cluster.getDesiredConfigByType("hbase-site") != null && cluster.getDesiredConfigByType("hbase-env") != null) { Map<String, String> hbaseEnvProps = new HashMap<String, String>(); Map<String, String> hbaseSiteProps = new HashMap<String, String>(); Set<String> hbaseEnvRemoveProps = new HashSet<String>(); Set<String> hbaseSiteRemoveProps = new HashSet<String>(); if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.region.server.rpc.scheduler.factory.class") && "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory".equals(cluster.getDesiredConfigByType("hbase-site").getProperties().get( "hbase.region.server.rpc.scheduler.factory.class"))) { hbaseEnvProps.put("phoenix_sql_enabled", "true"); } if (cluster.getDesiredConfigByType("hbase-env").getProperties().containsKey("phoenix_sql_enabled") && "true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-env").getProperties().get("phoenix_sql_enabled"))) { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); hbaseSiteProps.put("phoenix.functions.allowUserDefinedFunctions", "true"); } else { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.WALCellCodec"); hbaseSiteRemoveProps.add("hbase.rpc.controllerfactory.class"); hbaseSiteRemoveProps.add("phoenix.functions.allowUserDefinedFunctions"); } if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.security.authorization")) { if("true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-site").getProperties().get("hbase.security.authorization"))) { hbaseSiteProps.put("hbase.coprocessor.master.classes", "org.apache.hadoop.hbase.security.access.AccessController"); hbaseSiteProps.put("hbase.coprocessor.regionserver.classes", "org.apache.hadoop.hbase.security.access.AccessController"); } else { hbaseSiteProps.put("hbase.coprocessor.master.classes", ""); hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } } else { hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } updateConfigurationPropertiesForCluster(cluster, "hbase-site", hbaseSiteProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-env", hbaseEnvProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-site", new HashMap<String, String>(), hbaseSiteRemoveProps, false, true); updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String, String>(), hbaseEnvRemoveProps, false, true); } } } } } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion(); }
UpgradeCatalog210 extends AbstractUpgradeCatalog { protected void updateHBaseConfigs() 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()) { if (cluster.getDesiredConfigByType("hbase-site") != null && cluster.getDesiredConfigByType("hbase-env") != null) { Map<String, String> hbaseEnvProps = new HashMap<String, String>(); Map<String, String> hbaseSiteProps = new HashMap<String, String>(); Set<String> hbaseEnvRemoveProps = new HashSet<String>(); Set<String> hbaseSiteRemoveProps = new HashSet<String>(); if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.region.server.rpc.scheduler.factory.class") && "org.apache.phoenix.hbase.index.ipc.PhoenixIndexRpcSchedulerFactory".equals(cluster.getDesiredConfigByType("hbase-site").getProperties().get( "hbase.region.server.rpc.scheduler.factory.class"))) { hbaseEnvProps.put("phoenix_sql_enabled", "true"); } if (cluster.getDesiredConfigByType("hbase-env").getProperties().containsKey("phoenix_sql_enabled") && "true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-env").getProperties().get("phoenix_sql_enabled"))) { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec"); hbaseSiteProps.put("phoenix.functions.allowUserDefinedFunctions", "true"); } else { hbaseSiteProps.put("hbase.regionserver.wal.codec", "org.apache.hadoop.hbase.regionserver.wal.WALCellCodec"); hbaseSiteRemoveProps.add("hbase.rpc.controllerfactory.class"); hbaseSiteRemoveProps.add("phoenix.functions.allowUserDefinedFunctions"); } if (cluster.getDesiredConfigByType("hbase-site").getProperties().containsKey("hbase.security.authorization")) { if("true".equalsIgnoreCase(cluster.getDesiredConfigByType("hbase-site").getProperties().get("hbase.security.authorization"))) { hbaseSiteProps.put("hbase.coprocessor.master.classes", "org.apache.hadoop.hbase.security.access.AccessController"); hbaseSiteProps.put("hbase.coprocessor.regionserver.classes", "org.apache.hadoop.hbase.security.access.AccessController"); } else { hbaseSiteProps.put("hbase.coprocessor.master.classes", ""); hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } } else { hbaseSiteRemoveProps.add("hbase.coprocessor.regionserver.classes"); } updateConfigurationPropertiesForCluster(cluster, "hbase-site", hbaseSiteProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-env", hbaseEnvProps, true, false); updateConfigurationPropertiesForCluster(cluster, "hbase-site", new HashMap<String, String>(), hbaseSiteRemoveProps, false, true); updateConfigurationPropertiesForCluster(cluster, "hbase-env", new HashMap<String, String>(), hbaseEnvRemoveProps, false, true); } } } } } @Inject  UpgradeCatalog210(Injector injector); @Override String getSourceVersion(); @Override String getTargetVersion();  }