Example usage for org.apache.hadoop.fs FileSystem createNonRecursive

List of usage examples for org.apache.hadoop.fs FileSystem createNonRecursive

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FileSystem createNonRecursive.

Prototype

public FSDataOutputStream createNonRecursive(Path f, FsPermission permission, EnumSet<CreateFlag> flags,
        int bufferSize, short replication, long blockSize, Progressable progress) throws IOException 

Source Link

Document

Opens an FSDataOutputStream at the indicated Path with write-progress reporting.

Usage

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

License:Apache License

/**
 * Same as create(), except fails if parent directory doesn't already exist.
 *///w ww . j a  va  2  s. c  om
@Override
@SuppressWarnings("deprecation")
public FSDataOutputStream createNonRecursive(final Path f, final FsPermission permission,
        final EnumSet<CreateFlag> flag, final int bufferSize, final short replication, final long blockSize,
        final Progressable progress) throws IOException {
    statistics.incrementWriteOps(1);
    if (flag.contains(CreateFlag.OVERWRITE)) {
        flag.add(CreateFlag.CREATE);
    }
    Path absF = fixRelativePart(f);
    return new FileSystemLinkResolver<FSDataOutputStream>() {
        @Override
        public FSDataOutputStream doCall(final Path p) throws IOException, UnresolvedLinkException {
            final DFSOutputStream dfsos = dfs.create(getPathName(p), permission, flag, false, replication,
                    blockSize, progress, bufferSize, null);
            return dfs.createWrappedOutputStream(dfsos, statistics);
        }

        @Override
        public FSDataOutputStream next(final FileSystem fs, final Path p) throws IOException {
            return fs.createNonRecursive(p, permission, flag, bufferSize, replication, blockSize, progress);
        }
    }.resolve(this, absF);
}