Example usage for org.apache.hadoop.hdfs.web.resources BufferSizeParam BufferSizeParam

List of usage examples for org.apache.hadoop.hdfs.web.resources BufferSizeParam BufferSizeParam

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.web.resources BufferSizeParam BufferSizeParam.

Prototype

public BufferSizeParam(final String str) 

Source Link

Document

Constructor.

Usage

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public FSDataOutputStream create(final Path f, final FsPermission permission, final boolean overwrite,
        final int bufferSize, final short replication, final long blockSize, final Progressable progress)
        throws IOException {
    statistics.incrementWriteOps(1);/* w  w  w  . j a va2s.  c o m*/

    final HttpOpParam.Op op = PutOpParam.Op.CREATE;
    if (this.shouldUseEncryption) {
        return new EncryptedFsPathOutputStreamRunner(op, f, bufferSize,
                new PermissionParam(applyUMask(permission)), new OverwriteParam(overwrite),
                new BufferSizeParam(bufferSize), new ReplicationParam(replication),
                new BlockSizeParam(blockSize)).run();
    } else {
        return new FsPathOutputStreamRunner(op, f, bufferSize, new PermissionParam(applyUMask(permission)),
                new OverwriteParam(overwrite), new BufferSizeParam(bufferSize),
                new ReplicationParam(replication), new BlockSizeParam(blockSize)).run();
    }
}

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public FSDataOutputStream append(final Path f, final int bufferSize, final Progressable progress)
        throws IOException {
    statistics.incrementWriteOps(1);/*  w  w  w.j a  v a2s .c o  m*/

    final HttpOpParam.Op op = PostOpParam.Op.APPEND;
    if (this.shouldUseEncryption) {
        return new EncryptedFsPathOutputStreamRunner(op, f, bufferSize, new BufferSizeParam(bufferSize)).run();
    } else {
        return new FsPathOutputStreamRunner(op, f, bufferSize, new BufferSizeParam(bufferSize)).run();
    }
}

From source file:com.bigstep.datalake.DLFileSystem.java

License:Apache License

@Override
public FSDataInputStream open(final Path f, final int buffersize) throws IOException {
    statistics.incrementReadOps(1);//from w w  w . ja  va2  s  .c  o m
    final HttpOpParam.Op op = GetOpParam.Op.OPEN;

    if (this.shouldUseEncryption) {
        DLEncryptionUtils dlenc = DLEncryptionUtils.getInstance();

        int nHeaderSize = dlenc.getHeaderDetailLength();
        byte[] b = new byte[nHeaderSize];
        byte[] key = dlenc.getSecretKey();
        int nBlockSize = key.length;
        byte[] initVector = new byte[nBlockSize];

        // use a runner so the open can recover from an invalid token
        FsPathConnectionRunner runnerHeader = new FsPathConnectionRunner(op, f, new BufferSizeParam(buffersize),
                new LengthParam((long) nHeaderSize + nBlockSize));
        OffsetUrlInputStream inputStreamHeader = new OffsetUrlInputStream(new UnresolvedUrlOpener(runnerHeader),
                new OffsetUrlOpener(null));

        inputStreamHeader.readFully(0, b, 0, nHeaderSize);
        inputStreamHeader.readFully(nHeaderSize, initVector, 0, nBlockSize);

        FsPathConnectionRunner runnerData = new FsPathConnectionRunner(op, f, new BufferSizeParam(buffersize),
                new OffsetParam((long) nHeaderSize + nBlockSize));
        OffsetUrlInputStream inputStreamData = new OffsetUrlInputStream(new UnresolvedUrlOpener(runnerData),
                new OffsetUrlOpener(null));

        Properties props = new Properties();
        props.put("commons.crypto.stream.buffer.size", buffersize);
        return new FSDataInputStream(new DLPositionedCryptoInputStream(props,
                new DLStreamInput(inputStreamData, buffersize), key, initVector, 0L));
    } else {
        FsPathConnectionRunner runner = new FsPathConnectionRunner(op, f, new BufferSizeParam(buffersize));
        return new FSDataInputStream(
                new OffsetUrlInputStream(new UnresolvedUrlOpener(runner), new OffsetUrlOpener(null)));
    }
}