Re: [google-appengine] Re: Delete or unschedule a task?

2010-12-14 Thread ping2ravi
I would run a task may be every 10(atleast the double the time one player gets 
for his turn) minutes and that task will be able to work on as many games as 
possible. And ofcourse this number(10 min) will depend on how soon u want to 
inform users with the results.
But cleaning as many game as u can in one task is important instead of one task 
per game.
This setup will perform better if total games played are more then 24*60/10. 
Else one task per game is good enough from billing point of view.

Sent from my BlackBerry® wireless device

-Original Message-
From: Mark 
Sender: google-appengine@googlegroups.com
Date: Tue, 14 Dec 2010 06:49:44 
To: Google App Engine
Reply-To: google-appengine@googlegroups.com
Subject: [google-appengine] Re: Delete or unschedule a task?

Hi, yeah maybe that's the best way to go - then I can run a scheduled
task every two hours or so per game as a back up just in case,

Thanks!

On Dec 14, 9:42 am, ping2r...@gmail.com wrote:
> I am not expert of task queues, but looking at ur requirment may be u can 
> leave the future task at player's browser.
> Run a javascript timer at the browser and whenver it timeout inform the 
> server(ajax) and tell the player too. Timer can be set for  player's turn and 
> while he is waiting for other player. And ofcourse then u can run task(server 
> side) every fix time to clean games(to set game status as finished/abandoned 
> etc) which have been crashed/browser crash or people have left without 
> clicking proper buttons on ur app.
> May be it will save someof ur cpu and tasks count/billing :).
>
> Sent from my BlackBerry® wireless device
>
>
>
>
>
>
>
> -Original Message-
> From: Mark 
>
> Sender: google-appengine@googlegroups.com
> Date: Tue, 14 Dec 2010 06:28:30
> To: Google App Engine
> Reply-To: google-appengine@googlegroups.com
> Subject: [google-appengine] Delete or unschedule a task?
>
> Hi,
>
> Is there a way to delete or unschedule a task? I've got a multiplayer
> game. Whenever a player starts their turn, I schedule a task for now +
> n minutes, where n is the total time they have to perform their move.
> When the task executes, I check if they have performed the move, if
> not, I cancel their turn. But my queue will end up having many
> unnecessary tasks in it:
>
>    Round limit = 5 minutes
>    queued-task:  game=abc, check at 5:00pm
>    queued-task:  game=abc, check at 5:01pm
>    ...
>
> As each player starts their turn, all the tasks pile on as above.
> Ideally I only need one scheduled task in the queue at any given time.
> When a player starts their turn, I could flush the queue of all
> previous scheduled tasks, which are no longer needed.
>
> There doesn't appear to be a way to do this, named tasks block
> insertion of tasks with the same name, I was hoping to use that as a
> trick to find and remove or overwrite the tasks with the same name
> (using the game key as a unique identifier)?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to google-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-appengine?hl=en.

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

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



Re: [google-appengine] Delete or unschedule a task?

2010-12-14 Thread ping2ravi
I am not expert of task queues, but looking at ur requirment may be u can leave 
the future task at player's browser.
Run a javascript timer at the browser and whenver it timeout inform the 
server(ajax) and tell the player too. Timer can be set for  player's turn and 
while he is waiting for other player. And ofcourse then u can run task(server 
side) every fix time to clean games(to set game status as finished/abandoned 
etc) which have been crashed/browser crash or people have left without clicking 
proper buttons on ur app.
May be it will save someof ur cpu and tasks count/billing :).

Sent from my BlackBerry® wireless device

-Original Message-
From: Mark 
Sender: google-appengine@googlegroups.com
Date: Tue, 14 Dec 2010 06:28:30 
To: Google App Engine
Reply-To: google-appengine@googlegroups.com
Subject: [google-appengine] Delete or unschedule a task?

Hi,

Is there a way to delete or unschedule a task? I've got a multiplayer
game. Whenever a player starts their turn, I schedule a task for now +
n minutes, where n is the total time they have to perform their move.
When the task executes, I check if they have performed the move, if
not, I cancel their turn. But my queue will end up having many
unnecessary tasks in it:

   Round limit = 5 minutes
   queued-task:  game=abc, check at 5:00pm
   queued-task:  game=abc, check at 5:01pm
   ...

As each player starts their turn, all the tasks pile on as above.
Ideally I only need one scheduled task in the queue at any given time.
When a player starts their turn, I could flush the queue of all
previous scheduled tasks, which are no longer needed.

There doesn't appear to be a way to do this, named tasks block
insertion of tasks with the same name, I was hoping to use that as a
trick to find and remove or overwrite the tasks with the same name
(using the game key as a unique identifier)?

Thanks

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

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



Re: [google-appengine] Re: ascending ordering vs. descending ordering

2010-12-09 Thread ping2ravi
Then it must be ur recent change and indexes have not been exploded. Go to GAE 
dashboard and see if you can see all indexes there. May be status of this index 
where u want date as desc is still in pending or building.

Sent from my BlackBerry® wireless device

-Original Message-
From: ping 
Sender: google-appengine@googlegroups.com
Date: Thu, 9 Dec 2010 03:07:28 
To: Google App Engine
Reply-To: google-appengine@googlegroups.com
Subject: [google-appengine] Re: ascending ordering vs. descending ordering

Hi, Thank you...

 And how can i change the index to "descending" then ???
 The query works just fine on my local machine. There the following
datastore-indexes-auto.xml is generated:






























On Dec 9, 11:49 am, ping2r...@gmail.com wrote:
> You have ascending index but not desc, so just create(submit) those index 
> definition and wait while index will be created. Once created ur both query 
> will run fine.
>
> Sent from my BlackBerry® wireless device
>
>
>
>
>
>
>
> -Original Message-
> From: ping 
>
> Sender: google-appengine@googlegroups.com
> Date: Thu, 9 Dec 2010 02:45:26
> To: Google App Engine
> Reply-To: google-appengine@googlegroups.com
> Subject: [google-appengine] ascending ordering vs. descending ordering
>
> Hi :)
>
> What could be the reason that following query works fine with "asc"
> ordering and not with "desc" ???
>
> Query query = pm.newQuery(Purchase.class);
> query.setFilter("groupname == groupnameParameter");
> query.declareParameters("String groupnameParameter");
> query.setOrdering("date asc");
>
> in the log of the gae i read the following exception when i run the
> code with descending ordering :
>
> com.google.appengine.api.datastore.DatastoreNeedIndexException: no
> matching index found..       ancestor="false" source="manual">
>         
>         
>     
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to google-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/google-appengine?hl=en.

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

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



Re: [google-appengine] ascending ordering vs. descending ordering

2010-12-09 Thread ping2ravi
You have ascending index but not desc, so just create(submit) those index 
definition and wait while index will be created. Once created ur both query 
will run fine.

Sent from my BlackBerry® wireless device

-Original Message-
From: ping 
Sender: google-appengine@googlegroups.com
Date: Thu, 9 Dec 2010 02:45:26 
To: Google App Engine
Reply-To: google-appengine@googlegroups.com
Subject: [google-appengine] ascending ordering vs. descending ordering

Hi :)

What could be the reason that following query works fine with "asc"
ordering and not with "desc" ???

Query query = pm.newQuery(Purchase.class);
query.setFilter("groupname == groupnameParameter");
query.declareParameters("String groupnameParameter");
query.setOrdering("date asc");

in the log of the gae i read the following exception when i run the
code with descending ordering :

com.google.appengine.api.datastore.DatastoreNeedIndexException: no
matching index found..  




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

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



[google-appengine] Re: What is a pattern for keeping track of current users in google app engine?

2010-06-24 Thread ping2ravi
Hi,
If reading 1000+ user records(say keys) in ONE task execution is
problem then it doesnt matter if you use Memcache or data store, your
solution is not gonna be scalable to update 1000+ user record(for last
poll time) in ONE task execution.

What i understood your problem is that you want to keep every user's
last poll time updated against there user data. And as a solution you
are running kind of Timer thread in the form of Task Queus and update
all user's last poll time who accessed/polled in last 30/n seconds.
I am specifying a little different approach depending on my
understanding about your problem

Using memcache Solution 1)

>You dont need to create 30 poll cache or n poll cache. Just create one 
>Set object and put it in memcache and your polling request handler will 
>keep adding user's id/key in this cache.Using Set/HashSet will make sure that 
>you dont see to worry about merging or duplicacy.

> After 30/n seconds your task start executing it will take all the 
> data(Set from cache and then remove everything from set in memcache, so 
> that your polling request handler will find it empty and then they will start 
> adding adding new user id/key in it.

> Now it may be possible that you got a set of 1 or more from cache and 
> task execution may not be able to update all in 30 seconds, so you may want 
> to create another sub task who will take left over user key and do the same 
> thing again. Basically you will put the left over ids in memcache again with 
> different id and pass that memcach id to sub-task and that task can read it 
> from there. Or to make it more efficient, if you already know by experience 
> that you are able to update on 500 records in one execution then divide your 
> original left over user ids and divide it into set of 500 and create as many 
> task as you want and save set of 500 in memcache with different ids like 
> LEFT_OVER_SET_1, LEFT_OVER_SET_2 etc. and each task can read daat from 
> memcache using these provided ids and if something left over it will try to 
> invoke sub task again(divide by 500, but this time you will find total number 
> is already less then 500).

But still i say memcach edoesnt guarntee that over a span of time data
will still be avaiable so instead of memcache you can use datastore in
above solution.

Ravi.




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



[google-appengine] Re: What is a pattern for keeping track of current users in google app engine?

2010-06-23 Thread ping2ravi
I wouldnt suggest Memcache for this purpose as memcache doesnt
guarntee that what you put in it will be available after 30 seconds.
Memcach can be flushed because of number of reasons. And memcache
defnitely will not be scalable, if your number of ysers goes high then
least used entries will be deleted automatically even if that entry
comes under criteria of last 30 seconds.

I think your first thought about using datastore is good enough. Why
do you think Datastore will not be scalable? May be you can explain
your problem statement bit more.


On Jun 23, 9:11 am, "l.denardo"  wrote:
> I'm just giving a not-well-thought suggestion, but I'd rather use
> memcache for this.
>
> I guess something like using a time-dependent code as the key (i.e. a
> counter which increments every 30 seconds) and a list of user ids as
> the value, and simply doing a get() on the cache for the current
> counter value would work.
>
> I don't know how this could scale, due to concurrent updates, but I
> definitely think Memcache is the way to go, not datastore.
>
> Regards
> Lorenzo
>
> On Jun 23, 5:45 am, Ryan  wrote:
>
>
>
> > Each of my users is polling the server every few seconds. I need to
> > keep a list of the users that have polled in the last 30 seconds handy
> > for a task I have queued to run every few seconds.
>
> > The obvious way I see to do it is to update a datastore entry every
> > time the user polls, and query the entries that have a timestamp
> > within the last N seconds within my task queue. I can't imagine this
> > scaling well.
>
> > Any recommendations?
>
> > Thanks.- Hide quoted text -
>
> - Show quoted text -

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