Siddhant Sangwan created HDDS-11388:
---------------------------------------

             Summary: Unnecessary call to the Database in ContainerBalancer
                 Key: HDDS-11388
                 URL: https://issues.apache.org/jira/browse/HDDS-11388
             Project: Apache Ozone
          Issue Type: Bug
          Components: SCM
    Affects Versions: 1.5.0
            Reporter: Siddhant Sangwan


{code}
  /**
   * Get balancer status info.
   *
   * @return balancer status info if balancer started
   */
  public ContainerBalancerStatusInfo getBalancerStatusInfo() throws IOException 
{
    if (isBalancerRunning()) {
      ContainerBalancerConfigurationProto configProto = 
readConfiguration(ContainerBalancerConfigurationProto.class);
      return new ContainerBalancerStatusInfo(
              this.startedAt,
              configProto,
              task.getCurrentIterationsStatistic()
      );
    } else {
      return null;
    }

  }
{code}

`{{readConfiguration(ContainerBalancerConfigurationProto.class)}}` reads from 
SCM's RocksDB. Is this really necessary? At this point we've already determined 
that balancer is running, so it must have read configuration from the database 
into memory. We should try to just reuse that.

Also as it stands, this code is not thread-safe because another thread could be 
writing to the table at the same time.



--
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