Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Java and the cloud

Java and the cloud

Jozi Java User Group - Gentle introduction to the cloud

Len Weincier

October 28, 2013
Tweet

More Decks by Len Weincier

Other Decks in Programming

Transcript

  1. WHAT IS THE "CLOUD" ? For developers it means getting

    access to infrastructure via an API
  2. INFRASTRUCTURE ? What do we mean by infrastructure ? Infrastructure

    = fundamental building blocks of our env Servers : Disks / CPU's / RAM / Networking Storage : Shared persistent
  3. INFRASTRUCTURE AS CODE { " c p u s "

    : 1 , " r a m " : 1 0 2 4 , " d i s k s " : [ { " b o o t " : t r u e , " s i z e " : 4 0 9 6 0 } ] , " n i c s " : [ { " i p " : " 1 0 . 8 8 . 8 8 . 5 1 " , " n e t m a s k " : " 2 5 5 . 2 5 5 . 2 5 5 . 0 " , " g a t e w a y " : " 1 0 . 8 8 . 8 8 . 1 " , } ] }
  4. MODELLING INFRASTRUCTURE IN CODE c l a s s D

    i s k { b o o l e a n b o o t ; B i g D e c i m a l s i z e ; S t r i n g b a s e I m a g e ; } c l a s s N I C { p u b l i c S t r i n g I P ; p u b l i c S t r i n g N e t M a s k ; p u b l i c S t r i n g G a t e w a y ; }
  5. A MACHINE c l a s s M a c

    h i n e { p u b l i c I n t e g e r c p u s ; p u b l i c I n t e g e r R A M ; p u b l i c D i s k s [ ] ; p u b l i c N I C s [ ] ; }
  6. JSON VS XML Java tends to abstract this away and

    you could use annotations etc At CloudAfrica we are all Json now M a c h i n e m a c h i n e = n e w M a c h i n e ( ) ; / / s e t u p t h e b i t s y o u w a n t G s o n g s o n = n e w G s o n ( ) ; S t r i n g j s o n = g s o n . t o J s o n ( m a c h i n e ) ;
  7. API ? Using Apache HttpClient R e q u e

    s t . P o s t ( " h t t p s : / / w w w . c l o u d a f r i c a . n e t / a p i / s e r v e r s " ) . b o d y ( j s o n ) . a d d ( " u s e r n a m e " , " v i p " ) . a d d ( " p a s s w o r d " , " s e c r e t " ) . b u i l d ( ) ) . e x e c u t e ( ) . r e t u r n C o n t e n t ( ) ; This will return a machine ID you can use later. * t h i s i s b e t a - t a l k t o m e i f y o u w a n t t o p l a y !
  8. WE DON'T CREATE SERVERS THAT OFTEN ? THIS IS NOT

    THE JOB FOR A DEVELOPER ! I WANT THE SALARY OF THE SYSADMIN TOO !
  9. DEPLOYMENT m v n d e p l o y

    : t e s t i n g m v n d e p l o y : s t a g i n g m v n d e p l o y : p r o d u c t i o n You get to control what is needed at a machine level Machine specs can become part of your code
  10. BACKUPS P O S T / s e r v

    e r s / i d / b a c k u p s G E T / s e r v e r s / i d / b a c k u p s
  11. CLONING P O S T / s e r v

    e r s / i d / c l o n e s < - { n a m e : t e s t i n g } P O S T / s e r v e r s / i d / c l o n e s < - { n a m e : p r o d u c t i o n } G E T / s e r v e r s / i d / c l o n e s
  12. RESIZING P O S T / s e r v

    e r s / i d / < - { c p u s : 1 2 , r a m : 1 6 3 8 4 } * t h i s d o e s n o t r e a l l y w o r k w i t h t h e J V M w i t h o u t a r e s t a r t . . .