any specific reason SienaFuture does not implement java.util.concurrent.Future interface

18 views
Skip to first unread message

Max

unread,
May 13, 2011, 11:40:33 PM5/13/11
to siena-...@googlegroups.com
Hi, 

AFAIK, GAE async calls (both datastore and urlfetch) will return their implementation of java.util.concurrent.Future. Any reason why SienaFuture not using it? Is that because to integrate with other DBs? Also, what it's SienaFuture equivalent of cancel / isCancelled / isDone / get(long timeout, TimeUnit unit) ? 

Max

unread,
May 14, 2011, 12:14:18 AM5/14/11
to siena-...@googlegroups.com
for asIterator / asIterable, how about hardcode some value at the moment?

like isDone always return true / isCancelled always return false??

What do you think?

Pascal Voitot Dev

unread,
May 14, 2011, 5:28:29 AM5/14/11
to siena-...@googlegroups.com
In fact I got inspired by objectify project which gave lots of ideas (If you look at the code, I tell it in a few classes ;) ).
At the beginning, I wanted to provide a simple Future but this interface from Java has the very bad idea to return checked exceptions!!!!!!
so your code ends with lots of try/catch everywhere and this is exactly what we try to prevent in Siena.
That's why, as Objectify proposed, the SienaFuture is just a Future without the Exception problem. It's a simple domain converter class catching chekced exceptions and translating them in Siena Runtime Exceptions.

The other reason also is that GAE functions return a Future object. But then when you call the Future.get() function on it, it returns a GAE entity and not a Siena Entity.
What we want when we call .get() is to retrieve a Siena Model.
So we need to do the mapping to Siena Model also when calling the .get().
That's why I encapsulate the GAE Future into a SienaFutureWrapper (directly inherited from Google FutureWrapper) which provides the mapping feature. Look at the GaeAsyncPersistenceManager to see how it is used.
This wrapper is itself encapsulated into a SienaFutureContainer which allows to hide the Java Future Exception problem.

Concerning the other functions of the Future interface, they are not provided in the SienaFuture but this is only because I didn't use them until now. In fact, I don't really see any problem providing them as the SienaFutureContainer just call the encapsulated Future.

I've just discovered after a few weeks without looking at my code that SienaFutureWrapper directly inherit Google FutureWrapper so for another DB, it shouldn't be very good :D... anyway, this is a first draft and it will need some enhancements IMO.

That's for your comments, it helps me reconsider things ;)
pascal

On Sat, May 14, 2011 at 5:40 AM, Max <theb...@gmail.com> wrote:
Hi, 

AFAIK, GAE async calls (both datastore and urlfetch) will return their implementation of java.util.concurrent.Future. Any reason why SienaFuture not using it? Is that because to integrate with other DBs? Also, what it's SienaFuture equivalent of cancel / isCancelled / isDone / get(long timeout, TimeUnit unit) ? 

--
You received this message because you are subscribed to the Google Groups "Siena" group.
To post to this group, send email to siena-...@googlegroups.com.
To unsubscribe from this group, send email to siena-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/siena-discuss?hl=en.

Pascal Voitot Dev

unread,
May 14, 2011, 5:38:28 AM5/14/11
to siena-...@googlegroups.com

Do you mean, when I call asIterable from the GaeAsyncPersistenceManager?
If we implement isDone/isCancelled, you advise to return hard coded values as those asIterator/asIterable functions doesn't provide Future yet even if they do everything asynchronously, is it what you mean?

I must admit that I had some tricky issues with List asynchronous fetching. the asList() is not asynchronous yet (at least 2 months ago) and I had to use asIterable() which is asynchronous and do some tricks with Future classes.

If you need examples, look at GaeAsyncTest unit tests, they give lots of examples of what can be done and I was even astonished by the potential of these features...
If you see stupid things that I may have misunderstood, don't hesitate. I'm not an expert in asynchronism and I spent lots of time studying GAE doc but this is not always very clear :)

Pascal
 
Reply all
Reply to author
Forward
0 new messages