This is an automated email from the ASF dual-hosted git repository.

bharat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hadoop-ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 00799c2  HDDS-3393. Recon throws NPE in clusterState endpoint (#854)
00799c2 is described below

commit 00799c2b0e8917bb32c4a9e9ac6768c1f30e30f2
Author: Vivek Ratnavel Subramanian <[email protected]>
AuthorDate: Tue Apr 21 19:14:43 2020 -0700

    HDDS-3393. Recon throws NPE in clusterState endpoint (#854)
---
 .../ozone/recon/api/ClusterStateEndpoint.java      | 36 ++++++++++++----------
 .../recon/recovery/ReconOMMetadataManager.java     |  6 ++++
 .../recon/recovery/ReconOmMetadataManagerImpl.java | 10 ++++++
 .../webapps/recon/ozone-recon-web/api/db.json      | 28 ++++++++---------
 4 files changed, 49 insertions(+), 31 deletions(-)

diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
index e43dbf8..918ee18 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ClusterStateEndpoint.java
@@ -80,23 +80,25 @@ public class ClusterStateEndpoint {
         new DatanodeStorageReport(stats.getCapacity().get(),
             stats.getScmUsed().get(), stats.getRemaining().get());
     ClusterStateResponse.Builder builder = ClusterStateResponse.newBuilder();
-    try {
-      builder.setVolumes(
-          omMetadataManager.getVolumeTable().getEstimatedKeyCount());
-    } catch (Exception ex) {
-      LOG.error("Unable to get Volumes count in ClusterStateResponse.", ex);
-    }
-    try {
-      builder.setBuckets(
-          omMetadataManager.getBucketTable().getEstimatedKeyCount());
-    } catch (Exception ex) {
-      LOG.error("Unable to get Buckets count in ClusterStateResponse.", ex);
-    }
-    try {
-      builder.setKeys(
-          omMetadataManager.getKeyTable().getEstimatedKeyCount());
-    } catch (Exception ex) {
-      LOG.error("Unable to get Keys count in ClusterStateResponse.", ex);
+    if (omMetadataManager.isOmTablesInitialized()) {
+      try {
+        builder.setVolumes(
+            omMetadataManager.getVolumeTable().getEstimatedKeyCount());
+      } catch (Exception ex) {
+        LOG.error("Unable to get Volumes count in ClusterStateResponse.", ex);
+      }
+      try {
+        builder.setBuckets(
+            omMetadataManager.getBucketTable().getEstimatedKeyCount());
+      } catch (Exception ex) {
+        LOG.error("Unable to get Buckets count in ClusterStateResponse.", ex);
+      }
+      try {
+        builder.setKeys(
+            omMetadataManager.getKeyTable().getEstimatedKeyCount());
+      } catch (Exception ex) {
+        LOG.error("Unable to get Keys count in ClusterStateResponse.", ex);
+      }
     }
     ClusterStateResponse response = builder
         .setStorageReport(storageReport)
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java
index 8c7dca9..a6104bf 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOMMetadataManager.java
@@ -41,4 +41,10 @@ public interface ReconOMMetadataManager extends 
OMMetadataManager {
    * Database.
    */
   long getLastSequenceNumberFromDB();
+
+  /**
+   * Check if OM tables are initialized.
+   * @return true if OM Tables are initialized, otherwise false.
+   */
+  boolean isOmTablesInitialized();
 }
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOmMetadataManagerImpl.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOmMetadataManagerImpl.java
index e60d0dd..fc5cead 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOmMetadataManagerImpl.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/recovery/ReconOmMetadataManagerImpl.java
@@ -51,6 +51,7 @@ public class ReconOmMetadataManagerImpl extends 
OmMetadataManagerImpl
 
   private OzoneConfiguration ozoneConfiguration;
   private ReconUtils reconUtils;
+  private boolean omTablesInitialized = false;
 
   @Inject
   public ReconOmMetadataManagerImpl(OzoneConfiguration configuration,
@@ -94,6 +95,7 @@ public class ReconOmMetadataManagerImpl extends 
OmMetadataManagerImpl
     }
     if (getStore() != null) {
       initializeOmTables();
+      omTablesInitialized = true;
     }
   }
 
@@ -120,4 +122,12 @@ public class ReconOmMetadataManagerImpl extends 
OmMetadataManagerImpl
     }
   }
 
+  /**
+   * Check if OM tables are initialized.
+   * @return true if OM Tables are initialized, otherwise false.
+   */
+  @Override
+  public boolean isOmTablesInitialized() {
+    return omTablesInitialized;
+  }
 }
\ No newline at end of file
diff --git 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
index b4f181c..a198bed 100644
--- 
a/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
+++ 
b/hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/api/db.json
@@ -1,16 +1,16 @@
 {
   "clusterState": {
-    "totalDatanodes": 10,
-    "healthyDatanodes": 9,
-    "pipelines": 3,
+    "totalDatanodes": 24,
+    "healthyDatanodes": 24,
+    "pipelines": 32,
     "storageReport": {
-      "capacity": 1099511627778,
-      "used": 681826058240,
-      "remaining": 391915765760
+      "capacity": 32985348833280,
+      "used": 15942918602752,
+      "remaining": 12094627905536
     },
-    "containers": 54,
+    "containers": 3230,
     "volumes": 5,
-    "buckets": 100,
+    "buckets": 156,
     "keys": 253000
   },
   "datanodes": {
@@ -355,8 +355,8 @@
     "totalCount": 2,
     "containers": [
       {
-        "id": 1,
-        "keys": 3876,
+        "containerID": 1,
+        "keys": 1235,
         "replicas": [
           {
             "containerId": 1,
@@ -378,11 +378,11 @@
           }
         ],
         "missingSince": 1578491371528,
-        "pipelineId": "05e3d908-ff01-4ce6-ad75-f3ec79bcc7982"
+        "pipelineID": "05e3d908-ff01-4ce6-ad75-f3ec79bcc7982"
       },
       {
-        "id": 2,
-        "keys": 5943,
+        "containerID": 2,
+        "keys": 1356,
         "replicas": [
           {
             "containerId": 1,
@@ -404,7 +404,7 @@
           }
         ],
         "missingSince": 1578491471528,
-        "pipelineId": "04a5d908-ff01-4ce6-ad75-f3ec73dfc8a2"
+        "pipelineID": "04a5d908-ff01-4ce6-ad75-f3ec73dfc8a2"
       }
     ]
   },


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to