hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Haohui Mai (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-6156) Simplify the JMX API that provides snapshot information
Date Thu, 27 Mar 2014 18:09:22 GMT

    [ https://issues.apache.org/jira/browse/HDFS-6156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13949723#comment-13949723
] 

Haohui Mai commented on HDFS-6156:
----------------------------------

{code}
+    SnapshottableDirectoryStatus[] stats = getSnapshottableDirListing(null);
+    if (stats == null) {
+      return null;
+    }
+    List<SnapshotInfo.Bean> beans = new ArrayList<SnapshotInfo.Bean>();
+    for (SnapshottableDirectoryStatus d : stats) {
+      try {
+        for (Snapshot s : getSnapshottableRoot(
+            d.getFullPath().toString()).getSnapshotList()) {
+          beans.add(toBean(s));
         }
+      } catch (IOException e) {
+        continue;
{code}

It's more appropriate to refactor / inline {{getSnapshottableDirListing}} here to generate
the list.

{code}
+  private static SnapshottableDirectoryStatus.Bean toBean(
+      SnapshottableDirectoryStatus d) {
+    return new SnapshottableDirectoryStatus.Bean(d);
+  }
+  
+  private static SnapshotInfo.Bean toBean(Snapshot s) {
+    return new SnapshotInfo.Bean(s);
   }
{code}

Beans are abstractions between two different layers, thus they usually have no dependency
of the application logic (e.g., they don't take an application-level object in the constructor).
A better approach is:

{code}
// in the bean
    public Bean(String path, int snapshotNumber, int snapshotQuota, 
                long modificationTime, short permission, String owner, 
                String group) {
      this.path = path;
      this.snapshotNumber = snapshotNumber;
      this.snapshotQuota = snapshotQuota;
      this.modificationTime = modificationTime;
      this.permission = permission;
      this.owner = owner;
      this.group = group;
    }

// in snapshotmanager
    public Bean(SnapshottableDirectoryStatus s) {
      return new Bean(s.getFoo(), ...);
    }
{code}

bq. I think that we do not need to convert List into Arrays.

I think it has no differences in the final results, but it looks to me that it's also a convention
in beans. :-)


> Simplify the JMX API that provides snapshot information
> -------------------------------------------------------
>
>                 Key: HDFS-6156
>                 URL: https://issues.apache.org/jira/browse/HDFS-6156
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: Haohui Mai
>            Assignee: Shinichi Yamashita
>         Attachments: HDFS-6156.patch
>
>
> HDFS-5196 introduces a set of new APIs that provide snapshot information through JMX.
Currently. The API nests {{SnapshotDirectoryMXBean}} into {{SnapshotStatsMXBean}}, creating
another layer of composition.
> This jira proposes to inline {{SnapshotDirectoryMXBean}} into {{SnapshotStatsMXBean}}
and to simplify the API.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message