App Engine compat runtime has full access to AppEngine Services and API's.
This app provides:
- A web interface that uses Cloud Bigtable to track the number of visits from an opaque version of your Google account.
- A simple REST interface that can read and write arbitrary data to a Cloud Bigtable table using GET, POST, and DELETE verbs.
SECURITY WARNING – This app will read / write the two tables you create (gae-hello
and from-json
) The app provides NO ADDITIONAL SECURITY PROTECTIONS. We suggest that instances should only be available while testing and that test data be used.
- Requirements
- Project Setup
- Running Locally
- Deploying the AppEngine Runtime
- AppEngine Debugging Hints
- Using Bigtable-Hello
- Using-JSON
- Latest version of gcloud
- Update with
gcloud components update
gcloud init
(if you haven't already)gcloud components install alpha beta app-engine-java
- Java 1.8
- Maven
-
Follow the instructions for Creating a Google Developers Console project and client ID
-
Use Cloud Console to enable billing.
-
Select APIs & Auth > APIs
-
Enable the Cloud Bigtable API and the Cloud Bigtable Admin API
(You may need to search for the API.) -
Select Storage > Bigtable > Create Cluster
Create a new Cluster -- You will need both the Zone and the Cluster ID
-
Create the table (tableName, Column Family)
create 'gae-hello', 'visits'
create 'from-json', 'cf1', 'cf2', 'cf3', 'cf4'
exit
-
Build and run the Project
mvn clean gcloud:run -Pmac -Dbigtable.projectID=myProject -Dbigtable.clusterID=myCluster -Dbigtable.zone=myZone
Note the -Pmac
is REQUIRED for running on a Macintosh, -Pwindows
is used for running on Windows, and the option is not required for Linux.
- Access the page by going to
localhost:8080
from your browser, it should ask you to login, and count that for you.
-
Deploy the application
mvn clean gcloud:deploy -Dbigtable.projectID=myProject -Dbigtable.clusterID=myCluster -Dbigtable.zone=myZone
-
go to the new default module which will be displayed in results from the deploy. It will look like:
https://20150624t111224-dot-default-dot-PROJECTID.appspot.com
you can go to that url to test.
The first thing to do, if you'd like to debug is use the servlet.log()
methods, they seem to work when other loggers don't. Then take control of your GAE instance:
-
Find your instance
gcloud preview app modules list
-
Either show the container log
sudo docker logs <containerID>
or enter the containersudo docker exec -it <containerID> /bin/bash
-
With your browser, go to localhost:8080 in your browser. (Local) Or to https://.appspot.com
-
Sign-in with Google. Your visit should increment the counter.
- Entities (rows) can be accessed using //projectID.appspot.com/json/rowkey
- GET - Will wrap up everything as JSON
- POST - Will convert the JSON to ColumnFamily : Qualifier and write the data
- DELETE - Will remove the row.
-
The URL should be either localhost:8080, docker:8080, or https://.appspot.com
-
curl -H "Content-Type: application/json" -X POST -d '{"username":"red","id":535}' http://localhost:8080/json/blueword
-
curl -X GET http://localhost:8080/json/blueword
-
curl -H "Content-Type: application/json" -X DELETE http://localhost:8080/json/blueword
You will note that none of these examples use Column Family specifiers. It defaults to using cf1
, if you wish to use the other column families specify <columnFamily>:<column>
where columnFamily is one of cf1, cf2, cf3, or cf4 that you created earlier.