Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Google App Engine 101 v2

Uvod do App Engine...

Michal Srajer

on 18 November 2010

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Google App Engine 101 v2

Google App Engine is a platform for developing and hosting web applications in Google-managed data centers. Java & Python PaaS ale diky JVM i Groovy, JRuby, Scala, Clojure, JavaScript... datastore postaven nad BigTable frameworks například Rails, Sinatra, Grails, JSF, Spring MVC, Struts, Tapestry, SiteMesh... APIs http://bit.ly/AEtalk-fw ne IaaS jako EC2 - limits & quotas není k dispozici vše z JRE whitelist - read-only filesystem práce s thready naked domains loading requests http://bit.ly/AEtalk-white 30 sec + 10 MB = start nové instance aplikace (problém s frameworky) The White House's "Open For Questions" application
accepted 100K questions and 3.6M votes in under 48 hours registrace https://appengine.google.com/ vytvoření
app id stažení
SDK instalace
pluginů vytvoření
projektu deploy Co to je? Jak na to? BigTable is a sparse, distributed, persistent
multidimensional sorted map. rychle cteni X pomaly zapis výběr ze 3 API - JPA, JDO, low-level API
alternativa: Objectify import com.google.appengine.api.datastore.Key;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

public class Employee {
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

private String firstName;

private String lastName;

...} PersistenceManager pm = PMF.get().getPersistenceManager();

Employee e = new Employee("Alfred", "Smith", new Date());

try {
} finally {
Entity entity = new Entity("myKind");
Email myEmail = new Email("test@email.com");
entity.setProperty("emailProperty", myEmail);
Key key = datastore.put(entity);

Entity storedEntity = datastore.get(key);
Email storedEmail = (Email) storedEntity.getProperty("emailProperty"); JCache API
vše v RAM
10x rychlejší než datastore
java.net API
Google Secure Data Connector JavaMail API
send (via e-mail admina / usera)
receive (via Servlet)
send, receive, invite...
podobně jako Mail resize, rotate, crop, flip
composite, convert
enhance, get info
autentizace Google účtem
autorizace admina background tasks
data = HTTP POST
code = URL Blob nově až 2GB
upload na Blobstore -> rewrite
<form action="<%= blobstoreService.createUploadUrl("/upload") %>" method="post" enctype="multipart/form-data">
<input type="file" name="myFile">
<input type="submit" value="Submit">
</body> Queue queue = QueueFactory.getDefaultQueue();
queue.add(url("/worker").param("key", key)) UserService userService = UserServiceFactory.getUserService();

String thisURL = request.getRequestURI();
if (request.getUserPrincipal() != null) {
response.getWriter().println("<p>Hello, " + request.getUserPrincipal().getName() + "! You can <a href=\"" + userService.createLogoutURL(thisURL) + "\">sign out</a>.</p>");
} else {
response.getWriter().println("<p>Please <a href=\"" + userService.createLoginURL(thisURL) + "\">sign in</a>.</p>");
byte[] oldImageData; // ...

ImagesService imagesService = ImagesServiceFactory.getImagesService();

Image oldImage = ImagesServiceFactory.makeImage(oldImageData);
Transform resize = ImagesServiceFactory.makeResize(200, 300);

Image newImage = imagesService.applyTransform(resize, oldImage);

byte[] newImageData = newImage.getImageData(); JID jid = new JID("example@gmail.com");
String msgBody = "Someone has sent you a gift on Example.com. To view: http://example.com/gifts/";
Message msg = new MessageBuilder().withRecipientJids(jid).withBody(msgBody).build();

boolean messageSent = false;
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
if (xmpp.getPresence(jid).isAvailable()) {
SendResponse status = xmpp.sendMessage(msg);
messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
} Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);

String msgBody = "...";

try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("admin@example.com", "Example.com Admin"));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress("user@example.com", "Mr. User"));
msg.setSubject("Your Example.com account has been activated");

} try {
URL url = new URL("http://www.example.com/atom.xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;

while ((line = reader.readLine()) != null) {
// ...

} Cache cache;

try {
cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
} catch (CacheException e) {
// ...

String key; // ...
byte[] value; // ...

// Put the value into the cache.
cache.put(key, value);

// Get the value from the cache.
value = (byte[]) cache.get(key); K čemu to je? Google App Engine 101 Michal Šrajer @srakyi + rychlý startup projektu enterprise cena snadný vývoj využití standardních API postupně roste a zlepšuje se nutí k vývoji scalable apps dev server jen opravdu využité zdroje CPU Time, Bandwidth in, Bandwidth out, Storage, Email
Architecture Google infrastructure BTW právě hledáme posily! # new users of Corkbin per day provoz aplikací bez údržby škálování
Full transcript