@Test public void testUpdateHbaseEnvConfig() throws AmbariException { EasyMockSupport easyMockSupport = new EasyMockSupport(); final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class); final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class); final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class); final Map<String, String> propertiesHbaseEnv = new HashMap<String, String>() { { put("content", "test"); } }; final Config mockHbaseEnv = easyMockSupport.createNiceMock(Config.class); expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).once(); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AmbariManagementController.class).toInstance(mockAmbariManagementController); bind(Clusters.class).toInstance(mockClusters); bind(EntityManager.class).toInstance(entityManager); 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); }}).atLeastOnce(); expect(mockClusterExpected.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.2")); expect(mockClusterExpected.getDesiredConfigByType("hbase-env")).andReturn(mockHbaseEnv).atLeastOnce(); expect(mockHbaseEnv.getProperties()).andReturn(propertiesHbaseEnv).atLeastOnce(); easyMockSupport.replayAll(); mockInjector.getInstance(UpgradeCatalog220.class).updateHbaseEnvConfig(); easyMockSupport.verifyAll(); }
protected void updateHbaseEnvConfig() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); boolean updateConfig = false; for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { StackId stackId = cluster.getCurrentStackVersion(); Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG); if (hbaseEnvConfig != null) { String content = hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY); if (content != null) { if (!content.contains("-Djava.io.tmpdir")) { content += "\n\nexport HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\""; updateConfig = true; } if (stackId != null && stackId.getStackName().equals("HDP") && VersionUtils.compareVersions(stackId.getStackVersion(), "2.2") >= 0) { if (!content.contains("MaxDirectMemorySize={{hbase_max_direct_memory_size}}m")) { String newPartOfContent = "\n\nexport HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS {% if hbase_max_direct_memory_size %} -XX:MaxDirectMemorySize={{hbase_max_direct_memory_size}}m {% endif %}\"\n\n"; content += newPartOfContent; updateConfig = true; } if (updateConfig) { Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY, content); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true, false); } } } } } }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateHbaseEnvConfig() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); boolean updateConfig = false; for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { StackId stackId = cluster.getCurrentStackVersion(); Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG); if (hbaseEnvConfig != null) { String content = hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY); if (content != null) { if (!content.contains("-Djava.io.tmpdir")) { content += "\n\nexport HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\""; updateConfig = true; } if (stackId != null && stackId.getStackName().equals("HDP") && VersionUtils.compareVersions(stackId.getStackVersion(), "2.2") >= 0) { if (!content.contains("MaxDirectMemorySize={{hbase_max_direct_memory_size}}m")) { String newPartOfContent = "\n\nexport HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS {% if hbase_max_direct_memory_size %} -XX:MaxDirectMemorySize={{hbase_max_direct_memory_size}}m {% endif %}\"\n\n"; content += newPartOfContent; updateConfig = true; } if (updateConfig) { Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY, content); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true, false); } } } } } } }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateHbaseEnvConfig() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); boolean updateConfig = false; for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { StackId stackId = cluster.getCurrentStackVersion(); Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG); if (hbaseEnvConfig != null) { String content = hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY); if (content != null) { if (!content.contains("-Djava.io.tmpdir")) { content += "\n\nexport HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\""; updateConfig = true; } if (stackId != null && stackId.getStackName().equals("HDP") && VersionUtils.compareVersions(stackId.getStackVersion(), "2.2") >= 0) { if (!content.contains("MaxDirectMemorySize={{hbase_max_direct_memory_size}}m")) { String newPartOfContent = "\n\nexport HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS {% if hbase_max_direct_memory_size %} -XX:MaxDirectMemorySize={{hbase_max_direct_memory_size}}m {% endif %}\"\n\n"; content += newPartOfContent; updateConfig = true; } if (updateConfig) { Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY, content); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true, false); } } } } } } @Inject  UpgradeCatalog220(Injector injector); }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateHbaseEnvConfig() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); boolean updateConfig = false; for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { StackId stackId = cluster.getCurrentStackVersion(); Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG); if (hbaseEnvConfig != null) { String content = hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY); if (content != null) { if (!content.contains("-Djava.io.tmpdir")) { content += "\n\nexport HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\""; updateConfig = true; } if (stackId != null && stackId.getStackName().equals("HDP") && VersionUtils.compareVersions(stackId.getStackVersion(), "2.2") >= 0) { if (!content.contains("MaxDirectMemorySize={{hbase_max_direct_memory_size}}m")) { String newPartOfContent = "\n\nexport HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS {% if hbase_max_direct_memory_size %} -XX:MaxDirectMemorySize={{hbase_max_direct_memory_size}}m {% endif %}\"\n\n"; content += newPartOfContent; updateConfig = true; } if (updateConfig) { Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY, content); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true, false); } } } } } } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateHbaseEnvConfig() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); boolean updateConfig = false; for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { StackId stackId = cluster.getCurrentStackVersion(); Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG); if (hbaseEnvConfig != null) { String content = hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY); if (content != null) { if (!content.contains("-Djava.io.tmpdir")) { content += "\n\nexport HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\""; updateConfig = true; } if (stackId != null && stackId.getStackName().equals("HDP") && VersionUtils.compareVersions(stackId.getStackVersion(), "2.2") >= 0) { if (!content.contains("MaxDirectMemorySize={{hbase_max_direct_memory_size}}m")) { String newPartOfContent = "\n\nexport HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS {% if hbase_max_direct_memory_size %} -XX:MaxDirectMemorySize={{hbase_max_direct_memory_size}}m {% endif %}\"\n\n"; content += newPartOfContent; updateConfig = true; } if (updateConfig) { Map<String, String> updates = Collections.singletonMap(CONTENT_PROPERTY, content); updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true, false); } } } } } } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); static final String UPGRADE_PACKAGE_COL; static final String UPGRADE_TYPE_COL; static final String REPO_VERSION_TABLE; }