AnsweredAssumed Answered

Flush failed for file: using hdfs API for MapR

Question asked by matroyd on Jun 19, 2012
Following code is generating the error:

    ByteArrayOutputStream bos = null;
      ObjectOutput out = null;
      FSDataOutputStream ostr = null;
      FileSystem fs = null;
      try {
       fs = FileSystem.get(new Configuration());
       bos = new ByteArrayOutputStream();
       out = new ObjectOutputStream(bos);
       out.writeObject(data);
       byte[] rwBytes = bos.toByteArray();
       Path wfilepath = new Path(filePath);
       ostr = fs.create(wfilepath, true, 128 * 1024 * 1024, (short) 1,
         (long) (128 * 1024 * 1024));
       ostr.write(rwBytes);
       ostr.flush();
      } catch (Throwable t) {
       if (out != null) {
        try {
         out.close();
        } catch (IOException e) {
         e.printStackTrace();
        }
       }
       if (bos != null) {
        try {
         bos.close();
        } catch (IOException e) {
         e.printStackTrace();
        }
       }
       if (ostr != null) {
        try {
         ostr.close();
        } catch (IOException e) {
         e.printStackTrace();
        }
       }
       if (fs != null) {
        try {
         fs.close();
        } catch (IOException e) {
         e.printStackTrace();
        }
       }
      }

Errors are :

**2012-06-19 21:18:01,071 [ERROR:Thread-18] (Inode.java:284) - Flush failed for file: Foo.bar, error: Stale file handle**

**2012-06-19 20:35:50,5513 ERROR Client fs/client/fileclient/cc/writebuf.cc:234 Thread: 1193417024 FlushWrite failed: File Foo.bar, error: Stale File handle(116), pfid 2306.20410.3084234, off 327680 155400.32.16528**


Outcomes