Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Class captures information of a storage in Datanode.
*/
public class DatanodeStorage {
public class DatanodeStorage implements Comparable<DatanodeStorage> {
/** The state of the storage. */
public enum State {
NORMAL,
Expand Down Expand Up @@ -125,4 +125,9 @@ public boolean equals(Object other){
public int hashCode() {
return getStorageID().hashCode();
}

@Override
public int compareTo(DatanodeStorage that) {
return getStorageID().compareTo(that.getStorageID());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ List<DatanodeCommand> blockReport(long fullBrLeaseId) throws IOException {
StorageBlockReport reports[] =
new StorageBlockReport[perVolumeBlockLists.size()];

for(Map.Entry<DatanodeStorage, BlockListAsLongs> kvPair : perVolumeBlockLists.entrySet()) {
for (Map.Entry<DatanodeStorage, BlockListAsLongs> kvPair : perVolumeBlockLists.entrySet()) {
BlockListAsLongs blockList = kvPair.getValue();
reports[i++] = new StorageBlockReport(kvPair.getKey(), blockList);
totalBlockCount += blockList.getNumberOfBlocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;

Expand Down Expand Up @@ -2097,7 +2098,7 @@ public List<Long> getCacheReport(String bpid) {
@Override
public Map<DatanodeStorage, BlockListAsLongs> getBlockReports(String bpid) {
Map<DatanodeStorage, BlockListAsLongs> blockReportsMap =
new HashMap<DatanodeStorage, BlockListAsLongs>();
new TreeMap<DatanodeStorage, BlockListAsLongs>();

Map<String, BlockListAsLongs.Builder> builders =
new HashMap<String, BlockListAsLongs.Builder>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -837,7 +836,8 @@ synchronized BlockListAsLongs getBlockReport(String bpid,
@Override
public synchronized Map<DatanodeStorage, BlockListAsLongs> getBlockReports(
String bpid) {
Map<DatanodeStorage, BlockListAsLongs> blockReports = new HashMap<>();
Map<DatanodeStorage, BlockListAsLongs> blockReports =
new TreeMap<DatanodeStorage, BlockListAsLongs>();
for (SimulatedStorage storage : storages) {
blockReports.put(storage.getDnStorage(), getBlockReport(bpid, storage));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ public void unfinalizeBlock(ExtendedBlock b) throws IOException {

@Override
public Map<DatanodeStorage, BlockListAsLongs> getBlockReports(String bpid) {
final Map<DatanodeStorage, BlockListAsLongs> result =
new HashMap<DatanodeStorage, BlockListAsLongs>();
final Map<DatanodeStorage, BlockListAsLongs> result =
new TreeMap<DatanodeStorage, BlockListAsLongs>();

result.put(storage, BlockListAsLongs.EMPTY);
return result;
Expand Down