@@ -26,6 +26,8 @@ import org.apache.spark.executor.ExecutorExitCode
2626import org .apache .spark .network .netty .{PathResolver , ShuffleSender }
2727import org .apache .spark .util .Utils
2828
29+ import scala .collection .mutable .ArrayBuffer
30+
2931/**
3032 * Creates and maintains the logical mapping between logical blocks and physical on-disk
3133 * locations. By default, one block is mapped to one file with a name given by its BlockId.
@@ -44,6 +46,10 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
4446 * directory, create multiple subdirectories that we will hash files into, in order to avoid
4547 * having really large inodes at the top level. */
4648 private val localDirs : Array [File ] = createLocalDirs()
49+ if (localDirs.isEmpty) {
50+ logError(" Failed to create any local dir" )
51+ System .exit(ExecutorExitCode .DISK_STORE_FAILED_TO_CREATE_DIR )
52+ }
4753 private val subDirs = Array .fill(localDirs.length)(new Array [File ](subDirsPerLocalDir))
4854 private var shuffleSender : ShuffleSender = null
4955
@@ -115,8 +121,9 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
115121
116122 private def createLocalDirs (): Array [File ] = {
117123 logDebug(s " Creating local directories at root dirs ' $rootDirs' " )
124+ val localDirsResult = ArrayBuffer [File ]()
118125 val dateFormat = new SimpleDateFormat (" yyyyMMddHHmmss" )
119- rootDirs.split(" ," ).map { rootDir =>
126+ rootDirs.split(" ," ).foreach { rootDir =>
120127 var foundLocalDir = false
121128 var localDir : File = null
122129 var localDirId : String = null
@@ -137,11 +144,12 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
137144 }
138145 if (! foundLocalDir) {
139146 logError(s " Failed $MAX_DIR_CREATION_ATTEMPTS attempts to create local dir in $rootDir" )
140- System .exit(ExecutorExitCode .DISK_STORE_FAILED_TO_CREATE_DIR )
147+ } else {
148+ logInfo(s " Created local directory at $localDir" )
149+ localDirsResult += localDir
141150 }
142- logInfo(s " Created local directory at $localDir" )
143- localDir
144151 }
152+ localDirsResult.toArray
145153 }
146154
147155 private def addShutdownHook () {
0 commit comments