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

View File

@ -167,7 +167,7 @@ private void initializeVolumeSet() throws IOException {
// Ensure volume threads are stopped and scm df is saved during shutdown.
shutdownHook = () -> {
shutdown();
saveVolumeSetUsed();
};
ShutdownHookManager.get().addShutdownHook(shutdownHook,
SHUTDOWN_HOOK_PRIORITY);
@ -303,7 +303,11 @@ public HddsVolume chooseVolume(long 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()) {
try {
hddsVolume.shutdown();
@ -312,7 +316,14 @@ public void shutdown() {
ex);
}
}
}
/**
* Shutdown's the volumeset, if saveVolumeSetUsed is false, call's
* {@link VolumeSet#saveVolumeSetUsed}.
*/
public void shutdown() {
saveVolumeSetUsed();
if (shutdownHook != null) {
ShutdownHookManager.get().removeShutdownHook(shutdownHook);
}