Closed weilintsaiWand closed 9 years ago
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.
Class
.class)".Let's fix these first and then I'll do another review.
Let's fix those and then I'll do another review.
Fix done and ready for review.
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.
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.
This looks good. Couple more nits, while we are waiting for Plamen's resolution.
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.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.
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
. 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
Fix for removing Guava dependencies and reorder XAttrOp
and XAttrPermissionFilter
done.
Yes, this is what I meant. +1
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)
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.
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.
This looks good. I don't see anymore "Connection refused" exceptions. +1 from my end.
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.
We can just clean up the directory as in https://issues.apache.org/jira/browse/HDFS-7561
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.
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.
Yes, good point, Wei-Lin. Sounds like we perfected this patch quite well. Committing now.
I just committed this. Thank you Wei-Lin.
Implement extended attributes for Giraffa.