google app engine - soft uni 19.06.2014

55
App Engine Getting started for ... Java Developers @d_danailov

Upload: dimitar-danailov

Post on 11-May-2015

665 views

Category:

Software


5 download

DESCRIPTION

Запис от лекцията в Софтуерният Университет. Говорихме си какво е Cloud, кои са по - популярните публични клайдове и как все един от тях е решил да предоставя облачни услуги като след това преминахме към основната тема Google App Engine.

TRANSCRIPT

App Engine

Getting started for ... Java Developers@d_danailov

Topics Today

● Cloud Computing● What is Google App Engine(GAE) ?● Architecture of GAE● Quota & Pricing● Developing using GAE● Deploying Applications● Security● GAE datastore● Demo Application

Cloud computing

Classification of cloud computing

What is Google App Engine(GAE) ?

● Google’s platform to build Web Applications on the cloud

● Dynamic Web server● Transactional Data Store Model

Why GAE?

● Automatic scaling and load balancing● Lower total cost of ownership● Web administration console & utilities● Enhances developing & deploying of web applications● Multilanguage support (Java, Python, GO, PHP)● Fully featured SDK for local development● Rich set of Google APIs● Secure environment (Sandbox)

What is Google App Engine(GAE) ?

Quota & Pricing

● Google App Engine Pricing● Google Compute Engine● Google Cloud Storage● Google BigQuery● Google Cloud SQL

Application life Cycle

Application Developmentusing GAE

Development life Cycle

Your first GAE Application

● Hello, World

GAE Services

● Developers are focused on implementing custom business logic

● Wide range of services available○ User service○ Blobstore○ Task Queues○ Mail Service○ Image○ Memcache, etc

User Services

● Provides a simple API for authentication and authorization○ Detect if a user is signed in App○ Detect if a user is an admin

● Works in combination with web.xml security settings● Three authentication options

○ Google Account○ Google Apps domains users○ OpenID - experimental

User Services Demo

Blobstore Services

● The Blobstore Service allows your application to serve binary objects, larger than the entities in the Datastore.

● Blobs are created by uploading files through HTTP○ The upload and store logic is handled by the

Service○ The HTTP request is redirected to a dispatcher, by

specified by the developer

Blobstore Services Demo

Task Queues

● Task Queues allow the application to perform work, initiated by a user request, outside of that request.

● Suitable for triggering background processes● Different types of queues

○ Push queues○ Pull queues○ REST reference

Task Queues Demo

Storing Data

● GAE provides different ways of storing application data○ Datastore - provides a noSQL schemaless object

datastore with a query engine and transactions○ Google Cloud SQL - provides a relation database,

based on MySQL○ Google Cloud Storage - provides a storage service

for objects and files up to terabytes in size

SQL vs NoSQL : Battle of Backends

Datastore

● Based on Google Big Table● NoSQL object storage● Schemaless and Hierarchical● No joins and aggregations● Queries must rung against existing indexes● Access API using an instance of the DatastoreService

Class

Datastore - Types

● There are two different Datastore types we can use : ○ High Replication Datastore(HRD)○ Master / Slave Datastore

Datastore - Types (HRD)

● High Replication Datastore(HRD) is replicated across multiple data centers ○ Highest level of availability○ Higher latency on writes○ Query data is eventually consistent

Datastore - Types (Master/Slave)

● Master / Slave Datastore - one data center holds master copy of the data. Data in the master is asynchronously copied to the slaves.○ Periods of unavailability○ Low latency○ Highest level on consistency

Datastore - Entities

● Entities - contain key/value pairs● Each entity has a unique key comprised of :

○ The kind of the entity (Example : Person, Human)○ An identifier for the the individual entity that can be

■ a key name string■ an integer numeric ID

○ An optional ancestor path locating the entity in the Datastore hierarchy

Datastore - Entities (2)● The Entity class● Creating an Entity

○ Create an instance of the Entity class○ pass it to the DatastoreService.put() method

● Retrieving an Entity○ Pass an entity Key to the DatastoreService.get()

Datastore - Entities (3)● Updating an Entity

○ No different between creating and updating● Deleting an Entity

○ Pass an entity Key to the DatastoreService.delete() method

Datastore Entities Demo

Datastore - Queries

● Queries retrieve a number of entities that meet a specified set of conditions from Datastore

● Queries can specify : ○ Entity kind○ Zero or more filters, based on entity properties

values○ Zero or more sort order descriptions○ Default or you can set a limit clause

● Rung against an existing index

Datastore - Queries (2)● The Query Class

○ Pass entity kind as constructor parameter● Adding filters - Datastore Filter Class and setFilter

method○ Property name○ Operator - a value, defined in FilterOperator○ Value - the value to compare to

● Sorting - addsort() method○ Property name○ Sort order - a value, defined in SortDirection

Datastore - Queries (3)● Fetching results

○ Pass a Query instance to the DatastoreService.prepare() method

○ Use one of the methods of the PreparedQuery instance, returned as a result

○ Refine your results using FetchOptions

Datastore - Indexes● Similar to relational database indexes● Automatic indexed created for some queries● Other queries require indexes to be manually created

in the datastore-indexes.xml. They include : ○ Queries with multiple sort orders○ Queries with a sort order on keys in descending

order○ Queries with one or more inequality filters on a

property and one or more equality filters on other properties, etc.

Queries Demo

Datastore - Transactions● Transactions - a set of atomic operations● Transaction type :

○ Default transactions - work on a single entity○ Cross - group (XG) transactions - work on different

entity groups● Getting a Transaction instance - DatastoreService.

beginTransaction()

Datastore - Transactions (2)● Manipulating a transaction

○ Transaction.commit() - confirm changes○ Transaction.rollback - rollback changes, restore

previous state

Datastore Transactions Demo

Source

● https://cloud.google.com● http://upload.wikimedia.org● http://en.wikipedia.org● http://stackoverflow.com/● https://www.youtube.com