private DFSOutputStream(DFSClient dfsClient, String src, long blockSize,
Progressable progress, int bytesPerChecksum, short replication, boolean forceSync,
boolean doParallelWrites, DatanodeInfo[] favoredNodes,
WriteOptions options)
throws IOException {
super(new NativeCrc32(), bytesPerChecksum, 4, getProfile(dfsClient));
this.dfsClient = dfsClient;
this.forceSync = forceSync;
this.doParallelWrites = doParallelWrites;
this.src = src;
this.blockSize = blockSize;
this.blockReplication = replication;
this.progress = progress;
this.options = options;
this.pktIncludeVersion = dfsClient.ifPacketIncludeVersion();
this.packetVersion = dfsClient.getOutPacketVersion();
streamer = new DataStreamer();
packetTimeout =
dfsClient.conf.getLong("dfs.client.packet.timeout", 15000); // 15 seconds
// try block recovery 5 times:
maxRecoveryErrorCount =
dfsClient.conf.getInt("dfs.client.block.recovery.retries", 5);
if (progress != null) {
DFSClient.LOG.debug("Set non-null progress callback on DFSOutputStream "+src);
}
this.favoredNodes = favoredNodes;
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");
}
checksum = DataChecksum.newDataChecksum(FSConstants.CHECKSUM_TYPE,
bytesPerChecksum,
new NativeCrc32());
}