Hi Eyal, Independently of App Engine, how many seconds does it take to get an answer to your request to Google Analytics (as given above) when you run is "as a Java application" ? A servlet cannot last more than 30s in App Engine, so knwoing your timing is important. But, from my experience, you should get the answer in a matter of a few seconds at most.
Let us know didier On Nov 8, 6:32 pm, Eyal <[email protected]> wrote: > Just to complete the picture here's the initialization of the > AnalyticsService: > > AnalyticsService as = new > AnalyticsService("gaExportAPI_acctSample_v1.0"); > as.setUserCredentials(CLIENT_USERNAME, CLIENT_PASS); > > Thanks again, > Eyal > > On Nov 8, 7:27 pm, Eyal <[email protected]> wrote: > > > Hi Didier, > > > Sure, here is an example method: > > > public SiteBasicData getSiteBasicData(AnalyticsService as, Site > > site, > > DateTime date) { > > SiteBasicData sd = new SiteBasicData(); > > as.setConnectTimeout(10000); > > as.setReadTimeout(10000); > > DataFeed dataFeed = null; > > try { > > DataQuery query = new DataQuery(new > > URL("https://www.google.com/ > > analytics/feeds/data")); > > DateTimeFormatter fmt = > > DateTimeFormat.forPattern("yyyy-MM- > > dd"); > > query.setStartDate(date.toString(fmt)); > > query.setEndDate(date.toString(fmt)); > > > query.setMetrics("ga:visitors,ga:visits,ga:pageviews,ga:newVisits,ga:bounce > > s,ga:timeOnSite"); > > query.setMaxResults(50); > > query.setIds(site.getTableID()); > > > dataFeed = as.getFeed(query.getUrl(), DataFeed.class); > > > DataEntry entry = dataFeed.getEntries().get(0); > > DecimalFormat dfDouble = new DecimalFormat(".##"); > > DecimalFormat dfZero = new DecimalFormat("#"); > > > int visits = > > Integer.parseInt(entry.stringValueOf("ga:visits")); > > int uniques = > > Integer.parseInt(entry.stringValueOf("ga:visitors")); > > int newVisits = > > Integer.parseInt(entry.stringValueOf("ga:newVisits")); > > int pageViews = > > Integer.parseInt(entry.stringValueOf("ga:pageviews")); > > int bounces = > > Integer.parseInt(entry.stringValueOf("ga:bounces")); > > int timeOnSite = > > Integer.parseInt(entry.stringValueOf("ga:timeOnSite")); > > > sd.setSite(site); > > sd.setDate(date); > > sd.setVisitors(visits); > > sd.setUniqueVisitors(uniques); > > sd.setNewVisits(newVisits); > > sd.setReturningVisits(visits-newVisits); > > sd.setPageViews(pageViews); > > sd.setUniquePageViews(getUniquePageViews(as, site, date)); > > sd.setBounces(bounces); > > sd.setTimeOnSite(timeOnSite); > > > } catch(Exception e) { > > e.printStackTrace(); > > } > > return sd; > > } > > > Then I do the simple JDO to persist the sd object. But it doesn't even > > get there because I get the "Timeout while fetching" exception. > > > Thanks! > > Eyal > > > On Nov 8, 6:33 pm, Didier Durand <[email protected]> wrote: > > > > Hi Eyal, > > > > Can you detail (i.e post code samples) on what you do with Analytics > > > ("I need to be able to update the application's datastore with a feed > > > from Analytics.") and how you want to do it. > > > > It's too vague as of now. > > > > regards > > > > didier > > > > On Nov 8, 4:41 pm, Eyal <[email protected]> wrote: > > > > > Hi Didier, > > > > > Thanks for your reply. Here's the problem, though: when I run it as a > > > > web application I'm getting a timeout error. I've already posted this > > > > issue on the Analytics dev group at (http://groups.google.com/group/ > > > > google-analytics-data-export-api/browse_thread/thread/ > > > > 3f9956a25d718b59) but so far no one responded. > > > > > Do you have experience integrating analytics into app engine? I'm sure > > > > it can be done but I've been trying to get it to work for 2 days now > > > > with absolutely no progress. If you, or anyone can help me out I'm > > > > sure my company will be willing to pay for this service. > > > > > Thanks, > > > > Eyal > > > > > On Nov 8, 5:17 pm, Didier Durand <[email protected]> wrote: > > > > > > Eyal, > > > > > > Now it's clear = you MUST run the application as a Web Application to > > > > > be able to activate the App Engine environment with the Datastore that > > > > > you need for JDO. > > > > > > Then you MUST activate the local dev env for App Engine on your > > > > > machine : see my previous answer with the link. > > > > > > If you don't do both actions above, it can not work as you wish. > > > > > > regards > > > > > didier > > > > > > On Nov 8, 1:39 pm, Eyal <[email protected]> wrote: > > > > > > > On my dev, when running "As A Java Application." If I try to run it > > > > > > as > > > > > > a Web Application I get a Timeout exception, because the Analytics > > > > > > feed takes too long to respond... > > > > > > > Thanks for looking into this, Didier! > > > > > > > Eyal > > > > > > > On Nov 8, 1:55 pm, Didier Durand <[email protected]> wrote: > > > > > > > > Hi Eyal, > > > > > > > > Where do you run your application when getting this exception: on > > > > > > > your > > > > > > > dev env or on the google infrastructure ? > > > > > > > regards > > > > > > > didier > > > > > > > > On Nov 8, 8:44 am, Eyal <[email protected]> wrote: > > > > > > > > > Thank you lp, and Didier. > > > > > > > > > Actually this application will need to run in production, and > > > > > > > > not only > > > > > > > > in testing. > > > > > > > > > I need to be able to update the application's datastore with a > > > > > > > > feed > > > > > > > > from Analytics. When I create a very simple GUI for it using GWT > > > > > > > > (basically just a submit button,) I get a timeout exception > > > > > > > > because > > > > > > > > the Analytics server takes too long to respond (it seems to be > > > > > > > > unsolvable at this point.) So I thought I'll just run it as a > > > > > > > > simple > > > > > > > > Java application -- and than I don't have the timeout problem > > > > > > > > and the > > > > > > > > Analytics feed works beautifully. > > > > > > > > > But then -- this problem. When I create objects from the > > > > > > > > Analytics > > > > > > > > feed, and try to insert them into the datastore, I get the > > > > > > > > exception > > > > > > > > above. > > > > > > > > > What am I missing? > > > > > > > > > You help is greatly appreciated! > > > > > > > > > Eyal > > > > > > > > > On Nov 8, 6:21 am, Didier Durand <[email protected]> > > > > > > > > wrote: > > > > > > > > > > Hi, > > > > > > > > > > This comes when you are trying to run code within Eclipse > > > > > > > > > without > > > > > > > > > having starting properly the local runtime of App Engine: > > > > > > > > > seehttp://code.google.com/appengine/docs/java/tools/localunittesting.html > > > > > > > > > (parag Datastore tests) > > > > > > > > > > I can also supply my Junit init code when needed > > > > > > > > > > regards > > > > > > > > > didier > > > > > > > > > > On Nov 7, 5:45 pm, Eyal <[email protected]> wrote: > > > > > > > > > > > Hi all, > > > > > > > > > > > I'm trying to use JDO in an app engine application on > > > > > > > > > > Eclipse. When I > > > > > > > > > > use a web interface I'm able to make it work just fine. But > > > > > > > > > > I need to > > > > > > > > > > be able to run it as a java application and when I try I > > > > > > > > > > get the > > > > > > > > > > following exception: > > > > > > > > > > > java.lang.NullPointerException: No API environment is > > > > > > > > > > registered for > > > > > > > > > > this thread. > > > > > > > > > > at > > > > > > > > > > com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(Datas > > > > > > > > > > toreApiHelper.java: > > > > > > > > > > 108) > > > > > > > > > > at > > > > > > > > > > com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppIdNamesp > > > > > > > > > > ace(DatastoreApiHelper.java: > > > > > > > > > > 118) > > > > > > > > > > at > > > > > > > > > > com.google.appengine.api.datastore.Query.<init>(Query.java:87) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.appengine.query.DatastoreQuery.validate(DatastoreQuer > > > > > > > > > > y.java: > > > > > > > > > > 649) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(Datasto > > > > > > > > > > reQuery.java: > > > > > > > > > > 215) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery. > > > > > > > > > > java: > > > > > > > > > > 89) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.query.Query.executeQuery(Query.java:1489) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.query.Query.executeWithArray(Query.java: > > > > > > > > > > 1371) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.store.query.Query.execute(Query.java:1344) > > > > > > > > > > at > > > > > > > > > > org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:221) > > > > > > > > > > at > > > > > > > > > > com.eyes.manager.UpdateManager.main(UpdateManager.java:39) > > > > > > > > > > > This is my jdeoconfig.xml, which is generated by the > > > > > > > > > > Eclipse plugin: > > > > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > > > > > > <jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig" > > > > > > > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > > > > > > > > > > > > > > > > > > xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/ > > > > > > > > > > jdoconfig"> > > > > > > > > > > > <persistence-manager-factory > > > > > > > > > > name="transactions-optional"> > > > > > > > > > > <property > > > > > > > > > > name="javax.jdo.PersistenceManagerFactoryClass" > > > > > > > > > > > value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFa > > > > > > > > > > ctory"/ > > > > > > > > > > > <property name="javax.jdo.option.ConnectionURL" > > > > > > > > > > value="appengine"/> > > > > > > > > > > <property > > > > > > > > > > name="javax.jdo.option.NontransactionalRead" > > > > > > > > > > value="true"/> > > > > > > > > > > <property > > ... > > read more » -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
