You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/08/05 14:08:00 UTC

[jira] [Commented] (HDFS-16718) Improve Code with Lambda in org.apahce.hadoop.hdfs.server.datanode packages

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

ASF GitHub Bot commented on HDFS-16718:
---------------------------------------

ZanderXu opened a new pull request, #4708:
URL: https://github.com/apache/hadoop/pull/4708

   ### Description of PR
   Improve Code with Lambda in org.apahce.hadoop.hdfs.server.datanode packages.
   
   For example:
   Current logic:
   ```
   synchronized void startAll() throws IOException {
     try {
       UserGroupInformation.getLoginUser().doAs(
           new PrivilegedExceptionAction<Object>() {
             @Override
             public Object run() throws Exception {
               for (BPOfferService bpos : offerServices) {
                 bpos.start();
               }
               return null;
             }
           });
     } catch (InterruptedException ex) {
       IOException ioe = new IOException();
       ioe.initCause(ex.getCause());
       throw ioe;
     }
   }
   ```
   Improved Code with Lambda:
   ```
   synchronized void startAll() throws IOException {
     try {
       UserGroupInformation.getLoginUser().doAs(
           (PrivilegedExceptionAction<Object>) () -> {
             for (BPOfferService bpos : offerServices) {
               bpos.start();
             }
             return null;
           });
     } catch (InterruptedException ex) {
       IOException ioe = new IOException();
       ioe.initCause(ex.getCause());
       throw ioe;
     }
   }
   ```




> Improve Code with Lambda in org.apahce.hadoop.hdfs.server.datanode packages
> ---------------------------------------------------------------------------
>
>                 Key: HDFS-16718
>                 URL: https://issues.apache.org/jira/browse/HDFS-16718
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Major
>
> Improve Code with Lambda in org.apahce.hadoop.hdfs.server.datanode packages.
> For example:
> Current logic:
> {code:java}
> synchronized void startAll() throws IOException {
>   try {
>     UserGroupInformation.getLoginUser().doAs(
>         new PrivilegedExceptionAction<Object>() {
>           @Override
>           public Object run() throws Exception {
>             for (BPOfferService bpos : offerServices) {
>               bpos.start();
>             }
>             return null;
>           }
>         });
>   } catch (InterruptedException ex) {
>     IOException ioe = new IOException();
>     ioe.initCause(ex.getCause());
>     throw ioe;
>   }
> }{code}
> Improved Code with Lambda:
> {code:java}
> synchronized void startAll() throws IOException {
>   try {
>     UserGroupInformation.getLoginUser().doAs(
>         (PrivilegedExceptionAction<Object>) () -> {
>           for (BPOfferService bpos : offerServices) {
>             bpos.start();
>           }
>           return null;
>         });
>   } catch (InterruptedException ex) {
>     IOException ioe = new IOException();
>     ioe.initCause(ex.getCause());
>     throw ioe;
>   }
> }{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org