2. About me
Paul Bakker
• Trainer Info Support Hibernat
EJB 3
e
• NLJUG speaker JSF
Flex
• Java Magazine author Seam
Groovy
JavaFX
Grails
Spring
3. About Info Support
• Financieel gezond sinds oprichting 1986
• Focus op IT vakmanschap
• Brede en integrale dienstverlening
• Partnerships met o.a. Microsoft, IBM, NLJUG
• Vestigingen in Nederland en België
- 250+ medewerkers in Nederland
- 25 medewerkers in België
8. Infrastructure
as a Service
A virtual hardware platform
Full control of the operating system
Custom configuration of application servers
9. Infrastructure
as a Service
Pros
It’s just works like your old hardware
No development limitations
No lock-in
Cons
You still have to manage servers
No automatic scaling
10. Platform as a
Service
A virtual application server
No control of the operating system
Running in a sandbox
11. Platform as a
Service
Pros
No more server management
Easy deployment
Automatic scaling
Cons
Limited by the sandbox
Can’t run existing apps
12. Software as a
Service
Run an application from the cloud
Might extend the application using a
proprietary API
15. Handling requests
Each application gets a free domain name
http://yourappname.appspot.com
You can add your own domain name
Each request has a 30 second timeout
Streaming responses are not supported
16. Scaling
JVMs are started on demand
on app startup
after inactivity
when upscaling
Starting a JVM causes a “loading request”
the app is loaded during that request
17. Loading request
optimization
Application startup time is now important
the app might be started after a request
Reduce the use of libraries
Prevent heavy initialization code
share data with multiple JVMs using
MemCache
18. The sandbox
You can’t
Write to the file system
Open sockets
Start threads
Invoke most System calls
Reflect on classes not belonging to the app
Use JRE classes not on the white list
19. Supported
Java Data Objects (JDO)
Java Persistence API (JPA)
Java Server Faces (JSF)
Java Server Pages (JSP) and JSTL
Java Servlet API 2.4
JavaBeans Activation Framework (JAF)
Java Architecture for XML Binding (JAXB)
JavaMail
XML processing APIs including DOM, SAX and XSLT
20. Not Supported
Enterprise Java Beans (EJB)
JAX-WS and JAX-RPC
JDBC
Java EE Connector Architecture (JCA)
Java Management Extensions (JMX)
Java Message Service (JMS)
Java Naming and Directory Interface (JNDI)
Remote Method Invocation (RMI)
24. Sharded architecture
Row name Values
A [...]
B [...]
C [...]
Row name Values
D [...]
E [...]
F [...]
Row name Values
G [...]
H [...]
I [...]
25. Entity storage
Kind => table
Key => primary key
Entity Group => partition
Typed properties => columns
Kind Person
Entity Group /Person:Paul
Key /Person:Paul
name string: Paul Bakker
colleagues Key:/Speaker(68) Key:/Speaker(15)
26. Entity Groups
Entities are hierarchical
Useful for “owned” relations
a chapter can’t exist without a book
/Book(24)/Chapter(2)/Paragraph(3)
27. Queries
Supported filters
< less than
<= less than or equal to
= equal to
> greater than
>= greater than or equal to
!= not equal to
28. Indexes
Each query uses an index
One index for each combination of:
kind
filter property
operator
sort order
29. Index example
JPQL queries
select s from Speaker s order by s.firstname, s.lastname
select s from Speaker s WHERE s.firstname LIKE :firstname order by s.firstname, s.lastname
select s from Speaker s WHERE lastname LIKE :lastname order by s.lastname, s.firstname
Index configuration
30. Transactions
The DataStore is transactional
All DataStore write operations are atomic
Only a single Entity Group can be used
within a transaction
entities in the same group live physically
together
37. Transactions
Begin transaction
Create new Speaker (/Speaker(1))
Add Talk (/Speaker(1)/Talk(1))
Commit transaction
Begin transaction
Add new Speaker (/Speaker(2))
Commit transaction
38. Transaction Isolation
Within a transaction: Serializable
transactions are completely isolated
Outside a transaction: Read Committed
get() will only consist of committed data
queries are more subtle
39. Understand commits
A commit() consists of two milestones
1 changes to entities visible
2 changes to indexes visible
the entity is updated, but might not be
returned by a predicate query
40. Understand commits
bob.age == 18
Transaction 1
bob.age += 1
select ... where age = 18
Transaction 2
41. Understand commits
bob.age == 18
Transaction 1
bob.age += 1
select ... where age = 18
Transaction 2
bob is returned
42. Understand commits
bob.age == 18
Transaction 1
bob.age += 1
select ... where age = 18
Transaction 2
bob is returned
bob.age == 19
43. The low level API
JDBC like API
Work directly with untyped entities and
properties
Query using GQL
52. JPA limitations
No “Joined” inheritance
No “Single Table” inheritance
would be technically possible
No many-to-many relationships
No join-queries
No aggregation queries
No polymorphic queries
53. Owned relationships
The “owned” entity only has meaning when
it’s parent exists
Key includes parent key
/Department(24)/Employee(2)
72. Cron syntax
every N (hours|mins|minutes)
("every"|ordinal) (days) ["of" (monthspec)] (time)
Examples
every 5 minutes
every 12 hours
2nd,third mon,wed,thu of march 17:00
every monday 09:00
1st monday of sep,oct,nov 17:00
every day 00:00
74. Task Queues
Process asynchronous, parallel background
tasks
Modeled as web hooks
a request to a web hook is scheduled
the request handler is just like any other
user request
a web hook has data and code
75. Task queue use cases
Send multiple confirmation emails
each email is sent by a request to the
same task with different data
Place order
send confirmation email (task 1)
send notification to admin (task 2)
79. Saving files
Store files up to 50 mb in the BlobStore
Upload by form POST
file is uploaded to the BlogStore
get a blob key in code
Serve file using blob key
88. Frameworks
A lot of frameworks work “mostly”
but you never know if/when it breaks...
JSF 1.2 e.g. RichFaces is not!
JSF 2 disable threads
Grails using a plugin
Weld multiple issues
JAX-WS
EJB
Spring some modules are not
JMS
101. Quotas
Free Default Quota Billing Enabled Default Quota
Resource
Daily Limit Maximum Rate Daily Limit Maximum Rate
7,400 requests/ 43,000,000 30,000 requests/
Requests 1,300,000 requests
minute requests minute
Outgoing 56 megabytes/ 1 gigabyte free; 10 gigabytes/
Bandwidth (billable, 1 gigabyte 1,046 gigabytes
minute minute
includes HTTPS) maximum
Incoming 56 megabytes/ 1 gigabyte free; 10 gigabytes/
Bandwidth (billable, 1 gigabyte 1,046 gigabytes
minute minute
includes HTTPS) maximum
15 CPU-minutes/ 6.5 CPU-hours free; 72 CPU-minutes/
CPU Time (billable) 6.5 CPU-hours 1,729 CPU-hours
minute minute
maximum
102. Pricing
Resource Unit Unit cost
Outgoing
gigabytes $0.12
Bandwidth
Incoming
gigabytes $0.10
Bandwidth
CPU Time CPU hours $0.10
gigabytes per
Stored Data $0.15
month
Recipients
recipients $0.0001
Emailed
-Maak een nieuwe appengine applicatie
-Run de applicatie lokaal
-Pas het application id aan in de settings
-Upload de applicatie
-Bekijk in de browser
-Doe een aanpassing
-Bekijk opnieuw in de browser
Demo 1: DataStoreServlet
/datastoredemo
Een speaker heeft talks /Speaker(1)/Talk(1)
Een speaker en talk kan in dezelfde transactie worden opgeslagen
Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen.
Demo 1: DataStoreServlet
/datastoredemo
Een speaker heeft talks /Speaker(1)/Talk(1)
Een speaker en talk kan in dezelfde transactie worden opgeslagen
Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen.
Demo 1: DataStoreServlet
/datastoredemo
Een speaker heeft talks /Speaker(1)/Talk(1)
Een speaker en talk kan in dezelfde transactie worden opgeslagen
Twee verschillende speakers kunnen niet in dezelfde transactie worden opgeslagen.
Een speaker heeft ook collega&#x2019;s. Collega&#x2019;s zijn niet &#x201C;owned&#x201D; en daarom kan alleen de key worden opgeslagen ipv de entity zelf. Kijk naar speaker.addColleague en speaker.getCollegues