goiri commented on code in PR #4565:
URL: https://github.com/apache/hadoop/pull/4565#discussion_r921689045
##########
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();
Review Comment:
As we are at it, can we get rid of the guava use?
We should also set it with the capacity being `loggers.size()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]