HDFS-2334. Merging change r1195620 from trunk to 0.23
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1297858 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f93d40e2c9
commit
aa3bb33cd1
|
@ -100,6 +100,8 @@ Release 0.23.3 - UNRELEASED
|
||||||
|
|
||||||
HDFS-2158. Add JournalSet to manage the set of journals. (jitendra)
|
HDFS-2158. Add JournalSet to manage the set of journals. (jitendra)
|
||||||
|
|
||||||
|
HDFS-2334. Add Closeable to JournalManager. (Ivan Kelly via jitendra)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -76,6 +76,9 @@ class BackupJournalManager implements JournalManager {
|
||||||
public void recoverUnfinalizedSegments() throws IOException {
|
public void recoverUnfinalizedSegments() throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {}
|
||||||
|
|
||||||
public boolean matchesRegistration(NamenodeRegistration bnReg) {
|
public boolean matchesRegistration(NamenodeRegistration bnReg) {
|
||||||
return bnReg.getAddress().equals(this.bnReg.getAddress());
|
return bnReg.getAddress().equals(this.bnReg.getAddress());
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,6 +216,12 @@ public class FSEditLog {
|
||||||
endCurrentLogSegment(true);
|
endCurrentLogSegment(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
journalSet.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
LOG.warn("Error closing journalSet", ioe);
|
||||||
|
}
|
||||||
|
|
||||||
state = State.CLOSED;
|
state = State.CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,9 @@ class FileJournalManager implements JournalManager {
|
||||||
this.sd = sd;
|
this.sd = sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
synchronized public EditLogOutputStream startLogSegment(long txid)
|
synchronized public EditLogOutputStream startLogSegment(long txid)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs.server.namenode;
|
package org.apache.hadoop.hdfs.server.namenode;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ import java.io.IOException;
|
||||||
* each conceptual place of storage corresponds to exactly one instance of
|
* each conceptual place of storage corresponds to exactly one instance of
|
||||||
* this class, which is created when the EditLog is first opened.
|
* this class, which is created when the EditLog is first opened.
|
||||||
*/
|
*/
|
||||||
interface JournalManager {
|
interface JournalManager extends Closeable {
|
||||||
/**
|
/**
|
||||||
* Begin writing to a new segment of the log stream, which starts at
|
* Begin writing to a new segment of the log stream, which starts at
|
||||||
* the given transaction ID.
|
* the given transaction ID.
|
||||||
|
@ -81,6 +82,11 @@ interface JournalManager {
|
||||||
*/
|
*/
|
||||||
void recoverUnfinalizedSegments() throws IOException;
|
void recoverUnfinalizedSegments() throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the journal manager, freeing any resources it may hold.
|
||||||
|
*/
|
||||||
|
void close() throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate that a journal is cannot be used to load a certain range of
|
* Indicate that a journal is cannot be used to load a certain range of
|
||||||
* edits.
|
* edits.
|
||||||
|
|
|
@ -72,12 +72,21 @@ public class JournalSet implements JournalManager {
|
||||||
/**
|
/**
|
||||||
* Closes the stream, also sets it to null.
|
* Closes the stream, also sets it to null.
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException {
|
public void closeStream() throws IOException {
|
||||||
if (stream == null) return;
|
if (stream == null) return;
|
||||||
stream.close();
|
stream.close();
|
||||||
stream = null;
|
stream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Journal and Stream
|
||||||
|
*/
|
||||||
|
public void close() throws IOException {
|
||||||
|
closeStream();
|
||||||
|
|
||||||
|
journal.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aborts the stream, also sets it to null.
|
* Aborts the stream, also sets it to null.
|
||||||
*/
|
*/
|
||||||
|
@ -145,13 +154,23 @@ public class JournalSet implements JournalManager {
|
||||||
@Override
|
@Override
|
||||||
public void apply(JournalAndStream jas) throws IOException {
|
public void apply(JournalAndStream jas) throws IOException {
|
||||||
if (jas.isActive()) {
|
if (jas.isActive()) {
|
||||||
jas.close();
|
jas.closeStream();
|
||||||
jas.getManager().finalizeLogSegment(firstTxId, lastTxId);
|
jas.getManager().finalizeLogSegment(firstTxId, lastTxId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "finalize log segment " + firstTxId + ", " + lastTxId);
|
}, "finalize log segment " + firstTxId + ", " + lastTxId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
mapJournalsAndReportErrors(new JournalClosure() {
|
||||||
|
@Override
|
||||||
|
public void apply(JournalAndStream jas) throws IOException {
|
||||||
|
jas.close();
|
||||||
|
}
|
||||||
|
}, "close journal");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the best editlog input stream to read from txid.
|
* Find the best editlog input stream to read from txid.
|
||||||
|
@ -332,7 +351,7 @@ public class JournalSet implements JournalManager {
|
||||||
mapJournalsAndReportErrors(new JournalClosure() {
|
mapJournalsAndReportErrors(new JournalClosure() {
|
||||||
@Override
|
@Override
|
||||||
public void apply(JournalAndStream jas) throws IOException {
|
public void apply(JournalAndStream jas) throws IOException {
|
||||||
jas.close();
|
jas.closeStream();
|
||||||
}
|
}
|
||||||
}, "close");
|
}, "close");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue