HDFS-8676. Delayed rolling upgrade finalization can cause heartbeat expiration. Contributed by Walter Su.
(cherry picked from commit 5b43db47a3
)
This commit is contained in:
parent
61388b41e7
commit
efba749760
|
@ -66,6 +66,9 @@ Release 2.7.2 - UNRELEASED
|
||||||
HDFS-9178. Slow datanode I/O can cause a wrong node to be marked bad
|
HDFS-9178. Slow datanode I/O can cause a wrong node to be marked bad
|
||||||
(kihwal)
|
(kihwal)
|
||||||
|
|
||||||
|
HDFS-8676. Delayed rolling upgrade finalization can cause heartbeat
|
||||||
|
expiration. (Walter Su via kihwal)
|
||||||
|
|
||||||
Release 2.7.1 - 2015-07-06
|
Release 2.7.1 - 2015-07-06
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.hadoop.util.Daemon;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -92,6 +93,7 @@ public class BlockPoolSliceStorage extends Storage {
|
||||||
"^(.*)(" + BLOCK_POOL_ID_PATTERN_BASE + ")(" + TRASH_ROOT_DIR + ")(.*)$");
|
"^(.*)(" + BLOCK_POOL_ID_PATTERN_BASE + ")(" + TRASH_ROOT_DIR + ")(.*)$");
|
||||||
|
|
||||||
private String blockpoolID = ""; // id of the blockpool
|
private String blockpoolID = ""; // id of the blockpool
|
||||||
|
private Daemon trashCleaner;
|
||||||
|
|
||||||
public BlockPoolSliceStorage(StorageInfo storageInfo, String bpid) {
|
public BlockPoolSliceStorage(StorageInfo storageInfo, String bpid) {
|
||||||
super(storageInfo);
|
super(storageInfo);
|
||||||
|
@ -738,11 +740,39 @@ public class BlockPoolSliceStorage extends Storage {
|
||||||
* Delete all files and directories in the trash directories.
|
* Delete all files and directories in the trash directories.
|
||||||
*/
|
*/
|
||||||
public void clearTrash() {
|
public void clearTrash() {
|
||||||
|
final List<File> trashRoots = new ArrayList<>();
|
||||||
for (StorageDirectory sd : storageDirs) {
|
for (StorageDirectory sd : storageDirs) {
|
||||||
File trashRoot = getTrashRootDir(sd);
|
File trashRoot = getTrashRootDir(sd);
|
||||||
Preconditions.checkState(!(trashRoot.exists() && sd.getPreviousDir().exists()));
|
if (trashRoot.exists() && sd.getPreviousDir().exists()) {
|
||||||
FileUtil.fullyDelete(trashRoot);
|
LOG.error("Trash and PreviousDir shouldn't both exist for storage "
|
||||||
LOG.info("Cleared trash for storage directory " + sd);
|
+ "directory " + sd);
|
||||||
|
assert false;
|
||||||
|
} else {
|
||||||
|
trashRoots.add(trashRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stopTrashCleaner();
|
||||||
|
trashCleaner = new Daemon(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for(File trashRoot : trashRoots){
|
||||||
|
FileUtil.fullyDelete(trashRoot);
|
||||||
|
LOG.info("Cleared trash for storage directory " + trashRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "clearTrash() for " + blockpoolID;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
trashCleaner.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopTrashCleaner() {
|
||||||
|
if (trashCleaner != null) {
|
||||||
|
trashCleaner.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,7 @@ public class DataStorage extends Storage {
|
||||||
*/
|
*/
|
||||||
public void enableTrash(String bpid) {
|
public void enableTrash(String bpid) {
|
||||||
if (trashEnabledBpids.add(bpid)) {
|
if (trashEnabledBpids.add(bpid)) {
|
||||||
|
getBPStorage(bpid).stopTrashCleaner();
|
||||||
LOG.info("Enabled trash for bpid " + bpid);
|
LOG.info("Enabled trash for bpid " + bpid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue