dCache / nfs4j

Pure Java NFSv3 and NFSv4.2 implementation
Other
240 stars 76 forks source link

Missing callback for OP_CLOSE in VirtualFileSystem #38

Open dkocher opened 8 years ago

dkocher commented 8 years ago

I am missing a notification in the virtual filesystem for CLOSE operations. Would be nice if the VirtualFileSystem can be extended with a close operation that is called from org.dcache.nfs.v4.OperationCLOSE.

kofemann commented 8 years ago

As client can merge multiple opens into a single one you must bind your close action to open-state-id, which on dispose will call-back your onClose action.. By saying that I am pretty sure nfs4j does not provides a way to create such a binding. One possibility will be to extend CLOSE and OPEN operations and add required functionality. For example:

https://github.com/dCache/dcache/blob/master/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/proxy/ProxyIoClose.java

https://github.com/dCache/dcache/blob/master/modules/dcache-nfs/src/main/java/org/dcache/chimera/nfsv41/door/proxy/ProxyIoMdsOpFactory.java

As you have a valid use-case, I am fine to add a functionality which will make tracking of open+close operation simple. Can you provide a little bit more context?

dkocher commented 8 years ago

The context is as follows (sorry for asking for a solution instead of describing the problem): The implementation of the virtual filesystem handles a persistent connection for open files with java.io.* with an open output or input stream while a write or read operation is in progress. Therefore it is crucial to close the underlying stream once a CLOSE operation is received to flush the changes. We are looking to replace our current NFSv3 implementation in Mountain Duck with nfs4j.