Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 437277

Summary: Want best-effort filesystem listening
Product: [ECD] Orion Reporter: Evan Hughes <evan_hughes>
Component: ServerAssignee: Project Inbox <orion.server-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: ahunter.eclipse, john.arthorne
Version: unspecified   
Target Milestone: 7.0   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Evan Hughes CLA 2014-06-12 10:23:44 EDT
It would be useful to have a server-side notification mechanism for changes made via the Orion FS API (ie, stuff acting as a client). Complex mechanisms like locking and batching of events are out of scope. 

See https://jazz.net/jazz02/resource/itemName/com.ibm.team.workitem.WorkItem/115575
Comment 1 Evan Hughes CLA 2014-06-13 14:29:37 EDT
I've pushed the change to https://github.com/ehues/orion.server. I'm trying to push it to gerrit.
Comment 2 John Arthorne CLA 2014-07-14 15:29:26 EDT
Here is the Gerrit change:

https://git.eclipse.org/r/#/c/28509/
Comment 3 Anthony Hunter CLA 2014-07-15 12:41:43 EDT
Hi Evan,

I looked at your changes and they look good, but I have a few comments.

I initially had a bit of a problem "wrapping" my head around your wrapper pattern used in the FileStoreNotificationWrapper.

While the wrapper pattern you are using for IFileStore works fine, I am wondering if you can take advantage of IAdaptable instead. It is used all over the place in Eclipse while your wrapper pattern would be "new". IFileStore and IFileSystem are already IAdaptable so I think this would be a good fit. 

We should also change the name of IFilesystemModificationListener to IFileStoreModificationListener, since we are tracking modifications to an IFileStore. We do not use IFileSystem in Orion so likely should not introduce the term Filesystem. (i.e. Filesystem should be FileStore).

I would suggest that ChangeEvent be moved out into it's own class, renamed to FileStoreChangeEvent and have it extend EventObject.

I also think we could add a timeStamp field to FileStoreChangeEvent.

We also may want to distinguish between FileStoreChangeEvent.WRITE and CREATE versus UPDATE?

Once we turn this on, the first adopter should be the Indexer. Currently we reindex based on a Job timer, we can change this to only reindex changed files based on IFileSystem change event notifications.
Comment 4 Evan Hughes CLA 2014-07-15 16:32:20 EDT
Aww. I was hoping to see Gerrit in action. ;)

(In reply to Anthony Hunter from comment #3)
> While the wrapper pattern you are using for IFileStore works fine, I am
> wondering if you can take advantage of IAdaptable instead. It is used all
> over the place in Eclipse while your wrapper pattern would be "new".
> IFileStore and IFileSystem are already IAdaptable so I think this would be a
> good fit. 

  I'm not sure what that would look like. What adaptation should I participate in? Are you suggesting that instead of explicitly calling 'wrap()' I should call getAdapter(FileStoreNotificationWrapper.class) or something similar? 


> We should also change the name of IFilesystemModificationListener to
> IFileStoreModificationListener, since we are tracking modifications to an
> IFileStore. We do not use IFileSystem in Orion so likely should not
> introduce the term Filesystem. (i.e. Filesystem should be FileStore).

  Good point. 


> I would suggest that ChangeEvent be moved out into it's own class, renamed
> to FileStoreChangeEvent and have it extend EventObject.

  Alright. I guess the source would be the servlet that is requesting the object. 


> I also think we could add a timeStamp field to FileStoreChangeEvent.

  That would be the file/folder timestamp reported by the filesystem after the operation has completed? In SCM we've found that repeated writes can fall into the granularity of filesystem timestamp, so they are less useful than one would hope. ymmv.

  What's the use case?


> We also may want to distinguish between FileStoreChangeEvent.WRITE and
> CREATE versus UPDATE?

  What's the use case? 

  Do you want to do something beyond reading the flags passed into openOutputStream()?
Comment 5 Evan Hughes CLA 2014-07-16 10:27:51 EDT
I can't figure out how to push my new commit to Gerrit.
Comment 6 Paul Webster CLA 2014-07-16 10:33:11 EDT
(In reply to Evan Hughes from comment #5)
> I can't figure out how to push my new commit to Gerrit.

You can't do it from Orion at the moment.  If you're using EGit we can get it set up.

PW
Comment 7 Evan Hughes CLA 2014-07-16 11:10:49 EDT
(In reply to Paul Webster from comment #6)
> You can't do it from Orion at the moment.  If you're using EGit we can get
> it set up.

   Thanks, I'll come by.
Comment 8 Anthony Hunter CLA 2014-07-16 12:25:17 EDT
(In reply to Evan Hughes from comment #4)
> > I also think we could add a timeStamp field to FileStoreChangeEvent.
> 
>   That would be the file/folder timestamp reported by the filesystem after
> the operation has completed? In SCM we've found that repeated writes can
> fall into the granularity of filesystem timestamp, so they are less useful
> than one would hope. ymmv.
> 
>   What's the use case?

Your suggestion to use the filesystem timestamp is sufficient.
> 
> > We also may want to distinguish between FileStoreChangeEvent.WRITE and
> > CREATE versus UPDATE?
> 
>   What's the use case? 
> 
>   Do you want to do something beyond reading the flags passed into
> openOutputStream()?

Ok, I see you only notify of a write based on this action, so we are good.
Comment 9 Anthony Hunter CLA 2014-07-16 12:27:21 EDT
(In reply to Evan Hughes from comment #4)
> Aww. I was hoping to see Gerrit in action. ;)
> 
> (In reply to Anthony Hunter from comment #3)
> > While the wrapper pattern you are using for IFileStore works fine, I am
> > wondering if you can take advantage of IAdaptable instead. It is used all
> > over the place in Eclipse while your wrapper pattern would be "new".
> > IFileStore and IFileSystem are already IAdaptable so I think this would be a
> > good fit. 
> 
>   I'm not sure what that would look like. What adaptation should I
> participate in? Are you suggesting that instead of explicitly calling
> 'wrap()' I should call getAdapter(FileStoreNotificationWrapper.class) or
> something similar? 

I do not want to hold up the work so I will write up a what I had in mind when I get a chance.

I will push your latest changes in gerrit, they look ok.
Comment 10 Evan Hughes CLA 2014-07-16 13:18:01 EDT
Thanks Anthony.