[appengine-java] Re: Persistable JDO object - low-level entity?
Ikai, Thanks for the response. The issue is that I have two types of objects that need to be persisted: (1) a bunch of JDO managed objects (2) a bunch of low-level Entity objects. Is there any way that I could batch put all of them at once through the same API rather then calling the JDO api followed by the low-level api? On Nov 24, 5:09 pm, Ikai L (Google) ika...@google.com wrote: Erem, You can use the makePersistentAll() method of PersistenceManager to batch put items. See here: http://code.google.com/appengine/docs/java/datastore/creatinggettinga... This was introduced in SDK 1.2.5. On Mon, Nov 23, 2009 at 2:37 PM, Erem ehb...@gmail.com wrote: Hey all, Are there any built in tools in the API to translate a managed JDO object into a low-level Entity? I want to do a batch put of some JDO-managed objects and some low- level Entities. If I could translate JDO-managed objects into bigtable Entities, I could do this in one call to the low-level API rather than one call to persistenceManager.makePersistentAll(Collection) and another to datastoreService.put(IterableEntity). Thanks for the help! Erem -- 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=. -- Ikai Lan Developer Programs Engineer, Google App Engine -- 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] Persistable JDO object - low-level entity?
Hey all, Are there any built in tools in the API to translate a managed JDO object into a low-level Entity? I want to do a batch put of some JDO-managed objects and some low- level Entities. If I could translate JDO-managed objects into bigtable Entities, I could do this in one call to the low-level API rather than one call to persistenceManager.makePersistentAll(Collection) and another to datastoreService.put(IterableEntity). Thanks for the help! Erem -- 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=.
[appengine-java] Batched gets via pm.getObjectsById
Is there any particular reason that persistenceManager.getObjectsById isn't optimized to perform batch gets like the low-level API does? Seems like it would make sense and it would also make my current optimization problem easier. Context The getObjectsById function hasn't been optimized to perform a batch get, so you're just as well-off issuing multiple calls to getObjectById. If you need to issue a batch get, you'll need to use the low-level API. (http://groups.google.com/group/google-appengine-java/browse_thread/ thread/53f9acc11b6d1a84/4af4368394521b2f? lnk=gstq=newObjectIdInstance#4af4368394521b2f) -- 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=.
[appengine-java] Re: Session destruction events, API availability therein
Hi Jason, Thanks for the response. I'm seeing it in the development environment. I can't even get ahold of a stack trace in production because the logged events I try to throw just aren't reaching the Logs manager. I do know that it's not working, however, because the object doesn't get inserted in the following code. Here's some sample code to show what's happening, and a stack trace of the error it throws public class SessionListener implements HttpSessionListener { private static final Logger log = Logger .getLogger(DataNucleus.JDO); @Override public void sessionCreated(HttpSessionEvent ev) { System.out.println(Session starting); ev.getSession().setMaxInactiveInterval(2); } @Override public void sessionDestroyed(HttpSessionEvent ev) { try { System.out.println(Session ending); PersistenceManager pm = PMF.get().getPersistenceManager(); System.out.println(pm); PersistMe me = new PersistMe(); me.setName(Erem); pm.makePersistent(me); pm.close(); System.out.println(Session ended); } catch (Exception e) { log.log(Level.SEVERE, Failed in session cleanup, e); } } } This code, when run from the dev server makes this error Sep 11, 2009 3:50:53 PM lotr.server.SessionListener sessionDestroyed SEVERE: Failed in session cleanup java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId (DatastoreApiHelper.java:63) at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace (DatastoreApiHelper.java:73) at com.google.appengine.api.datastore.Key.init(Key.java:100) at com.google.appengine.api.datastore.Key.init(Key.java:85) at com.google.appengine.api.datastore.Key.init(Key.java:81) at com.google.appengine.api.datastore.Entity.init(Entity.java:103) at com.google.appengine.api.datastore.Entity.init(Entity.java:84) at org.datanucleus.store.appengine.DatastoreFieldManager.init (DatastoreFieldManager.java:167) at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject (DatastorePersistenceHandler.java:178) at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent (JDOStateManagerImpl.java:3185) at org.datanucleus.state.JDOStateManagerImpl.makePersistent (JDOStateManagerImpl.java:3161) at org.datanucleus.ObjectManagerImpl.persistObjectInternal (ObjectManagerImpl.java:1298) at org.datanucleus.ObjectManagerImpl.persistObject (ObjectManagerImpl.java:1175) at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent (JDOPersistenceManager.java:669) at org.datanucleus.jdo.JDOPersistenceManager.makePersistent (JDOPersistenceManager.java:694) at lotr.server.SessionListener.sessionDestroyed(SessionListener.java: 26) at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession (AbstractSessionManager.java:661) at org.mortbay.jetty.servlet.AbstractSessionManager$Session.timeout (AbstractSessionManager.java:918) at org.mortbay.jetty.servlet.HashSessionManager.scavenge (HashSessionManager.java:200) at org.mortbay.jetty.servlet.HashSessionManager.access$000 (HashSessionManager.java:36) at org.mortbay.jetty.servlet.HashSessionManager$1.run (HashSessionManager.java:144) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) On Sep 11, 11:37 am, Jason (Google) apija...@google.com wrote: Hi Erum. Are you seeing this error in the development environment or in production? - Jason On Wed, Sep 9, 2009 at 5:43 PM, Erem ehb...@gmail.com wrote: Hey All, What is the best way to tie into session destruction events? I have implemented an HttpSessionListener and put it in my web.xml. The SessionListener gets called, but any attempt to do DataStore or URLFetch API calls within sessionDestroyed results in errors. For example, the JDO API throws: Exception in thread Timer-125 java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId (DatastoreApiHelper.java:63) at com.google.appengine.api.datastore.QueryTranslator.convertToPb (QueryTranslator.java:35) My app has constructs of Visitors (anyone who comes to the site) and Users (verified accounts). The former's data get stored in sessions, the latter explicitly in the datastore. Every User has an ArrayListVisitor, listing the visitors currently logged in to the User's account. When a session
[appengine-java] Re: Session destruction events, API availability therein
The same code in a request works fine btw. On Sep 11, 3:54 pm, Erem ehb...@gmail.com wrote: Hi Jason, Thanks for the response. I'm seeing it in the development environment. I can't even get ahold of a stack trace in production because the logged events I try to throw just aren't reaching the Logs manager. I do know that it's not working, however, because the object doesn't get inserted in the following code. Here's some sample code to show what's happening, and a stack trace of the error it throws public class SessionListener implements HttpSessionListener { private static final Logger log = Logger .getLogger(DataNucleus.JDO); @Override public void sessionCreated(HttpSessionEvent ev) { System.out.println(Session starting); ev.getSession().setMaxInactiveInterval(2); } @Override public void sessionDestroyed(HttpSessionEvent ev) { try { System.out.println(Session ending); PersistenceManager pm = PMF.get().getPersistenceManager(); System.out.println(pm); PersistMe me = new PersistMe(); me.setName(Erem); pm.makePersistent(me); pm.close(); System.out.println(Session ended); } catch (Exception e) { log.log(Level.SEVERE, Failed in session cleanup, e); } } } This code, when run from the dev server makes this error Sep 11, 2009 3:50:53 PM lotr.server.SessionListener sessionDestroyed SEVERE: Failed in session cleanup java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId (DatastoreApiHelper.java:63) at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamespace (DatastoreApiHelper.java:73) at com.google.appengine.api.datastore.Key.init(Key.java:100) at com.google.appengine.api.datastore.Key.init(Key.java:85) at com.google.appengine.api.datastore.Key.init(Key.java:81) at com.google.appengine.api.datastore.Entity.init(Entity.java:103) at com.google.appengine.api.datastore.Entity.init(Entity.java:84) at org.datanucleus.store.appengine.DatastoreFieldManager.init (DatastoreFieldManager.java:167) at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject (DatastorePersistenceHandler.java:178) at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent (JDOStateManagerImpl.java:3185) at org.datanucleus.state.JDOStateManagerImpl.makePersistent (JDOStateManagerImpl.java:3161) at org.datanucleus.ObjectManagerImpl.persistObjectInternal (ObjectManagerImpl.java:1298) at org.datanucleus.ObjectManagerImpl.persistObject (ObjectManagerImpl.java:1175) at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent (JDOPersistenceManager.java:669) at org.datanucleus.jdo.JDOPersistenceManager.makePersistent (JDOPersistenceManager.java:694) at lotr.server.SessionListener.sessionDestroyed(SessionListener.java: 26) at org.mortbay.jetty.servlet.AbstractSessionManager.removeSession (AbstractSessionManager.java:661) at org.mortbay.jetty.servlet.AbstractSessionManager$Session.timeout (AbstractSessionManager.java:918) at org.mortbay.jetty.servlet.HashSessionManager.scavenge (HashSessionManager.java:200) at org.mortbay.jetty.servlet.HashSessionManager.access$000 (HashSessionManager.java:36) at org.mortbay.jetty.servlet.HashSessionManager$1.run (HashSessionManager.java:144) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) On Sep 11, 11:37 am, Jason (Google) apija...@google.com wrote: Hi Erum. Are you seeing this error in the development environment or in production? - Jason On Wed, Sep 9, 2009 at 5:43 PM, Erem ehb...@gmail.com wrote: Hey All, What is the best way to tie into session destruction events? I have implemented an HttpSessionListener and put it in my web.xml. The SessionListener gets called, but any attempt to do DataStore or URLFetch API calls within sessionDestroyed results in errors. For example, the JDO API throws: Exception in thread Timer-125 java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId (DatastoreApiHelper.java:63) at com.google.appengine.api.datastore.QueryTranslator.convertToPb (QueryTranslator.java:35) My app has constructs of Visitors (anyone who comes to the site) and Users (verified accounts). The former's data get
[appengine-java] Session destruction events, API availability therein
Hey All, What is the best way to tie into session destruction events? I have implemented an HttpSessionListener and put it in my web.xml. The SessionListener gets called, but any attempt to do DataStore or URLFetch API calls within sessionDestroyed results in errors. For example, the JDO API throws: Exception in thread Timer-125 java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId (DatastoreApiHelper.java:63) at com.google.appengine.api.datastore.QueryTranslator.convertToPb (QueryTranslator.java:35) My app has constructs of Visitors (anyone who comes to the site) and Users (verified accounts). The former's data get stored in sessions, the latter explicitly in the datastore. Every User has an ArrayListVisitor, listing the visitors currently logged in to the User's account. When a session is destroyed, meaning a Visitor has left, I want to remove that visitor from the user's Logged in ArrayList. Having trouble thinking of another way to do it =( Any advice would be much appreciated. Erem --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[appengine-java] Re: Warning message about junit plugin from datanucleus in my logs when running Junit tests
I just found out that it all gets spammed as a response to JDOHelper.getPersistenceManagerFactory(). It only happens when running the Local Service implementation as specified on the AppEngine wiki On Sep 8, 3:34 pm, Erem ehb...@gmail.com wrote: Hi Rajeev, Thanks for the response! It's a normal JUnit launch config. There are only 2 classpath entries in my launch config: --- v Bootstrap Entries JRE System Library [jre1.6.0_15 - 32-bit[ v User Entries MyProject (default classpath) I still can't figure it out how to shut these logs up =/ On Aug 31, 11:52 am, Rajeev Dayal rda...@google.com wrote: Hi, Is this a normal JUnit Launch Configuration, or is there a special plugin that you're using? Can you navigate to the launch configuration's classpath tab and list out the entries? Thanks, Rajeev On Wed, Aug 26, 2009 at 4:58 PM, Amendmen7 ehb...@gmail.com wrote: I'm having the same issues. I have tried turning off all known loggers in the setUp methods of my LocalDatastoreTestCase superclass, but it has no effect re: this logspam! Has anyone found an answer? On Aug 5, 8:41 am, Stephan stephanv...@gmail.com wrote: I'm having the same problem here. Using a fresh eclipse install and a simple test-application, I get the same messages. They only appear when I use JDO in my unit tests. Except for the error log messages, everything seems to work fine. But starting each unit-test with more then 30 warnings and errors doesn't seem like a clean way to test an application. Did you find a solution yet? I'd think there would be a much larger group with the same problem, or isn't anyone unit-testing here? :) On 27 jun, 15:57, Peter Recore peterrec...@gmail.com wrote: I have a warning message showing up in my logs when I run my unit tests in Eclipse, using the junit plugin. I have the google plugin installed. The messages seem to be coming from the DataNucleus logger. Here is one line. There are about 30 more all referencing different extension points. Jun 27, 2009 8:42:40 AM org.datanucleus.plugin.NonManagedPluginRegistry registerExtensions WARNING: Extension Point org.eclipse.ui.views not registered, but plugin org.eclipse.jdt.junit defined in file:/C:/Documents%20and %20Settings/peter/Desktop/eclipse/configuration/org.eclipse.osgi/ bundles/307/1/.cp/META-INF/MANIFEST.MF refers to it. Then there are some that look like this: Jun 27, 2009 8:42:40 AM org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints SEVERE: Bundle org.eclipse.jdt.junit4.runtime requires org.junit4 but it cannot be resolved. I'm hoping someone can give me a hint as to whether this is an eclipse issue, a junit issue, a datanucleus issue, or something else. Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[appengine-java] Re: Warning message about junit plugin from datanucleus in my logs when running Junit tests
The root problem unsurprisingly turns out to be logging configuration. Stop this from happening by setting the following DataNucleus loggers PRIOR to your JDOHelper.getPersistenceManagerFactory() calls: //This one caused all the WARNING and SEVERE logs about eclipse UI elements Logger.getLogger(DataNucleus.Plugin).setLevel(Level.OFF); //This one logged the last couple INFOs about Persistence configuration Logger.getLogger(DataNucleus.Persistence).setLevel(Level.WARNING); As it doesn't seem even the WARNINGs or SEVEREs affect test outcomes, this seems like a perfectly fine way to do it. On Sep 8, 3:40 pm, Erem ehb...@gmail.com wrote: I just found out that it all gets spammed as a response to JDOHelper.getPersistenceManagerFactory(). It only happens when running the Local Service implementation as specified on the AppEngine wiki On Sep 8, 3:34 pm, Erem ehb...@gmail.com wrote: Hi Rajeev, Thanks for the response! It's a normal JUnit launch config. There are only 2 classpath entries in my launch config: --- v Bootstrap Entries JRE System Library [jre1.6.0_15 - 32-bit[ v User Entries MyProject (default classpath) I still can't figure it out how to shut these logs up =/ On Aug 31, 11:52 am, Rajeev Dayal rda...@google.com wrote: Hi, Is this a normal JUnit Launch Configuration, or is there a special plugin that you're using? Can you navigate to the launch configuration's classpath tab and list out the entries? Thanks, Rajeev On Wed, Aug 26, 2009 at 4:58 PM, Amendmen7 ehb...@gmail.com wrote: I'm having the same issues. I have tried turning off all known loggers in the setUp methods of my LocalDatastoreTestCase superclass, but it has no effect re: this logspam! Has anyone found an answer? On Aug 5, 8:41 am, Stephan stephanv...@gmail.com wrote: I'm having the same problem here. Using a fresh eclipse install and a simple test-application, I get the same messages. They only appear when I use JDO in my unit tests. Except for the error log messages, everything seems to work fine. But starting each unit-test with more then 30 warnings and errors doesn't seem like a clean way to test an application. Did you find a solution yet? I'd think there would be a much larger group with the same problem, or isn't anyone unit-testing here? :) On 27 jun, 15:57, Peter Recore peterrec...@gmail.com wrote: I have a warning message showing up in my logs when I run my unit tests in Eclipse, using the junit plugin. I have the google plugin installed. The messages seem to be coming from the DataNucleus logger. Here is one line. There are about 30 more all referencing different extension points. Jun 27, 2009 8:42:40 AM org.datanucleus.plugin.NonManagedPluginRegistry registerExtensions WARNING: Extension Point org.eclipse.ui.views not registered, but plugin org.eclipse.jdt.junit defined in file:/C:/Documents%20and %20Settings/peter/Desktop/eclipse/configuration/org.eclipse.osgi/ bundles/307/1/.cp/META-INF/MANIFEST.MF refers to it. Then there are some that look like this: Jun 27, 2009 8:42:40 AM org.datanucleus.plugin.NonManagedPluginRegistry resolveConstraints SEVERE: Bundle org.eclipse.jdt.junit4.runtime requires org.junit4 but it cannot be resolved. I'm hoping someone can give me a hint as to whether this is an eclipse issue, a junit issue, a datanucleus issue, or something else. Thanks! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[appengine-java] JDO Sequences in AppEngine
Hey guys, I wanted to use a JDO persistence-backed Sequence to provide monotonically increasing visitor #'s in my webapp. A static variable doesn't cut it because I want the number to survive redeployments, upgrades, etc. I didn't see any info on Sequence in the wiki Using JDO section so I did this. It works but it seemed kinda hacky. Is this the best way to configure a JDO-backed Sequence in AppEngine? (FWIW I'm using the eclipse plug-in.) (1) Make the following file: MyProject/META-INF/package.jdo * This directory should already contain a jdoconfig.xml. * Both files will be autoplaced into MyProject/war/WEB-INF/classes/ META-INF on deploy. (2) Paste the following XML into package.jdo: ?xml version=1.0 encoding=UTF-8 ? jdo xmlns=http://java.sun.com/xml/ns/jdo/jdo; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/jdo/jdo http://java.sun.com/xml/ns/jdo/jdo_2_2.xsd; !-- name the package whatever you want -- package name=MyProject sequence name=VisitorSequence datastore- sequence=VISITOR_SEQUENCE strategy=contiguous / /package /jdo (3) When you need the next value in your application, call: PersistenceManager pm = //...allocate pm //the sequence name is package name.sequence name //from the corresponding tags in package.jdo Sequence seq = pm.getSequence(MyProject.VisitorSequence); //If strategy from package.jdo was contiguous, this has to happen //in a transaction. long nextValue = seq.nextValue(); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[appengine-java] JCache best practices
Hey guys, Would appreciate your help in answering a few specific questions about using the JCache API on my AppEngine project. (1) Are any of the following three operations so expensive (like JDOHelper.getPersistenceManagerFactory()) that I should try to only do them once in the application and carry around a singleton of their result from then on? (a) CacheManager.getInstance() (b) .getCacheFactory() (c) .getCache() (2) Is there a reason I shouldn't have an application-wide singleton Cache instance that I create on startup? What about CacheFactory? What about an instance of CacheManager? (3) Should I forget all this singleton business and call CacheManager.getInstance().getCache(myCache) every time I need it in a method? Does that cost me in performance at all? Thanks for the advice! Erem --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---