1. <i id='vpMHv'><tr id='vpMHv'><dt id='vpMHv'><q id='vpMHv'><span id='vpMHv'><b id='vpMHv'><form id='vpMHv'><ins id='vpMHv'></ins><ul id='vpMHv'></ul><sub id='vpMHv'></sub></form><legend id='vpMHv'></legend><bdo id='vpMHv'><pre id='vpMHv'><center id='vpMHv'></center></pre></bdo></b><th id='vpMHv'></th></span></q></dt></tr></i><div id='vpMHv'><tfoot id='vpMHv'></tfoot><dl id='vpMHv'><fieldset id='vpMHv'></fieldset></dl></div>
    2. <tfoot id='vpMHv'></tfoot>
        <bdo id='vpMHv'></bdo><ul id='vpMHv'></ul>

      <small id='vpMHv'></small><noframes id='vpMHv'>

    3. <legend id='vpMHv'><style id='vpMHv'><dir id='vpMHv'><q id='vpMHv'></q></dir></style></legend>

        执行 BufferedReader.close() 时 Hadoop FileSystem 关闭异常

        时间:2023-09-26

          <i id='8gGv3'><tr id='8gGv3'><dt id='8gGv3'><q id='8gGv3'><span id='8gGv3'><b id='8gGv3'><form id='8gGv3'><ins id='8gGv3'></ins><ul id='8gGv3'></ul><sub id='8gGv3'></sub></form><legend id='8gGv3'></legend><bdo id='8gGv3'><pre id='8gGv3'><center id='8gGv3'></center></pre></bdo></b><th id='8gGv3'></th></span></q></dt></tr></i><div id='8gGv3'><tfoot id='8gGv3'></tfoot><dl id='8gGv3'><fieldset id='8gGv3'></fieldset></dl></div>
        1. <legend id='8gGv3'><style id='8gGv3'><dir id='8gGv3'><q id='8gGv3'></q></dir></style></legend>

                <tbody id='8gGv3'></tbody>
                <bdo id='8gGv3'></bdo><ul id='8gGv3'></ul>
                <tfoot id='8gGv3'></tfoot>
                • <small id='8gGv3'></small><noframes id='8gGv3'>

                  本文介绍了执行 BufferedReader.close() 时 Hadoop FileSystem 关闭异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 Reduce 设置方法中,我试图关闭 BufferedReader 对象并获得 FileSystem 关闭异常.它不会一直发生.这是我用来创建 BufferedReader 的一段代码.

                  From within the Reduce setup method,I am trying to close a BufferedReader object and getting a FileSystem closed exception. It does not happen all the time. This is the piece of code I used to create the BufferedReader.

                      String fileName = <some HDFS file path>
                      Configuration conf = new Configuration();
                      FileSystem fs = FileSystem.get(conf);
                      Path hdfsPath = new Path(filename);
                      FSDataInputStream in = fs.open(hdfsPath);
                      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
                      BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                  

                  我从 bufferedReader 读取内容,一旦所有读取完成,我就关闭它.

                  I read contents from the bufferedReader and once all the reading is done, I close it.

                  这是读取它的一段代码

                  String line;
                  while ((line = reader.readLine()) != null) {
                      // Do something
                  }
                  

                  这段代码关闭了阅读器.

                  This the piece of code that closes the reader.

                      if (bufferedReader != null) {
                          bufferedReader.close();
                      }
                  

                  这是我执行 bufferedReader.close() 时发生的异常的堆栈跟踪.

                  This is the stack trace for the exception that happens when I do a bufferedReader.close().

                  我,[2013-11-18T04:56:51.601135 #25683] 信息——:尝试_201310111840_142285_r_000009_0:在org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:565)

                  I, [2013-11-18T04:56:51.601135 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at org.apache.hadoop.hdfs.DFSClient.checkOpen(DFSClient.java:565)

                  我,[2013-11-18T04:56:51.601168 #25683] 信息 -- :尝试_201310111840_142285_r_000009_0:在org.apache.hadoop.hdfs.DFSInputStream.close(DFSInputStream.java:522)

                  I, [2013-11-18T04:56:51.601168 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at org.apache.hadoop.hdfs.DFSInputStream.close(DFSInputStream.java:522)

                  我,[2013-11-18T04:56:51.601199 #25683] 信息——:尝试_201310111840_142285_r_000009_0:在java.io.FilterInputStream.close(FilterInputStream.java:155)

                  I, [2013-11-18T04:56:51.601199 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at java.io.FilterInputStream.close(FilterInputStream.java:155)

                  我,[2013-11-18T04:56:51.601230 #25683] 信息——:尝试_201310111840_142285_r_000009_0:在sun.nio.cs.StreamDecoder.implClose(StreamDecoder.java:358)

                  I, [2013-11-18T04:56:51.601230 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at sun.nio.cs.StreamDecoder.implClose(StreamDecoder.java:358)

                  我,[2013-11-18T04:56:51.601263 #25683] 信息 -- :尝试_201310111840_142285_r_000009_0:在sun.nio.cs.StreamDecoder.close(StreamDecoder.java:173)

                  I, [2013-11-18T04:56:51.601263 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at sun.nio.cs.StreamDecoder.close(StreamDecoder.java:173)

                  我,[2013-11-18T04:56:51.601356 #25683] 信息 -- :尝试_201310111840_142285_r_000009_0:在java.io.InputStreamReader.close(InputStreamReader.java:182)

                  I, [2013-11-18T04:56:51.601356 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at java.io.InputStreamReader.close(InputStreamReader.java:182)

                  我,[2013-11-18T04:56:51.601395 #25683] 信息 -- :尝试_201310111840_142285_r_000009_0:在java.io.BufferedReader.close(BufferedReader.java:497)

                  I, [2013-11-18T04:56:51.601395 #25683] INFO -- : attempt_201310111840_142285_r_000009_0: at java.io.BufferedReader.close(BufferedReader.java:497)

                  我不确定为什么会发生此异常.这不是多线程的,所以我不希望有任何形式的竞争条件.你能帮我理解吗?

                  I am not sure why this exception is happening. This is not multithreaded and so, I do not expect there to be a race condition of any sort. Can you please help me understand.

                  谢谢,

                  文克

                  推荐答案

                  hadoop 文件系统 API 有一个鲜为人知的陷阱:FileSystem.get 每次调用都返回相同的对象文件系统.因此,如果一个在任何地方都关闭了,那么它们都是关闭的.你可以辩论这个决定的优点,但事实就是这样.

                  There is a little-known gotcha with the hadoop filesystem API: FileSystem.get returns the same object for every invocation with the same filesystem. So if one is closed anywhere, they are all closed. You could debate the merits of this decision, but that's the way it is.

                  因此,如果您尝试关闭 BufferedReader,并且它尝试清除已缓冲的一些数据,但底层流连接到已关闭的 FileSystem,您将收到此错误.检查您的代码是否有任何其他要关闭 FileSystem 对象的位置,并查找竞争条件.另外,我相信 Hadoop 本身会在某个时候关闭文件系统,所以为了安全起见,您可能应该只从 Reducer 的设置、减少或清理方法(或配置、减少和关闭,具体取决于哪个 API)中访问它你正在使用).

                  So, if you attempt to close your BufferedReader, and it tries to flush out some data it has buffered, but the underlying stream is connected to a FileSystem that is already closed, you'll get this error. Check your code for any other places you are closing a FileSystem object, and look for race conditions. Also, I believe Hadoop itself will at some point close the FileSystem, so to be safe, you should probably only be accessing it from within the Reducer's setup, reduce, or cleanup methods (or configure, reduce, and close, depending on which API you're using).

                  这篇关于执行 BufferedReader.close() 时 Hadoop FileSystem 关闭异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:/bin/bash:/bin/java: 在 MacOS 的 Yarn 应用程序中没有这 下一篇:映射中的值类型不匹配:预期 org.apache.hadoop.io.Nu

                  相关文章

                  最新文章

                    <i id='93rG1'><tr id='93rG1'><dt id='93rG1'><q id='93rG1'><span id='93rG1'><b id='93rG1'><form id='93rG1'><ins id='93rG1'></ins><ul id='93rG1'></ul><sub id='93rG1'></sub></form><legend id='93rG1'></legend><bdo id='93rG1'><pre id='93rG1'><center id='93rG1'></center></pre></bdo></b><th id='93rG1'></th></span></q></dt></tr></i><div id='93rG1'><tfoot id='93rG1'></tfoot><dl id='93rG1'><fieldset id='93rG1'></fieldset></dl></div>

                  1. <tfoot id='93rG1'></tfoot>
                  2. <legend id='93rG1'><style id='93rG1'><dir id='93rG1'><q id='93rG1'></q></dir></style></legend>

                    <small id='93rG1'></small><noframes id='93rG1'>

                      <bdo id='93rG1'></bdo><ul id='93rG1'></ul>