# Graceful shutdown

> Graceful shutdown of Apache Hadoop HDFS JournalNodes, NameNodes and DataNodes, covering the configurable shutdown timeout per role.

You can configure the graceful shutdown as described in [Graceful shutdown](https://docs.stackable.tech/home/stable/concepts/operations/graceful_shutdown/index.md).

## JournalNodes

As a default, JournalNodes have `15 minutes` to shut down gracefully.

The JournalNode process receives a `SIGTERM` signal when Kubernetes wants to terminate the Pod. It logs the received signal as shown in the log below and initiate a graceful shutdown. After the graceful shutdown timeout runs out, and the process is still running, Kubernetes issues a `SIGKILL` signal.

[This](https://github.com/apache/hadoop/blob/a585a73c3e02ac62350c136643a5e7f6095a3dbb/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNode.java#L272) is the relevant code that gets executed in the JournalNodes as of HDFS version `3.3.4`.

```text
2023-10-10 13:37:41,525 ERROR server.JournalNode (LogAdapter.java:error(75)) - RECEIVED SIGNAL 15: SIGTERM
2023-10-10 13:37:41,526 INFO  server.JournalNode (LogAdapter.java:info(51)) - SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down JournalNode at hdfs-journalnode-default-0/10.244.0.38
************************************************************/
```

## NameNodes

As a default, NameNodes have `15 minutes` to shut down gracefully. They use the same mechanism described above.

[This](https://github.com/apache/hadoop/blob/a585a73c3e02ac62350c136643a5e7f6095a3dbb/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java#L1080) is the relevant code that gets executed in the NameNodes as of HDFS version `3.3.4`.

## DataNodes

As a default, DataNodes have `30 minutes` to shut down gracefully. They use the same mechanism described above.

[This](https://github.com/apache/hadoop/blob/a585a73c3e02ac62350c136643a5e7f6095a3dbb/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java#L2004) is the relevant code that gets executed in the DataNodes as of HDFS version `3.3.4`.
