cloudconf2011 introduction to google app engine

33
21.11.11 Introduction into Google App Engine Halil-Cem Gürsoy adesso AG Tw @hgutwit G+ http://goo.gl/hljRS

Upload: adesso-ag

Post on 29-Nov-2014

891 views

Category:

Technology


0 download

DESCRIPTION

Diese Präsentation gibt eine Einführung in die Google AppEngine für Java.

TRANSCRIPT

Page 1: CloudConf2011 Introduction to Google App Engine

21.11.11

Introduction into Google App Engine

Halil-Cem Gürsoyadesso AG

Tw @hgutwit

G+ http://goo.gl/hljRS

Page 2: CloudConf2011 Introduction to Google App Engine

The speaker

► More then 12 years development in Java

► Before getting a “consulting developer“ some years research

(calculation of RNA folding with genetic algorithms using Pascal)

► Senior Software Engineer at adesso AG, Dortmund

► Speaker on some conferences: (W)-JAX, DOAG, HerbstCampus etc.

► Mostly EAI/SOA projects... with plain good old Java / JEE

► … and a bit Scala

21.11.11 CloudConf 2011 - GAE/J2

Page 3: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J3

Page 4: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J4

Page 5: CloudConf2011 Introduction to Google App Engine

The Google App Engine

► A classic PaaS

► No control over the OS

► A runtime for Web Application

► At the start, only Python was supported

► Since 2009 Java, now Google Go

> Java-Support is limited!

21.11.11 CloudConf 2011 - GAE/J5

Page 6: CloudConf2011 Introduction to Google App Engine

Talking about GAE/J

► GAE/J = JRE6

> A Sandbox with restrictions

► Supports out of the box

> Servlet API 2.4 (*)

> JSF 1.1, 2.0 (*)

> JSP (*)

> JDO 2.3 (?!)

> JPA 1(*)

► Support for Google Services und API‘s

21.11.11 CloudConf 2011 - GAE/J6

Page 7: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J7

Page 8: CloudConf2011 Introduction to Google App Engine

Persistence in GEA

► Default Store is a Key-Value NoSQL-DB (Google BigTable)

► JDO and JPA supported… partially

> ORM via DataNucleus v1.1

► JDO is still better documented than JPA in the GAE/J documentation

► You can use the low level API for Google BigTable

► You can use in-memory Databases

► Enhancement of Entity Classes needed (good to know for Build)

► MySQL-Support is upcoming (now in Beta, chosen accounts)

21.11.11 CloudConf 2011 - GAE/J8

Page 9: CloudConf2011 Introduction to Google App Engine

GAE - JPA

► Transactional behavior is configured in the persistence.xml

<persistence-unit name="transactions-optional">

<provider>org.datanucleus.store.appegine.jpa.DatastorePersistenceProvider

</provider>

<properties>

<property name="datanucleus.NontransactionalRead” value="true" />

<property name="datanucleus.NontransactionalWrite” value="true" />

<property name="datanucleus.ConnectionURL” value="appengine" />

</properties>

</persistence-unit>

21.11.11 CloudConf 2011 - GAE/J9

Page 10: CloudConf2011 Introduction to Google App Engine

More on JPA

► @ManyToMany is not supported

► Join-Queries are not supported

► You can not use

> InheritanceType.SINGLE_TABLE

> InheritanceType.JOINED

► No support for aggregation queries > group by, having, sum, avg, min, max

► No support for polymorphic queries

21.11.11 CloudConf 2011 - GAE/J10

Page 11: CloudConf2011 Introduction to Google App Engine

More to know about limits in JPA

► Resultsets are not initialized, you have to do it!> resultSet.size();

► Id Fields: don’t use long type> Unsupported primary key type: long

► GenerationType.TABLE results in an error> javax.persistence.PersistenceEception: Transaction is still

active.

► Solution@Id

GeneratedValue(strategy = GenerationType.IDENTITY)

private com.google.appengine.api.datastore.Key key;

21.11.11 CloudConf 2011 - GAE/J11

Page 12: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J12

Page 13: CloudConf2011 Introduction to Google App Engine

Other Limits in GAE

► The “JRE Whitelist” defines all supported JRE classes

> http://code.google.com/intl/de-DE/appengine/docs/java/jrewhitelist.html

> Only ~ 1500 classes

► Your application should not

> …start own threads (due to that, no Akka-Support if you use Scala)

> …write files

> …open network sockets

21.11.11 CloudConf 2011 - GAE/J13

Page 14: CloudConf2011 Introduction to Google App Engine

Will it play?

► Overview about the support for frameworks and JVM languages:> http://code.google.com/p/googleappengine/wiki/WillItPlayInJava

► No support for…> JAX-RPC

> JDBC

> JMS (!)

> JNDI

> …and much more!

► A little bit support for JAX-WS, good support for REST

► Scala, Groovy (look @ Gealky) etc. supported

► Spring Core is supported

21.11.11 CloudConf 2011 - GAE/J14

Page 15: CloudConf2011 Introduction to Google App Engine

Spring support

► Not all Spring Projects are supported - core is► Running: Spring MVC with Spring beans► Setup: JAR files into /WAR/WEB-INF/lib and add to Classpath► Example:

<listener> <listener-class>

org.springframework.web.context.ContextLoaderListener</listener-class>

</listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>

org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/springgae/*</url-pattern> </servlet-mapping>

21.11.11 CloudConf 2011 - GAE/J15

Page 16: CloudConf2011 Introduction to Google App Engine

Why?

21.11.11 CloudConf 2011 - GAE/J16

Page 17: CloudConf2011 Introduction to Google App Engine

GAE and Android

► Tight integration of GAE and Android via Android Cloud to Device

Framework (C2DM)

> http://code.google.com/android/c2dm/

► C2DM enables Android Apps to use all GAE as the backend

► ...e.g. use the GAE Data Store

► ...e.g. send Mails from GAE

► Example: Chrome to Phone-Extension and App

> http://code.google.com/p/chrometophone/

21.11.11 CloudConf 2011 - GAE/J17

Page 18: CloudConf2011 Introduction to Google App Engine

More Reasons…

► No one enforces you to use JPA or JDO on GAE!

> Use the native Interface

> You have a free, full distributed, NoSQL Key-Value DB!

► Transparent scaling of your app

> You have not to care about how many instances you have to start and

then to start

> GAE is not Beanstalk / CloudFoundry

> In Beanstalk / CloudFoundry you have still to take care about LB and

your infrastructure

21.11.11 CloudConf 2011 - GAE/J18

Page 19: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J19

Page 20: CloudConf2011 Introduction to Google App Engine

Quota

► GAE with limits w/o fee

► New Billing System to overcome limits

► Quota exceeded: HTTP 403 Errors or Exceptions (bad if you not aware of quota)

► Per minute quota = aprox. 500 Req./min.

21.11.11 CloudConf 2011 - GAE/J20

Page 21: CloudConf2011 Introduction to Google App Engine

Measured Performance

21.11.11 CloudConf 2011 - GAE/J21

Page 22: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J22

Page 23: CloudConf2011 Introduction to Google App Engine

Build-Tools

► Ant is supported

> Enhancement of entity classes

> Deployment

► Maven

> Maven2 plug-in available (http://code.google.com/p/maven-gae-plugin/ )

> Archetypes for JSP, GWT and Wicket-Projects

> GAE SDK not available via Maven repositories anymore (?)

21.11.11 CloudConf 2011 - GAE/J23

Page 24: CloudConf2011 Introduction to Google App Engine

Agenda

► Google App Engine

► Persistence in Google App Engine

► Limits in GAE/J

► Quota and Performance

► Build-Tools

► Hands-On

21.11.11 CloudConf 2011 - GAE/J24

Page 25: CloudConf2011 Introduction to Google App Engine

Hands on?

► Some slides to tell you that is needed

► Ask me afterwards for a live demo

► Get ready...

21.11.11 CloudConf 2011 - GAE/J25

Page 26: CloudConf2011 Introduction to Google App Engine

Getting started

► Google App Engine Account activated?

> You need your mobile number for activation

► Eclipse with the Google Plug-in

► Manual installation via Eclipse Market Place

> http://marketplace.eclipse.org/content/google-plugin-eclipse

► SDK with CLI and more resources at GAE-Homepage

– http://code.google.com/appengine/

21.11.11 CloudConf 2011 - GAE/J26

Page 27: CloudConf2011 Introduction to Google App Engine

Create new project

21.11.11 CloudConf 2011 - GAE/J27

Page 28: CloudConf2011 Introduction to Google App Engine

Hello World

21.11.11 CloudConf 2011 - GAE/J28

Page 29: CloudConf2011 Introduction to Google App Engine

Test in the local sandbox

► You can test your application in the local sandbox

► http://localhost:8888/[your_project_name]

21.11.11 CloudConf 2011 - GAE/J29

Page 30: CloudConf2011 Introduction to Google App Engine

Create your cloud app

► Register your application in your GAE account

► https://appengine.google.com/ -> “Create Application”

► Choose an Application Identifier and an Application Name (note them!)

► Choose the Authentication Option> Default is “Open to all Google Account users”

> User can sign in into your app using their Google Account

► Choose Storage Option> High Replication (default) vs. Master/Slave

> High Replication is “eventualy consistent” (latency in writes)

21.11.11 CloudConf 2011 - GAE/J30

Page 31: CloudConf2011 Introduction to Google App Engine

Deployment

► Choose „Google – Deploy to App Engine“ from context menu

► Provide your App Engine data

21.11.11 CloudConf 2011 - GAE/J31

Page 32: CloudConf2011 Introduction to Google App Engine

Calling now on the cloud

► Call your Application now on the cloud!

► [appid].appspot.com/[servletname] (Servletname = Projectname by

default)

► The servlet should greet you…

► Check your Application-Dashboard

– https://appengine.google.com/

21.11.11 CloudConf 2011 - GAE/J32

Page 33: CloudConf2011 Introduction to Google App Engine

Thank you for your attention!

[email protected]