Janus Chow created HDDS-4702:
--------------------------------

             Summary: Add assertion of having locks in lock related methods
                 Key: HDDS-4702
                 URL: https://issues.apache.org/jira/browse/HDDS-4702
             Project: Hadoop Distributed Data Store
          Issue Type: Improvement
            Reporter: Janus Chow


When reading the code of "KeyManagerImpl", there is a method named 
getBucketInfo as follows:
{code:java}
private OmBucketInfo getBucketInfo(String volumeName, String bucketName)
    throws IOException {
  String bucketKey = metadataManager.getBucketKey(volumeName, bucketName);
  return metadataManager.getBucketTable().get(bucketKey);
}
{code}
When I first saw the method, I found it a little strange, since it's querying 
from the metadata table, but there is no lock related code. Then I found that 
the method were invoked in "createDirectory" and "openKey", in which the 
writeLock of  BUCKET_LOCK were already acquired. So the method of getBucketInfo 
is OK in logic but a little hard for understanding.

In the code of NameNode in Hadoop, there are a lot of using of "assert 
hasXxxLock", indicating that the method has already got the readLock or 
writeLock, quite easy for understanding. I think it would be good to add this 
tradition in Ozone.
{code:java}
assert namesystem.hasReadLock();
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to