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:
parent
56c8aa5f1c
commit
6545b7eeef
@ -678,7 +678,15 @@ private Consumer<List<DatanodeInfoWithStorage>> createSecondaryNodeSorter() {
|
|||||||
Consumer<List<DatanodeInfoWithStorage>> secondarySort = null;
|
Consumer<List<DatanodeInfoWithStorage>> secondarySort = null;
|
||||||
if (readConsiderStorageType) {
|
if (readConsiderStorageType) {
|
||||||
Comparator<DatanodeInfoWithStorage> comp =
|
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);
|
secondarySort = list -> Collections.sort(list, comp);
|
||||||
}
|
}
|
||||||
if (readConsiderLoad) {
|
if (readConsiderLoad) {
|
||||||
|
Loading…
Reference in New Issue
Block a user