HDFS-6499. Use NativeIO#renameTo instead of File#renameTo in FileJournalManager. Contributed by Yongjun Zhang.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1602542 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3f5e04946d
commit
d18af7edd4
@ -443,6 +443,9 @@ Release 2.5.0 - UNRELEASED
|
|||||||
HDFS-6529. Trace logging for RemoteBlockReader2 to identify remote datanode
|
HDFS-6529. Trace logging for RemoteBlockReader2 to identify remote datanode
|
||||||
and file being read. (Anubhav Dhoot via atm)
|
and file being read. (Anubhav Dhoot via atm)
|
||||||
|
|
||||||
|
HDFS-6499. Use NativeIO#renameTo instead of File#renameTo in
|
||||||
|
FileJournalManager. (Yongjun Zhang via atm)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn)
|
HDFS-6214. Webhdfs has poor throughput for files >2GB (daryn)
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile;
|
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
import org.apache.hadoop.hdfs.server.protocol.NamespaceInfo;
|
||||||
import org.apache.hadoop.hdfs.server.protocol.RemoteEditLog;
|
import org.apache.hadoop.hdfs.server.protocol.RemoteEditLog;
|
||||||
|
import org.apache.hadoop.io.nativeio.NativeIO;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
@ -132,10 +134,14 @@ synchronized public void finalizeLogSegment(long firstTxId, long lastTxId)
|
|||||||
Preconditions.checkState(!dstFile.exists(),
|
Preconditions.checkState(!dstFile.exists(),
|
||||||
"Can't finalize edits file " + inprogressFile + " since finalized file " +
|
"Can't finalize edits file " + inprogressFile + " since finalized file " +
|
||||||
"already exists");
|
"already exists");
|
||||||
if (!inprogressFile.renameTo(dstFile)) {
|
|
||||||
|
try {
|
||||||
|
NativeIO.renameTo(inprogressFile, dstFile);
|
||||||
|
} catch (IOException e) {
|
||||||
errorReporter.reportErrorOnFile(dstFile);
|
errorReporter.reportErrorOnFile(dstFile);
|
||||||
throw new IllegalStateException("Unable to finalize edits file " + inprogressFile);
|
throw new IllegalStateException("Unable to finalize edits file " + inprogressFile, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inprogressFile.equals(currentInProgress)) {
|
if (inprogressFile.equals(currentInProgress)) {
|
||||||
currentInProgress = null;
|
currentInProgress = null;
|
||||||
}
|
}
|
||||||
@ -513,11 +519,16 @@ private void renameSelf(String newSuffix) throws IOException {
|
|||||||
File src = file;
|
File src = file;
|
||||||
File dst = new File(src.getParent(), src.getName() + newSuffix);
|
File dst = new File(src.getParent(), src.getName() + newSuffix);
|
||||||
// renameTo fails on Windows if the destination file already exists.
|
// renameTo fails on Windows if the destination file already exists.
|
||||||
if (!src.renameTo(dst)) {
|
try {
|
||||||
if (!dst.delete() || !src.renameTo(dst)) {
|
if (dst.exists()) {
|
||||||
throw new IOException(
|
if (!dst.delete()) {
|
||||||
"Couldn't rename log " + src + " to " + dst);
|
throw new IOException("Couldn't delete " + dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
NativeIO.renameTo(src, dst);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IOException(
|
||||||
|
"Couldn't rename log " + src + " to " + dst, e);
|
||||||
}
|
}
|
||||||
file = dst;
|
file = dst;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user