szetszwo commented on code in PR #10000:
URL: https://github.com/apache/ozone/pull/10000#discussion_r3328941800
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java:
##########
@@ -634,22 +636,23 @@ private boolean isOpenWithUnregisteredNodes(Pipeline
pipeline) {
}
@Override
- public boolean hasEnoughSpace(Pipeline pipeline) {
- for (DatanodeDetails node : pipeline.getNodes()) {
- if (!nodeManager.hasSpaceForNewContainerAllocation(node.getID())) {
+ public boolean checkSpaceAndRecordAllocation(Pipeline pipeline, ContainerID
containerID) {
+ List<DatanodeDetails> successfulNodes = new ArrayList<>();
+ for (DatanodeDetails dn : pipeline.getNodes()) {
Review Comment:
We should getDatanodeInfo first:
```java
public boolean checkSpaceAndRecordAllocation(Pipeline pipeline,
ContainerID containerID) {
final Set<DatanodeDetails> datanodeDetails = pipeline.getNodeSet();
final List<DatanodeInfo> datanodeInfos = new
ArrayList<>(datanodeDetails.size());
for (DatanodeDetails dn : datanodeDetails) {
final DatanodeInfo info = nodeManager.getDatanodeInfo(dn);
if (info == null) {
LOG.warn("DatanodeInfo not found for {}", dn.getID());
return false;
}
datanodeInfos.add(info);
}
final List<DatanodeInfo> successfulNodes = new
ArrayList<>(datanodeInfos.size());
for (DatanodeInfo dn : datanodeInfos) {
if (!nodeManager.checkSpaceAndRecordAllocation(dn, containerID)) {
for (DatanodeInfo rollbackNode : successfulNodes) {
nodeManager.removePendingAllocationForDatanode(rollbackNode,
containerID);
}
return false;
}
successfulNodes.add(dn);
}
return true;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]