HDDS-310. VolumeSet shutdown hook fails on datanode restart. Contributed by Bharat Viswanadham.
This commit is contained in:
parent
735b492556
commit
41da2050bd
@ -167,7 +167,7 @@ private void initializeVolumeSet() throws IOException {
|
|||||||
|
|
||||||
// Ensure volume threads are stopped and scm df is saved during shutdown.
|
// Ensure volume threads are stopped and scm df is saved during shutdown.
|
||||||
shutdownHook = () -> {
|
shutdownHook = () -> {
|
||||||
shutdown();
|
saveVolumeSetUsed();
|
||||||
};
|
};
|
||||||
ShutdownHookManager.get().addShutdownHook(shutdownHook,
|
ShutdownHookManager.get().addShutdownHook(shutdownHook,
|
||||||
SHUTDOWN_HOOK_PRIORITY);
|
SHUTDOWN_HOOK_PRIORITY);
|
||||||
@ -303,7 +303,11 @@ public HddsVolume chooseVolume(long containerSize,
|
|||||||
return choosingPolicy.chooseVolume(getVolumesList(), containerSize);
|
return choosingPolicy.chooseVolume(getVolumesList(), containerSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
/**
|
||||||
|
* This method, call shutdown on each volume to shutdown volume usage
|
||||||
|
* thread and write scmUsed on each volume.
|
||||||
|
*/
|
||||||
|
private void saveVolumeSetUsed() {
|
||||||
for (HddsVolume hddsVolume : volumeMap.values()) {
|
for (HddsVolume hddsVolume : volumeMap.values()) {
|
||||||
try {
|
try {
|
||||||
hddsVolume.shutdown();
|
hddsVolume.shutdown();
|
||||||
@ -312,7 +316,14 @@ public void shutdown() {
|
|||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shutdown's the volumeset, if saveVolumeSetUsed is false, call's
|
||||||
|
* {@link VolumeSet#saveVolumeSetUsed}.
|
||||||
|
*/
|
||||||
|
public void shutdown() {
|
||||||
|
saveVolumeSetUsed();
|
||||||
if (shutdownHook != null) {
|
if (shutdownHook != null) {
|
||||||
ShutdownHookManager.get().removeShutdownHook(shutdownHook);
|
ShutdownHookManager.get().removeShutdownHook(shutdownHook);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user