Your SlideShare is downloading. ×
  • Like
  • Save
App Engine Meetup
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

App Engine Meetup

  • 1,835 views
Published

JRuby on Google App Engine …

JRuby on Google App Engine

Extending the Java Platform & APIs

2010-05-04

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,835
On SlideShare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
0
Comments
0
Likes
5

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Wednesday, May 5, 2010
  • 2. JRuby on Google App Engine Extending the Java Platform & APIs John Woodell May 4, 2010 2 Sunday, May 9, 2010
  • 3. Google App Engine 3 Wednesday, May 5, 2010
  • 4. Key Features • No need to install or maintain your own stack • Use Google scalable services via standard APIs • Built-in application management console • Google does the scaling for you • Pay-as-you-go, with free quota to get started 4 Wednesday, May 5, 2010
  • 5. Quotas and Billing Resource Provided Free Additional Cost CPU time 6.5 hours/day $0.10/hour Bandwidth In 1GByte/day $0.10/GByte Bandwidth Out 1GByte/day $0.12/GByte Stored Data 1 GB $0.005/GB-day Emails sent 2000/day to users $0.0001/email 50000/day to admins 6 Wednesday, May 5, 2010
  • 6. Key Limitations • No native code • No threads or sockets • No writing to the filesystem • No relational database • No more than 30 seconds per request 7 Wednesday, May 5, 2010
  • 7. JRuby on App Engine 8 Wednesday, May 5, 2010
  • 8. Current Issues with JRuby on App Engine • Several seconds to “spin-up” a new JRuby instance • Some gems still need their extensions ported to Java • Not officially supported, but you have all that you need + 9 Wednesday, May 5, 2010
  • 9. App Engine Gems • Development Gems – appengine-rack – appengine-tools . . . . dev_appserver.rb & appcfg.rb – appengine-sdk – appengine-jruby-jars • Runtime Gems – appengine-rack – dm-appengine – appengine-apis 10 Wednesday, May 5, 2010
  • 10. Dev AppServer • Local implementation of services – LRU memcache – Disk-backed datastore – HttpClient-backed URLFetch • Emulates the production environment – Sandbox restrictions may be inconsistent, so run tests on production servers as well 11 Wednesday, May 5, 2010
  • 11. Deployment • Your app lives at – <app_id>.appspot.com, or – Custom domain with Google Apps • Deploying uploads – Static files – Resource files – Other metadata (datastore indexes, cron jobs) • Admin Console – dashboards – manage multiple versions – view logs 12 Wednesday, May 5, 2010
  • 12. App Engine JRuby APIs • AppEngine::Users • AppEngine::Datastore • AppEngine::Memcache • AppEngine::Mail • AppEngine::URLFetch • AppEngine::Images • AppEngine::Logger • AppEngine::XMPP • AppEngine::Labs::TaskQueue 13 Wednesday, May 5, 2010
  • 13. Users API • Existing User Account • Restrict your app to a domain map '/src' do use AppEngine::Rack::AdminRequired use AppEngine::Rack::SSLRequired run ActionController::Dispatcher.new end map '/' do run ActionController::Dispatcher.new end 14 Wednesday, May 5, 2010
  • 14. Datastore API + DataMapper # Comparisons you’d expect Zoo.first(:name => 'Galveston') # The 'gt/lt' means greater/less-than. Person.all(:age.gt => 30) Person.all(:age.lt => 40) # The 'gte/lte' means greather/less-than-or-equal-to. Person.all(:age.gte => 30) Person.all(:age.lte => 40) # The value of a pair is an Array Person.all(:name => 'Sam', :id => [ 1, 2, 3, 4, 5 ]) Person.all(:name => [ 'bob', 'rick', 'steve' ]) # Ordering Person.all(:order => [ :age.desc ]) 15 Wednesday, May 5, 2010
  • 15. Memcache API • No configuration required • Same API as Ruby-Memcache • Keys can be any Symbol or String • Can store any Marshalable or Serializable object cache = AppEngine::Memcache.new cache.set_many({:a => 1, :foo => 1..5}) a, foo = cache.get(:a, :foo) 16 Wednesday, May 5, 2010
  • 16. URL Fetch API • Drop-in replacement for Net::HTTP AppEngine::URLFetch.fetch(url, options={}) :method :payload :headers :allow_truncated :follow_redirects :deadline 17 Wednesday, May 5, 2010
  • 17. XMPP API 18 Wednesday, May 5, 2010
  • 18. App Engine JRuby Milestones • 2009-04-07 Early look at Java • 2009-04-08 @olabini publishes blog post on YARBL • 2009-05-06 RailsConf (Sinatra Demo) • 2009-11-02 0.0.5 bundler, precompilation & Duby • 2009-11-20 RubyConf (Rails 3 Demo) • 2009-12-02 0.0.6 Image manipulation examples • 2010-01-21 0.0.8 Rails 2.3.5 Primer for DM & TinyDS • 2010-01-26 0.0.9 Mechanize and Hpricot examples • 2010-02-19 @carlhuda publishes bundler08 • 2010-02-27 0.0.10 ActionMailer example • 2010-04-08 0.0.11 Deferred Dispatcher (early look) • 2010-05-05 0.0.12 JRuby 1.5.0.dev (jruby-openssl) 19 Wednesday, May 5, 2010
  • 19. App Engine Product Roadmap • SSL for third-party domains • Background servers capable of running for longer than 30s • Ability to reserve instances to reduce application loading overhead • Ability to select different availability vs. latency options for Datastore • Support for mapping operations across datasets • Datastore dump and restore facility • Raise request/response size limits for some APIs • Improved monitoring and alerting of application serving • Support for Browser Push (Comet) communication • Built-in support for OAuth & OpenID 20 Wednesday, May 5, 2010
  • 20. Resources • John Woodell, woodie@google.com • Twitter, @johnwoodell • Blog: JRuby on App Engine Blog – http://jruby-appengine.blogspot.com/ • Google App Engine for JRuby – http://code.google.com/p/appengine-jruby/ • Google Group – http://groups.google.com/group/appengine-jruby 21 Wednesday, May 5, 2010
  • 21. Bio • John Wang iPhone, Android, and Web Developer at Fresh Blocks in Honolulu, HI Twitter: @johntwang Github: jwang • Objective I wanted to show that JRuby on GAE is a viable solution for providing RESTful JSON with Google’s Datastore to iPhone and Android apps. Tuesday, May 4, 2010
  • 22. My App • iPhone-JSON is a demo app used to show that AppEngine with Rails 2.3.5 is fully capable of being a RESTful provider with DataMapper. • It is currently up and running on iphone- json.appspot.com for others to copy. • It is also serving as the datastore for an iPhone and an iPad App that are awaiting approval from Apple. Tuesday, May 4, 2010
  • 23. What I Learned • When I started out, I knew I would have to use the DM-Serializer plugin to add back in the RESTful abilities to DM. I did not expect the JSON being POSTed to be case-sensitive for the parameters. • There was a small bug in the DM adapter that was causing problems initially, but that was remedied very quickly thanks to John. • I did need to add in the necessary render statements to each area in the generated responds_to and was also able to get custom REST actions to work without any problems. • Most 3rd Party gems come with scripts to generate models, tables, etc take for work as scripts are written for ActiveRecord and not DataMapper. I needed to modify some scripts for other 3-party gems. Primarily the ones I’m using for doing Push Notifications to the iPhone from GAE. Tuesday, May 4, 2010
  • 24. !"#$!%&'(&!"#!$%&%&'%( )'((*+ C1'!%44!8!"2.(0+!2/.-3!D%.(/! ,#!-%,'!./!)"*"(+,!+$- E<F<G!%-7!H%0%I%44':+!./!5%(('7! .+"!&"$/0%(01*231!,*/0!4'*4('! !"#$!%&'(&0%-7!01:*231!.0! 5%((!,'!"1"1%"2/6%-7!86"2.(7!%44/! %-#*-'!5%-!,*-.0*:!01'.:! 9*:!%!(.;.-3< '@4'-/'/B'%:-.-3/!%-7!J.9! #*2K:'!%!L:''M!5.0.&'-?! =*2!5%-!9.-7!,'!%0> 01'6:'5'.40/!#*2!3%01':!9:*,! "?!%&%&'%(<@'(.@./<-'0 #*2:!42:51%/'/< 0?!0A.00':<5*,B%&%&'%( 3?!3.012"<5*,B%&%&'%( 0%@/0':<3:!1%/!J52::'-0(#?!EEN! 2/':/<
  • 25. !"#$%$&"'()$*''+,)$-..$/0+10)2341,( 56 748)$9#$'!0$&,':;$!1<"':<$=)10+$4$(#($4;9106 >6 ?1;$#':$0'<1&)$<")$@*''+,)@$10(1;)$@*''+,)$-..$/0+10)@A B6 %<C($DE))$D'E$(94,,$4..(6 F6 G))9);$4$=1<$10<)E)(<10+$<'$;)8),'.$:(10+$341,($D'E$4$ (#(<)9$<"4<$;1;0C<$(:..'E<$1<$5HHI6$J),<$4$=1<$"4&KL1("6 M6 N'"0$O'';),,$0)8)E$(,)).(6$3)4,,# 6
  • 26. !"#$%&'"()* +,-./*%0,#0%#12%*344"*2$%0"%5"1)%5-0,%#%6/27%-.*0#''6% $".80%9-:2%13&;<"42.-$=%"42.**'>: +,2%*4-.<34%-**32%5#*%#%4#-.%3.0-'%?312)#0%$"7-.#02$%-0: @8A2%.2A21%12#(,2$%0,2%4"-.0%5,212%@8$%.22$%#% *2(".$#1;%-.*0#.(2%0"%*21A2%7;%3*21*%9;20>%&30%@%B22'% 0,#0%5,2.%@%$"=%-08''%,310:
  • 27. !"##$%$&'$"($)*)"+, -./0/12$+'$3.)+3/$(.)($%$!'+1($4/$&/5/#'6"+*$!"(.$7)"#2$)+&$ &/6#'8"+*$'+$9''*#/$:66$;+*"+/< !"#$%&'()*'*+#,-$. #/#/+#0
  • 28. MYSELF • Joshua Moore, Quality • Find me here: Assurance Manger at Armorize Technologies • Twitter: @codingforrent • Wanted to develop apps • github: http://github.com/ with Rails without the pains joshsmoore of being a sys admin so started to work with Rails • blog: on the GAE www.codingforrent.com Monday, May 3, 2010
  • 29. MY APP • Rails Turbine - Goal to be a no config drop in blog engine for built with Rails on the GAE (still a work in progress). • Open source on github • Built with Rails 2.3.5, Datamapper, and HAML • Coauthor the rails_dm_datastore gem to fix some rails/dm bugs • Currently it powers my blog (www.codingforrent.com) Monday, May 3, 2010
  • 30. ROAD BLOCKS • Initiallyhad some bugs with datamapper and rails not always playing nice together. Most of those are worked out in the rails_dm_datastore. • The next biggest problem has been testing. It can be difficult and sometimes unreliable for testing within the Datastore environment. Monday, May 3, 2010
  • 31. Wednesday, May 5, 2010