ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject ambari git commit: AMBARI-16001. Fix bad entry in hbase-env.sh, added as part of 2.2.0-2.2.1.1 upgrade (ajit)
Date Thu, 21 Apr 2016 14:21:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9be2ba288 -> dc6cde341


AMBARI-16001. Fix bad entry in hbase-env.sh, added as part of 2.2.0-2.2.1.1 upgrade (ajit)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dc6cde34
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dc6cde34
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dc6cde34

Branch: refs/heads/trunk
Commit: dc6cde341097308aca190b1dde38591f90108b17
Parents: 9be2ba2
Author: Ajit Kumar <ajit@apache.org>
Authored: Thu Apr 21 07:20:04 2016 -0700
Committer: Ajit Kumar <ajit@apache.org>
Committed: Thu Apr 21 07:20:40 2016 -0700

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog222.java       | 34 +++++++++++
 .../server/upgrade/UpgradeCatalog222Test.java   | 59 +++++++++++++++-----
 2 files changed, 80 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dc6cde34/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index a6a8991..d8658f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -24,6 +24,7 @@ import java.lang.reflect.Type;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -83,6 +84,8 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
   private static final String ATLAS_SERVER_HTTP_PORT_PROPERTY = "atlas.server.http.port";
   private static final String ATLAS_SERVER_HTTPS_PORT_PROPERTY = "atlas.server.https.port";
   private static final String ATLAS_REST_ADDRESS_PROPERTY = "atlas.rest.address";
+  private static final String HBASE_ENV_CONFIG = "hbase-env";
+  private static final String CONTENT_PROPERTY = "content";
 
   private static final String UPGRADE_TABLE = "upgrade";
   private static final String UPGRADE_SUSPENDED_COLUMN = "suspended";
@@ -99,6 +102,7 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
   public static final String AMS_WEBAPP_ADDRESS_PROPERTY = "timeline.metrics.service.webapp.address";
   public static final String HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD_PROPERTY = "hbase.client.scanner.timeout.period";
   public static final String HBASE_RPC_TIMEOUT_PROPERTY = "hbase.rpc.timeout";
+
   public static final String PHOENIX_QUERY_TIMEOUT_PROPERTY = "phoenix.query.timeoutMs";
   public static final String PHOENIX_QUERY_KEEPALIVE_PROPERTY = "phoenix.query.keepAliveMs";
   public static final String TIMELINE_METRICS_CLUSTER_AGGREGATOR_INTERPOLATION_ENABLED
@@ -181,6 +185,7 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
     updateHDFSWidgetDefinition();
     updateYARNWidgetDefinition();
     updateHBASEWidgetDefinition();
+    updateHbaseEnvConfig();
     updateCorruptedReplicaWidget();
     updateZookeeperConfigs();
     createNewSliderConfigVersion();
@@ -478,6 +483,35 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
     updateWidgetDefinitionsForService("HBASE", widgetMap, sectionLayoutMap);
   }
 
+
+  protected void updateHbaseEnvConfig() throws AmbariException {
+    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
+    for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values())
{
+      Config hbaseEnvConfig = cluster.getDesiredConfigByType(HBASE_ENV_CONFIG);
+      if (hbaseEnvConfig != null) {
+        Map<String, String> updates = getUpdatedHbaseEnvProperties(hbaseEnvConfig.getProperties().get(CONTENT_PROPERTY));
+        if (!updates.isEmpty()) {
+          updateConfigurationPropertiesForCluster(cluster, HBASE_ENV_CONFIG, updates, true,
false);
+        }
+
+      }
+    }
+  }
+
+  protected Map<String, String> getUpdatedHbaseEnvProperties(String content) {
+    if (content != null) {
+      //Fix bad config added in Upgrade 2.2.0.
+      String badConfig = "export HBASE_OPTS=\"-Djava.io.tmpdir={{java_io_tmpdir}}\"";
+      String correctConfig = "export HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\"";
+
+      if (content.contains(badConfig)) {
+        content = content.replace(badConfig, correctConfig);
+        return Collections.singletonMap(CONTENT_PROPERTY, content);
+      }
+    }
+    return Collections.emptyMap();
+  }
+
   private void updateWidgetDefinitionsForService(String serviceName, Map<String, List<String>>
widgetMap,
                                                  Map<String, String> sectionLayoutMap)
throws AmbariException {
     AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/dc6cde34/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index f0158fd..327807a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -32,6 +32,7 @@ import static org.easymock.EasyMock.expectLastCall;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
 import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -133,6 +134,7 @@ public class UpgradeCatalog222Test {
     Method updateHDFSWidget = UpgradeCatalog222.class.getDeclaredMethod("updateHDFSWidgetDefinition");
     Method updateYARNWidget = UpgradeCatalog222.class.getDeclaredMethod("updateYARNWidgetDefinition");
     Method updateHBASEWidget = UpgradeCatalog222.class.getDeclaredMethod("updateHBASEWidgetDefinition");
+    Method updateHbaseEnvConfig = UpgradeCatalog222.class.getDeclaredMethod("updateHbaseEnvConfig");
     Method updateCorruptedReplicaWidget = UpgradeCatalog222.class.getDeclaredMethod("updateCorruptedReplicaWidget");
     Method createNewSliderConfigVersion = UpgradeCatalog222.class.getDeclaredMethod("createNewSliderConfigVersion");
     Method updateZookeeperConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateZookeeperConfigs");
@@ -148,6 +150,7 @@ public class UpgradeCatalog222Test {
       .addMockedMethod(updateHDFSWidget)
       .addMockedMethod(updateYARNWidget)
       .addMockedMethod(updateHBASEWidget)
+      .addMockedMethod(updateHbaseEnvConfig)
       .addMockedMethod(updateCorruptedReplicaWidget)
       .addMockedMethod(createNewSliderConfigVersion)
       .addMockedMethod(updateZookeeperConfigs)
@@ -155,31 +158,19 @@ public class UpgradeCatalog222Test {
       .createMock();
 
     upgradeCatalog222.addNewConfigurationsFromXml();
-    expectLastCall().once();
     upgradeCatalog222.updateAlerts();
-    expectLastCall().once();
     upgradeCatalog222.updateStormConfigs();
-    expectLastCall().once();
     upgradeCatalog222.updateAMSConfigs();
-    expectLastCall().once();
     upgradeCatalog222.updateHostRoleCommands();
-    expectLastCall().once();
     upgradeCatalog222.updateHiveConfig();
-    expectLastCall().once();
     upgradeCatalog222.updateHDFSWidgetDefinition();
-    expectLastCall().once();
+    upgradeCatalog222.updateHbaseEnvConfig();
     upgradeCatalog222.updateYARNWidgetDefinition();
-    expectLastCall().once();
     upgradeCatalog222.updateHBASEWidgetDefinition();
-    expectLastCall().once();
     upgradeCatalog222.updateCorruptedReplicaWidget();
-    expectLastCall().once();
     upgradeCatalog222.updateZookeeperConfigs();
-    expectLastCall().once();
     upgradeCatalog222.createNewSliderConfigVersion();
-    expectLastCall().once();
     upgradeCatalog222.initializeStromAndKafkaWidgets();
-    expectLastCall().once();
 
     replay(upgradeCatalog222);
 
@@ -788,6 +779,48 @@ public class UpgradeCatalog222Test {
   }
 
   @Test
+  public void testGetUpdatedHbaseEnvProperties_BadConfig() {
+    String badContent = "export HBASE_HEAPSIZE=1000;\n\n" +
+            "export HBASE_OPTS=\"-Djava.io.tmpdir={{java_io_tmpdir}}\"\n\n" +
+            "export HBASE_LOG_DIR={{log_dir}}";
+    String expectedContent = "export HBASE_HEAPSIZE=1000;\n\n" +
+            "export HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\"\n\n"
+
+            "export HBASE_LOG_DIR={{log_dir}}";
+    testGetUpdatedHbaseEnvProperties(badContent, expectedContent);
+  }
+
+  @Test
+  public void testGetUpdatedHbaseEnvProperties_GoodConfig() {
+
+    String goodContent = "export HBASE_HEAPSIZE=1000;\n\n" +
+            "export HBASE_OPTS=\"${HBASE_OPTS} -Djava.io.tmpdir={{java_io_tmpdir}}\"\n\n"
+
+            "export HBASE_LOG_DIR={{log_dir}}";
+    testGetUpdatedHbaseEnvProperties(goodContent, null);
+  }
+
+  @Test
+  public void testGetUpdatedHbaseEnvProperties_NoConfig() {
+    String content = "export HBASE_HEAPSIZE=1000;\n\n" +
+            "export HBASE_LOG_DIR={{log_dir}}";
+    testGetUpdatedHbaseEnvProperties(content, null);
+  }
+
+  private void testGetUpdatedHbaseEnvProperties(String content, String expectedContent) {
+    Module module = new Module() {
+      @Override
+      public void configure(Binder binder) {
+        binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+      }
+    };
+
+    Injector injector = Guice.createInjector(module);
+    UpgradeCatalog222 upgradeCatalog222 = injector.getInstance(UpgradeCatalog222.class);
+    Map<String, String> update = upgradeCatalog222.getUpdatedHbaseEnvProperties(content);
+    assertEquals(expectedContent, update.get("content"));
+  }
+
+  @Test
   public void testUpdateHostRoleCommands() throws Exception {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
     dbAccessor.createIndex(eq("idx_hrc_status_role"), eq("host_role_command"), eq("status"),
eq("role"));


Mime
View raw message