You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-issues@hadoop.apache.org by "Daryn Sharp (JIRA)" <ji...@apache.org> on 2013/12/03 18:54:38 UTC
[jira] [Commented] (HDFS-5514) FSNamesystem's fsLock should allow
custom implementation
[ https://issues.apache.org/jira/browse/HDFS-5514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13837952#comment-13837952 ]
Daryn Sharp commented on HDFS-5514:
-----------------------------------
Yes, I meant coarse, nice catch. :)
I think I can quickly explain the basic approach w/o a couple page doc, if not, let me know and I'll write something up.
The reason for creating a separate class is to move towards providing a pluggable lock context for ops to use. The default will be coarse as it is today to not destabilize the NN. The general principle is changing the pattern of:
{code}
readLock();
try {
...
} finally {
readUnlock();
}
{code}
to something more like:
{code}
LockContext lockContext = fsLock.getLockContext(LockState.READ);
try {
...
lockContext.readLock(path);
lockContext.writeLock(path);
lockContext.writeLockParent(path);
...
} finally {
lockContext.unlock();
}
{code}
Use of the context is optional. The existing fsn readLock/writeLock methods will continue to exist to avoid changing anything but {{FSNamesystem}}. This also means not every fsn method needs to be converted immediately.
For a coarse lock context, the initial lock state is applied to the global rw lock now wrapped by the {{FSNamesystemLock}} in this patch. The path locking methods are no-ops. Existing fsn readLock/writeLock methods will use the same global lock - which is how I localize the changes to the fsn.
For the initial finer grain lock context, which I'll post in yet another future subtask, the context's initial lock state is effectively always a read lock on the global lock to prevent safemode/HA transitions. The path locking methods associate unique rw locks with inodes on a demand basis (the NN won't create or maintain a lock for every single inode). These locks are tracked in the context. However, these are only implementation details of a specific context for finer grain locking. Other implementations may do something completely different. I hope to use a lock-free scoreboard in the future to control/schedule which handlers are allowed to execute - but again just an implementation detail.
The initial prototype I'm hoping to implement via the parent jira will not require lock changes to classes other than {{FSNamesystem}} as described above. I just need the {{FSNameSystemLock}} abstraction in this jira, and the addition of the aforementioned path locking apis I'll post in another jira.
> FSNamesystem's fsLock should allow custom implementation
> --------------------------------------------------------
>
> Key: HDFS-5514
> URL: https://issues.apache.org/jira/browse/HDFS-5514
> Project: Hadoop HDFS
> Issue Type: Sub-task
> Components: namenode
> Affects Versions: 2.0.0-alpha, 3.0.0
> Reporter: Daryn Sharp
> Assignee: Daryn Sharp
> Attachments: HDFS-5514.patch
>
>
> Changing {{fsLock}} from a {{ReentrantReadWriteLock}} to an API compatible class that encapsulates the rwLock will allow for more sophisticated locking implementations such as fine grain locking.
--
This message was sent by Atlassian JIRA
(v6.1#6144)