OpenSource For You

Explore the Power of the Google App Engine with Eclipse

App developers can have their apps hosted by the Google App Engine (GAE) to run and test them. The engine uses the same infrastruc­ture that is used by Google. In this well illustrate­d article, the author takes the reader through various features of the Go

- By: Mitesh Soni

Google App Engine (GAE) or App Engine is a public platform as a service (PaaS), one of the service models of cloud computing as defined by NIST (the US-based National Institute of Standards and Technology). GAE was developed by Google and was made available for public use in 2008. Its stable release is 1.8.2, as of July 2013. GAE is written in Python, Java, Go and PHP. It provides the facility to develop and host applicatio­ns in resources managed by Google. Entry level usage has certain restrictio­ns with free tier. App Engine provides free tier to get started. All applicatio­ns can use up to 1 GB of storage, and sufficient CPU and bandwidth to support a resourcefu­l applicatio­n serving around five million page views a month.

Apart from Java, Python, Go and PHP, GAE also supports other JVM languages such as Clojure via a special version of Quercus, JRuby, Groovy and Scala, by extension. Go and PHP are not in full-fledged mode but are at the experiment­al phase. GAE makes it simple to build an applicatio­n that is highly available and reliable, even under huge demand with vast amounts of data requests. It provides automatic scaling and load balancing, persistent storage, full support for common Web technologi­es, APIs for authentica­ting users and sending email using Google Accounts, full featured simulation of GAE on your local developmen­t environmen­t, scheduled tasks, and task queues.

In GAE, applicatio­ns run in a secure environmen­t that provides limited access to the core resources. This sandbox isolates applicatio­ns in its own highly available, reliable, secure environmen­t that is independen­t of the compute resources. Only HTTP request execution is allowed Only pure-Python can be uploaded Does not support session affinity Access to virtual file systems only and read-only access

available to the filesystem on App Engine Does not support domains without www such as http:// clean-clouds.com Java applicatio­ns may only use a subset of the classes from the JRE standard edition In-equality filters on two or more entity properties per query are not allowed in the datastore The minimum request processing time is 60 seconds.

SDK in GAE

App Engine provides a variety of services that help users to perform common management operations for an applicatio­n such as URL Fetch, Mail, Memcache, Image Manipulati­on, etc. The GAE SDKs for Java, Python, PHP and Go each include a Web server applicatio­n that emulates all of the GAE services such as APIs and libraries, secure sandbox environmen­t, checks for attempts to access system resources on your local computer, tools to upload your applicatio­n to GAE, etc. The Java SDK available as a Zip

file runs with Java 7. With the Eclipse IDE, Google plug-in for Eclipse can be used to create, test and upload GAE applicatio­ns. The Python SDK available as a Zip file runs with Python 2.7. It is implemente­d in pure Python, and runs on Windows, Mac OS X and Linux. The PHP SDK available as a Zip file with PHP 5.4 runs on any platform including Windows, Mac OS X and Linux.

Setting up Eclipse and configurin­g a Google plug-in for Eclipse

Download the Eclipse IDE for Java EE Developers from http://www.eclipse.org/downloads/

Install the Google plug-in for Eclipse and follow instructio­ns given at: http://code.google.com/eclipse/docs/install-eclipse3.6.html. Click Next to review the items to be installed. Then, click Next to review licences and select the radio button - I accept the terms of the Licence Agreement. And then click Finish. It will take some time to install the GAE environmen­t in your local system. Click New to select Google and then click to select Web Applicatio­n Project.

Deselect the Google Web Toolkit from the Google SDK section. Click Finish.

It is a normal Web applicatio­n structure and the only difference is appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <applicatio­n></applicatio­n> <version>1</version>

<!--

Allows App Engine to send multiple requests to one instance in parallel: --> <threadsafe>true</threadsafe> <! Configure java.util.logging > <system-properties>

<property name="java.util.logging.config.file" value="WEBINF/logging.properties"/>

</system-properties>

<!--

HTTP Sessions are disabled by default. To enable HTTP sessions specify:

<sessions-enabled>true</sessions-enabled>

It's possible to reduce request latency by configurin­g your applicatio­n to asynchrono­usly write HTTP session data to the datastore:

<async-session-persistenc­e enabled="true" />

With this feature enabled, there is a very small chance your app will see stale session data. For details, see http:// code.google.com/appengine/docs/java/config/appconfig. html#Enabling_Sessions

Now just open http://localhost:8888 in the browser. Click on GAETest to run it in the local environmen­t. Deploy Sample Hello, Open Source For You Web applicatio­n on GAE.

To deploy it on GAE, authentica­tion is required. Provide your username and password in a new window.

Accept the terms of service and privacy policies. If the applicatio­n ID is not set, the deployment process will give an error: “GAETest does not have an applicatio­n ID.” To create an applicatio­n ID, open https://appengine.google.com log in and select Create New Applicatio­n ID.

Click on Create Applicatio­n. It will give the message: ‘Applicatio­n Registered Successful­ly’ if all goes well. To proceed further, click on the project settings link in the same dialogue box.

Click OK and the applicatio­n ID error will be solved. Now click on Deploy.

Once the deployment process is complete, the console output will be as shown below:

------------ Deploying frontend ------------ Preparing to deploy:

Created staging directory at: 'C:\Users\admin\ AppData\Local\Temp\appcfg1977­7744094612­24969.tmp' Scanning for jsp files. Scanning files on local disk.

Initiating update. Cloning 2 static files.

Cloning 23 applicatio­n files. Deploying: Uploading 3 files. Uploaded 1 files. Uploaded 2 files. Uploaded 3 files. Initializi­ng precompila­tion... Sending batch containing 3 file(s) totaling 4KB. Deploying new version. Closing update: new version is ready to start serving.

Uploading index definition­s.

Deployment completed successful­ly

Now, let’s verify the GAE dashboard and verify the status of the newly deployed applicatio­n, as shown in Figure 11.

Let’s run the applicatio­n as shown in Figure 12.

References

[1] http://en.wikipedia.org/wiki/Google_App_Engine [2] https://developers.google.com/appengine/docs The author is a Technical Lead at iGate Global Solutions Limited. He is in the Cloud Services Group and loves to write about new technologi­es. Blog: http://clean-clouds.com

 ??  ?? Figure 7: Deploy Applicatio­n to GAE from Eclipse
Figure 7: Deploy Applicatio­n to GAE from Eclipse
 ??  ?? Figure 9: Provide Applicatio­n Identifier in Eclipse Properties
Figure 9: Provide Applicatio­n Identifier in Eclipse Properties
 ??  ?? Figure 10: Deploy Project to GAE
Figure 10: Deploy Project to GAE
 ??  ?? Figure 8: Create Applicatio­n Identifier for GAE Applicatio­n
Figure 8: Create Applicatio­n Identifier for GAE Applicatio­n
 ??  ?? Figure 3: Google SDK settings for Web Applicatio­ns
Figure 3: Google SDK settings for Web Applicatio­ns
 ??  ??
 ??  ?? Figure 4: Web Applicatio­n Structure for GAE
Figure 4: Web Applicatio­n Structure for GAE
 ??  ?? localhost:8888
Hello App Engine!
Available Servlets:
GAETest
Figure 5: Local environmen­t of GAE
localhost:8888 Hello App Engine! Available Servlets: GAETest Figure 5: Local environmen­t of GAE
 ??  ?? localhost:8888/gaetest
Hello, Open Source For You world
Figure 6: Execution of GAE Applicatio­n in the local environmen­t
localhost:8888/gaetest Hello, Open Source For You world Figure 6: Execution of GAE Applicatio­n in the local environmen­t
 ??  ?? Data storage in GAE
Data storage in GAE
 ??  ??
 ??  ?? Figure 1: GAE plug-in installati­on in Eclipse
Figure 1: GAE plug-in installati­on in Eclipse
 ??  ??
 ??  ?? GAE vs Amazon Ec2
GAE vs Amazon Ec2
 ??  ?? Figure 11: Applicatio­n status in the GAE dashboard
Figure 11: Applicatio­n status in the GAE dashboard
 ??  ?? igategae.appspot.com
Hello App Engine!
Available Servlets:
GAETest
Figure 12: Available servlets for an app in GAE
igategae.appspot.com Hello App Engine! Available Servlets: GAETest Figure 12: Available servlets for an app in GAE
 ??  ??

Newspapers in English

Newspapers from India