|
@@ -1661,11 +1661,14 @@ public class DFSOutputStream extends FSOutputSummer
|
|
|
}
|
|
|
|
|
|
/** Construct a new output stream for append. */
|
|
|
- private DFSOutputStream(DFSClient dfsClient, String src, boolean toNewBlock,
|
|
|
- Progressable progress, LocatedBlock lastBlock, HdfsFileStatus stat,
|
|
|
- DataChecksum checksum) throws IOException {
|
|
|
+ private DFSOutputStream(DFSClient dfsClient, String src,
|
|
|
+ EnumSet<CreateFlag> flags, Progressable progress, LocatedBlock lastBlock,
|
|
|
+ HdfsFileStatus stat, DataChecksum checksum) throws IOException {
|
|
|
this(dfsClient, src, progress, stat, checksum);
|
|
|
initialFileSize = stat.getLen(); // length of file when opened
|
|
|
+ this.shouldSyncBlock = flags.contains(CreateFlag.SYNC_BLOCK);
|
|
|
+
|
|
|
+ boolean toNewBlock = flags.contains(CreateFlag.NEW_BLOCK);
|
|
|
|
|
|
// The last partial block of the file has to be filled.
|
|
|
if (!toNewBlock && lastBlock != null) {
|
|
@@ -1682,13 +1685,13 @@ public class DFSOutputStream extends FSOutputSummer
|
|
|
}
|
|
|
|
|
|
static DFSOutputStream newStreamForAppend(DFSClient dfsClient, String src,
|
|
|
- boolean toNewBlock, int bufferSize, Progressable progress,
|
|
|
+ EnumSet<CreateFlag> flags, int bufferSize, Progressable progress,
|
|
|
LocatedBlock lastBlock, HdfsFileStatus stat, DataChecksum checksum,
|
|
|
String[] favoredNodes) throws IOException {
|
|
|
TraceScope scope =
|
|
|
dfsClient.getPathTraceScope("newStreamForAppend", src);
|
|
|
try {
|
|
|
- final DFSOutputStream out = new DFSOutputStream(dfsClient, src, toNewBlock,
|
|
|
+ final DFSOutputStream out = new DFSOutputStream(dfsClient, src, flags,
|
|
|
progress, lastBlock, stat, checksum);
|
|
|
if (favoredNodes != null && favoredNodes.length != 0) {
|
|
|
out.streamer.setFavoredNodes(favoredNodes);
|