HDFS-5099. Merging change r1514481 from trunk to branch-2.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1514484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b433db32fd
commit
ba0456da0e
|
@ -113,6 +113,9 @@ Release 2.1.1-beta - UNRELEASED
|
||||||
HDFS-5080. BootstrapStandby not working with QJM when the existing NN is
|
HDFS-5080. BootstrapStandby not working with QJM when the existing NN is
|
||||||
active. (jing9)
|
active. (jing9)
|
||||||
|
|
||||||
|
HDFS-5099. Namenode#copyEditLogSegmentsToSharedDir should close
|
||||||
|
EditLogInputStreams upon finishing. (Chuan Liu via cnauroth)
|
||||||
|
|
||||||
Release 2.1.0-beta - 2013-08-22
|
Release 2.1.0-beta - 2013-08-22
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -958,41 +958,49 @@ public class NameNode implements NameNodeStatusMXBean {
|
||||||
FSEditLog sourceEditLog = fsns.getFSImage().editLog;
|
FSEditLog sourceEditLog = fsns.getFSImage().editLog;
|
||||||
|
|
||||||
long fromTxId = fsns.getFSImage().getMostRecentCheckpointTxId();
|
long fromTxId = fsns.getFSImage().getMostRecentCheckpointTxId();
|
||||||
Collection<EditLogInputStream> streams = sourceEditLog.selectInputStreams(
|
|
||||||
fromTxId+1, 0);
|
|
||||||
|
|
||||||
// Set the nextTxid to the CheckpointTxId+1
|
Collection<EditLogInputStream> streams = null;
|
||||||
newSharedEditLog.setNextTxId(fromTxId + 1);
|
try {
|
||||||
|
streams = sourceEditLog.selectInputStreams(fromTxId + 1, 0);
|
||||||
|
|
||||||
// Copy all edits after last CheckpointTxId to shared edits dir
|
// Set the nextTxid to the CheckpointTxId+1
|
||||||
for (EditLogInputStream stream : streams) {
|
newSharedEditLog.setNextTxId(fromTxId + 1);
|
||||||
LOG.debug("Beginning to copy stream " + stream + " to shared edits");
|
|
||||||
FSEditLogOp op;
|
// Copy all edits after last CheckpointTxId to shared edits dir
|
||||||
boolean segmentOpen = false;
|
for (EditLogInputStream stream : streams) {
|
||||||
while ((op = stream.readOp()) != null) {
|
LOG.debug("Beginning to copy stream " + stream + " to shared edits");
|
||||||
if (LOG.isTraceEnabled()) {
|
FSEditLogOp op;
|
||||||
LOG.trace("copying op: " + op);
|
boolean segmentOpen = false;
|
||||||
}
|
while ((op = stream.readOp()) != null) {
|
||||||
if (!segmentOpen) {
|
if (LOG.isTraceEnabled()) {
|
||||||
newSharedEditLog.startLogSegment(op.txid, false);
|
LOG.trace("copying op: " + op);
|
||||||
segmentOpen = true;
|
}
|
||||||
|
if (!segmentOpen) {
|
||||||
|
newSharedEditLog.startLogSegment(op.txid, false);
|
||||||
|
segmentOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
newSharedEditLog.logEdit(op);
|
||||||
|
|
||||||
|
if (op.opCode == FSEditLogOpCodes.OP_END_LOG_SEGMENT) {
|
||||||
|
newSharedEditLog.logSync();
|
||||||
|
newSharedEditLog.endCurrentLogSegment(false);
|
||||||
|
LOG.debug("ending log segment because of END_LOG_SEGMENT op in "
|
||||||
|
+ stream);
|
||||||
|
segmentOpen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newSharedEditLog.logEdit(op);
|
if (segmentOpen) {
|
||||||
|
LOG.debug("ending log segment because of end of stream in " + stream);
|
||||||
if (op.opCode == FSEditLogOpCodes.OP_END_LOG_SEGMENT) {
|
|
||||||
newSharedEditLog.logSync();
|
newSharedEditLog.logSync();
|
||||||
newSharedEditLog.endCurrentLogSegment(false);
|
newSharedEditLog.endCurrentLogSegment(false);
|
||||||
LOG.debug("ending log segment because of END_LOG_SEGMENT op in " + stream);
|
|
||||||
segmentOpen = false;
|
segmentOpen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
if (segmentOpen) {
|
if (streams != null) {
|
||||||
LOG.debug("ending log segment because of end of stream in " + stream);
|
FSEditLog.closeAllStreams(streams);
|
||||||
newSharedEditLog.logSync();
|
|
||||||
newSharedEditLog.endCurrentLogSegment(false);
|
|
||||||
segmentOpen = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue