Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Using the gcd Tool to Test Apps and Manage Indexes

You can use the gcd tool to test your app locally and to manage indexes for your production Datastore instance. This page overviews the typical workflow for these activities. For language-specific examples using sample applications, see the Hands-On tutorials.

The gcd tool supports the following workflow:

  1. Create local support for a dataset, including directory, required files, and dataset ID.
  2. Start up the local development server, which provides local emulation of the production Datastore environment.
  3. Generate index definitions from your app's queries to the local development server.
  4. Upload manually created or generated index definitions to your production Datastore dataset.
  5. Delete unused indexes from your production Datastore dataset.

The development workflow using gcd

The following is the typical workflow using the gcd tool:

  1. Create the local Datastore directory by invoking gcd.sh create -d <dataset-id> <directory> , where the value replacing <dataset-id> is the Datastore project ID and <directory> is your local project directory, as shown in the following sample invocation and invocation result:

    gcd.sh create -d my-dataset my-project
    

    Check for a success message similar to this one:

    Created new Datastore project in '/someroot/somepath/my-project' with dataset ID 'my-dataset'
    
  2. Start the development server to run your local dataset using gcd.sh start <directory> where <directory> is your local project directory, for example:

    gcd.sh start my-project
    

    Check for a success message similar to this one:

    ...
    INFO: The admin console is running at http://localhost:8080/_ah/admin
    Aug 07, 2013 4:58:30 PM com.google.appengine.tools.development.DevAppServerImpl start
    INFO: Dev App Server is now running
    
  3. The Python and Java Protocol Buffers client libraries have helper functions that look for two environment variables named DATASTORE_HOST and DATASTORE_DATASET . These two variables tell your app where to connect and what dataset to use, respectively. Set these to point to the local development server and your local dataset, replacing <your-local-dataset-id> below with the value you specified in step 1:

    export DATASTORE_HOST=http://localhost:8080
    export DATASTORE_DATASET=<your-local-dataset-id>
    
  4. Start your app and test it against the local development server. You need to run the queries your app uses against the local development server in order to generates indexes for your production Datastore.

  5. Upload the generated indexes by invoking gcd.sh updateindexes <directory> where <directory> is your local project directory, for example,

    gcd.sh updateindexes my-project
    
  6. Run your app against your production dataset:

    1. Follow all of the steps provided in the activation page under Google Cloud Datastore from other platforms . You will need the service account and the private key described in that procedure.
    2. Remove the DATASTORE_HOST env variable as follows:

      unset DATASTORE_HOST
      
    3. Set the DATASTORE_SERVICE_ACCOUNT variable to the service account you obtained previously:

       export DATASTORE_SERVICE_ACCOUNT=myserviceaccount@developer.gserviceaccount.com
      
    4. Set the DATASTORE_PRIVATE_KEY_FILE to the full pathname of the private key obtained previously:

       export DATASTORE_PRIVATE_KEY_FILE=~/beyond/the/yellow/brick/road/my-privatekey.p12
      
    5. Run your app against production Datastore.

  7. Over time, you might no longer use some of the indexes. You can delete unused indexes from your production dataset by invoking gcd.sh vacuumindexes <directory> , where <directory> is the local project directory, as in the following example:

    gcd.sh vacuumindexes my-project
    

More details on local development server and index configuration

Refer to the following pages for a more in-depth description of:

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.