You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by xk...@apache.org on 2019/08/06 16:50:30 UTC
[hadoop] branch branch-3.0 updated: HDFS-14697. Backport of
HDFS-14513. FSImage which is saving should be clean while NameNode
shutdown. Contributed by He Xiaoqiao.
This is an automated email from the ASF dual-hosted git repository.
xkrogen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new b0c5151 HDFS-14697. Backport of HDFS-14513. FSImage which is saving should be clean while NameNode shutdown. Contributed by He Xiaoqiao.
b0c5151 is described below
commit b0c515195911a719b6e7664fe51c1a13760951df
Author: Erik Krogen <ek...@linkedin.com>
AuthorDate: Tue Aug 6 09:15:24 2019 -0700
HDFS-14697. Backport of HDFS-14513. FSImage which is saving should be clean while NameNode shutdown. Contributed by He Xiaoqiao.
(cherry picked from ee1547a8071fbdebb72d409ddfcd46e6c63f82aa)
(cherry picked from 69e3ac5cbb2547416b27dbcfb458099c3a951101)
---
.../hadoop/hdfs/server/namenode/FSImage.java | 28 ++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
index 041a5cc..12e3101 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java
@@ -72,6 +72,7 @@ import org.apache.hadoop.io.MD5Hash;
import org.apache.hadoop.log.LogThrottlingHelper;
import org.apache.hadoop.log.LogThrottlingHelper.LogAction;
import org.apache.hadoop.util.ExitUtil;
+import org.apache.hadoop.util.ShutdownHookManager;
import org.apache.hadoop.util.Time;
import com.google.common.base.Joiner;
@@ -87,6 +88,11 @@ import com.google.common.collect.Lists;
public class FSImage implements Closeable {
public static final Log LOG = LogFactory.getLog(FSImage.class.getName());
+ /**
+ * Priority of the FSImageSaver shutdown hook: {@value}.
+ */
+ public static final int SHUTDOWN_HOOK_PRIORITY = 10;
+
protected FSEditLog editLog = null;
private boolean isUpgradeFinalized = false;
@@ -1035,6 +1041,21 @@ public class FSImage implements Closeable {
@Override
public void run() {
+ // Deletes checkpoint file in every storage directory when shutdown.
+ Runnable cancelCheckpointFinalizer = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ deleteCancelledCheckpoint(context.getTxId());
+ LOG.info("FSImageSaver clean checkpoint: txid = "
+ + context.getTxId() + " when meet shutdown.");
+ } catch (IOException e) {
+ LOG.error("FSImageSaver cancel checkpoint threw an exception:", e);
+ }
+ }
+ };
+ ShutdownHookManager.get().addShutdownHook(cancelCheckpointFinalizer,
+ SHUTDOWN_HOOK_PRIORITY);
try {
saveFSImage(context, sd, nnf);
} catch (SaveNamespaceCancelledException snce) {
@@ -1044,6 +1065,13 @@ public class FSImage implements Closeable {
} catch (Throwable t) {
LOG.error("Unable to save image for " + sd.getRoot(), t);
context.reportErrorOnStorageDirectory(sd);
+ try {
+ deleteCancelledCheckpoint(context.getTxId());
+ LOG.info("FSImageSaver clean checkpoint: txid = "
+ + context.getTxId() + " when meet Throwable.");
+ } catch (IOException e) {
+ LOG.error("FSImageSaver cancel checkpoint threw an exception:", e);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org