Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Objectify 4.0 and <threadsafe>true</threadsafe>
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vidal B.  
View profile  
 More options Nov 5 2012, 1:31 am
From: "Vidal B." <vidalborro...@gmail.com>
Date: Sun, 4 Nov 2012 22:31:34 -0800 (PST)
Local: Mon, Nov 5 2012 1:31 am
Subject: Objectify 4.0 and <threadsafe>true</threadsafe>

What is the proper way (or ways) to use Objectify 4.0 with the
<threadsafe>true</threadsafe> setting in an AppEngine app? The following is
in the "Caching" Wiki page, but what else should we be aware of?
The session cache is *not* thread-safe. You should never share an Objectify instance
between threads.

 - Also, on a side-note: is there a way to temporarily disable the session
cache for our own testing purposes - not involving ofy().clear()?

(Love Objectify, btw.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Schnitzer  
View profile  
 More options Nov 5 2012, 2:47 am
From: Jeff Schnitzer <j...@infohazard.org>
Date: Mon, 5 Nov 2012 02:47:37 -0500
Local: Mon, Nov 5 2012 2:47 am
Subject: Re: [objectify-appengine] Objectify 4.0 and <threadsafe>true</threadsafe>

On Mon, Nov 5, 2012 at 1:31 AM, Vidal B. <vidalborro...@gmail.com> wrote:
> What is the proper way (or ways) to use Objectify 4.0 with the
> <threadsafe>true</threadsafe> setting in an AppEngine app? The following
> is in the "Caching" Wiki page, but what else should we be aware of?
> The session cache is *not* thread-safe. You should never share an
> Objectify instance between threads.

Just don't share an Objectify instance between multiple requests (eg, put
it in a static context).  This is just normal programming in a servlet
environment.  Very few parts of the GAE SDK are officially thread-safe, so
this shouldn't be an unusual pattern.

>  - Also, on a side-note: is there a way to temporarily disable the session
> cache for our own testing purposes - not involving ofy().clear()?

Not at present.  Because of the way @Load works, it's not a trivial change.

Jeff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vidal B.  
View profile  
 More options Nov 6 2012, 9:19 pm
From: "Vidal B." <vidalborro...@gmail.com>
Date: Tue, 6 Nov 2012 18:19:42 -0800 (PST)
Local: Tues, Nov 6 2012 9:19 pm
Subject: Re: [objectify-appengine] Objectify 4.0 and <threadsafe>true</threadsafe>

Ok. Follow-up questions...

Given the following code:
Objectify objectifyInstance = ObjectifyService.factory().begin();

1) The javadoc for begin() indicates:

The default options are:

   - Do NOT begin a transaction.
   - *Do NOT use a session cache. *
   - DO use a global cache.
   - Use STRONG consistency.
   - Apply no deadline to calls.

But the wiki page says the session cache is enabled automatically. Is the
javadoc just out-of-date?

2) And just to double-check, is the above code the proper way to start a
new session (e.g. in a servlet's doPost() method) when running in
threadsafe-mode?

3) When using multiple Objectify instances, is there anything
(resource-wise) we need to deal with when an instance is about to be
discarded (e.g. at the end of a doPost() method)?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Schnitzer  
View profile  
 More options Nov 6 2012, 9:28 pm
From: Jeff Schnitzer <j...@infohazard.org>
Date: Tue, 6 Nov 2012 21:28:06 -0500
Local: Tues, Nov 6 2012 9:28 pm
Subject: Re: [objectify-appengine] Objectify 4.0 and <threadsafe>true</threadsafe>

Ooops, obsolete javadoc.  Fixed.

2) And just to double-check, is the above code the proper way to start a

> new session (e.g. in a servlet's doPost() method) when running in
> threadsafe-mode?

The proper way is to always call ofy(), the static method on
ObjectifyService.  You will always get the right session.  You should not
call begin() directly in your code.

All of the current documentation examples show the ofy() pattern.

3) When using multiple Objectify instances, is there anything

> (resource-wise) we need to deal with when an instance is about to be
> discarded (e.g. at the end of a doPost() method)?

No, there is nothing you need to do to close session.  But unless you
really know what you're doing (say, running two transactions in parallel)
you shouldn't even be asking this question - just use ofy() every time you
want to access Objectify.  If you need to escape a transaction temporarily,
use ofy().transactionless().load()...etc

Jeff
BTW:  4.0 beta 1 should be in Maven Central tomorrow.  Just waiting for
sonatype to approve the release.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vidal B.  
View profile  
 More options Nov 7 2012, 12:40 pm
From: "Vidal B." <vidalborro...@gmail.com>
Date: Wed, 7 Nov 2012 09:40:47 -0800 (PST)
Local: Wed, Nov 7 2012 12:40 pm
Subject: Re: [objectify-appengine] Objectify 4.0 and <threadsafe>true</threadsafe>

Thanks for clearing that up.

I was peeking around in the Objectify source, and I understand how it works
internally now...
static final ThreadLocal<Deque<Objectify>> STACK = new
ThreadLocal<Deque<Objectify>>();

I have peace of mind.

Keep up the great work, Jeff. Objectify is awesome!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »