IT Notes

Development, testing, ideas

Wednesday, April 14, 2010

Zero Downtime App Upgrade on GAE

Here's the scenario for such a trick:
  1. Prepare new version of your app, and deploy it as some other version that current production has
  2. Go to Versions tab of your app's dashboard at http://appengine.google.com and get URL of the newly deployed version
  3. Check your new version of app using this URL
  4. On the Versions tab, select new version and make it default.
That's it!

Thursday, March 18, 2010

Async Twitting from Google App Engine

It's pretty nice to have some real-time monitoring info of what's happening in your app. Twitter and Task Queues can help to introduce non-intrusive, flexible and easy-to-to implement real-time monitoring.

  1. Put Twitter4J library jar to your app's WEB-INF/lib folder.
  2. In the place you want to monitor, add the following code that will schedule async twitter servlet call (assuming there's some entity that represents event we plan to publish):
    QueueFactory.getDefaultQueue().add(url("/twit").
    param("key", KeyFactory.keyToString(entity.getKey())));
  3. Create simple servlet, map it to handle /twit requests, and put the follwing code inside its doPostMethod:
    Twitter twitter = new TwitterFactory().getInstance("login", "pass");
    String keyString = req.getParameter("key");
    Key key = KeyFactory.stringToKey(keyString);
    String twit = buildTwitString(key);
    twitter.updateStatus(twit);
That's it!
Note. Don't forget to protect your twit servlet. You may want also use task request headers to handle reties.

Note 2. In the first code snippet, url method is static-imported from com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url;

Friday, March 12, 2010

Google App Engine - Speedup Data Storage

I've replaced Entity.setProperty() call with Entity.setUnindexedProperty() for fields that do not need to be indexed (I have about 100 of them for one entity).

This caused significant CPU API time usage decreasing. Moreover, this allows you to save some storage space.

Monday, August 3, 2009

What is SVN Going to Commit?

To find this out, use the following command:
svn status | grep -v '?' | less

Tuesday, January 27, 2009

Remove unversioned files from SVN working copy

In ubuntu, we can accomplish this with only one command:
svn status | awk '/^\?/{print $2}' | xargs rm -rf

About Me

My photo
Kharkov, Ukraine
Trying to find inspiration in work