ozone icon indicating copy to clipboard operation
ozone copied to clipboard

HDDS-10830. Replace ConcurrentHashMap with HashMap protected by ReadWriteLock in NodeStateMap

Open Montura opened this issue 9 months ago • 1 comments

There is a class NodeStateMap with 3 fields:

  1. ConcurrentHashMap<UUID, DatanodeInfo> nodeMap
  2. ConcurrentHashMap<UUID, Set<ContainerID>> nodeToContainer
  3. private final ReadWriteLock lock

Both read and write operations in NodeStateMap are protected by lock.

What changes were proposed in this pull request?

  1. Replace ConcurrentHashMap with pure HashMap to avoid extra lock operations.
  2. Create private NodeStateMap::getNodeInfoUnsafe method without lock.readLock.lock() to use it when lock.writeLock.lock() has already acquired:
    • NodeStateMap::updateNodeHealthState
    • NodeStateMap::updateNodeOperationalState

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10830

How was this patch tested?

Use standalone tests

Montura avatar May 08 '24 07:05 Montura

@adoroszlai, done!

Montura avatar May 09 '24 08:05 Montura

Thanks @Montura for the contribution.

adoroszlai avatar May 09 '24 13:05 adoroszlai