HDDS-310. VolumeSet shutdown hook fails on datanode restart. Contributed by Bharat Viswanadham.

This commit is contained in:
Nanda kumar 2018-08-02 11:35:22 +05:30
parent 735b492556
commit 41da2050bd
1 changed files with 13 additions and 2 deletions

View File

@ -167,7 +167,7 @@ public class VolumeSet {
// 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 class VolumeSet {
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 class VolumeSet {
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);
} }