Bug 198683 - [EFS][Doc] Add Javadoc how concurrently open Streams should be handled
Summary: [EFS][Doc] Add Javadoc how concurrently open Streams should be handled
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2007-08-02 10:59 EDT by Martin Oberhuber CLA
Modified: 2009-05-06 10:14 EDT (History)
2 users (show)

See Also:


Attachments
Proposal v01 (4.44 KB, patch)
2009-05-06 09:22 EDT, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2007-08-02 10:59:18 EDT
Javadoc for IFileStore#openInputStream() seems to assume that the EFS Provider implementation is always capable of opening an additional stream -- at least the "reasons include" for exceptions does not talk about the case where no more streams are available.

The problem for EFS providers is, that they cannot keep an arbitrary number of stream open. Typical SSH / Sftp servers, for instance, allow only 4 concurrent file download sessions to be open at the same time. For FTP, only a single stream at a time may be supported.

Clients may be interested in keeping a stream open for longer. But when a client has used up all available streams, what should the provider do? Is there a minumum number of concurrently open streams that it must support? Should it just throw a CoreException saying "no more streams"? Should it retreat to downloading the entire requested file to a temp location and return a stream to that file? Should there be a timeout after which pending open streams are closed automatically? Or should openStram() requests just be queued, such that the progress for a new openInputStream() would be stalled infinitely until a new handle gets available by closing another stream?

I think that Javadoc for
  IFileStore#openInputStream()
  IFileStore#openOutputStream()
should
  1. Make clients aware that the number of concurrently open streams can be
     very limited, and they are encouraged to close open streams as soon as
     possible.
  2. Define the behavior that providers should expose in case they run out
     of available streams (supposedly just throw an exception; queueing
     requests would be another option though more risky I'd guess; perhaps
     there should be a queuing time of e.g. 20 seconds and throwing the
     "no more streams" exception afterwards).
  3. Potentially define a minimum number of streams that an EFS provider
     must support in order to be valid. For instance, one could require
     that the bare mimimum is to support 
       - one open input stream
       - one open output stream
       - plus the capability to do childNames() or fetchInfo() concurrently
         while the two streams are open.
     For providers like FTP, this would mean that they need to support
     3 concurrent connections at the same time.
     Another option would be to allow providers only support a single
     stream at any one time, so "well behaving" clients should not assume
     they can keep multiple streams open.

Any comments on that issue?
Comment 1 John Arthorne CLA 2007-08-06 23:35:03 EDT
1 and 2 sound reasonable. For 3, I don't like the idea of creating an arbitrary limit. A very simple client could function on an implementation that only supported a single connection, so it would be overly restrictive to define such a limit - it would prevent certain uses that would otherwise be fine.
Comment 2 Martin Oberhuber CLA 2007-08-07 09:50:14 EDT
Ok, so it looks like to improve the Javadoc for
  IFileStore#getInputStream()
  IFileStore#getOutputStream()
in the following ways:

1. Tell clients that the number of concurrently open Streams can be limited, the
   limit can depend on the Provider, and may be as low as only 1; so, the client
   should close the Stream as soon as it can
2. Specify that a CoreException can be thrown when no more Streams are 
   available
3. Specify that providers _may_ enqueue the get*Stream() request
   in case no Streams are available, such that they wait until a Stream
   becomes available or the (maximum timeout?) expires and they fire a
   "no more streams" CoreException. We may want to discuss what that 
   timeout could be, perhaps it should be free for the provider to choose.
   At any rate, while the Provider waits for a Stream, it should periodically
   check the IProgressMonitor so the request can be canceled when it takes
   too long.

Because these are all changes of Javadoc, I changed the Summary to more clearly reflect what we want (previous value was: "Need advice how providers should handle multiple open streams")
Comment 3 Martin Oberhuber CLA 2007-08-08 08:43:16 EDT
Looking at the FileStore#copy() implementation, which is also referenced by FileStore#move(), it seems that the minimum requirement for a proper EFS provider is to support 
   1 InputStream
   1 OutputStream
in parallel (or, the provider would need to override the copy() and move() operations such that it works with a single Stream only).
Comment 4 Szymon Brandys CLA 2007-12-13 08:13:13 EST
Martin, are you considering providing the patch?


Comment 5 Kevin McGuire CLA 2008-06-10 15:08:15 EDT
We're past the time for this kind of item for 3.4. Please move milestone.
Comment 6 Szymon Brandys CLA 2008-06-11 04:35:04 EDT
I think that the EFS chapter in the dev guide should be updated along with javadocs. It's not too late for such bugs, however I will take care of it during 3.5.
Comment 7 Szymon Brandys CLA 2009-05-06 09:22:08 EDT
Created attachment 134609 [details]
Proposal v01
Comment 8 John Arthorne CLA 2009-05-06 10:01:15 EDT
+1. The only change is "has exceeded" should be changed to "has been exceeded".
Comment 9 Szymon Brandys CLA 2009-05-06 10:14:35 EDT
Thanks John. The update to javadoc released to HEAD.