HDFS-5721. sharedEditsImage in Namenode#initializeSharedEdits() should be closed before method returns. (Ted Yu via junping_du)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1556803 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
519d5d3014
commit
7186000367
@ -245,6 +245,9 @@ Trunk (Unreleased)
|
|||||||
HDFS-5715. Use Snapshot ID to indicate the corresponding Snapshot for a
|
HDFS-5715. Use Snapshot ID to indicate the corresponding Snapshot for a
|
||||||
FileDiff/DirectoryDiff. (jing9)
|
FileDiff/DirectoryDiff. (jing9)
|
||||||
|
|
||||||
|
HDFS-5721. sharedEditsImage in Namenode#initializeSharedEdits() should be
|
||||||
|
closed before method returns. (Ted Yu via junping_du)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HDFS-5349. DNA_CACHE and DNA_UNCACHE should be by blockId only. (cmccabe)
|
HDFS-5349. DNA_CACHE and DNA_UNCACHE should be by blockId only. (cmccabe)
|
||||||
|
@ -619,8 +619,14 @@ public static FSNamesystem loadFromDisk(Configuration conf)
|
|||||||
|
|
||||||
long loadStart = now();
|
long loadStart = now();
|
||||||
String nameserviceId = DFSUtil.getNamenodeNameServiceId(conf);
|
String nameserviceId = DFSUtil.getNamenodeNameServiceId(conf);
|
||||||
namesystem.loadFSImage(startOpt, fsImage,
|
try {
|
||||||
HAUtil.isHAEnabled(conf, nameserviceId));
|
namesystem.loadFSImage(startOpt, fsImage,
|
||||||
|
HAUtil.isHAEnabled(conf, nameserviceId));
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
LOG.warn("Encountered exception loading fsimage", ioe);
|
||||||
|
fsImage.close();
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
long timeTakenToLoadFSImage = now() - loadStart;
|
long timeTakenToLoadFSImage = now() - loadStart;
|
||||||
LOG.info("Finished loading FSImage in " + timeTakenToLoadFSImage + " msecs");
|
LOG.info("Finished loading FSImage in " + timeTakenToLoadFSImage + " msecs");
|
||||||
NameNodeMetrics nnMetrics = NameNode.getNameNodeMetrics();
|
NameNodeMetrics nnMetrics = NameNode.getNameNodeMetrics();
|
||||||
|
@ -816,14 +816,20 @@ private static boolean format(Configuration conf, boolean force,
|
|||||||
System.out.println("Formatting using clusterid: " + clusterId);
|
System.out.println("Formatting using clusterid: " + clusterId);
|
||||||
|
|
||||||
FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat);
|
FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat);
|
||||||
FSNamesystem fsn = new FSNamesystem(conf, fsImage);
|
try {
|
||||||
fsImage.getEditLog().initJournalsForWrite();
|
FSNamesystem fsn = new FSNamesystem(conf, fsImage);
|
||||||
|
fsImage.getEditLog().initJournalsForWrite();
|
||||||
|
|
||||||
if (!fsImage.confirmFormat(force, isInteractive)) {
|
if (!fsImage.confirmFormat(force, isInteractive)) {
|
||||||
return true; // aborted
|
return true; // aborted
|
||||||
|
}
|
||||||
|
|
||||||
|
fsImage.format(fsn, clusterId);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
LOG.warn("Encountered exception during format: ", ioe);
|
||||||
|
fsImage.close();
|
||||||
|
throw ioe;
|
||||||
}
|
}
|
||||||
|
|
||||||
fsImage.format(fsn, clusterId);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -897,6 +903,7 @@ private static boolean initializeSharedEdits(Configuration conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NNStorage existingStorage = null;
|
NNStorage existingStorage = null;
|
||||||
|
FSImage sharedEditsImage = null;
|
||||||
try {
|
try {
|
||||||
FSNamesystem fsns =
|
FSNamesystem fsns =
|
||||||
FSNamesystem.loadFromDisk(getConfigurationWithoutSharedEdits(conf));
|
FSNamesystem.loadFromDisk(getConfigurationWithoutSharedEdits(conf));
|
||||||
@ -906,7 +913,7 @@ private static boolean initializeSharedEdits(Configuration conf,
|
|||||||
|
|
||||||
List<URI> sharedEditsDirs = FSNamesystem.getSharedEditsDirs(conf);
|
List<URI> sharedEditsDirs = FSNamesystem.getSharedEditsDirs(conf);
|
||||||
|
|
||||||
FSImage sharedEditsImage = new FSImage(conf,
|
sharedEditsImage = new FSImage(conf,
|
||||||
Lists.<URI>newArrayList(),
|
Lists.<URI>newArrayList(),
|
||||||
sharedEditsDirs);
|
sharedEditsDirs);
|
||||||
sharedEditsImage.getEditLog().initJournalsForWrite();
|
sharedEditsImage.getEditLog().initJournalsForWrite();
|
||||||
@ -934,6 +941,13 @@ private static boolean initializeSharedEdits(Configuration conf,
|
|||||||
LOG.error("Could not initialize shared edits dir", ioe);
|
LOG.error("Could not initialize shared edits dir", ioe);
|
||||||
return true; // aborted
|
return true; // aborted
|
||||||
} finally {
|
} finally {
|
||||||
|
if (sharedEditsImage != null) {
|
||||||
|
try {
|
||||||
|
sharedEditsImage.close();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
LOG.warn("Could not close sharedEditsImage", ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Have to unlock storage explicitly for the case when we're running in a
|
// Have to unlock storage explicitly for the case when we're running in a
|
||||||
// unit test, which runs in the same JVM as NNs.
|
// unit test, which runs in the same JVM as NNs.
|
||||||
if (existingStorage != null) {
|
if (existingStorage != null) {
|
||||||
|
@ -190,24 +190,29 @@ private int doRun() throws IOException {
|
|||||||
// Load the newly formatted image, using all of the directories (including shared
|
// Load the newly formatted image, using all of the directories (including shared
|
||||||
// edits)
|
// edits)
|
||||||
FSImage image = new FSImage(conf);
|
FSImage image = new FSImage(conf);
|
||||||
image.getStorage().setStorageInfo(storage);
|
try {
|
||||||
image.initEditLog();
|
image.getStorage().setStorageInfo(storage);
|
||||||
assert image.getEditLog().isOpenForRead() :
|
image.initEditLog();
|
||||||
|
assert image.getEditLog().isOpenForRead() :
|
||||||
"Expected edit log to be open for read";
|
"Expected edit log to be open for read";
|
||||||
|
|
||||||
// Ensure that we have enough edits already in the shared directory to
|
// Ensure that we have enough edits already in the shared directory to
|
||||||
// start up from the last checkpoint on the active.
|
// start up from the last checkpoint on the active.
|
||||||
if (!checkLogsAvailableForRead(image, imageTxId, curTxId)) {
|
if (!checkLogsAvailableForRead(image, imageTxId, curTxId)) {
|
||||||
return ERR_CODE_LOGS_UNAVAILABLE;
|
return ERR_CODE_LOGS_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
image.getStorage().writeTransactionIdFileToStorage(curTxId);
|
image.getStorage().writeTransactionIdFileToStorage(curTxId);
|
||||||
|
|
||||||
// Download that checkpoint into our storage directories.
|
// Download that checkpoint into our storage directories.
|
||||||
MD5Hash hash = TransferFsImage.downloadImageToStorage(
|
MD5Hash hash = TransferFsImage.downloadImageToStorage(
|
||||||
otherHttpAddr, imageTxId,
|
otherHttpAddr, imageTxId,
|
||||||
storage, true);
|
storage, true);
|
||||||
image.saveDigestAndRenameCheckpointImage(imageTxId, hash);
|
image.saveDigestAndRenameCheckpointImage(imageTxId, hash);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
image.close();
|
||||||
|
throw ioe;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user