我正在尝试从Web应用程序访问HDFS FileSystem。
代码如下所示:
Configuration conf = new Configuration();
conf.addResource(new Path("/path/core-site.xml"));
conf.addResource(new Path("/path/hdfs-site.xml"));
conf.addResource(new Path("path/mapred-site.xml"));
Path pathToServices = new Path("/file.txt");
try {
FileSystem fs = FileSystem.get(conf);
InputStreamReader reader = new InputStreamReader(fs.open(pathToServices));
...
...
我从servlet中调用此代码,但是当从tomcat部署或取消部署应用程序时,我看到这些消息:
14-Sep-2016 12:42:27.850 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [pipelineUIBackend] created a ThreadLocal with key of type [org.apache.hadoop.hdfs.DFSUtil$1] (value [org.apache.hadoop.hdfs.DFSUtil$1@12fb4cd4]) and a value of type [java.util.Random] (value [java.util.Random@3c6bbf2b]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
14-Sep-2016 12:42:27.850 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [pipelineUIBackend] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@498268e]) and a value of type [org.apache.hadoop.fs.FileSystem.Statistics.StatisticsData] (value [2439206 bytes read, 2436769 bytes written, 20 read ops, 0 large read ops, 10 write ops]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
14-Sep-2016 12:42:27.850 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [pipelineUIBackend] created a ThreadLocal with key of type [org.apache.hadoop.io.Text$1] (value [org.apache.hadoop.io.Text$1@4c4d4725]) and a value of type [sun.nio.cs.UTF_8.Encoder] (value [sun.nio.cs.UTF_8$Encoder@2dbe2b60]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
14-Sep-2016 12:42:27.850 SEVERE [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [pipelineUIBackend] created a ThreadLocal with key of type [org.apache.hadoop.io.Text$2] (value [org.apache.hadoop.io.Text$2@50a1c86a]) and a value of type [sun.nio.cs.UTF_8.Decoder] (value [sun.nio.cs.UTF_8$Decoder@154828a6]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
我相信这可能是因为从Web应用程序使用FileSystem,但我不知道如何调试它,如果它确实是一个问题。 我是否需要在某处关闭FileSystem对象?