Skip to content
Merged
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 @@ -682,6 +682,11 @@ public Set<ContainerID> getContainers(UUID uuid)
return nodeStateMap.getContainers(uuid);
}

public int getContainerCount(UUID uuid)
throws NodeNotFoundException {
return nodeStateMap.getContainerCount(uuid);
}

/**
* Move Stale or Dead node to healthy if we got a heartbeat from them.
* Move healthy nodes to stale nodes if it is needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,7 @@ public DatanodeUsageInfo getUsageInfo(DatanodeDetails dn) {
SCMNodeStat stat = getNodeStatInternal(dn);
DatanodeUsageInfo usageInfo = new DatanodeUsageInfo(dn, stat);
try {
int containerCount = getContainers(dn).size();
usageInfo.setContainerCount(containerCount);
usageInfo.setContainerCount(getContainerCount(dn));
} catch (NodeNotFoundException ex) {
LOG.error("Unknown datanode {}.", dn, ex);
}
Expand Down Expand Up @@ -1458,6 +1457,11 @@ public Set<ContainerID> getContainers(DatanodeDetails datanodeDetails)
return nodeStateManager.getContainers(datanodeDetails.getUuid());
}

public int getContainerCount(DatanodeDetails datanodeDetails)
throws NodeNotFoundException {
return nodeStateManager.getContainerCount(datanodeDetails.getUuid());
}

@Override
public void addDatanodeCommand(UUID dnId, SCMCommand command) {
writeLock().lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ public Set<ContainerID> getContainers(UUID uuid)
}
}

public int getContainerCount(UUID uuid) throws NodeNotFoundException {
lock.readLock().lock();
try {
checkIfNodeExist(uuid);
return nodeToContainer.get(uuid).size();
} finally {
lock.readLock().unlock();
}
}

public void removeContainer(UUID uuid, ContainerID containerID) throws
NodeNotFoundException {
lock.writeLock().lock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ public Response getDatanodes() {
}
});
try {
Set<ContainerID> allContainers = nodeManager.getContainers(datanode);

builder.withContainers(allContainers.size());
builder.withContainers(nodeManager.getContainerCount(datanode));
builder.withOpenContainers(openContainers.get());
} catch (NodeNotFoundException ex) {
LOG.warn("Cannot get containers, datanode {} not found.",
Expand Down