HDFS-17098. DatanodeManager does not handle null storage type properly. (#6840). Contributed by ConfX.

Signed-off-by: Shilun Fan <slfan1989@apache.org>
This commit is contained in:
Hexiaoqiao 2024-06-19 20:58:57 +08:00 committed by GitHub
parent 56c8aa5f1c
commit 6545b7eeef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -678,7 +678,15 @@ private Consumer<List<DatanodeInfoWithStorage>> createSecondaryNodeSorter() {
Consumer<List<DatanodeInfoWithStorage>> secondarySort = null;
if (readConsiderStorageType) {
Comparator<DatanodeInfoWithStorage> comp =
Comparator.comparing(DatanodeInfoWithStorage::getStorageType);
Comparator.comparing(DatanodeInfoWithStorage::getStorageType, (s1, s2) -> {
if (s1 == null) {
return (s2 == null) ? 0 : -1;
} else if (s2 == null) {
return 1;
} else {
return s2.compareTo(s1);
}
});
secondarySort = list -> Collections.sort(list, comp);
}
if (readConsiderLoad) {