HBASE-10010 eliminate the put latency spike on the new log file beginning

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1549384 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-12-09 05:01:54 +00:00
parent 3f58873f08
commit 0e8a141437
2 changed files with 7 additions and 12 deletions

View File

@ -532,6 +532,13 @@ class FSHLog implements HLog, Syncable {
FSDataOutputStream nextHdfsOut = null;
if (nextWriter instanceof ProtobufLogWriter) {
nextHdfsOut = ((ProtobufLogWriter)nextWriter).getStream();
// perform the costly sync before we get the lock to roll writers.
try {
nextWriter.sync();
} catch (IOException e) {
// optimization failed, no need to abort here.
LOG.warn("pre-sync failed", e);
}
}
Path oldFile = null;

View File

@ -141,12 +141,6 @@ public class TestReplicationHLogReaderManager {
// Grab the path that was generated when the log rolled as part of its creation
Path path = pathWatcher.currentPath;
// open it, it's empty so it fails
try {
logManager.openReader(path);
fail("Shouldn't be able to open an empty file");
} catch (EOFException ex) {}
assertEquals(0, logManager.getPosition());
appendToLog();
@ -184,12 +178,6 @@ public class TestReplicationHLogReaderManager {
path = pathWatcher.currentPath;
// Finally we have a new empty log, which should still give us EOFs
try {
logManager.openReader(path);
fail();
} catch (EOFException ex) {}
for (int i = 0; i < nbRows; i++) { appendToLogPlus(walEditKVs); }
log.rollWriter();
logManager.openReader(path);