Example usage for org.apache.hadoop.hdfs DFSClient getDefaultWriteCachingStrategy

List of usage examples for org.apache.hadoop.hdfs DFSClient getDefaultWriteCachingStrategy

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSClient getDefaultWriteCachingStrategy.

Prototype

public CachingStrategy getDefaultWriteCachingStrategy() 

Source Link

Usage

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

License:Apache License

protected DFSOutputStream(DFSClient dfsClient, String src, Progressable progress, HdfsFileStatus stat,
        DataChecksum checksum) throws IOException {
    super(getChecksum4Compute(checksum, stat));
    this.dfsClient = dfsClient;
    this.src = src;
    this.fileId = stat.getFileId();
    this.blockSize = stat.getBlockSize();
    this.blockReplication = stat.getReplication();
    this.fileEncryptionInfo = stat.getFileEncryptionInfo();
    this.progress = progress;
    this.cachingStrategy = new AtomicReference<CachingStrategy>(dfsClient.getDefaultWriteCachingStrategy());
    this.jxioResource = dfsClient.getJXIOResource();
    this.usingJxioClientResource = true;
    this.eventQHandler = jxioResource.getEqh();
    this.msgPool = jxioResource.getMsgPool();
    this.headerAckTimeoutUsec = dfsClient.getConf().getHeaderAckTimeoutUsec();

    if ((progress != null) && DFSOutputStream.LOG.isDebugEnabled()) {
        DFSOutputStream.LOG.debug("Set non-null progress callback on DFSOutputStream " + src);
    }/*  www. ja v  a2  s  .  com*/

    this.bytesPerChecksum = checksum.getBytesPerChecksum();
    if (bytesPerChecksum < 1 || blockSize % bytesPerChecksum != 0) {
        throw new IOException("io.bytes.per.checksum(" + bytesPerChecksum + ") and blockSize(" + blockSize
                + ") do not match. " + "blockSize should be a " + "multiple of io.bytes.per.checksum");

    }
    this.name = String.format("[hash=%X] ", DFSOutputStream.this.hashCode());
    this.checksum = checksum;

    if (toPrintBreakdown) {
        long now = System.nanoTime();
        DFSOutputStream.LOG.info(String.format("%.3f", (float) now / 1000000000.) + ", "
                + (now - lastOperationTS) / 1000000000. + " : DFSOutputStream constructed successfully.");
        synchronized (lastOperationTSLock) {
            lastOperationTS = now;
        }
        // } else {
        // LOG.info("Mellanox RDMA-accelerated DFSOutputStream constructed successfully.");
    }
}