Monday, February 14, 2011

How to Vacuum Indexes (Java) on App Engine

Note, you need App Engine SDK 1.4.2 or higher.

On Linux:
./appengine-java-sdk/bin/appcfg.sh vacuum_indexes myapp/war

On Windows
appengine-java-sdk\bin\appcfg.cmd vacuum_indexes myapp/war

You need to run this from command line on your local PC. This command deletes all indexes for the app that are not mentioned in the local versions of datastore-indexes.xml and generated/datastore-indexes-auto.xml.

About parameters:

  • appcfg.cmd file is part of GAE SDK and so you have to look for it in the folder where SDK is installed. If you use Eclipse then App Engine plugin is installed under "eclipse\plugins\" folder. There might be several GAE SDK folders in there, so make sure you pick the right version. For example for version 1.4.2 the folder name starts with "com.google.appengine.eclipse.sdkbundle.1.4.2".

  • vacuum_indexes - name of the action.

  • myapp/war  - path to the war folder of your application. You need to specify the full path in there.


 Here is corresponding App Engine doc.

After you execute this command, it's going to ask you if you actually want to delete index or not. See screenshot below. 

[caption id="attachment_100" align="alignnone" width="683" caption="Delete index confirmation"]Delete index confirmation[/caption]

-=Oleg=-

Sunday, February 13, 2011

How to download App Engine logs in Windows

The web interface provided by admin console does not provide a lot of flexibility for analyzing your logs and sometimes you just need to have them locally to study carefully. If you are working on Windows and you feel that information provided in App Engine docs is too short, then this blog is for you.

App Engine Docs say you need to run this:

./appengine-java-sdk/bin/appcfg.sh request_logs myapp/war mylogs.txt

Well this is for Linux. If you are on Windows, here what you need to do:

  1. Find the location of the “appcfg.cmd” on your computer. I use Eclipse and in my case it was here:
    "c:\Program Files\eclipse\plugins\com.google.appengine.eclipse.
    sdkbundle.1.4.0_1.4.0.v201012021502\appengine-java-sdk-1.4.0\bin\appcfg.cmd".

  2. Find the location of your app. You need the “war” folder. Here is what I have on my machine:
    "c:\svn\mysource\myapp\trunk\war"

  3. And the final step is to put it all together. Open command prompt and type:
    "c:\Program Files\eclipse\plugins\com.google.appengine.eclipse.
    sdkbundle.1.4.0_1.4.0.v201012021502\appengine-java-sdk-1.4.0\bin\appcfg.cmd" request_logs c:\svn\mysource\myapp\trunk\war mylogs.txt


This will do the magic of downloading your application logs to your computer. Just be patient because it may take a while. In my case downloading 9 hours of logs (~1,000,000 records) took about 30 minutes.

BTW, if you don’t specify the destination folder then file is downloaded into "c:\Documents and Settings\username\" folder.

BTW2, running appcfg.cmd without parameters will show you a help page where you can read how to specify number of days and minimum log level if you need to. By default it will be 1 day of request logs only.

-=Oleg=-