Sarveksha Yeshavantha Raju created HDDS-14048:
-------------------------------------------------

             Summary: Optimise NodesOutOfSpace metric logic
                 Key: HDDS-14048
                 URL: https://issues.apache.org/jira/browse/HDDS-14048
             Project: Apache Ozone
          Issue Type: Sub-task
            Reporter: Sarveksha Yeshavantha Raju
            Assignee: Sarveksha Yeshavantha Raju


Below code will be computation intensive, and metrics will be queried every 30 
sec.
DN can have 100K of containers, including OPEN and CLOSED containers.We can 
optimize as, # if node stats at volume level have committed space < block size, 
no space (can have approx 15 loop for volumes at dn level)
 # if have space, possibility of being distributed at every container can be 
checked as below.

Just thinking if we can avoid below check, just depending on committed space 
for some approx info, as container close event will be triggered by DN for 4.5G 
full case.
So we need not loop like below.
{code:java}
private boolean hasContainerWithSpace(DatanodeInfo dnInfo, long blockSize, long 
containerSize) {
    try {
      Set<ContainerID> containers = getContainers(dnInfo);
      for (ContainerID containerID : containers) {
        ContainerInfo containerInfo = 
scmContext.getScm().getContainerManager().getContainer(containerID);

        if (containerInfo.getState() == HddsProtos.LifeCycleState.OPEN &&
            containerInfo.getUsedBytes() + blockSize <= containerSize) {
          return true;
        }
      }
    } catch (Exception e) {
      LOG.debug("Error checking containers for datanode {}: {}", 
dnInfo.getID(), e.getMessage());
    }
    return false;
  } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to