Profs. Thiruvathukal, Laufer, and myself have been working on
filesystems and filesystems frameworks for several years.
Our first project was OLFS. OLFS was a FUSE filesystem similar to
UnionFS, but written in Java. This was an excellent learning
experience for us.
Building on our experience with OLFS, we developed two frameworks:
NOFS and RestFS. We believe that both of these frameworks help to
both bring filesystems development to high level languages and
greatly simplify the problem space.
In most OOP graphical applications, there are a few common
components:
A domain model
A view/presentation layer
A controller layer that translates between the domain model and
the presentation layer
A persistence layer. This can be the filesystem or a database.
The principle behind the NO part of NOFS (Naked Objects) is that a
behaviorally complete domain model can be all that an application
needs if the other layers can be generated in an automated fashion.
For many applications the Naked Objects architecture reduces the
amount of development effort and complexity while producing a decent
application
The principle behind NOFS is that the fundamental structures or
domain objects of a filesystem should be all that need to be
implemented and the interface to any VFS layer or any persistence
mechanism (hard disk, database, filesystem) should be provided in an
automatic fashion.
With NOFS, it is possible to build a complete filesystem with a
single Java class containing no more than 50-60 lines of code and
little or no knowledge about the filesystem contract (operations like
truncate, read, write, seek, etc…) or the underlying storage
architecture (hard disk, files, etc…)
@RootFolderObject@DomainObject@FolderObject(CanAdd=false,CanRemove=false)publicclassBook{privateIDomainObjectContainer<Book>_bookContainer;privateIDomainObjectContainerManager_containerManager;@NeedsContainerpublicvoidsetContainer(IDomainObjectContainer<Book>container){_bookContainer=container;}@NeedsContainerManagerpublicvoidsetContainerManager(IDomainObjectContainerManagermanager){_containerManager=manager;}privateIDomainObjectContainerManagerGetContainerManager()throwsException{if(_containerManager--null){thrownewException("container manager is null");}return_containerManager;}publicList<Contact>getContacts()throwsException{IDomainObjectContainer<Contact>contactContainer=GetContainerManager().GetContainer(Contact.class);if(contactContainer--null){thrownewException("Container for Contact is null");}returnnewLinkedList<Contact>(contactContainer.GetAllInstances());}
With NOFS, the developer can fill in as many details as they are
concerned about.
If the developer wants to implement details about permissions, random
file access, persistence, caches, etc.. it is optional. Any details
left out are filled in by the NOFS framework with reasonable
defaults.
For application oriented filesystems - filesystems that are oriented
more towards behavior than storage - the developer does not need to
be concerned with any detail of the filesystem contract.
For storage oriented filesystems, the developer needs to manage more
details. Things like permissions, access / modify times, user, and
group ownership become more relevant.
NOFS - Architecture - Relation to FUSE and the OS¶
While developing NOFS, we realized that there were two common types
of application oriented filesystems
The first type is a local or mixed local / remote behavioral
filesystem. Something like the addressbook example that we
demonstrated earlier.
The second type that we discovered where filesystems that connected
to web services. One example we built was a NOFS filesystem in about
400-500 lines of code to mount a Flickr photo album as a folder of
pictures.
With the knowledge that RESTful services are very similar to
filesystems architecturally and how well NOFS was doing with
application oriented filesystems. We asked ourselves if we could make
accessing web services even easier.
While developing application filesystems for web services with NOFS,
we found that domain model modifications were roughly mapping one or
two FUSE operations to a HTTP verb.
So, our first attempt with RestFS has been to provide file and
configuration file pairs to map particular FS system calls onto
particular web methods.
This has allowed us to do things such as configure a file so that
when it is ’touched’ that a Google search can be performed with the
results stored to the file.