[ 
https://issues.apache.org/jira/browse/HDFS-10742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15447021#comment-15447021
 ] 

Chris Douglas commented on HDFS-10742:
--------------------------------------

bq. I can't be sure other developers will prefer using this instead of manually 
adding the unlock calls. findbugs doesn't eliminate human error as committers 
can miss findbugs warnings (I've been guilty of this too).
It's not just Hadoop that's standardized on {{Lock}}, it's Java. Moreover, 
{{AutoCloseableLock}} doesn't actually restrict the API to make it less 
error-prone.

If its sole purpose is this syntactic sugar, perhaps this class is sufficient:
{code}
public final class AutoLock implements Closeable {
  private final Lock lock;
  public AutoLock(Lock lock) {
    lock.lock();
    this.lock = lock;
  }
  public AutoLock(Lock lock, long timeout, TimeUnit unit) throws 
TimeoutException {
    if (!lock.tryLock(timeout, unit)) {
      throw new TimeoutException();
    }
    this.lock = lock;
  }
  @Override
  public void close() {
    lock.unlock();
  }
}  
{code}
Then this JIRA (and variants) could remain behind the {{Lock}} interface, 
rather than a custom API.

bq. I'm considering using hadoop's built-in metric system, instead of 
maintaining and printing locally maintained stats, what do you think about this?

That's less information than this records. Is the intent to (dis)prove a 
hypothesis about FsDatasetImpl as a bottleneck, or to debug a common, known 
issue with stack traces, etc.?

> Measurement of lock held time in FsDatasetImpl
> ----------------------------------------------
>
>                 Key: HDFS-10742
>                 URL: https://issues.apache.org/jira/browse/HDFS-10742
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: datanode
>    Affects Versions: 3.0.0-alpha2
>            Reporter: Chen Liang
>            Assignee: Chen Liang
>         Attachments: HDFS-10742.001.patch, HDFS-10742.002.patch, 
> HDFS-10742.003.patch, HDFS-10742.004.patch, HDFS-10742.005.patch, 
> HDFS-10742.006.patch, HDFS-10742.007.patch, HDFS-10742.008.patch
>
>
> This JIRA proposes to measure the time the of lock of {{FsDatasetImpl}} is 
> held by a thread. Doing so will allow us to measure lock statistics.
> This can be done by extending the {{AutoCloseableLock}} lock object in 
> {{FsDatasetImpl}}. In the future we can also consider replacing the lock with 
> a read-write lock.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to