HDFS-8709. Clarify automatic sync in FSEditLog#logEdit.
(cherry picked from commit 5fddc5177d
)
This commit is contained in:
parent
55bf014a07
commit
efe9ae9fc6
|
@ -360,6 +360,8 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-8703. Merge refactor of DFSInputStream from ErasureCoding branch
|
HDFS-8703. Merge refactor of DFSInputStream from ErasureCoding branch
|
||||||
(vinayakumarb)
|
(vinayakumarb)
|
||||||
|
|
||||||
|
HDFS-8709. Clarify automatic sync in FSEditLog#logEdit. (wang)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
|
||||||
|
|
|
@ -410,10 +410,14 @@ public class FSEditLog implements LogsPurgeable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write an operation to the edit log. Do not sync to persistent
|
* Write an operation to the edit log.
|
||||||
* store yet.
|
* <p/>
|
||||||
|
* Additionally, this will sync the edit log if required by the underlying
|
||||||
|
* edit stream's automatic sync policy (e.g. when the buffer is full, or
|
||||||
|
* if a time interval has elapsed).
|
||||||
*/
|
*/
|
||||||
void logEdit(final FSEditLogOp op) {
|
void logEdit(final FSEditLogOp op) {
|
||||||
|
boolean needsSync = false;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
assert isOpenForWrite() :
|
assert isOpenForWrite() :
|
||||||
"bad state: " + state;
|
"bad state: " + state;
|
||||||
|
@ -435,14 +439,16 @@ public class FSEditLog implements LogsPurgeable {
|
||||||
endTransaction(start);
|
endTransaction(start);
|
||||||
|
|
||||||
// check if it is time to schedule an automatic sync
|
// check if it is time to schedule an automatic sync
|
||||||
if (!shouldForceSync()) {
|
needsSync = shouldForceSync();
|
||||||
return;
|
if (needsSync) {
|
||||||
|
isAutoSyncScheduled = true;
|
||||||
}
|
}
|
||||||
isAutoSyncScheduled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sync buffered edit log entries to persistent store
|
// Sync the log if an automatic sync is required.
|
||||||
logSync();
|
if (needsSync) {
|
||||||
|
logSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1192,11 +1198,13 @@ public class FSEditLog implements LogsPurgeable {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return journalSet.getEditLogManifest(fromTxId);
|
return journalSet.getEditLogManifest(fromTxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalizes the current edit log and opens a new log segment.
|
* Finalizes the current edit log and opens a new log segment.
|
||||||
* @return the transaction id of the BEGIN_LOG_SEGMENT transaction
|
*
|
||||||
* in the new log.
|
* @param layoutVersion The layout version of the new edit log segment.
|
||||||
|
* @return the transaction id of the BEGIN_LOG_SEGMENT transaction in the new
|
||||||
|
* log.
|
||||||
*/
|
*/
|
||||||
synchronized long rollEditLog(int layoutVersion) throws IOException {
|
synchronized long rollEditLog(int layoutVersion) throws IOException {
|
||||||
LOG.info("Rolling edit logs");
|
LOG.info("Rolling edit logs");
|
||||||
|
|
Loading…
Reference in New Issue