GAE Overview
Moch Nasrullah R
Samsung R&D Institute Indonesia
(SRIN)
November 2013
As presented at:
Agenda
•
•
•
•

Cloud Computing
GAE Overview
GAE/J Overview
GAE/J Getting Started
Cloud Computing
Cloud Services

Cloud Clients
(Web browser, Desktop App,
Mobile App, embeded, ...)
http://upload.wikimedia.org/wikipedia/commons/b/b5/Cloud_computing.svg
Cloud classification
Software as a Service (SaaS)

Application:
-Web Apps
-Desktop Apps
-Mobile Apps
(Google Apps, Google ...
Google App Engine
• run your web applications on Google's
infrastructure
– Google handles the maintenance infrasturcture:
...
GAE Limits & Quota
•
•
•
•

10 Apps per user
5 Mio pageview free per month
6.5 hours of CPU and 1 Gb in & out traffic
http...
Why GAE
• Easy to build
– Language support (Java, Python, GO, PHP)
– Automatic scaling & load balancing

• Easy to maintai...
GAE/J Overview

developers.google.com/appengine/docs/java/
Let’s give it a try
• Follow the getting started in link below:
•

https://developers.google.com/appengine/docs/java/getti...
Run Eclipse after Installing JDK
Installing Plugin

https://developers.google.com/eclipse/docs/install-eclipse-4.3
Install from zip
Creating Project
Configure SDK

Directory where
Appengine extracted
The Servlet Class
package guestbook;
import java.io.IOException;
import javax.servlet.http.*;
public class GuestbookServle...
Project Structure
Java source code
other configuration

JARs for libraries

app configuration
JSPs, images, data files
Running Application
Preparation for deployment
• Register to Google App Engine
• Create an Application
• Deploy via Eclipse
Register to App Engine
• Register at: https://appengine.google.com/
• Create an Application
Create an Application
• For now, just fill in ‘Application Identifier’ and ‘Application
Title’, than accept ‘Term of Servi...
Problem when Deploying

• Adding VM config
o Open eclipse.ini in the eclipse folder
o Add below lines before -vmargs
-vm
C...
Adding VM config
•
•
•
•

Open eclipse.ini in the eclipse folder
Add below lines before -vmargs
-vm
C:Javajdk1.7.0_40binja...
Sign in to Deploy
Setting App ID & Version

Input Application Identifier
registered at appspot.com
Refactor Example to MVC
• Using JSP as View template
– JSP files will resides inside ‘WEB-INF/jsp’ folder
– So users can n...
GuestbookServlet.java – doGet()
UserService userService = UserServiceFactory.getUserService();
User user = userService.get...
/WEB-INF/jsp/guestbook.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fn" uri="h...
/WEB-INF/jsp/guestbook.jsp
Iterate Greeting List
<c:forEach items="${greetingList}" var="greeting">
Passed from Servlet
<c...
Maybe Next Time
• Using Guice in GAE/J
• Using GAE Python
Reference
• http://www.slideshare.net/dimityrdanailov/google-app-enginevarna-lab-19062013
• http://www.slideshare.net/Lars...
Thanks
• SRIN Members
About
• https://sites.google.com/site/meetnasrul/
Upcoming SlideShare
Loading in...5
×

Google App Engine overview (GAE/J)

10,682

Published on

Googe App Engine Overview, Getting Started using Java

Published in: Technology, News & Politics
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
10,682
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
55
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Google App Engine overview (GAE/J)

  1. 1. GAE Overview Moch Nasrullah R Samsung R&D Institute Indonesia (SRIN) November 2013
  2. 2. As presented at:
  3. 3. Agenda • • • • Cloud Computing GAE Overview GAE/J Overview GAE/J Getting Started
  4. 4. Cloud Computing Cloud Services Cloud Clients (Web browser, Desktop App, Mobile App, embeded, ...)
  5. 5. http://upload.wikimedia.org/wikipedia/commons/b/b5/Cloud_computing.svg
  6. 6. Cloud classification Software as a Service (SaaS) Application: -Web Apps -Desktop Apps -Mobile Apps (Google Apps, Google Translate, Office 360, NetSuite, IBM Lotus Live, GitHub) Platform as a Service (PaaS) Development Platform + Runtime Tools + Environment (Google App Engine, Heroku, Windows Azure, force.com, Rollbase) Infrastructure as a Service (IaaS) CPU Networks Data Storage (AWS, VM Ware, Joyent, Rackspace)
  7. 7. Google App Engine • run your web applications on Google's infrastructure – Google handles the maintenance infrasturcture: hardware failures, security patches, OS upgrades • Free ... within quota
  8. 8. GAE Limits & Quota • • • • 10 Apps per user 5 Mio pageview free per month 6.5 hours of CPU and 1 Gb in & out traffic https://developers.google.com/appengine/do cs/quotas
  9. 9. Why GAE • Easy to build – Language support (Java, Python, GO, PHP) – Automatic scaling & load balancing • Easy to maintain – Web based admin dashboard • Easy to scale (traffic & data storage) – GAE Datastore – Google Cloud SQL – Google Cloud Storage
  10. 10. GAE/J Overview developers.google.com/appengine/docs/java/
  11. 11. Let’s give it a try • Follow the getting started in link below: • https://developers.google.com/appengine/docs/java/gettingstarted/introduction
  12. 12. Run Eclipse after Installing JDK
  13. 13. Installing Plugin https://developers.google.com/eclipse/docs/install-eclipse-4.3
  14. 14. Install from zip
  15. 15. Creating Project
  16. 16. Configure SDK Directory where Appengine extracted
  17. 17. The Servlet Class package guestbook; import java.io.IOException; import javax.servlet.http.*; public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Hello, world"); } }
  18. 18. Project Structure Java source code other configuration JARs for libraries app configuration JSPs, images, data files
  19. 19. Running Application
  20. 20. Preparation for deployment • Register to Google App Engine • Create an Application • Deploy via Eclipse
  21. 21. Register to App Engine • Register at: https://appengine.google.com/ • Create an Application
  22. 22. Create an Application • For now, just fill in ‘Application Identifier’ and ‘Application Title’, than accept ‘Term of Service’
  23. 23. Problem when Deploying • Adding VM config o Open eclipse.ini in the eclipse folder o Add below lines before -vmargs -vm C:Javajdk1.7.0_40binjavaw.exe
  24. 24. Adding VM config • • • • Open eclipse.ini in the eclipse folder Add below lines before -vmargs -vm C:Javajdk1.7.0_40binjavaw.exe
  25. 25. Sign in to Deploy
  26. 26. Setting App ID & Version Input Application Identifier registered at appspot.com
  27. 27. Refactor Example to MVC • Using JSP as View template – JSP files will resides inside ‘WEB-INF/jsp’ folder – So users can not access our template directly • Using Servlet as Controller – Put model in request attribute – Forward to proper View – Change SignGuestbookServlet.java so it redirect to servlet (not JSP): resp.sendRedirect("/guestbook?guestbookName=" + guestbookName);
  28. 28. GuestbookServlet.java – doGet() UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); String signUrl = ""; String userNickname = ""; if (user!=null) { signUrl = userService.createLogoutURL(req.getRequestURI()); userNickname = user.getNickname(); } else { signUrl = userService.createLoginURL(req.getRequestURI()); } Login or Logout URL String guestbookName = req.getParameter("guestbookName"); if (guestbookName == null) { guestbookName = "default"; } Retrieve data from DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); datastore Key guestbookKey = KeyFactory.createKey("Guestbook", guestbookName); Query query = new Query("Greeting", guestbookKey).addSort("date", Query.SortDirection.DESCENDING); List<Entity> greetings = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(5)); // put data tobe displayed in JSP req.setAttribute("signUrl", signUrl); req.setAttribute("userNickname", userNickname); req.setAttribute("guestbookName", guestbookName); req.setAttribute("greetingList", greetings); Put data in Request Attribute String templateFile = "/WEB-INF/jsp/guestbook.jsp"; RequestDispatcher rd = getServletContext().getRequestDispatcher(templateFile); rd.forward(req, resp); Forward to View
  29. 29. /WEB-INF/jsp/guestbook.jsp <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> Taglib <html> <head> <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" /> </head> <body> <c:if test="${userNickname!=''}"> <p>Hello, ${fn:escapeXml(userNickname)}! (You can <a href="${signUrl}">sign out</a>.)</p> Say proper hello to </c:if> sign in user <c:if test="${userNickname==''}"> <p>Hello! <a href="${signUrl}">Sign in</a> to include your name with greetings you post.</p> </c:if> <c:if test="${empty greetingList}"> <p>Guestbook '${fn:escapeXml(guestbookName)}' has no messages.</p> </c:if> <c:if test="${not empty greetingList}"> <p>Messages in Guestbook '${fn:escapeXml(guestbookName)}'.</p> </c:if>
  30. 30. /WEB-INF/jsp/guestbook.jsp Iterate Greeting List <c:forEach items="${greetingList}" var="greeting"> Passed from Servlet <c:if test="${not empty greeting.properties['user']}"> <p><b>${fn:escapeXml(greeting.properties['user'].nickname)}</b> wrote:</p> </c:if> <c:if test="${empty greeting.properties['user']}"> <p>An anonymous person wrote:</p> </c:if> <blockquote>${fn:escapeXml(greeting.properties['content'])}</blockquote> </c:forEach> Form same as previous <form action="/sign" method="post"> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="Post Greeting" /></div> <input type="hidden" name="guestbookName" value="${fn:escapeXml(guestbookName)}"/> </form> </body> </html>
  31. 31. Maybe Next Time • Using Guice in GAE/J • Using GAE Python
  32. 32. Reference • http://www.slideshare.net/dimityrdanailov/google-app-enginevarna-lab-19062013 • http://www.slideshare.net/LarsVogel/google-app-engine-for-java7698966 • http://www.google.com/events/io/2009/sessions.html#appengine • http://www.google.com/events/io/2010/sessions.html#App%20Eng ine • http://www.google.com/events/io/2011/sessions.html#appengine-track • https://developers.google.com/events/io/2012/sessions#cloudplatform • https://developers.google.com/events/io/2013/sessions#t-googlecloud-platform • https://developers.google.com/appengine/
  33. 33. Thanks • SRIN Members
  34. 34. About • https://sites.google.com/site/meetnasrul/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×