Example usage for org.apache.hadoop.hdfs DFSOutputStream close

List of usage examples for org.apache.hadoop.hdfs DFSOutputStream close

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSOutputStream close.

Prototype

@Override
public void close() throws IOException 

Source Link

Document

Closes this output stream and releases any system resources associated with this stream.

Usage

From source file:com.mellanox.r4h.DFSClient.java

License:Apache License

/** Close/abort all files being written. */
private void closeAllFilesBeingWritten(final boolean abort) {
    for (;;) {//from  w ww.j  a  v  a 2s . c  o m
        final long inodeId;
        final DFSOutputStream out;
        synchronized (filesBeingWritten) {
            if (filesBeingWritten.isEmpty()) {
                return;
            }
            inodeId = filesBeingWritten.keySet().iterator().next();
            out = filesBeingWritten.remove(inodeId);
        }
        if (out != null) {
            try {
                if (abort) {
                    out.abort();
                } else {
                    out.close();
                }
            } catch (IOException ie) {
                LOG.error("Failed to " + (abort ? "abort" : "close") + " inode " + inodeId, ie);
            }
        }
    }
}