From dc6d2ad0e51d965e288b436881e846b2c23afe5c Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 09:44:17 +0800 Subject: [PATCH 1/6] [SPARK-20875] Spark should print the log when the directory has been deleted --- core/src/main/scala/org/apache/spark/util/Utils.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index edfe229792323..322829b512f5e 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1004,6 +1004,7 @@ private[spark] object Utils extends Logging { for (child <- listFilesSafely(file)) { try { deleteRecursively(child) + logInfo(file.getAbsolutePath + s" has been deleted") } catch { // In case of multiple exceptions, only last one will be thrown case ioe: IOException => savedIOException = ioe From 9d0f507cf93b7f486bbf64e32dfb389556e71f25 Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 15:21:48 +0800 Subject: [PATCH 2/6] change the log level --- core/src/main/scala/org/apache/spark/util/Utils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 322829b512f5e..4d5661918c287 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1004,7 +1004,7 @@ private[spark] object Utils extends Logging { for (child <- listFilesSafely(file)) { try { deleteRecursively(child) - logInfo(file.getAbsolutePath + s" has been deleted") + logTrace(file.getAbsolutePath + s" has been deleted") } catch { // In case of multiple exceptions, only last one will be thrown case ioe: IOException => savedIOException = ioe From 10db5ce4bc383ad7fb3db6c68d4d7f51ff759a02 Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 18:39:46 +0800 Subject: [PATCH 3/6] fix the string message --- core/src/main/scala/org/apache/spark/util/Utils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 4d5661918c287..4296ebddeebd4 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1004,7 +1004,7 @@ private[spark] object Utils extends Logging { for (child <- listFilesSafely(file)) { try { deleteRecursively(child) - logTrace(file.getAbsolutePath + s" has been deleted") + logTrace(file.getAbsolutePath + " has been deleted") } catch { // In case of multiple exceptions, only last one will be thrown case ioe: IOException => savedIOException = ioe From 9c96f25a998967d68e2e1266b200fb067d8351d3 Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 18:55:42 +0800 Subject: [PATCH 4/6] use string interpolation --- core/src/main/scala/org/apache/spark/util/Utils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 4296ebddeebd4..de1d852018e5b 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1004,7 +1004,7 @@ private[spark] object Utils extends Logging { for (child <- listFilesSafely(file)) { try { deleteRecursively(child) - logTrace(file.getAbsolutePath + " has been deleted") + logTrace(s"${file.getAbsolutePath} has been deleted") } catch { // In case of multiple exceptions, only last one will be thrown case ioe: IOException => savedIOException = ioe From 5d32be90066b554a4aa8a08cca0a1c67e5ff4f11 Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 19:39:42 +0800 Subject: [PATCH 5/6] change the lcoation of logTrace --- core/src/main/scala/org/apache/spark/util/Utils.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index de1d852018e5b..800ffa18ea71c 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1004,7 +1004,6 @@ private[spark] object Utils extends Logging { for (child <- listFilesSafely(file)) { try { deleteRecursively(child) - logTrace(s"${file.getAbsolutePath} has been deleted") } catch { // In case of multiple exceptions, only last one will be thrown case ioe: IOException => savedIOException = ioe @@ -1016,7 +1015,9 @@ private[spark] object Utils extends Logging { ShutdownHookManager.removeShutdownDeleteDir(file) } } finally { - if (!file.delete()) { + if (file.delete()) { + logTrace(s"${file.getAbsolutePath} has been deleted") + } else { // Delete can also fail if the file simply did not exist if (file.exists()) { throw new IOException("Failed to delete: " + file.getAbsolutePath) From 1a5853f4fa9081113241e9fb335a7e3fa3e2ce20 Mon Sep 17 00:00:00 2001 From: liuzhaokun Date: Thu, 25 May 2017 20:29:11 +0800 Subject: [PATCH 6/6] change the spaced indentation --- core/src/main/scala/org/apache/spark/util/Utils.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 800ffa18ea71c..520837bd19bb3 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1016,7 +1016,7 @@ private[spark] object Utils extends Logging { } } finally { if (file.delete()) { - logTrace(s"${file.getAbsolutePath} has been deleted") + logTrace(s"${file.getAbsolutePath} has been deleted") } else { // Delete can also fail if the file simply did not exist if (file.exists()) {