Ex­plore the Power of the Google App En­gine with Eclipse

App de­vel­op­ers can have their apps hosted by the Google App En­gine (GAE) to run and test them. The en­gine uses the same in­fra­struc­ture that is used by Google. In this well il­lus­trated ar­ti­cle, the au­thor takes the reader through var­i­ous fea­tures of the Go

OpenSource For You - - CONTENTS - By: Mitesh Soni

Google App En­gine (GAE) or App En­gine is a pub­lic plat­form as a ser­vice (PaaS), one of the ser­vice mod­els of cloud com­put­ing as de­fined by NIST (the US-based Na­tional In­sti­tute of Stan­dards and Tech­nol­ogy). GAE was de­vel­oped by Google and was made avail­able for pub­lic use in 2008. Its sta­ble re­lease is 1.8.2, as of July 2013. GAE is writ­ten in Python, Java, Go and PHP. It pro­vides the fa­cil­ity to de­velop and host ap­pli­ca­tions in re­sources man­aged by Google. En­try level us­age has cer­tain re­stric­tions with free tier. App En­gine pro­vides free tier to get started. All ap­pli­ca­tions can use up to 1 GB of stor­age, and suf­fi­cient CPU and band­width to sup­port a re­source­ful ap­pli­ca­tion serv­ing around five mil­lion page views a month.

Apart from Java, Python, Go and PHP, GAE also sup­ports other JVM lan­guages such as Clo­jure via a spe­cial ver­sion of Quer­cus, JRuby, Groovy and Scala, by ex­ten­sion. Go and PHP are not in full-fledged mode but are at the ex­per­i­men­tal phase. GAE makes it sim­ple to build an ap­pli­ca­tion that is highly avail­able and re­li­able, even un­der huge de­mand with vast amounts of data re­quests. It pro­vides au­to­matic scal­ing and load bal­anc­ing, per­sis­tent stor­age, full sup­port for com­mon Web tech­nolo­gies, APIs for au­then­ti­cat­ing users and send­ing email us­ing Google Ac­counts, full fea­tured simulation of GAE on your lo­cal de­vel­op­ment en­vi­ron­ment, sched­uled tasks, and task queues.

In GAE, ap­pli­ca­tions run in a se­cure en­vi­ron­ment that pro­vides limited ac­cess to the core re­sources. This sand­box iso­lates ap­pli­ca­tions in its own highly avail­able, re­li­able, se­cure en­vi­ron­ment that is in­de­pen­dent of the com­pute re­sources. Only HTTP re­quest ex­e­cu­tion is al­lowed Only pure-Python can be up­loaded Does not sup­port ses­sion affin­ity Ac­cess to vir­tual file sys­tems only and read-only ac­cess

avail­able to the filesys­tem on App En­gine Does not sup­port do­mains without www such as http:// clean-clouds.com Java ap­pli­ca­tions may only use a sub­set of the classes from the JRE stan­dard edi­tion In-equal­ity fil­ters on two or more en­tity prop­er­ties per query are not al­lowed in the data­s­tore The min­i­mum re­quest pro­cess­ing time is 60 sec­onds.

SDK in GAE

App En­gine pro­vides a va­ri­ety of ser­vices that help users to per­form com­mon man­age­ment op­er­a­tions for an ap­pli­ca­tion such as URL Fetch, Mail, Mem­cache, Im­age Ma­nip­u­la­tion, etc. The GAE SDKs for Java, Python, PHP and Go each in­clude a Web server ap­pli­ca­tion that em­u­lates all of the GAE ser­vices such as APIs and li­braries, se­cure sand­box en­vi­ron­ment, checks for at­tempts to ac­cess sys­tem re­sources on your lo­cal com­puter, tools to up­load your ap­pli­ca­tion to GAE, etc. The Java SDK avail­able as a Zip

file runs with Java 7. With the Eclipse IDE, Google plug-in for Eclipse can be used to create, test and up­load GAE ap­pli­ca­tions. The Python SDK avail­able as a Zip file runs with Python 2.7. It is im­ple­mented in pure Python, and runs on Win­dows, Mac OS X and Linux. The PHP SDK avail­able as a Zip file with PHP 5.4 runs on any plat­form in­clud­ing Win­dows, Mac OS X and Linux.

Set­ting up Eclipse and con­fig­ur­ing a Google plug-in for Eclipse

Down­load the Eclipse IDE for Java EE De­vel­op­ers from http://www.eclipse.org/down­loads/

In­stall the Google plug-in for Eclipse and fol­low in­struc­tions given at: http://code.google.com/eclipse/docs/in­stall-eclipse3.6.html. Click Next to re­view the items to be in­stalled. Then, click Next to re­view li­cences and se­lect the ra­dio but­ton - I ac­cept the terms of the Li­cence Agree­ment. And then click Fin­ish. It will take some time to in­stall the GAE en­vi­ron­ment in your lo­cal sys­tem. Click New to se­lect Google and then click to se­lect Web Ap­pli­ca­tion Project.

De­s­e­lect the Google Web Tool­kit from the Google SDK sec­tion. Click Fin­ish.

It is a nor­mal Web ap­pli­ca­tion struc­ture and the only dif­fer­ence is ap­pengine-web.xml

<?xml ver­sion="1.0" en­cod­ing="utf-8"?>

<ap­pengine-web-app xmlns="http://ap­pengine.google.com/ns/1.0"> <ap­pli­ca­tion></ap­pli­ca­tion> <ver­sion>1</ver­sion>

<!--

Al­lows App En­gine to send mul­ti­ple re­quests to one in­stance in par­al­lel: --> <thread­safe>true</thread­safe> <!­­ Con­fig­ure java.util.log­ging ­­> <sys­tem-prop­er­ties>

<prop­erty name="java.util.log­ging.con­fig.file" value="WEBINF/log­ging.prop­er­ties"/>

</sys­tem-prop­er­ties>

<!--

HTTP Ses­sions are dis­abled by de­fault. To en­able HTTP ses­sions spec­ify:

<ses­sions-en­abled>true</ses­sions-en­abled>

It's pos­si­ble to re­duce re­quest la­tency by con­fig­ur­ing your ap­pli­ca­tion to asyn­chronously write HTTP ses­sion data to the data­s­tore:

<async-ses­sion-per­sis­tence en­abled="true" />

With this fea­ture en­abled, there is a very small chance your app will see stale ses­sion data. For de­tails, see http:// code.google.com/ap­pengine/docs/java/con­fig/ap­p­con­fig. html#En­abling_Ses­sions

Now just open http://lo­cal­host:8888 in the browser. Click on GAETest to run it in the lo­cal en­vi­ron­ment. De­ploy Sam­ple Hello, Open Source For You Web ap­pli­ca­tion on GAE.

To de­ploy it on GAE, au­then­ti­ca­tion is re­quired. Pro­vide your user­name and pass­word in a new win­dow.

Ac­cept the terms of ser­vice and pri­vacy poli­cies. If the ap­pli­ca­tion ID is not set, the de­ploy­ment process will give an er­ror: “GAETest does not have an ap­pli­ca­tion ID.” To create an ap­pli­ca­tion ID, open https://ap­pengine.google.com log in and se­lect Create New Ap­pli­ca­tion ID.

Click on Create Ap­pli­ca­tion. It will give the mes­sage: ‘Ap­pli­ca­tion Reg­is­tered Suc­cess­fully’ if all goes well. To pro­ceed fur­ther, click on the project set­tings link in the same di­a­logue box.

Click OK and the ap­pli­ca­tion ID er­ror will be solved. Now click on De­ploy.

Once the de­ploy­ment process is com­plete, the con­sole out­put will be as shown be­low:

------------ De­ploy­ing fron­tend ------------ Pre­par­ing to de­ploy:

Cre­ated stag­ing di­rec­tory at: 'C:\Users\ad­min\ Ap­pData\Lo­cal\Temp\ap­pcfg1977774409461224969.tmp' Scan­ning for jsp files. Scan­ning files on lo­cal disk.

Ini­ti­at­ing up­date. Cloning 2 static files.

Cloning 23 ap­pli­ca­tion files. De­ploy­ing: Up­load­ing 3 files. Up­loaded 1 files. Up­loaded 2 files. Up­loaded 3 files. Ini­tial­iz­ing pre­com­pi­la­tion... Send­ing batch con­tain­ing 3 file(s) to­tal­ing 4KB. De­ploy­ing new ver­sion. Clos­ing up­date: new ver­sion is ready to start serv­ing.

Up­load­ing in­dex def­i­ni­tions.

De­ploy­ment com­pleted suc­cess­fully

Now, let’s ver­ify the GAE dash­board and ver­ify the sta­tus of the newly de­ployed ap­pli­ca­tion, as shown in Fig­ure 11.

Let’s run the ap­pli­ca­tion as shown in Fig­ure 12.

Ref­er­ences

[1] http://en.wikipedia.org/wiki/Google_Ap­p_Engine [2] https://de­vel­op­ers.google.com/ap­pengine/docs The au­thor is a Tech­ni­cal Lead at iGate Global So­lu­tions Limited. He is in the Cloud Ser­vices Group and loves to write about new tech­nolo­gies. Blog: http://clean-clouds.com

Fig­ure 7: De­ploy Ap­pli­ca­tion to GAE from Eclipse

Fig­ure 9: Pro­vide Ap­pli­ca­tion Iden­ti­fier in Eclipse Prop­er­ties

Fig­ure 10: De­ploy Project to GAE

Fig­ure 8: Create Ap­pli­ca­tion Iden­ti­fier for GAE Ap­pli­ca­tion

Fig­ure 3: Google SDK set­tings for Web Ap­pli­ca­tions

Fig­ure 4: Web Ap­pli­ca­tion Struc­ture for GAE

lo­cal­host:8888 Hello App En­gine! Avail­able Servlets: GAETest Fig­ure 5: Lo­cal en­vi­ron­ment of GAE

lo­cal­host:8888/gaetest Hello, Open Source For You world Fig­ure 6: Ex­e­cu­tion of GAE Ap­pli­ca­tion in the lo­cal en­vi­ron­ment

Data stor­age in GAE

Fig­ure 1: GAE plug-in in­stal­la­tion in Eclipse

GAE vs Ama­zon Ec2

Fig­ure 11: Ap­pli­ca­tion sta­tus in the GAE dash­board

igate­gae.appspot.com Hello App En­gine! Avail­able Servlets: GAETest Fig­ure 12: Avail­able servlets for an app in GAE

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.