Closed milandesai closed 8 years ago
Created a pull request that demonstrates what the end result would look like. Note that the INode class was entirely rewritten so its best to look at the new version than the diff. The consequential changes are constrained to INodeManager and NamespaceProcessor, with minimal leakage into tests and the web server. All tests are passing.
The refactoring looks good. Couple of things
inodeId
as it is common for files and directories.asFile()
/
asDirectory()
another is valueOf()
. We should choose one and stick to it. I do not have preferences, but valueOf()
seems to be more "scalable" if you had more INode types. Although it is more chatty, as you need to use the class name INodeFile.valueOf()
. But this is cleaner as you explicitly name the class to which you cast.
Yet another way is to parametrize static <T> T valueOf()
. Seems like the least amount of code?I also added a shortcut method INode.getPath() to replace the lengthy getKey().getPath() used everywhere. All tests are passing.
There is one unused import of IOException in INode. I removed it and will commit. Looks good.
I just committed this. Thank you Milan.
I think it will be useful and cleaner to make INode an abstract class and subclass it into INodeFile and INodeDirectory, similar to HDFS. That will make it easier to add additional INode fields and to construct INodes by reducing the number of required parameters, especially for directories. It also makes the code less prone to errors related to properties meant only for files or directories. I noticed this when experimenting with INodeId-based RowKeys.