From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf ·...
Transcript of From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf ·...
![Page 2: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/2.jpg)
1. Closer to "Big Switch" idea plug and play.
Why Port to AppEngine?
![Page 3: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/3.jpg)
2. Cheaper vs EC2 costsWhy Port to AppEngine?
Basic EC2 instance: ~ $60/month
AppEngineJava: low usage is FREE
![Page 4: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/4.jpg)
3. Simpler development cycle
Just upload code and go!
Why Port to AppEngine?
![Page 5: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/5.jpg)
Amazon feels like this....
Why Port to AppEngine?
![Page 6: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/6.jpg)
Google is like this...
Toaster with wall socket
Why Port to AppEngine?
![Page 7: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/7.jpg)
The Application
HTML & Javascript coded with GWT (Google Web Toolkit)
Description
Server
Java Servlets
Amazon SimpleDB for database
Amazon S3 for metadata and content storage
Client UI
Web page text and image annotation for research and scholarshoip.
![Page 8: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/8.jpg)
30 second timeout
No threads
No file system writes
No sockets
AppEngine Limitations
more details:http://code.google.com/appengine/docs/java/runtime.html
No long running apps, e.g. genetic algorithm, no streaming.
Servlet cannot spawn threads (impacts SimpleDB)
Impacts on libraries
All writes must be to persistance storage, including log files
![Page 9: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/9.jpg)
AppEngine Limitations
AppEngineJava != Java
![Page 10: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/10.jpg)
Components
Works out of the box ... ...but project structure differences are enough to drive you a little crazy
GWT (Google Web Toolkit) - Eclipse plugin
![Page 11: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/11.jpg)
Standard GWT project layout
![Page 12: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/12.jpg)
Standard GWT project layout
Which means the relative path to the image is direct, e.g: DOM.setStyleAttribute(widget.getElement(), "backgroundImage", "url(image/myimage.jpg)");
![Page 13: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/13.jpg)
AppEngine project layout
![Page 14: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/14.jpg)
AppEngine project layout
Which means the relative path to the image starts from a higher directory e.g: DOM.setStyleAttribute(widget.getElement(), "backgroundImage", "url(../image/myimage.jpg)");
Therefore you will likely have to ensure that all resource strings, in code and CSS files are modified for this new structure.
![Page 15: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/15.jpg)
AppEngine project layout
src/com/cloud/demo/MY_APPENGINE_PROJECT.gwt.xml
![Page 16: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/16.jpg)
AppEngine project layout
WEB-INF/web.xml
Configuration hell. Can be very tiresome to ensure all the parts are correct. It may be easier to import the code into a new base project to save the effort.
![Page 17: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/17.jpg)
AppEngine project layout
war/MY_APPENGINE_PROJECT.html
Configuration hell. Can be very tiresome to ensure all the parts are correct. It may be easier to import the code into a new base project to save the effort.
![Page 18: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/18.jpg)
Checking 3rd Party Libraries
![Page 19: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/19.jpg)
Checking 3rd Party Libraries
![Page 20: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/20.jpg)
Checking 3rd Party Libraries
![Page 21: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/21.jpg)
Checking 3rd Party Libraries
![Page 22: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/22.jpg)
The libraries
Works fine, no illegal code.
Jet S3 libraryhttps://jets3t.dev.java.net/
![Page 23: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/23.jpg)
The libraries
Works fine, no illegal code.
Jet S3 libraryhttps://jets3t.dev.java.net/
...except you don't need it now!
![Page 24: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/24.jpg)
SimpleDB => HardDB
Java Library for Amazon SimpleDB - Full featured library, if somewhat over engineered.- Creates all request strings - Uses Apache commons libraries.- developer: Elena@AWS [Used by my application] 'Simple' SimpleDB code in single Java file/class (240 lines) - Very simple - Assumes user creates request strings.- developer: ian schumacher
![Page 25: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/25.jpg)
SimpleDB = HardDB
1. Java Library for Amazon SimpleDB - Full featured library, if somewhat over engineered.- Creates all request strings - Uses Apache commons libraries.- Elena@AWS [Used by my application] 2. 'Simple' SimpleDB code in single Java file/class (240 lines) - Very simple - Assumes user creates request strings.- ianschumacher
Both fail illegal code test. option 1 fails as Apache libraries uses socket connections that are called in code.
option 2 can be fixed with modification of base64 encoding
![Page 26: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/26.jpg)
SimpleDB = HardDB
The SimpleDB library option was abandoned as there was no reasonable hope of rebuilding and modifying the Apache libraries to work.
In addition, my project used the older SimpleDB API which required threading for performance.
The 'simple' SimpleDB code was not used because it would require creating a new library around that core.
There are no other library solutions that can be used out of the box with AppEngineJava
![Page 27: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/27.jpg)
SimpleDB = HardDB
Decision was made to go with Google DataStore
![Page 28: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/28.jpg)
Google DataStore
A repository that stores data objects and that can be queried like a database.
A PersistanceManager handles the CRUD operations.
Very easy to implement.
![Page 29: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/29.jpg)
Google DataStore
Limitations:
Similar to SimpleDBQuery options are even more limited than SimpleDB, but sufficient. (e.g. no logical NOT)
![Page 30: From EC2 to AppEngineJava - Meetupfiles.meetup.com/677520/Migrating to the App Engine.pdf · 2009-06-12 · From EC2 to AppEngineJava @ Alex Tolley alexandertolley@gmail.com June](https://reader034.fdocuments.in/reader034/viewer/2022042201/5ea102c615c0654bc84e72ba/html5/thumbnails/30.jpg)
Summary:Check that your application can live with the AppEngine sandbox and timeout limitations
AppEngineJava != Java. AppEngineJava has language restrictions
Try to use OSS and import libraries
Create the GWT as a fresh project and import the old project, possibly renaming the entrypoint class.
Amazon S3 is fine - but do you need it?
Amazon SimpleDB - needs a AppEngineJava friendly library - seriously consider DataStore instead in this case.