[
https://issues.apache.org/jira/browse/HDFS-14260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16764014#comment-16764014
]
Íñigo Goiri commented on HDFS-14260:
------------------------------------
The setter happens for every packet and the getter happens with exception.
I would not expect a big performance improvement but I think is better to not
synchronize everything and use the atomic setting.
> Synchronized Method in BlockReceiver Can Be Replaced with Atomic Value
> ----------------------------------------------------------------------
>
> Key: HDFS-14260
> URL: https://issues.apache.org/jira/browse/HDFS-14260
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: datanode
> Affects Versions: 3.2.0
> Reporter: BELUGA BEHR
> Assignee: BELUGA BEHR
> Priority: Minor
> Attachments: HDFS-14260.1.patch, HDFS-14260.2.patch
>
>
> This synchronized block is protecting {{lastSentTime}} which is a native
> long. Can use AtomicLong and remove this synchronization.
> {code}
> synchronized boolean packetSentInTime() {
> long diff = Time.monotonicNow() - lastSentTime;
> if (diff > maxSendIdleTime) {
> LOG.info("A packet was last sent " + diff + " milliseconds ago.");
> return false;
> }
> return true;
> }
> {code}
> https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java#L392-L399
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]