You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2016/03/13 17:49:36 UTC

ambari git commit: AMBARI-12931. Ambari shows "Corrupted Blocks" but it is "Corrupted replica" (oleewere)

Repository: ambari
Updated Branches:
  refs/heads/trunk d02eb1f9b -> 8d2265bcf


AMBARI-12931. Ambari shows "Corrupted Blocks" but it is "Corrupted replica" (oleewere)


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

Branch: refs/heads/trunk
Commit: 8d2265bcf4dcace45cbebf1348c3817341cc9778
Parents: d02eb1f
Author: oleewere <ol...@gmail.com>
Authored: Sun Mar 13 17:45:22 2016 +0100
Committer: oleewere <ol...@gmail.com>
Committed: Sun Mar 13 17:45:22 2016 +0100

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog222.java       | 28 +++++++++++++
 .../common-services/HDFS/2.1.0.2.0/widgets.json |  6 +--
 .../stacks/HDP/2.3/services/HDFS/widgets.json   |  6 +--
 .../server/upgrade/UpgradeCatalog222Test.java   | 42 ++++++++++++++++++++
 .../data/widget_layouts/HDFS_SUMMARY.json       |  6 +--
 ambari-web/app/messages.js                      |  2 +-
 6 files changed, 80 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/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 78cf8bd..b3ae237 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
@@ -96,6 +96,19 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
   private static final String[] HDFS_WIDGETS_TO_UPDATE = new String[] {
     "NameNode RPC", "NN Connection Load" };
 
+  protected static final String WIDGET_TABLE = "widget";
+  protected static final String WIDGET_DESCRIPTION = "description";
+  protected static final String WIDGET_NAME = "widget_name";
+  protected static final String WIDGET_CORRUPT_BLOCKS = "Corrupted Blocks";
+  protected static final String WIDGET_CORRUPT_REPLICAS = "Blocks With Corrupted Replicas";
+  protected static final String WIDGET_CORRUPT_REPLICAS_DESCRIPTION = "Number represents data blocks with at least one " +
+    "corrupted replica (but not all of them). Its indicative of HDFS bad health.";
+  protected static final String WIDGET_VALUES = "widget_values";
+  protected static final String WIDGET_VALUES_VALUE =
+    "${Hadoop:service\\" +
+    "\\u003dNameNode,name\\" +
+    "\\u003dFSNamesystem.CorruptBlocks}";
+
 
   // ----- Constructors ------------------------------------------------------
 
@@ -150,6 +163,7 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
     updateHiveConfig();
     updateHostRoleCommands();
     updateHDFSWidgetDefinition();
+    updateCorruptedReplicaWidget();
   }
 
   protected void updateStormConfigs() throws  AmbariException {
@@ -460,6 +474,20 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
     }
   }
 
+  protected void updateCorruptedReplicaWidget() throws SQLException {
+    String widgetValues = String.format("[{\"name\": \"%s\", \"value\": \"%s\"}]",
+      WIDGET_CORRUPT_REPLICAS, WIDGET_VALUES_VALUE);
+    String updateStatement = "UPDATE %s SET %s='%s', %s='%s', %s='%s' WHERE %s='%s'";
+
+    LOG.info("Update widget definition for HDFS corrupted blocks metric");
+    dbAccessor.executeUpdate(String.format(updateStatement,
+      WIDGET_TABLE,
+      WIDGET_NAME, WIDGET_CORRUPT_REPLICAS,
+      WIDGET_DESCRIPTION, WIDGET_CORRUPT_REPLICAS_DESCRIPTION,
+      WIDGET_VALUES, widgetValues,
+      WIDGET_NAME, WIDGET_CORRUPT_BLOCKS
+    ));
+  }
 
   private String convertToDaysIfInSeconds(String secondsString) {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/widgets.json b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/widgets.json
index 89aab13..2d4877f 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/widgets.json
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/widgets.json
@@ -281,8 +281,8 @@
           }
         },
         {
-          "widget_name": "Corrupted Blocks",
-          "description": "Number represents data blocks that have become corrupted or missing. Its indicative of HDFS bad health.",
+          "widget_name": "Blocks With Corrupted Replicas",
+          "description": "Number represents data blocks with at least one corrupted replica (but not all of them). Its indicative of HDFS bad health.",
           "widget_type": "NUMBER",
           "is_visible": true,
           "metrics": [
@@ -295,7 +295,7 @@
           ],
           "values": [
             {
-              "name": "Corrupted Blocks",
+              "name": "Blocks With Corrupted Replicas",
               "value": "${Hadoop:service=NameNode,name=FSNamesystem.CorruptBlocks}"
             }
           ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/widgets.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/widgets.json b/ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/widgets.json
index ee745d9..800def9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/widgets.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/HDFS/widgets.json
@@ -329,8 +329,8 @@
           }
         },
         {
-          "widget_name": "Corrupted Blocks",
-          "description": "Number represents data blocks that have become corrupted or missing. Its indicative of HDFS bad health.",
+          "widget_name": "Blocks With Corrupted Replicas",
+          "description": "Number represents data blocks with at least one corrupted replica (but not all of them). Its indicative of HDFS bad health.",
           "widget_type": "NUMBER",
           "is_visible": true,
           "metrics": [
@@ -344,7 +344,7 @@
           ],
           "values": [
             {
-              "name": "Corrupted Blocks",
+              "name": "Blocks With Corrupted Replicas",
               "value": "${Hadoop:service=NameNode,name=FSNamesystem.CorruptBlocks}"
             }
           ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/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 f6dcb18..2c09aa8 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
@@ -28,6 +28,7 @@ import com.google.inject.Injector;
 import com.google.inject.Module;
 import com.google.inject.Provider;
 import com.google.inject.persist.PersistService;
+import java.sql.SQLException;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -55,6 +56,7 @@ import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.commons.io.FileUtils;
 import org.easymock.Capture;
+import org.easymock.CaptureType;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
 import org.junit.After;
@@ -126,6 +128,7 @@ public class UpgradeCatalog222Test {
     Method updateHiveConfigs = UpgradeCatalog222.class.getDeclaredMethod("updateHiveConfig");
     Method updateHostRoleCommands = UpgradeCatalog222.class.getDeclaredMethod("updateHostRoleCommands");
     Method updateHDFSWidget = UpgradeCatalog222.class.getDeclaredMethod("updateHDFSWidgetDefinition");
+    Method updateCorruptedReplicaWidget = UpgradeCatalog222.class.getDeclaredMethod("updateCorruptedReplicaWidget");
 
 
     UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
@@ -136,6 +139,7 @@ public class UpgradeCatalog222Test {
       .addMockedMethod(updateHiveConfigs)
       .addMockedMethod(updateHostRoleCommands)
       .addMockedMethod(updateHDFSWidget)
+      .addMockedMethod(updateCorruptedReplicaWidget)
       .createMock();
 
     upgradeCatalog222.addNewConfigurationsFromXml();
@@ -152,6 +156,8 @@ public class UpgradeCatalog222Test {
     expectLastCall().once();
     upgradeCatalog222.updateHDFSWidgetDefinition();
     expectLastCall().once();
+    upgradeCatalog222.updateCorruptedReplicaWidget();
+    expectLastCall().once();
 
     replay(upgradeCatalog222);
 
@@ -466,4 +472,40 @@ public class UpgradeCatalog222Test {
     easyMockSupport.verifyAll();
   }
 
+  @Test
+  public void testUpdateCorruptedReplicaWidget() throws SQLException{
+    final DBAccessor dbAccessor = createStrictMock(DBAccessor.class);
+    Module module = new Module() {
+      @Override
+      public void configure(Binder binder) {
+        binder.bind(DBAccessor.class).toInstance(dbAccessor);
+        binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+        binder.bind(EntityManager.class).toInstance(entityManager);
+      }
+    };
+
+    Injector injector = Guice.createInjector(module);
+
+    String expectedWidgetUpdate = "UPDATE widget SET widget_name='%s', description='%s', " +
+      "widget_values='[{\"name\": \"%s\", \"value\": \"%s\"}]' WHERE widget_name='%s'";
+    Capture<String> capturedStatements = Capture.newInstance(CaptureType.ALL);
+
+    expect(dbAccessor.executeUpdate(capture(capturedStatements))).andReturn(1);
+
+    UpgradeCatalog222 upgradeCatalog222 = injector.getInstance(UpgradeCatalog222.class);
+    replay(dbAccessor);
+
+    upgradeCatalog222.updateCorruptedReplicaWidget();
+
+    List<String> statements = capturedStatements.getValues();
+
+    assertTrue(statements.contains(String.format(expectedWidgetUpdate,
+      UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS,
+      UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS_DESCRIPTION,
+      UpgradeCatalog222.WIDGET_CORRUPT_REPLICAS,
+      UpgradeCatalog222.WIDGET_VALUES_VALUE,
+      UpgradeCatalog222.WIDGET_CORRUPT_BLOCKS)));
+
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/ambari-web/app/assets/data/widget_layouts/HDFS_SUMMARY.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/widget_layouts/HDFS_SUMMARY.json b/ambari-web/app/assets/data/widget_layouts/HDFS_SUMMARY.json
index a97c9e5..e55d104 100644
--- a/ambari-web/app/assets/data/widget_layouts/HDFS_SUMMARY.json
+++ b/ambari-web/app/assets/data/widget_layouts/HDFS_SUMMARY.json
@@ -132,11 +132,11 @@
               "description" : null,
               "scope" : "CLUSTER",
               "properties" : "{}",
-              "widget_name" : "Corrupted Blocks",
+              "widget_name" : "Blocks With Corrupted Replicas",
               "widget_type" : "NUMBER",
               "time_created" : 1429906622107,
-              "display_name" : "Corrupted Blocks",
-              "values" : "[{\"name\":\"Corrupted Blocks\",\"value\":\"${Hadoop:service\\u003dNameNode,name\\u003dFSNamesystem.CorruptBlocks}\"}]",
+              "display_name" : "Blocks With Corrupted Replicas",
+              "values" : "[{\"name\":\"Blocks With Corrupted Replicas\",\"value\":\"${Hadoop:service\\u003dNameNode,name\\u003dFSNamesystem.CorruptBlocks}\"}]",
               "cluster_name" : "c1"
             }
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d2265bc/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index d9e34b0..47a3caf 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2591,7 +2591,7 @@ Em.I18n.translations = {
   'dashboard.services.hdfs.nodes.heap':'NameNode Heap',
   'dashboard.services.hdfs.nodes.heapUsed':'{0} / {1} ({2}% used)',
   'dashboard.services.hdfs.chart.label':'Capacity (Used/Total)',
-  'dashboard.services.hdfs.blockErrors':'{0} corrupt / {1} missing / {2} under replicated',
+  'dashboard.services.hdfs.blockErrors':'{0} corrupt replica / {1} missing / {2} under replicated',
   'dashboard.services.hdfs.datanode.status.tooltip.live': 'This is the number of DataNodes that are live as reported from ' +
     'the NameNode. Even if a DataNode process is up, NameNode might see the status as dead ' +
     'if the DataNode is not communicating with the NameNode as expected. This can be due situations ' +