From d79f705a30845bee24ac4a0b4fd88d5b251eb9bf Mon Sep 17 00:00:00 2001 From: Eric Badger Date: Wed, 13 Jan 2021 23:53:16 +0000 Subject: [PATCH] YARN-10562. Follow up changes for YARN-9833. Contributed by Jim Brennan. (cherry picked from commit 768e2f42ba3f82802e2ebf39d44fe6c30037583c) --- .../yarn/server/nodemanager/DirectoryCollection.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DirectoryCollection.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DirectoryCollection.java index ded1ed1fdcf..d8d2d70ba69 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DirectoryCollection.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DirectoryCollection.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -29,7 +30,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; @@ -239,9 +239,9 @@ public class DirectoryCollection { throw new YarnRuntimeException(e); } - localDirs = new CopyOnWriteArrayList<>(dirs); - errorDirs = new CopyOnWriteArrayList<>(); - fullDirs = new CopyOnWriteArrayList<>(); + localDirs = new ArrayList<>(Arrays.asList(dirs)); + errorDirs = new ArrayList<>(); + fullDirs = new ArrayList<>(); directoryErrorInfo = new ConcurrentHashMap<>(); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); @@ -287,7 +287,7 @@ public class DirectoryCollection { List getFailedDirs() { this.readLock.lock(); try { - return ImmutableList.copyOf( + return Collections.unmodifiableList( DirectoryCollection.concat(errorDirs, fullDirs)); } finally { this.readLock.unlock(); @@ -315,7 +315,7 @@ public class DirectoryCollection { List getErroredDirs() { this.readLock.lock(); try { - return Collections.unmodifiableList(errorDirs); + return ImmutableList.copyOf(errorDirs); } finally { this.readLock.unlock(); }