GiraffaFS / giraffa

Giraffa FileSystem (Slack: giraffa-fs.slack.com)
https://giraffa.ci.cloudbees.com
Apache License 2.0
17 stars 6 forks source link

Add extended attributes (XAttr) functionality #179

Closed weilintsaiWand closed 9 years ago

weilintsaiWand commented 9 years ago

Implement extended attributes for Giraffa.

weilintsaiWand commented 9 years ago

Summary of changes for init commit:

To do

Not sure parts

weilintsaiWand commented 9 years ago
Changes for second commit

Add logic to check if DFS_NAMENODE_XATTRS_ENABLED_KEY is disabled The logic is in NamespaceProcessor.java. Hence, we will have some permission checking logic in NamespaceProcessor.java and some are in XAttrOp.java. It's possible to let them all in XAttrOp.java but I choose current approach for now.

weilintsaiWand commented 9 years ago

Update Summary

What we checked

What we didn't support

What is different

What need review

Tests
pjeli commented 9 years ago

Let's fix these first and then I'll do another review.

pjeli commented 9 years ago

Let's fix those and then I'll do another review.

weilintsaiWand commented 9 years ago

Fix done and ready for review.

shvachko commented 9 years ago

Hey Wei-Lin. I noticed there is bunch of warnings in TestXAttr. They are related to that you do not parametrize PrivilegedExceptionAction. The parameter should be the same as the return value of run() method. It seems that you do not need to return anything. In this case the common practice is to use Void. E.g.:

new PrivilegedExceptionAction<Void>() {
  public Void run() throws Exception {
    return null;
  }
}

Plamen, let me know if this is ready otherwise.

weilintsaiWand commented 9 years ago

Thanks Konstantin, To be honest, the code style is copied from Hadoop. Since I never used PrivilegedExceptionAction before, I was not aware that it's a generic . I also found Intellij didn't report warnings for non-parametrized situation so I will try to enable this checking in my Intellij. Hopefully it would not happen again.

The fix is ready for your reference. Please help check it. Thanks.

shvachko commented 9 years ago

This looks good. Couple more nits, while we are waiting for Plamen's resolution.

  1. Let's replace Lists.newArrayListWithCapacity with new ArrayList<XAttr>(int). You used google.common in several places. We should stick to java types and libraries, rather than introducing new dependencies as I said in another issue.
  2. We should move XAttrOp and XAttrPermissionFilter under org.apache.giraffa package, because there is nothing hbase specific there. A general rule of thumb is to keep as much as possible outside of hbase and hdfs dependent packages.
    • Except for HBaseRpcUtil, which is used to obtain FSPermissionChecker. I suggest you use NamespaceProcessor.getFsPermissionChecker() to obtain the checker. You may pass it as parameter to XAttrOp methods. Then you can remove a few members XAttrOp.fsOwnerShortUserName and supergroup.
weilintsaiWand commented 9 years ago

Thanks Konstantin for the dependencies reminder, I checked the code and found in NamespaceProcessor I use int size = xAttr.getName().getBytes(Charsets.UTF_8).length; which I copied from Hadoop. I am planning to replace this line with int size = xAttr.getName().getBytes().length; so we don't need import com.google.common.base.Charsets; Please correct me if I was wrong

weilintsaiWand commented 9 years ago

Fix for removing Guava dependencies and reorder XAttrOp and XAttrPermissionFilter done.

shvachko commented 9 years ago

Yes, this is what I meant. +1

shvachko commented 9 years ago

Just finished running the test suite and found one more thing. At the end of the log for TestXAtt I see several ConnectException: Connection refused. This means the test is not closing something that it opened. This exception persists through subsequent tests, which means this thread from TestXAtt keeps trying to connect to ZK within the following tests. Should investigate this.

15/07/20 10:54:35 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:54434. Will not attempt to authenticate using SASL (unknown error)
15/07/20 10:54:35 WARN zookeeper.ClientCnxn: Session 0x14eac98edb700c3 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)
weilintsaiWand commented 9 years ago

Seems like there are some flaws in my Mock parts. Hence, something is open when we change the user to verify permission parts any may not close properly after test finished. Still working on it now.

weilintsaiWand commented 9 years ago

Fix and refactor the code to use a private static variable to keep a FS opened by child-thread. Hence, the FS open/close operation can be handled properly.

pjeli commented 9 years ago

This looks good. I don't see anymore "Connection refused" exceptions. +1 from my end.

shvachko commented 9 years ago

I just pushed some more changes to your branch. The main thing that I removed redundant member TestXAttr.grfs, renamed anotherThreadFs to user1fs and made it initialized explicitly in beforeClass(), also reused member conf. Hope this simplified things. One last thing to fix is that when I run the test in Eclipse it incorrectly creates build directory under giraffa-core. build directory should be under giraffa-core/target, otherwise it is not cleaned up by mvn clean target.

shvachko commented 9 years ago

We can just clean up the directory as in https://issues.apache.org/jira/browse/HDFS-7561

weilintsaiWand commented 9 years ago

The build directory is created in base test's @BeforeClass void init() method. It's hard to change the behavior because all Mock/Override/Configuration Setting take place after base class's @BeforeClass method. As a result, we use a work around solution to deleted build directory manually in our @AfterClass method. I also removed Mock of init since it's useless.

weilintsaiWand commented 9 years ago

After Konstantin's simplification, we have shared user1fs among all tests. Hence, it seems like we don't need user1.doAs in each test. As a result, I refine the code to remove that part in the latest commit. Please correct me if I was wrong.

shvachko commented 9 years ago

Yes, good point, Wei-Lin. Sounds like we perfected this patch quite well. Committing now.

shvachko commented 9 years ago

I just committed this. Thank you Wei-Lin.