[ 
https://issues.apache.org/jira/browse/HDFS-16661?focusedWorklogId=791182&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-791182
 ]

ASF GitHub Bot logged work on HDFS-16661:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Jul/22 23:21
            Start Date: 14/Jul/22 23:21
    Worklog Time Spent: 10m 
      Work Description: goiri commented on code in PR #4565:
URL: https://github.com/apache/hadoop/pull/4565#discussion_r921687765


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/AsyncLoggerSet.java:
##########
@@ -206,197 +194,114 @@ List<AsyncLogger> getLoggersForTests() {
   ///////////////////////////////////////////////////////////////////////////
   
   public QuorumCall<AsyncLogger, GetJournalStateResponseProto> 
getJournalState() {
-    Map<AsyncLogger, ListenableFuture<GetJournalStateResponseProto>> calls =
-        Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.getJournalState());
-    }
+    Map<AsyncLogger, ListenableFuture<GetJournalStateResponseProto>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.getJournalState()));
     return QuorumCall.create(calls);    
   }
   
   public QuorumCall<AsyncLogger, Boolean> isFormatted() {
     Map<AsyncLogger, ListenableFuture<Boolean>> calls = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.isFormatted());
-    }
+    loggers.forEach(l -> calls.put(l, l.isFormatted()));
     return QuorumCall.create(calls);
   }
 
-  public QuorumCall<AsyncLogger,NewEpochResponseProto> newEpoch(
-      NamespaceInfo nsInfo,
-      long epoch) {
-    Map<AsyncLogger, ListenableFuture<NewEpochResponseProto>> calls =
-        Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.newEpoch(epoch));
-    }
+  public QuorumCall<AsyncLogger,NewEpochResponseProto> newEpoch(long epoch) {
+    Map<AsyncLogger, ListenableFuture<NewEpochResponseProto>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.newEpoch(epoch)));
     return QuorumCall.create(calls);    
   }
 
-  public QuorumCall<AsyncLogger, Void> startLogSegment(
-      long txid, int layoutVersion) {
+  public QuorumCall<AsyncLogger, Void> startLogSegment(long txid, int 
layoutVersion) {
     Map<AsyncLogger, ListenableFuture<Void>> calls = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.startLogSegment(txid, layoutVersion));
-    }
+    loggers.forEach(l -> calls.put(l, l.startLogSegment(txid, layoutVersion)));
     return QuorumCall.create(calls);
   }
   
-  public QuorumCall<AsyncLogger, Void> finalizeLogSegment(long firstTxId,
-      long lastTxId) {
+  public QuorumCall<AsyncLogger, Void> finalizeLogSegment(long firstTxId, long 
lastTxId) {
     Map<AsyncLogger, ListenableFuture<Void>> calls = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.finalizeLogSegment(firstTxId, lastTxId));
-    }
+    loggers.forEach(l -> calls.put(l, l.finalizeLogSegment(firstTxId, 
lastTxId)));
     return QuorumCall.create(calls);
   }
   
   public QuorumCall<AsyncLogger, Void> sendEdits(
       long segmentTxId, long firstTxnId, int numTxns, byte[] data) {
     Map<AsyncLogger, ListenableFuture<Void>> calls = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      ListenableFuture<Void> future = 
-        logger.sendEdits(segmentTxId, firstTxnId, numTxns, data);
-      calls.put(logger, future);
-    }
+    loggers.forEach(l -> calls.put(l, l.sendEdits(segmentTxId, firstTxnId, 
numTxns, data)));
     return QuorumCall.create(calls);
   }
 
   public QuorumCall<AsyncLogger, GetJournaledEditsResponseProto>
   getJournaledEdits(long fromTxnId, int maxTransactions) {
-    Map<AsyncLogger,
-        ListenableFuture<GetJournaledEditsResponseProto>> calls
-        = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      ListenableFuture<GetJournaledEditsResponseProto> future =
-          logger.getJournaledEdits(fromTxnId, maxTransactions);
-      calls.put(logger, future);
-    }
+    Map<AsyncLogger, ListenableFuture<GetJournaledEditsResponseProto>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.getJournaledEdits(fromTxnId, 
maxTransactions)));
     return QuorumCall.create(calls);
   }
 
   public QuorumCall<AsyncLogger, RemoteEditLogManifest> getEditLogManifest(
       long fromTxnId, boolean inProgressOk) {
-    Map<AsyncLogger,
-        ListenableFuture<RemoteEditLogManifest>> calls
-        = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      ListenableFuture<RemoteEditLogManifest> future =
-          logger.getEditLogManifest(fromTxnId, inProgressOk);
-      calls.put(logger, future);
-    }
+    Map<AsyncLogger, ListenableFuture<RemoteEditLogManifest>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.getEditLogManifest(fromTxnId, 
inProgressOk)));
     return QuorumCall.create(calls);
   }
 
-  QuorumCall<AsyncLogger, PrepareRecoveryResponseProto>
-      prepareRecovery(long segmentTxId) {
-    Map<AsyncLogger,
-      ListenableFuture<PrepareRecoveryResponseProto>> calls
-      = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      ListenableFuture<PrepareRecoveryResponseProto> future =
-          logger.prepareRecovery(segmentTxId);
-      calls.put(logger, future);
-    }
+  QuorumCall<AsyncLogger, PrepareRecoveryResponseProto> prepareRecovery(long 
segmentTxId) {
+    Map<AsyncLogger, ListenableFuture<PrepareRecoveryResponseProto>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.prepareRecovery(segmentTxId)));
     return QuorumCall.create(calls);
   }
 
-  QuorumCall<AsyncLogger,Void>
-      acceptRecovery(SegmentStateProto log, URL fromURL) {
-    Map<AsyncLogger, ListenableFuture<Void>> calls
-      = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      ListenableFuture<Void> future =
-          logger.acceptRecovery(log, fromURL);
-      calls.put(logger, future);
-    }
+  QuorumCall<AsyncLogger,Void> acceptRecovery(SegmentStateProto log, URL 
fromURL) {

Review Comment:
   QuorumCall<AsyncLogger,Void> acceptRecovery(SegmentStateProto log, URL 
fromURL) {:25: ',' is not followed by whitespace. [WhitespaceAfter]



##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/client/AsyncLoggerSet.java:
##########
@@ -206,197 +194,114 @@ List<AsyncLogger> getLoggersForTests() {
   ///////////////////////////////////////////////////////////////////////////
   
   public QuorumCall<AsyncLogger, GetJournalStateResponseProto> 
getJournalState() {
-    Map<AsyncLogger, ListenableFuture<GetJournalStateResponseProto>> calls =
-        Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.getJournalState());
-    }
+    Map<AsyncLogger, ListenableFuture<GetJournalStateResponseProto>> calls = 
Maps.newHashMap();
+    loggers.forEach(l -> calls.put(l, l.getJournalState()));
     return QuorumCall.create(calls);    
   }
   
   public QuorumCall<AsyncLogger, Boolean> isFormatted() {
     Map<AsyncLogger, ListenableFuture<Boolean>> calls = Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.isFormatted());
-    }
+    loggers.forEach(l -> calls.put(l, l.isFormatted()));
     return QuorumCall.create(calls);
   }
 
-  public QuorumCall<AsyncLogger,NewEpochResponseProto> newEpoch(
-      NamespaceInfo nsInfo,
-      long epoch) {
-    Map<AsyncLogger, ListenableFuture<NewEpochResponseProto>> calls =
-        Maps.newHashMap();
-    for (AsyncLogger logger : loggers) {
-      calls.put(logger, logger.newEpoch(epoch));
-    }
+  public QuorumCall<AsyncLogger,NewEpochResponseProto> newEpoch(long epoch) {

Review Comment:
   public QuorumCall<AsyncLogger,NewEpochResponseProto> newEpoch(long epoch) 
{:32: ',' is not followed by whitespace. [WhitespaceAfter]





Issue Time Tracking
-------------------

    Worklog Id:     (was: 791182)
    Time Spent: 40m  (was: 0.5h)

> Improve Code With Lambda in AsyncLoggerSet class
> ------------------------------------------------
>
>                 Key: HDFS-16661
>                 URL: https://issues.apache.org/jira/browse/HDFS-16661
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Improve Code With Lambda in AsyncLoggerSet class



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

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

Reply via email to