Re: [appengine-java] Re: Objectify-Appengine, a typesafe data persistence tier for App Engine

2010-03-06 Thread Nacho Coloma
> About this I must disagree.  Everything I've learned about the
> appengine datastore says that unless you specifically need
> transactions, you should avoid using parent entities.
>
> When any entity is written, the optimistic concurrency journal is
> maintained for the root of the entity group.  If you make writes all
> over a large entity graph, they will all contend for the same journal,
> diminishing throughput.

I stand corrected - I misunderstood the explanation about entity
groups in the GAE documentation.

>> This _is_ redundant since internally GAE stores the owner inside the
>> Key field. So we settled for the simplest solution, that was to make
>> visible the Key system used by GAE. It also makes getting by primary
>> key more efficient, since you don't have to pass the class.
>
> You completely lost me with this one.  What's more efficient?  Using
> the datastore Key class means you get no help from the compiler.  If
> you pass Key objects around through methods you can very quickly lose
> track of what those keys are supposed to point to!  The generic
> Key may require a little more typing but it will
> significantly reduce the probability of bugs.

We are checking out the Key ancestor line while retrieving and storing
entities. As far as our experience went, this was the most common
source of bugs in our code, other than that we were fine. Of course
YMMV, and I can see your point.

> Objectify ofy1 = ObjectifyService.beginTransaction();
> Objectify ofy2 = ObjectifyService.beginTransaction();
>
> Foo foo = ofy1.get(Foo.class, 123);
> Bar bar = ofy2.get(Bar.class, 987);
>
> The transaction is bound to the object instance.  You can merrily work
> with ofy1 and ofy2 in separate transactions.

It's cleaner than the JDO alternative, but requires one Objectity
instance per transaction (or no transaction). We are doing it using
aspects (disclaimer: snapshot code):

@Transactional
public void put(Foo entity) {
   Transaction tx = transactionManager.beginTransaction();
   entityManager.put(tx, entity);
}

There is no need of commiting or rolling back, and you only need one
entityManager.

Different way of doing things, I will take a look at Objectify to see
what else I can learn :)

-- Nacho.
P.S.: hey GAE guys: can you add a datastore.getActiveTransactions()
method? We are storing the same info using a redundant ThreadLocal!
(GAE is doing the same, just make that information public :)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Objectify-Appengine, a typesafe data persistence tier for App Engine

2010-03-06 Thread John Patterson


On 6 Mar 2010, at 17:35, Nacho Coloma wrote:


-- Nacho.
P.S.: hey GAE guys: can you add a datastore.getActiveTransactions()
method? We are storing the same info using a redundant ThreadLocal!
(GAE is doing the same, just make that information public :)


Nacho, there is already a public  
DatastoreService.getActiveTransactions() that returns the threads open  
transactions.  Is this not what you want?


http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#getActiveTransactions()

--
You received this message because you are subscribed to the Google Groups "Google 
App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Objectify-Appengine, a typesafe data persistence tier for App Engine

2010-03-06 Thread Nacho Coloma
> Nacho, there is already a public DatastoreService.getActiveTransactions()
> that returns the threads open transactions.  Is this not what you want?
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#getActiveTransactions()

OK, now I am just embarrassed. I was searching exactly for that, I
even guessed the correct name, and somehow I missed it in my face.

I make great dumb moments sometimes.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: JDO Level2 Cache setup for dummies

2010-03-06 Thread datanucleus
> Is it possible that DN L2 caching in GAE drives down CPU milliseconds
> used but overall response times get slower?

Benefits of an L2 cache are subject to what you're doing (it's benefit
is for multiple PM's for a PMF accessing the same objects, and hence
providing a "quick" way of accessing them). Obviously the log tells
you timings of everything related to it.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Objectify-Appengine, a typesafe data persistence tier for App Engine

2010-03-06 Thread John Patterson
ha ha perhaps you could have designed the API... at least it shows you  
are thinking along the same lines as the Google Engineers :)


On 6 Mar 2010, at 18:01, Nacho Coloma wrote:

Nacho, there is already a public  
DatastoreService.getActiveTransactions()
that returns the threads open transactions.  Is this not what you  
want?

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html#getActiveTransactions()


OK, now I am just embarrassed. I was searching exactly for that, I
even guessed the correct name, and somehow I missed it in my face.

I make great dumb moments sometimes.

--
You received this message because you are subscribed to the Google  
Groups "Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com 
.
To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en 
.




--
You received this message because you are subscribed to the Google Groups "Google 
App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Threads in Java

2010-03-06 Thread wiilycy
I am doing a project where I will try to optimize google engine by using
multi-core cpus. So, now i am doing a research how the low API works in
order to find out if such an optimization is possible.

On Fri, Mar 5, 2010 at 7:20 PM, John Patterson wrote:

> Basically each request is a thread in app engine.  There are a couple of
> ways to create multiple requests:
>
>
>1. task queues - when you don't need to wait for a response
>2. async url fetch - when you do need the results of your threads
>
>
>
> On 5 Mar 2010, at 23:54, Marios wrote:
>
> Hello there,
> I've just read the documentation on Google App Engine and I realised
> that you cannot create any threads in an application. You can only use
> the main one which is created automatically with any runnable java
> program.
> I am wondering if there is the possibility to create threads using the
> low-level API datastore. I've searched the internet and didn't find an
> answer. If someone tried to create a new thread or knows for sure if
> you can create one, please reply to this message.
> Thank you very much,
>  Marios.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Threads in Java

2010-03-06 Thread itsnotvalid
Then it seems that App Engine is not the tool you want to use for this
research.

You may try paid services from other vendors, which generally would
have more resources available to you.

On Mar 6, 10:02 pm, wiilycy  wrote:
> I am doing a project where I will try to optimize google engine by using
> multi-core cpus. So, now i am doing a research how the low API works in
> order to find out if such an optimization is possible.
>
> On Fri, Mar 5, 2010 at 7:20 PM, John Patterson wrote:
>
>
>
> > Basically each request is a thread in app engine.  There are a couple of
> > ways to create multiple requests:
>
> >    1. task queues - when you don't need to wait for a response
> >    2. async url fetch - when you do need the results of your threads
>
> > On 5 Mar 2010, at 23:54, Marios wrote:
>
> > Hello there,
> > I've just read the documentation on Google App Engine and I realised
> > that you cannot create any threads in an application. You can only use
> > the main one which is created automatically with any runnable java
> > program.
> > I am wondering if there is the possibility to create threads using the
> > low-level API datastore. I've searched the internet and didn't find an
> > answer. If someone tried to create a new thread or knows for sure if
> > you can create one, please reply to this message.
> > Thank you very much,
> >  Marios.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Google App Engine for Java" group.
> > To post to this group, send email to
> > google-appengine-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Should I use JPA or JDO for DataStore?

2010-03-06 Thread itsnotvalid
Just in cast I want to make use of some existing Java APIs for messing
with DataStore, which may be the low-level API would work the best.

I just wonder, as I am still a college student, one of my lecturer
told me that "we should use JPA (2.0) now as JDO is not the preferred
way for persisting data in JavaEE anymore."

I just wonder, however, for the case with App Engine (which now most
of my assignments are implemented using JPA 2.0 with EclipseLink,
however,) is it best to use JPA or should I follow most tutorials and
use JDO instead?

In view of the implementation of both APIs in App Engine, which one is
more robust, or which would is better in terms of performance?

Hope to see Google staff to answer this newbie question.

Thanks.

Alan(@itsnotvalid)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Best practices for datastore and JDO?

2010-03-06 Thread objectuser
I think the gap here is that a RDBMS (PostgreSQL) and the App Engine
Datastore are totally different.  In fact, I think the latter
influences your design much more than the former.

The sorts of joins you used to be able to do in your DB to efficiently
retrieve data don't work in the GAE datastore.  You need to build your
data model around the queries you want to run efficiently.  To say
again, your data needs to be modeled to support your most important
queries.

I go through some of the reasoning in the modeling section of my blog
(I've been away from GAE for a while so some of this could have
changed):

http://objectuser.wordpress.com/google-app-engine/

However, if you've not done so, I highly recommend reading the Google
documentation:

http://code.google.com/appengine/docs/java/datastore/

On Mar 5, 6:54 am, vennervald  wrote:
> Hi Guys
>
> We have a small application running on JBoss, Seam, Hibernate and
> PostgreSQL that we are thinking about moving to GAE/J.
> To test the datastore we uploaded our data 1-1 so all our tables from
> Postgres were represented as entity types in the datastore with the
> entities relating to eachother through their keys.
> As a proof of concept of the performance of the datastore, we did an
> implemented one of our heaviest reports by joining 6 entities
> together. And the performance proved to be really bad. Infact we
> received the deadline exception before we got to join all the
> entities. From the platform we are running on now, this could be done
> in less than a second.
> This doesn't tell me that Google datastore is worthless. It tells me,
> that I'm doing something wrong, and that I need to think differently
> about the data structures to make it perform on GAE.
> I've been looking around and I can't seem to find really good sources
> on datastore/JDO best practises.
> Does anybody have any good resources on this toppic?
> I would really apriciate your help.
>
> /Jacob :)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Should I use JPA or JDO for DataStore?

2010-03-06 Thread objectuser
Since you're a student, and if you have the time, I'd recommend
learning JDO for the following reasons:
1. You already know JPA.  Might as well learn something new. :)
2. JDO, imo, fits the GAE datastore much better (I think there are
quite a few discussions around here as to why).

Enjoy!

On Mar 6, 8:28 am, itsnotvalid  wrote:
> Just in cast I want to make use of some existing Java APIs for messing
> with DataStore, which may be the low-level API would work the best.
>
> I just wonder, as I am still a college student, one of my lecturer
> told me that "we should use JPA (2.0) now as JDO is not the preferred
> way for persisting data in JavaEE anymore."
>
> I just wonder, however, for the case with App Engine (which now most
> of my assignments are implemented using JPA 2.0 with EclipseLink,
> however,) is it best to use JPA or should I follow most tutorials and
> use JDO instead?
>
> In view of the implementation of both APIs in App Engine, which one is
> more robust, or which would is better in terms of performance?
>
> Hope to see Google staff to answer this newbie question.
>
> Thanks.
>
> Alan(@itsnotvalid)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] 1.3.1 Security Fallout

2010-03-06 Thread Steve Pritchard
Under 1.2.8 and 1.3.0 I created a SocketLogger that was extremely
useful in sending messages to a second machine in my development
enviroment so I could easily see what was going on in the AppServer
handlers.

Previously under Eclipse I put a jar in  plugins/version-str/appengine-
java-sdk-1.x.x/lib/shared
and as expected it bypassed the security for the classes in this
special jar. ie.  They could open a socket.

I had to make sure that the app-engine SDK was in the class path
before any other copies of the socket using class.

Now under 1.3.1 this technique does not work, even if the SDK lib is
the only occurrence of the socket using class.

Has the security model changed?

This technique presents no security exposure to the production
environment since I cannot insert the special jar into that
environment.  My software automatically detects the environment and
turns off accessing these special features.

Any help would be appreciated.  This second screen is a great
productivity booster.

Thanks,
Steve Pritchard

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: Best practices for datastore and JDO?

2010-03-06 Thread Sandeep Sathaye
Relational theory, SQL and JDBC are functional specifications and RDBMS
vendors implement these specifications. Actually speaking data model has
nothing to do with technology. A data model in software
engineering is
an abstract model  that
describes how data  is
represented and accessed. Data models formally define data
elements and
relationships among data elements for a domain of interest.

The principles you mentioned in your blog are correct but the difference is
that Cloud2db applies these principles without exposing these to designers
and developers. In short Cloud2db engine extrapolates proper strategy for
storing and accessing data based on your data model. There will be instances
where you will need to adjust your model for better performance. But don't
you do the same with RDBMS? Don't you de-normalize your models in certain
scenarios for better performance?

On Sat, Mar 6, 2010 at 9:49 AM, objectuser  wrote:

> I think the gap here is that a RDBMS (PostgreSQL) and the App Engine
> Datastore are totally different.  In fact, I think the latter
> influences your design much more than the former.
>
> The sorts of joins you used to be able to do in your DB to efficiently
> retrieve data don't work in the GAE datastore.  You need to build your
> data model around the queries you want to run efficiently.  To say
> again, your data needs to be modeled to support your most important
> queries.
>
> I go through some of the reasoning in the modeling section of my blog
> (I've been away from GAE for a while so some of this could have
> changed):
>
> http://objectuser.wordpress.com/google-app-engine/
>
> However, if you've not done so, I highly recommend reading the Google
> documentation:
>
> http://code.google.com/appengine/docs/java/datastore/
>
> On Mar 5, 6:54 am, vennervald  wrote:
> > Hi Guys
> >
> > We have a small application running on JBoss, Seam, Hibernate and
> > PostgreSQL that we are thinking about moving to GAE/J.
> > To test the datastore we uploaded our data 1-1 so all our tables from
> > Postgres were represented as entity types in the datastore with the
> > entities relating to eachother through their keys.
> > As a proof of concept of the performance of the datastore, we did an
> > implemented one of our heaviest reports by joining 6 entities
> > together. And the performance proved to be really bad. Infact we
> > received the deadline exception before we got to join all the
> > entities. From the platform we are running on now, this could be done
> > in less than a second.
> > This doesn't tell me that Google datastore is worthless. It tells me,
> > that I'm doing something wrong, and that I need to think differently
> > about the data structures to make it perform on GAE.
> > I've been looking around and I can't seem to find really good sources
> > on datastore/JDO best practises.
> > Does anybody have any good resources on this toppic?
> > I would really apriciate your help.
> >
> > /Jacob :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine-java+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] MemCache development mode persistence

2010-03-06 Thread Steve Pritchard
I was looking for a way to persist my MemCache so I could do
production like testing in development mode to make sure I correctly
handle various use cases.

I tried writing a file using the technique described in
 
http://groups.google.com/group/google-appengine-java/browse_thread/thread/cdd3abc956a2fba1#
but it failed for the same reason. (Security exception
java.security.AccessControlException: access denied
(java.io.FilePermission .\persist\cache.byt write)

Is there a way to persist MemCache between server restarts. I have not
found in the documentation.

I want to avoid writing via Datanucleus because I am trying to do a
warm start without hitting the startup latency that it involves.

Thanks,
Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Request was aborted

2010-03-06 Thread Henning
Hello,

I have one chron job that should be triggered every minute once. I
have now the problem that about every 5 minutes the following warning
occurs. I also notice that the datastore gets stuck sometimes leading
to a timeout. The later happens maybe every hour or something once.
Ther is really no load yet and every request should not take more than
maybe 2-4 seconds. What can I do about it? What does this warning
mean?

Henning.

Warning:


#

   1.
  03-06 09:07AM 23.164 /cron/chatUserCleanup 500 10125ms 0cpu_ms
0kb
  See details

  0.1.0.1 - - [06/Mar/2010:09:07:33 -0800] "GET /cron/
chatUserCleanup HTTP/1.1" 500 0 - - "studyhebrewonline.appspot.com"

   2.
  W 03-06 09:07AM 33.289

  Request was aborted after waiting too long to attempt to service
your request. Most likely, this indicates that you have reached your
simultaneous dynamic request limit. This is almost always due to
excessively high latency in your app. Please see
http://code.google.com/appengine/docs/quotas.html for more details.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: MemCache development mode persistence

2010-03-06 Thread Steve Pritchard
SOLUTION:
I wrote it to the Datastore myself using the low-level API.

But socket I/O would be nice in the development environment.

Steve Pritchard

On Mar 6, 12:06 pm, Steve Pritchard  wrote:
> I was looking for a way to persist my MemCache so I could do
> production like testing in development mode to make sure I correctly
> handle various use cases.
>
> I tried writing a file using the technique described in
>  http://groups.google.com/group/google-appengine-java/browse_thread/th...
> but it failed for the same reason. (Security exception
> java.security.AccessControlException: access denied
> (java.io.FilePermission .\persist\cache.byt write)
>
> Is there a way to persist MemCache between server restarts. I have not
> found in the documentation.
>
> I want to avoid writing via Datanucleus because I am trying to do a
> warm start without hitting the startup latency that it involves.
>
> Thanks,
> Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] transaction 'scope', unexpected behaviour

2010-03-06 Thread AJ

I am seeing some transaction-related behaviour, using JDO and GAE
1.3.1, that puzzles me.

I get an exception if I do something like the following.  All entities
below are in separate entity groups:

  PersistenceManager pm = PMF.get().getPersistenceManager();
  //... fetch entity a1 of kind A, modify a1...

  // create or update several instances of kind 'B' (none share an
entity group)
  for (String i: coll) {
Transaction tx = pm.currentTransaction();
tx.begin();
//... create or update instance i of kind B, make persistent
tx.commit();
  }

  // ...
  pm.close();

Each transaction only includes work on a single entity (of kind B).
However, the transactions throw the "can't operate on multiple entity
groups in a single transaction" exception with respect to kinds A and
B.  Note that entity a1 was NOT actually part of any transactional
activity but *was* accessed first as part of the PersistenceManager
session.

When I use a second different PersistenceManager session for the
series of transactions (and make no other code mods), all is well.
e.g.:

  PersistenceManager pm = PMF.get().getPersistenceManager();
  //... fetch entity A1 of kind A, modify A1...

  PersistenceManager pm2 = PMF.get().getPersistenceManager();
  // create or update several instances of kind 'B' (none share an
entity group)
  for (String i: coll) {
Transaction tx = pm2.currentTransaction();
tx.begin();
//... create or update instance i of kind B, make persistent
tx.commit();
  }
  pm2.close();

  // ...
  pm.close();

Here, each of the different instances of kind B are in their own
individual entity group, but the series of transactions can share a
PersistenceManager session without error.
But, sharing a PersistenceManager session with the entity of kind A
was problematic.   Is it that one can't 'mix' transactions and non-
transactional operations in the same PersistenceManager session?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Children in an owned one-to-many relationship not being retrieved, what am I doing wrong?

2010-03-06 Thread tempy
I have the following 3-part owned relationship...

Users, the root entity, have a collection of Decks, as such (I am not
including the specific subclass of User as it doesn't seem to be
relevant):

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
public abstract class User {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
protected Key _ID;

@Persistent
protected String _UniqueIdentifier;

@Persistent(defaultFetchGroup = "true", mappedBy = "_Owner")
@Element(dependent = "true")
protected Set _Decks;

protected KleioUser()
{
}
}

Each Deck has a collection of Cards, as such:
@PersistenceCapable
public class Deck {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key _ID;

@Persistent
String _Name;

@Persistent(defaultFetchGroup = "true", mappedBy = "_Parent")
@Element(dependent = "true")
private Set _Cards =  new HashSet();

@Persistent
private Set _Tags = new HashSet();


@Persistent
private KleioUser _Owner;

}

And finally, each card:

@PersistenceCapable
public class Card {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key _ID;

   @Persistent
private Text _Question;
@Persistent
private Text _Answer;
@Persistent
private Deck _Parent;
}

I've only run this on the dev server.  When I create a new user and
populate the corresponding decks and corresponding cards and then call
pm.makepersistent(user), everything looks fine and I can see all the
user, deck, and card entities in the development datastore.  However,
when I try to retrieve a user with the following query:

Query query = _pm.newQuery(SpecificUser.class);
query.setFilter("_UniqueIdentifier == TheUser");
query.declareParameters("String TheUser");

try {
List results = 
(List)query.execute(ID);

if(results.size() == 0)
return null;
else
return results.get(0);

} finally {
query.closeAll();
}

I get the user just fine, and all the user's corresponding decks.  But
the decks have no cards.  "Touching" the deck's cards collection with
a .size() method doesn't load the cards, just returns 0, nor does
setting the cards to the default fetch group.  I also tried to set the
pm's fetchplan to -1, but that didn't have the desired effect either.

The weird thing is that if I persist the Deck without a parent user,
then I will get the deck back, along with all its cards, with no
problems.

I've tried a lot of other things too and I'm starting to run low on
ideas (and high on frustration), so any help would be appreciated.

Thanks,
Mike

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Task Queue Problems

2010-03-06 Thread rletness
Ok so either I'm doing something really stupid or I can't get a simple
task to execute.  I have defined a task worker at /tasks/foo.

I can hit /tasks/foo no problem and the code executes fine (just a
simple servlet of course).  The problem is when I add a task to the
queue like:

queue.add(TaskOptions.Builder.url("/tasks/foo").method(Method.GET));

I can't seem to get the code in the task servlet to execute.  If I
check the queue in admin console it shows a task executed and in the
request logs it shows that /foo/task was called and returned 200, but
the code never executed.  Just to make sure I wasn't insane I modified
the task servlet to simply throw a RuntimeException so it would return
500.  When invoked manually, it returns 500 as expected, but when
invoked through the task queue, it shows /tasks/foo returning 200.
Any ideas?

Here is the request log.  The first request is the one i invoked
manually from the browser and the second is one invoked by the task
queue.  It shows the first returning 500 (as expected) but the second
returns 200.

   1.
  03-05 06:38PM 54.097 /tasks/foo 500 37ms 38cpu_ms 3kb Mozilla/
5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.8) Gecko/
20100202 Firefox/3.5.8,gzip(gfe),gzip(gfe)



   1.
  03-05 06:37PM 54.803 /tasks/foo 200 60ms 19cpu_ms 3kb AppEngine-
Google; (+http://code.google.com/appengine)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Emails sending from AppEngine (javax.mail) never received on free.fr domain

2010-03-06 Thread raoul
hi,
All emails sent from my App to free.fr domain are never received. I
received the following response from their server:
"IP 209.85.221.110 is blacklisted for 85775s (too many errors
(unexisting recipients, broken connections), rejecting mail)"

On other domains, all emails are received.
How I can have more information about this error ? Is my code
responsible of this failure ?

Raoul

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Updating a simple boolean

2010-03-06 Thread A1programmer
I'm trying to update a simple boolean value on a collection of objects
returned by a query.  The objects are being returned, and I set the
value on the bean, then persist, but it's not working. What am I
missing?

The Submission class has a "notifyAfter" as a Long (raw date), and an
"isNotified" Boolean.



public void notifySubmissions( ){

PersistenceManager pm = pmf.getPersistenceManager();

Long rawDate = new Date().getTime() ;

Query query = pm.newQuery(Submission.class);
query.setFilter("rawDate >= notifyAfter && isNotified == false");

query.declareParameters("Long rawDateParam");

try {

List results = (List)
query.execute( rawDate);


if ( results.size() > 0 ) {
log.info(" " + results.size() + " results found");

Properties props = new Properties();
Session session = Session.getDefaultInstance(props, 
null);

for (Submission s : results) {

log.info("Emailing: " + s.getEmail());
Boolean mailed = true;

try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("...", 
"...") );

msg.setText( ... );

msg.addRecipient(Message.RecipientType.TO, 
new
InternetAddress(s.getEmail()));

msg.setSubject("... Notification");


Transport.send(msg);
log.info("Mail sent to: " + s.getEmail());

} catch (AddressException ae) {
log.warning( ae.getMessage() );
mailed = false;
} catch (Exception e2) {
mailed = false;
log.warning( e2.getMessage() );
}

if (mailed){
s.setIsNotified(true);
pm.makePersistent( s );
}

}
} else {
   log.info("No results found");
}
} finally {
query.closeAll();
}

}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Task queue not starting the action when expected

2010-03-06 Thread kazunori_279
Hi,

I've experienced the same phenomenon so that I added a new issue for
this:

http://code.google.com/p/googleappengine/issues/detail?id=2924

Thanks,

Kaz

On Feb 26, 8:05 am, Jerome  wrote:
> Hello,
>
> We have been using task queues for a few months without problem. We
> handle actions that must execute right away.
>
> At the time of the release of 1.3.1, we noticed that sometimes, some
> tasks will take 1 to 2 minutes to start, but in the task queue, the
> ETA shows as a date in the past (like 0:01:12 ago), usually 1 second
> or so after the creation time.
>
> This is not a consistent issue. I might works perfectly (task being
> kicked in within 1 second of creation) for several times and suddenly,
> the next task takes 1.5 minutes to get started.
>
> Our task queue is empty when we see this issue.
> Our queue is setup with a max rate of 5/s and a bucket size of 1.
>
> Any idea of what we can do to work around or solve this new issue?
>
> Jerome

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.