Search in sources :

Example 6 with BlockSize

use of org.apache.hadoop.fs.Options.CreateOpts.BlockSize in project hadoop by apache.

the class FileSystemTestWrapper method createFile.

/*
   * Create files with numBlocks blocks each with block size blockSize.
   */
public long createFile(Path path, int numBlocks, CreateOpts... options) throws IOException {
    BlockSize blockSizeOpt = CreateOpts.getOpt(CreateOpts.BlockSize.class, options);
    long blockSize = blockSizeOpt != null ? blockSizeOpt.getValue() : DEFAULT_BLOCK_SIZE;
    FSDataOutputStream out = create(path, EnumSet.of(CreateFlag.CREATE), options);
    byte[] data = getFileData(numBlocks, blockSize);
    out.write(data, 0, data.length);
    out.close();
    return data.length;
}
Also used : CreateOpts(org.apache.hadoop.fs.Options.CreateOpts) BlockSize(org.apache.hadoop.fs.Options.CreateOpts.BlockSize)

Example 7 with BlockSize

use of org.apache.hadoop.fs.Options.CreateOpts.BlockSize in project hadoop by apache.

the class FileSystemTestWrapper method appendToFile.

public void appendToFile(Path path, int numBlocks, CreateOpts... options) throws IOException {
    BlockSize blockSizeOpt = CreateOpts.getOpt(CreateOpts.BlockSize.class, options);
    long blockSize = blockSizeOpt != null ? blockSizeOpt.getValue() : DEFAULT_BLOCK_SIZE;
    FSDataOutputStream out;
    out = fs.append(path);
    byte[] data = getFileData(numBlocks, blockSize);
    out.write(data, 0, data.length);
    out.close();
}
Also used : CreateOpts(org.apache.hadoop.fs.Options.CreateOpts) BlockSize(org.apache.hadoop.fs.Options.CreateOpts.BlockSize)

Aggregations

CreateOpts (org.apache.hadoop.fs.Options.CreateOpts)7 BlockSize (org.apache.hadoop.fs.Options.CreateOpts.BlockSize)7 FsPermission (org.apache.hadoop.fs.permission.FsPermission)1 Progressable (org.apache.hadoop.util.Progressable)1