From 10a1b8ea01bc4eff7fc6fb7543012bb085680b15 Mon Sep 17 00:00:00 2001 From: Nicole00 Date: Fri, 17 Sep 2021 15:12:01 +0800 Subject: [PATCH] remove the close for hdfs system --- .../nebula/exchange/utils/HDFSUtils.scala | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/nebula-exchange/src/main/scala/com/vesoft/nebula/exchange/utils/HDFSUtils.scala b/nebula-exchange/src/main/scala/com/vesoft/nebula/exchange/utils/HDFSUtils.scala index e3a7b2a7..ba37676d 100644 --- a/nebula-exchange/src/main/scala/com/vesoft/nebula/exchange/utils/HDFSUtils.scala +++ b/nebula-exchange/src/main/scala/com/vesoft/nebula/exchange/utils/HDFSUtils.scala @@ -22,36 +22,23 @@ object HDFSUtils { conf.set("fs.default.name", namenode) conf.set("fs.defaultFS", namenode) } - conf.set("fs.hdfs.impl.disable.cache", "true") FileSystem.get(conf) } def list(path: String): List[String] = { val system = getFileSystem() - try { - system.listStatus(new Path(path)).map(_.getPath.getName).toList - } finally { - system.close() - } + system.listStatus(new Path(path)).map(_.getPath.getName).toList } def exists(path: String): Boolean = { val system = getFileSystem() - try { - system.exists(new Path(path)) - } finally { - system.close() - } + system.exists(new Path(path)) } def getContent(path: String): String = { val system = getFileSystem() val inputStream = system.open(new Path(path)) - try { - Source.fromInputStream(inputStream).mkString - } finally { - system.close() - } + Source.fromInputStream(inputStream).mkString } def saveContent(path: String, @@ -79,10 +66,6 @@ object HDFSUtils { e) } val system = getFileSystem(namenode) - try { - system.copyFromLocalFile(new Path(localPath), new Path(remotePath)) - } finally { - system.close() - } + system.copyFromLocalFile(new Path(localPath), new Path(remotePath)) } }