HDFS-11903. Ozone: Cleaning up local storage when closing MiniOzoneCluster. Contributed by Mingliang Liu

This commit is contained in:
Mingliang Liu 2017-05-31 15:00:09 -07:00 committed by Owen O'Malley
parent 6b9915fcbd
commit 677dcf529c

View File

@ -17,6 +17,7 @@
*/ */
package org.apache.hadoop.ozone; package org.apache.hadoop.ozone;
import java.io.File;
import java.util.Optional; import java.util.Optional;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -126,6 +127,15 @@ public void close() {
String errorMessage = "Cleaning up metadata directories failed." + e; String errorMessage = "Cleaning up metadata directories failed." + e;
assertFalse(errorMessage, true); assertFalse(errorMessage, true);
} }
try {
final String localStorage =
conf.getTrimmed(OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT,
OzoneConfigKeys.OZONE_LOCALSTORAGE_ROOT_DEFAULT);
FileUtils.deleteDirectory(new File(localStorage));
} catch (IOException e) {
LOG.error("Cleaning up local storage failed", e);
}
} }
@Override @Override