|
@@ -24,8 +24,10 @@ import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.PriorityQueue;
|
|
|
import java.util.SortedSet;
|
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
@@ -38,13 +40,9 @@ import org.apache.hadoop.hdfs.server.common.StorageInfo;
|
|
|
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
|
|
import org.apache.hadoop.hdfs.server.protocol.RemoteEditLog;
|
|
|
import org.apache.hadoop.hdfs.server.protocol.RemoteEditLogManifest;
|
|
|
-
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
import com.google.common.base.Preconditions;
|
|
|
-import com.google.common.collect.ImmutableList;
|
|
|
-import com.google.common.collect.ImmutableListMultimap;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.google.common.collect.Multimaps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
/**
|
|
@@ -634,7 +632,7 @@ public class JournalSet implements JournalManager {
|
|
|
*/
|
|
|
public synchronized RemoteEditLogManifest getEditLogManifest(long fromTxId) {
|
|
|
// Collect RemoteEditLogs available from each FileJournalManager
|
|
|
- List<RemoteEditLog> allLogs = Lists.newArrayList();
|
|
|
+ List<RemoteEditLog> allLogs = new ArrayList<>();
|
|
|
for (JournalAndStream j : journals) {
|
|
|
if (j.getManager() instanceof FileJournalManager) {
|
|
|
FileJournalManager fjm = (FileJournalManager)j.getManager();
|
|
@@ -645,15 +643,17 @@ public class JournalSet implements JournalManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
// Group logs by their starting txid
|
|
|
- ImmutableListMultimap<Long, RemoteEditLog> logsByStartTxId =
|
|
|
- Multimaps.index(allLogs, RemoteEditLog.GET_START_TXID);
|
|
|
+ final Map<Long, List<RemoteEditLog>> logsByStartTxId = new HashMap<>();
|
|
|
+ allLogs.forEach(input -> {
|
|
|
+ long key = RemoteEditLog.GET_START_TXID.apply(input);
|
|
|
+ logsByStartTxId.computeIfAbsent(key, k-> new ArrayList<>()).add(input);
|
|
|
+ });
|
|
|
long curStartTxId = fromTxId;
|
|
|
-
|
|
|
- List<RemoteEditLog> logs = Lists.newArrayList();
|
|
|
+ List<RemoteEditLog> logs = new ArrayList<>();
|
|
|
while (true) {
|
|
|
- ImmutableList<RemoteEditLog> logGroup = logsByStartTxId.get(curStartTxId);
|
|
|
+ List<RemoteEditLog> logGroup =
|
|
|
+ logsByStartTxId.getOrDefault(curStartTxId, Collections.emptyList());
|
|
|
if (logGroup.isEmpty()) {
|
|
|
// we have a gap in logs - for example because we recovered some old
|
|
|
// storage directory with ancient logs. Clear out any logs we've
|