Re: [appengine-java] Re: Get execution duration of an asynchronous urlfetch

2011-01-30 Thread Fabrizio Accatino
Didier,

your idea is good but can/want execute activity on a task. I need simple
approach: run X async urlfetch, wait for end of execution and store
execution time of each fetch.

I've opened a feature request on the issue tracker:
http://code.google.com/p/googleappengine/issues/detail?id=4476


   Fabrizio


On Sun, Jan 30, 2011 at 8:28 AM, Didier Durand durand.did...@gmail.comwrote:

 Hi,

 You're right: async url fetch doesn't seem to provide any way to
 measure fetch time.

 Then, I have a proposal: why don't you schedule a task per fetch, this
 task will then do a regular synchronous url fetch for which measuring
 will be easy.

 So, your original servlet / task will schedule as many tasks as you
 have fetches and wait via a loop of Thread.sleep() until all fetches
 are done and their results (incl fetch time) written somewhere
 (datastore / memcache) that the original servlet / task can access to
 complete the work.

 The only question though: can the application afford to launch those
 tasks as they will incurr some overhead : some tenths of milliseconds
 of cpu to schedule a task and run it + cpu time to write result to
 cacche or ds in order to be shareable with originator.

 If not acceptable, I hope it will at least give you some other ideas
 to follow

 regards

 didier

 On Jan 29, 9:50 am, Fabrizio Accatino fht...@gmail.com wrote:
  Hello,
 
  I'm playing with async urlfetch. My ispiration was Ikai athttp://
 ikaisays.com/2010/06/29/using-asynchronous-urlfetch-on-java-ap...
 
  I run some request in parallel. All works fine. But now I'd like to get
 info
  about execution time of each request. The target URLs I call are
 different
  so the response time are very different.
  I read the documentation but HTTPResponse does not expose a execution
  duration or similar value.
 
  Any idea?
 
  Fabrizio

 --
 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.comgoogle-appengine-java%2bunsubscr...@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-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.



Re: [appengine-java] Re: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Artur Downar
So, you mean polling on the database.

I wrote:
try {
for (int i=0; i100; i++) {
entity = ofy.find(ToModemInfoEntity.class, whatever);
if (entity != null) {
log.info(got data from db, do my stuff here...);
} else {
Thread.sleep(100);
}
}
}catch (Throwable th) {
th.printStackTrace();
}


It is cpu-time consuming.
It polls for about 11seconds and it takes about 1500ms of the cpu time.
It makes more than 2hours of the CPU time per natural day.

I can extend the Time.sleep(period) but it still seems unacceptable due to
CPU costs.




On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand durand.did...@gmail.comwrote:

 Sorry,

 hit send too quicly

 b) why don't you do something like this

 Side reading data:
 ==

 do {
read new data from ds;
 if (new data) {
 mark data as read in ds
do what you need
return;
} else {
  Thread.sleep(100)
}
 } until (running time near 30s)
 if (no new data) {
give error message to waiting user
 }

 Side writing data
 ==

 write new data to datastore (with corresponding status showing that
 it's new and not read yet)


 N.B: the 30s is a hard limit imposed by gae. You've to check for it
 and end gracefully else your servlet will be killed by GAE.

 regards

 didier

 On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
  Hi,
 
  To answer your questions:
 
  a) yes, you can say how long you waits Thread.sleep(millis) where
  millis says how many milliseconds you want to wait
 
  b) why don't you do something like this
 
  do {
  read new data from ds;
 
  }
 
  On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com wrote:
 
   At the moment the Channel API is javascript only. There are a lot of
 people
   that would like it to be open to other languages for things just like
 you
   want to do. You might be able to use something like Rhino to run the
   javascript in Java but not sure if that will work. You should take a
 look at
   XMPP, it's very simple to have the server send instant messages. I did
 a
   quick search for XMPP libraries in Java and here is one I found. I'm
 sure
   there are many others. Check outhttp://
 twit88.com/blog/2009/02/17/java-xmpp-client-library/
   On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
   artur.dow...@googlemail.comwrote:
 
Thank you.
 
I took a brief look on channel API and it seems I it is the thing I
 need.
 
I have a small question.
 
The modem device is a java embedded device and it has no public IP.
 There
is no javascript on it. Only java.
 
Is it enough for GAE channel API to communicate with it ?
 
  On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
 onepagewo...@gmail.com
 wrote:
 
Sounds like you need more of a Push style. Checkout the Channel API
 or the
XMPP api.
 
   On Sat, Jan 29, 2011 at 1:47 PM, Artur Downar 
artur.dow...@googlemail.com wrote:
 
 The external device polls for data from GAE.
It is not specified when the data arrives. To describe it more
 clearly.
The device is a GSM modem device that sends an SMS on the user
 request.
 
The user launches a web browser and writes a mobile phone number.
 The
browser sends data to the GAE and the sms should be send
 immediately
 
So I cannot specify how long I can wait in Thread.sleep().
 
You mention about Objectify. I use that library but I'm quite new
 to it.
 
 Does it have the mechanism that works like:
 
 process A waits for data until data into database arrives or
 timeout
expires
 process B puts the data into database
 process a continues processing the data inserted by process B
 
?
 
On Sat, Jan 29, 2011 at 3:59 PM, Didier Durand 
 durand.did...@gmail.comwrote:
 
Hi,
 
Forgot: you can use Thread.sleep() to wait (java.lang.Thread is
 also
part of the JRE)
 
regards
 
didier
 
On Jan 29, 3:35 pm, Didier Durand durand.did...@gmail.com
 wrote:
 Hi,
 
 LinkedBlokingQueue is part of JRE WhiteList:
   http://code.google.com/appengine/docs/java/jrewhitelist.html. So,
 you
 can use it.
 
 But, I dont see the need. Why don't you just from on the
 datastore on
 1 side and read from it on the other. It would be very simple
 and rely
 on the most basic (i.e solid) mechanism of gae. (I would
 recommend
 Objectify for ds read/ write)
 
 As you have network round-trips, the read / write time will be
 negligible even it can seem high compared to an in-memory
 mechanism
 like a Queue.
 
 regards
 
 didier
 
 On Jan 29, 1:51 pm, arturad artur.dow...@googlemail.com
 wrote:
 
  In my application an embedded device (no public IP) should
 connect
to
  the GAE in order to obtain some data from it. The data are
 provided
by
  the web browser.
 
  

[appengine-java] persist generics

2011-01-30 Thread Owen Powell
Hi all,

Does anyone know if it's possible to persist generic classes (with JDO, for 
example)? I have a class like this:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = 
true)
public class MyClassT extends IsSerializable implements IsSerializable {
...
}

but the JDO compiler is having a problem with recognizing T (see 
transcript below).

Has anyone persisted generic classes with JDO and GAE?

Thanks,

~Owen

LOG:

30-ene-2011 12:33:07 org.datanucleus.enhancer.asm.ASMClassEnhancer enhance
GRAVE: Error thrown enhancing with ASMClassEnhancer
java.lang.IllegalStateException: Unknown type: T
at 
org.datanucleus.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:1659)
at 
org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:169)
at 
org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:136)
at 
org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2278)
at 
org.datanucleus.jdo.metadata.JDOMetaDataManager.getMetaDataForClassInternal(JDOMetaDataManager.java:369)
at 
org.datanucleus.metadata.MetaDataManager.getMetaDataForClass(MetaDataManager.java:1125)
at 
org.datanucleus.enhancer.AbstractClassEnhancer.isPersistenceCapable(AbstractClassEnhancer.java:183)
at 
org.datanucleus.enhancer.asm.JdoMethodAdapter.visitFieldInsn(JdoMethodAdapter.java:81)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at 
org.datanucleus.enhancer.asm.ASMClassEnhancer.enhance(ASMClassEnhancer.java:355)
at 
org.datanucleus.enhancer.DataNucleusEnhancer.enhanceClass(DataNucleusEnhancer.java:974)
at 
org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:570)
at 
org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.appengine.tools.enhancer.Enhancer.execute(Enhancer.java:57)
at com.google.appengine.tools.enhancer.Enhance.init(Enhance.java:60)
at com.google.appengine.tools.enhancer.Enhance.main(Enhance.java:41)

-- 
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: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Didier Durand
Hi,

the most efficient for ofy is to get on a Long key

So, could you try again with a ofy.get() on entity with a fixed key ?
Should reduce the cpu

NB; with 2 hours / day. you're still on the gratis zone (6.5 h/day)

regards

didier

On Jan 30, 1:10 pm, Artur Downar artur.dow...@googlemail.com wrote:
 So, you mean polling on the database.

 I wrote:

 try {
             for (int i=0; i100; i++) {
                 entity = ofy.find(ToModemInfoEntity.class, whatever);
                 if (entity != null) {
                     log.info(got data from db, do my stuff here...);
                 } else {
                     Thread.sleep(100);
                 }
             }
         }catch (Throwable th) {
             th.printStackTrace();
         }

 It is cpu-time consuming.
 It polls for about 11seconds and it takes about 1500ms of the cpu time.
 It makes more than 2hours of the CPU time per natural day.

 I can extend the Time.sleep(period) but it still seems unacceptable due to
 CPU costs.

 On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand durand.did...@gmail.comwrote:

  Sorry,

  hit send too quicly

  b) why don't you do something like this

  Side reading data:
  ==

  do {
     read new data from ds;
      if (new data) {
          mark data as read in ds
         do what you need
         return;
     } else {
       Thread.sleep(100)
     }
  } until (running time near 30s)
  if (no new data) {
     give error message to waiting user
  }

  Side writing data
  ==

  write new data to datastore (with corresponding status showing that
  it's new and not read yet)

  N.B: the 30s is a hard limit imposed by gae. You've to check for it
  and end gracefully else your servlet will be killed by GAE.

  regards

  didier

  On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
   Hi,

   To answer your questions:

   a) yes, you can say how long you waits Thread.sleep(millis) where
   millis says how many milliseconds you want to wait

   b) why don't you do something like this

   do {
       read new data from ds;

   }

   On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com wrote:

At the moment the Channel API is javascript only. There are a lot of
  people
that would like it to be open to other languages for things just like
  you
want to do. You might be able to use something like Rhino to run the
javascript in Java but not sure if that will work. You should take a
  look at
XMPP, it's very simple to have the server send instant messages. I did
  a
quick search for XMPP libraries in Java and here is one I found. I'm
  sure
there are many others. Check outhttp://
  twit88.com/blog/2009/02/17/java-xmpp-client-library/
On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
artur.dow...@googlemail.comwrote:

 Thank you.

 I took a brief look on channel API and it seems I it is the thing I
  need.

 I have a small question.

 The modem device is a java embedded device and it has no public IP.
  There
 is no javascript on it. Only java.

 Is it enough for GAE channel API to communicate with it ?

   On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
  onepagewo...@gmail.com
  wrote:

 Sounds like you need more of a Push style. Checkout the Channel API
  or the
 XMPP api.

    On Sat, Jan 29, 2011 at 1:47 PM, Artur Downar 
 artur.dow...@googlemail.com wrote:

  The external device polls for data from GAE.
 It is not specified when the data arrives. To describe it more
  clearly.
 The device is a GSM modem device that sends an SMS on the user
  request.

 The user launches a web browser and writes a mobile phone number.
  The
 browser sends data to the GAE and the sms should be send
  immediately

 So I cannot specify how long I can wait in Thread.sleep().

 You mention about Objectify. I use that library but I'm quite new
  to it.

  Does it have the mechanism that works like:

  process A waits for data until data into database arrives or
  timeout
 expires
  process B puts the data into database
  process a continues processing the data inserted by process B

 ?

 On Sat, Jan 29, 2011 at 3:59 PM, Didier Durand 
  durand.did...@gmail.comwrote:

 Hi,

 Forgot: you can use Thread.sleep() to wait (java.lang.Thread is
  also
 part of the JRE)

 regards

 didier

 On Jan 29, 3:35 pm, Didier Durand durand.did...@gmail.com
  wrote:
  Hi,

  LinkedBlokingQueue is part of JRE WhiteList:
http://code.google.com/appengine/docs/java/jrewhitelist.html. So,
  you
  can use it.

  But, I dont see the need. Why don't you just from on the
  datastore on
  1 side and read from it on the other. It would be very simple
  and rely
  on the most basic (i.e solid) mechanism of gae. (I would
  recommend
  Objectify for ds read/ write)

  As you have network round-trips, the read / write time 

[appengine-java] Re: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Didier Durand
PS: you should also combine memcache + ds datastore to reduce cpu.

regards

didier

On Jan 30, 1:10 pm, Artur Downar artur.dow...@googlemail.com wrote:
 So, you mean polling on the database.

 I wrote:

 try {
             for (int i=0; i100; i++) {
                 entity = ofy.find(ToModemInfoEntity.class, whatever);
                 if (entity != null) {
                     log.info(got data from db, do my stuff here...);
                 } else {
                     Thread.sleep(100);
                 }
             }
         }catch (Throwable th) {
             th.printStackTrace();
         }

 It is cpu-time consuming.
 It polls for about 11seconds and it takes about 1500ms of the cpu time.
 It makes more than 2hours of the CPU time per natural day.

 I can extend the Time.sleep(period) but it still seems unacceptable due to
 CPU costs.

 On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand durand.did...@gmail.comwrote:

  Sorry,

  hit send too quicly

  b) why don't you do something like this

  Side reading data:
  ==

  do {
     read new data from ds;
      if (new data) {
          mark data as read in ds
         do what you need
         return;
     } else {
       Thread.sleep(100)
     }
  } until (running time near 30s)
  if (no new data) {
     give error message to waiting user
  }

  Side writing data
  ==

  write new data to datastore (with corresponding status showing that
  it's new and not read yet)

  N.B: the 30s is a hard limit imposed by gae. You've to check for it
  and end gracefully else your servlet will be killed by GAE.

  regards

  didier

  On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
   Hi,

   To answer your questions:

   a) yes, you can say how long you waits Thread.sleep(millis) where
   millis says how many milliseconds you want to wait

   b) why don't you do something like this

   do {
       read new data from ds;

   }

   On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com wrote:

At the moment the Channel API is javascript only. There are a lot of
  people
that would like it to be open to other languages for things just like
  you
want to do. You might be able to use something like Rhino to run the
javascript in Java but not sure if that will work. You should take a
  look at
XMPP, it's very simple to have the server send instant messages. I did
  a
quick search for XMPP libraries in Java and here is one I found. I'm
  sure
there are many others. Check outhttp://
  twit88.com/blog/2009/02/17/java-xmpp-client-library/
On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
artur.dow...@googlemail.comwrote:

 Thank you.

 I took a brief look on channel API and it seems I it is the thing I
  need.

 I have a small question.

 The modem device is a java embedded device and it has no public IP.
  There
 is no javascript on it. Only java.

 Is it enough for GAE channel API to communicate with it ?

   On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
  onepagewo...@gmail.com
  wrote:

 Sounds like you need more of a Push style. Checkout the Channel API
  or the
 XMPP api.

    On Sat, Jan 29, 2011 at 1:47 PM, Artur Downar 
 artur.dow...@googlemail.com wrote:

  The external device polls for data from GAE.
 It is not specified when the data arrives. To describe it more
  clearly.
 The device is a GSM modem device that sends an SMS on the user
  request.

 The user launches a web browser and writes a mobile phone number.
  The
 browser sends data to the GAE and the sms should be send
  immediately

 So I cannot specify how long I can wait in Thread.sleep().

 You mention about Objectify. I use that library but I'm quite new
  to it.

  Does it have the mechanism that works like:

  process A waits for data until data into database arrives or
  timeout
 expires
  process B puts the data into database
  process a continues processing the data inserted by process B

 ?

 On Sat, Jan 29, 2011 at 3:59 PM, Didier Durand 
  durand.did...@gmail.comwrote:

 Hi,

 Forgot: you can use Thread.sleep() to wait (java.lang.Thread is
  also
 part of the JRE)

 regards

 didier

 On Jan 29, 3:35 pm, Didier Durand durand.did...@gmail.com
  wrote:
  Hi,

  LinkedBlokingQueue is part of JRE WhiteList:
http://code.google.com/appengine/docs/java/jrewhitelist.html. So,
  you
  can use it.

  But, I dont see the need. Why don't you just from on the
  datastore on
  1 side and read from it on the other. It would be very simple
  and rely
  on the most basic (i.e solid) mechanism of gae. (I would
  recommend
  Objectify for ds read/ write)

  As you have network round-trips, the read / write time will be
  negligible even it can seem high compared to an in-memory
  mechanism
  like a Queue.

  regards

  didier

  On Jan 29, 

[appengine-java] Re: persist generics

2011-01-30 Thread Miroslav Genov
Why you wanna do that ? 

As I can see from your example, you can do MyClassPerson and also 
MyClassTable, but what is in common between tables and the persons ? 

If you have some common logic, you can use some kind of service class that 
could do that.

-- 
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.



Re: [appengine-java] Re: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Artur Downar
Yes, you are right.
It takes 400-600ms so it costs about an hour of the cpu time per 24hours.
It is acceptable.


 I DO it following way:

MapObject, ToModemInfoEntity entity;

try {
for (int i=0; i100; i++) {
entity =  ofy.get(ToModemInfoEntity.class);
if (entity != null  !entity.isEmpty()) {
log.info(got data from db, do my stuff here...);
} else {
Thread.sleep(100);
}
}
}

Can I improove anything else, please ?







On Sun, Jan 30, 2011 at 1:36 PM, Didier Durand durand.did...@gmail.comwrote:

 PS: you should also combine memcache + ds datastore to reduce cpu.

 regards

 didier

 On Jan 30, 1:10 pm, Artur Downar artur.dow...@googlemail.com wrote:
  So, you mean polling on the database.
 
  I wrote:
 
  try {
  for (int i=0; i100; i++) {
  entity = ofy.find(ToModemInfoEntity.class, whatever);
  if (entity != null) {
  log.info(got data from db, do my stuff here...);
  } else {
  Thread.sleep(100);
  }
  }
  }catch (Throwable th) {
  th.printStackTrace();
  }
 
  It is cpu-time consuming.
  It polls for about 11seconds and it takes about 1500ms of the cpu time.
  It makes more than 2hours of the CPU time per natural day.
 
  I can extend the Time.sleep(period) but it still seems unacceptable due
 to
  CPU costs.
 
  On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand durand.did...@gmail.com
 wrote:
 
   Sorry,
 
   hit send too quicly
 
   b) why don't you do something like this
 
   Side reading data:
   ==
 
   do {
  read new data from ds;
   if (new data) {
   mark data as read in ds
  do what you need
  return;
  } else {
Thread.sleep(100)
  }
   } until (running time near 30s)
   if (no new data) {
  give error message to waiting user
   }
 
   Side writing data
   ==
 
   write new data to datastore (with corresponding status showing that
   it's new and not read yet)
 
   N.B: the 30s is a hard limit imposed by gae. You've to check for it
   and end gracefully else your servlet will be killed by GAE.
 
   regards
 
   didier
 
   On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
Hi,
 
To answer your questions:
 
a) yes, you can say how long you waits Thread.sleep(millis) where
millis says how many milliseconds you want to wait
 
b) why don't you do something like this
 
do {
read new data from ds;
 
}
 
On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com wrote:
 
 At the moment the Channel API is javascript only. There are a lot
 of
   people
 that would like it to be open to other languages for things just
 like
   you
 want to do. You might be able to use something like Rhino to run
 the
 javascript in Java but not sure if that will work. You should take
 a
   look at
 XMPP, it's very simple to have the server send instant messages. I
 did
   a
 quick search for XMPP libraries in Java and here is one I found.
 I'm
   sure
 there are many others. Check outhttp://
   twit88.com/blog/2009/02/17/java-xmpp-client-library/
 On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
 artur.dow...@googlemail.comwrote:
 
  Thank you.
 
  I took a brief look on channel API and it seems I it is the thing
 I
   need.
 
  I have a small question.
 
  The modem device is a java embedded device and it has no public
 IP.
   There
  is no javascript on it. Only java.
 
  Is it enough for GAE channel API to communicate with it ?
 
On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
   onepagewo...@gmail.com
   wrote:
 
  Sounds like you need more of a Push style. Checkout the Channel
 API
   or the
  XMPP api.
 
 On Sat, Jan 29, 2011 at 1:47 PM, Artur Downar 
  artur.dow...@googlemail.com wrote:
 
   The external device polls for data from GAE.
  It is not specified when the data arrives. To describe it more
   clearly.
  The device is a GSM modem device that sends an SMS on the user
   request.
 
  The user launches a web browser and writes a mobile phone
 number.
   The
  browser sends data to the GAE and the sms should be send
   immediately
 
  So I cannot specify how long I can wait in Thread.sleep().
 
  You mention about Objectify. I use that library but I'm quite
 new
   to it.
 
   Does it have the mechanism that works like:
 
   process A waits for data until data into database arrives or
   timeout
  expires
   process B puts the data into database
   process a continues processing the data inserted by process B
 
  ?
 
  On Sat, Jan 29, 2011 at 3:59 PM, Didier Durand 
   durand.did...@gmail.comwrote:
 
  Hi,
 
  Forgot: you 

Re: [appengine-java] Re: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Stephen Johnson
If where you have specified log.info(do your stuff here) you intend to
send data back to the client and then loop again and wait for more data I
think you are going to be disappointed. I don't believe any data will be
sent back to the client until your servlet completes. So you'll have to
re-establish a connection every time data gets sent back down.

On Sun, Jan 30, 2011 at 11:20 AM, Artur Downar
artur.dow...@googlemail.comwrote:

 Yes, you are right.
 It takes 400-600ms so it costs about an hour of the cpu time per 24hours.
 It is acceptable.


  I DO it following way:

 MapObject, ToModemInfoEntity entity;


 try {
 for (int i=0; i100; i++) {
 entity =  ofy.get(ToModemInfoEntity.class);
 if (entity != null  !entity.isEmpty()) {

 log.info(got data from db, do my stuff here...);
 } else {
 Thread.sleep(100);
 }
 }
 }

 Can I improove anything else, please ?








 On Sun, Jan 30, 2011 at 1:36 PM, Didier Durand durand.did...@gmail.comwrote:

 PS: you should also combine memcache + ds datastore to reduce cpu.

 regards

 didier

 On Jan 30, 1:10 pm, Artur Downar artur.dow...@googlemail.com wrote:
  So, you mean polling on the database.
 
  I wrote:
 
  try {
  for (int i=0; i100; i++) {
  entity = ofy.find(ToModemInfoEntity.class, whatever);
  if (entity != null) {
  log.info(got data from db, do my stuff here...);
  } else {
  Thread.sleep(100);
  }
  }
  }catch (Throwable th) {
  th.printStackTrace();
  }
 
  It is cpu-time consuming.
  It polls for about 11seconds and it takes about 1500ms of the cpu time.
  It makes more than 2hours of the CPU time per natural day.
 
  I can extend the Time.sleep(period) but it still seems unacceptable due
 to
  CPU costs.
 
  On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand durand.did...@gmail.com
 wrote:
  
   Sorry,
 
   hit send too quicly
 
   b) why don't you do something like this
 
   Side reading data:
   ==
 
   do {
  read new data from ds;
   if (new data) {
   mark data as read in ds
  do what you need
  return;
  } else {
Thread.sleep(100)
  }
   } until (running time near 30s)
   if (no new data) {
  give error message to waiting user
   }
 
   Side writing data
   ==
 
   write new data to datastore (with corresponding status showing that
   it's new and not read yet)
 
   N.B: the 30s is a hard limit imposed by gae. You've to check for it
   and end gracefully else your servlet will be killed by GAE.
 
   regards
 
   didier
 
   On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
Hi,
 
To answer your questions:
 
a) yes, you can say how long you waits Thread.sleep(millis) where
millis says how many milliseconds you want to wait
 
b) why don't you do something like this
 
do {
read new data from ds;
 
}
 
On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com
 wrote:
 
 At the moment the Channel API is javascript only. There are a lot
 of
   people
 that would like it to be open to other languages for things just
 like
   you
 want to do. You might be able to use something like Rhino to run
 the
 javascript in Java but not sure if that will work. You should take
 a
   look at
 XMPP, it's very simple to have the server send instant messages. I
 did
   a
 quick search for XMPP libraries in Java and here is one I found.
 I'm
   sure
 there are many others. Check outhttp://
   twit88.com/blog/2009/02/17/java-xmpp-client-library/
 On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
 artur.dow...@googlemail.comwrote:
 
  Thank you.
 
  I took a brief look on channel API and it seems I it is the
 thing I
   need.
 
  I have a small question.
 
  The modem device is a java embedded device and it has no public
 IP.
   There
  is no javascript on it. Only java.
 
  Is it enough for GAE channel API to communicate with it ?
 
On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
   onepagewo...@gmail.com
   wrote:
 
  Sounds like you need more of a Push style. Checkout the Channel
 API
   or the
  XMPP api.
 
 On Sat, Jan 29, 2011 at 1:47 PM, Artur Downar 
  artur.dow...@googlemail.com wrote:
 
   The external device polls for data from GAE.
  It is not specified when the data arrives. To describe it more
   clearly.
  The device is a GSM modem device that sends an SMS on the user
   request.
 
  The user launches a web browser and writes a mobile phone
 number.
   The
  browser sends data to the GAE and the sms should be send
   immediately
 
  So I cannot specify how long I can wait in Thread.sleep().
 
  You mention 

[appengine-java] Re: OAuth with a custom domain

2011-01-30 Thread Eurig Jones
Anyone have any experience with authenticating non gmail.com google
accounuts with GAE OAuth?

On Jan 19, 10:30 pm, Eurig Jones eurigjo...@gmail.com wrote:
 Hi. I have an android app which has a GAE backend and validates its
 users using OAuth. It does not seem to validate users with a custom
 google domain. What do I need to do to get this to work?

 Thanks!Eurig

-- 
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.



Re: [appengine-java] Re: Semaphores/ LinkedBlockingQueue on GAE for java

2011-01-30 Thread Artur Downar
Yes I know it. I have to fill the response end return from the doGet (req,
resp) method.
I'm very sad because of the 1hour of wasted CPU  time. It is the very basic
functionality, but it would consume so much...




I have to investigate both the channel API and the XMPP before I choose the
solution.



Will see if it would be possible to write my own not javascript library to
use the channel API and how much time it will take.



I guess I would like to avoid the XMPP because my modem processor is quite
weak. have to make some investigation if it handles the requirements.



On Sun, Jan 30, 2011 at 7:30 PM, Stephen Johnson onepagewo...@gmail.comwrote:

 If where you have specified log.info(do your stuff here) you intend to
 send data back to the client and then loop again and wait for more data I
 think you are going to be disappointed. I don't believe any data will be
 sent back to the client until your servlet completes. So you'll have to
 re-establish a connection every time data gets sent back down.

 On Sun, Jan 30, 2011 at 11:20 AM, Artur Downar 
 artur.dow...@googlemail.com wrote:

 Yes, you are right.
 It takes 400-600ms so it costs about an hour of the cpu time per 24hours.
 It is acceptable.


  I DO it following way:

 MapObject, ToModemInfoEntity entity;


 try {
 for (int i=0; i100; i++) {
 entity =  ofy.get(ToModemInfoEntity.class);
 if (entity != null  !entity.isEmpty()) {

 log.info(got data from db, do my stuff here...);
 } else {
 Thread.sleep(100);
 }
 }
 }

 Can I improove anything else, please ?








 On Sun, Jan 30, 2011 at 1:36 PM, Didier Durand 
 durand.did...@gmail.comwrote:

 PS: you should also combine memcache + ds datastore to reduce cpu.

 regards

 didier

 On Jan 30, 1:10 pm, Artur Downar artur.dow...@googlemail.com wrote:
  So, you mean polling on the database.
 
  I wrote:
 
  try {
  for (int i=0; i100; i++) {
  entity = ofy.find(ToModemInfoEntity.class, whatever);
  if (entity != null) {
  log.info(got data from db, do my stuff here...);
  } else {
  Thread.sleep(100);
  }
  }
  }catch (Throwable th) {
  th.printStackTrace();
  }
 
  It is cpu-time consuming.
  It polls for about 11seconds and it takes about 1500ms of the cpu time.
  It makes more than 2hours of the CPU time per natural day.
 
  I can extend the Time.sleep(period) but it still seems unacceptable due
 to
  CPU costs.
 
  On Sun, Jan 30, 2011 at 8:21 AM, Didier Durand 
 durand.did...@gmail.comwrote:
  
   Sorry,
 
   hit send too quicly
 
   b) why don't you do something like this
 
   Side reading data:
   ==
 
   do {
  read new data from ds;
   if (new data) {
   mark data as read in ds
  do what you need
  return;
  } else {
Thread.sleep(100)
  }
   } until (running time near 30s)
   if (no new data) {
  give error message to waiting user
   }
 
   Side writing data
   ==
 
   write new data to datastore (with corresponding status showing that
   it's new and not read yet)
 
   N.B: the 30s is a hard limit imposed by gae. You've to check for it
   and end gracefully else your servlet will be killed by GAE.
 
   regards
 
   didier
 
   On Jan 30, 8:15 am, Didier Durand durand.did...@gmail.com wrote:
Hi,
 
To answer your questions:
 
a) yes, you can say how long you waits Thread.sleep(millis) where
millis says how many milliseconds you want to wait
 
b) why don't you do something like this
 
do {
read new data from ds;
 
}
 
On Jan 29, 10:38 pm, Stephen Johnson onepagewo...@gmail.com
 wrote:
 
 At the moment the Channel API is javascript only. There are a lot
 of
   people
 that would like it to be open to other languages for things just
 like
   you
 want to do. You might be able to use something like Rhino to run
 the
 javascript in Java but not sure if that will work. You should
 take a
   look at
 XMPP, it's very simple to have the server send instant messages.
 I did
   a
 quick search for XMPP libraries in Java and here is one I found.
 I'm
   sure
 there are many others. Check outhttp://
   twit88.com/blog/2009/02/17/java-xmpp-client-library/
 On Sat, Jan 29, 2011 at 2:07 PM, Artur Downar
 artur.dow...@googlemail.comwrote:
 
  Thank you.
 
  I took a brief look on channel API and it seems I it is the
 thing I
   need.
 
  I have a small question.
 
  The modem device is a java embedded device and it has no public
 IP.
   There
  is no javascript on it. Only java.
 
  Is it enough for GAE channel API to communicate with it ?
 
On Sat, Jan 29, 2011 at 9:49 PM, Stephen Johnson 
   onepagewo...@gmail.com
 

[appengine-java] Powered by Google Technologies

2011-01-30 Thread Michael Weinberg
Wanted to share our project called CitySale.ca which is built entirely
on the Google stack:

Google APIs - App Engine, GWT, Maps, Fusion Tables, Geocoding, Places,
Search, ...
Google Tools - Analytics, DoubleClick, Webmaster

The GWT Client and the App Engine based server are also deeply
integrated with Facebook APIs.

It is a bit scary to completely rely on a single company (Google) for
all your technology/infrastructure needs, but for us the benefits
outweigh this concern!

Would be great to get some feedback and if I would be happy to answer
any questions about how this service was built.

p.s. if you are from Canada, we hope you would actually sign up and
use the service too :)

the url is  http://www.citysale.ca

Thanks,
Michael Weinberg

-- 
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] Uploading photos from Android

2011-01-30 Thread g123k
Hello,

I have an Android application and I want to upload photos to my
appEngine.
I send the photo using a image/jpeg content-type and a POST request.

However, the only code that I've found needs multipart/form-data or
multipart/mixed :

 ServletFileUpload upload = new ServletFileUpload();
 FileItemIterator iter = upload.getItemIterator(req);
 FileItemStream imageItem = iter.next();
 InputStream imgStream = imageItem.openStream();
 Blob imageBlob = new Blob(IOUtils.toByteArray(imgStream));

Do you have a working code or another solution ?

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.



Re: [appengine-java] Just getting started with Datastore

2011-01-30 Thread Matt Reeves
Thanks for the feedback.  I am willing to try the low-level API first and 
that's what I thought I was doing but could not figure out (and am still 
confused about) how to initially define data.  For example I want to have a 
persistent entity with two properties of type string and one numerical 
property.  When I use this bulkloader tool it is storing all the data as 
string, so maybe my problem is just learning how to use this tool to load 
data (which I definitely want to do).

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.



Re: [appengine-java] Re: Prerelease 1.3.4 SDK ready for download

2011-01-30 Thread Rajkumar Radhakrishnan
Hi John Brennan,

Just saw your reply, when I was searching for this issue to quote in the
following reddit thread..
http://www.reddit.com/r/AppEngine/comments/fbwkz/oauth_with_gae_and_custom_google_domains/

Just checked again now and the issue seems to have been fixed.

That is, I am now able to login with both the Google Apps user account
r...@my-google-apps-domain.com and a Google Account created with the same
email-id (both with diff passwords), by using the appropriate login options
in my Google App Engine based CRM app http://crm.ifreetools.com/. Hope it
is fixed for you too.

On a related note, this must have been fixed at least before Jan 18, 2011 as
I have now started getting signups from Google Accounts having yahoo /
hotmail email-ids, which had stopped after I had moved to federated login,
due to this issue.

Regards,
R.Rajkumar


On Wed, Dec 8, 2010 at 5:43 PM, John Brennan jbren...@connectit.ie wrote:


 Rajkumar Radhakrishnan r.rajkumar@... writes:

 
 
  Thanks for enquiring, Ikai.
 
  Was held up implementing some features - including integrating OpenId
 support
 - that I missed reading the groups' emails for a few days.
 
 
  Regarding snags.. except when I try to login with a Google Account
 created
 using a Google Apps email-id, everything works fine.
 
  Details  :
  When users login using normal Google Accounts and normal Google Apps user
 accounts, by providing the domain name, there are no issues.
 
  But, when one has a Google Apps user account with email id
 u...@myappsdomain.com and had created a Google Account
 providing this email-id. Then, logging in with this Google Account (instead
 of
 Google Apps account) an Internal Server Error occurs..
 
 
  Error: Server Error
 
  The server encountered an error and could not complete your request.
 
 
  If the problem persists, please report your problem and mention this
 error
 message and the query that caused it.
 
 
 



 Hi R.Rajkumar,
 I'm having the exact same problem. Did you ever resolve the issue?
 I'm able to use a Google Account, created using a Google Apps email, to
 login
 into other sample applications on Appengine using federated log in so there
 must
 be a way to get around it.

 Thanks
 John Brennan



 --
 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.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.




-- 

http://crm.ifreetools.com

-- 
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.