Wednesday, April 20, 2011

CloudFoundry PaaS Test Drive

I checked out today the recently announced VMWare SpringSource PaaS, I'll have to admit that my first experience went pretty well, from 0 to up & running in the cloud in less than 15 min total (excluding download time from maven for some dependencies, your mileage may vary :), this is amazingly RAD!!. I used the vmc client instead of the STS plug-in, I needed an app to deploy so I used Roo (which also has a plugin) to generate the PetClinic app from sample script file that ships with it, below are my foot-steps, follow along if you happen to be checking it out too:
# install ruby, below is the ubuntu distro way, use pkg installer accordingly
sudo apt‐get install ruby‐full
sudo apt‐get install rubygems
sudo install gem vmc
# either add to $PATH on .bashrc or just create quickly an alias as below
alias vmc='/var/lib/gems/1.8/bin/vmc'
# once installed then launch vmc then with a target cloud + login
vmc target api.cloudfoundry.com
vmc login
> enter email and password, you can use 'vmc passwd' to reset given temp password
> roo
script /samples/clinic.roo
perform package
exit
cd yourRooProjRoot/target/petclinic-0.1.0.BUILD-SNAPSHOT
vmc push
# accept all defaults and give a unique name
https://petclinicroo.cloudfoundry.com And below are some useful vmc app commands you can run afterwards:
  • vmc -h
  • vmc apps
  • vmc stats petclinicroo
  • vmc logs petclinicroo
  • vmc instances petclinicroo
  • vmc logout
I found the vmc client very straightforward to use. Though this is a very plain app test drive, what's important to identify here is (which I found better than other solutions):
  • Support for some JVM languages
  • Data storage SQL + NoSQL support [MySQL,MongoDB,Redis], more to come
  • Open paradigm, no lock in, public, private and cross infrastructure
  • PaaS is becoming the imminent sweet-spot for application developers, and VMware has stepped up the game in the future of the cloud. Update: 08/10/2011, here's a PoC js data grid doing CRUD ops (some features not implemented) invoking RESTful service using provisioned MongoDB for persistence and Spring profiles
    https://restgrid.cloudfoundry.com (System.getenv("VCAP_APPLICATION") != null) ? "Cloud" : "Local" )
    public class CloudApplicationContextInitializer implements
                  ApplicationContextInitializer<ConfigurableApplicationContext> {
    @Override
    public void initialize(ConfigurableApplicationContext applicationContext) {
      CloudEnvironment env = new CloudEnvironment();
        if (env.getInstanceInfo() != null) {
          applicationContext.getEnvironment().setActiveProfiles("cloud");
        } else {
          applicationContext.getEnvironment().setActiveProfiles("dev");
        }
      }
    }
    
    <mongo:db-factory id="mongoDbFactory"
     dbname="#{serviceProperties['mongodb-db.db']}"
     host="#{serviceProperties['mongodb-db.hostname']}"
     port="#{serviceProperties['mongodb-db.port']}"
     username="#{serviceProperties['mongodb-db.username']}"
     password="#{serviceProperties['mongodb-db.password']}"
    />             
    
    <bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
    <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
    </bean>
    
    <beans profile="dev">
    <util:properties id="serviceProperties">
    <prop key="mongodb-db.db">db</prop>
    <prop key="mongodb-db.hostname">127.0.0.1</prop>
    <prop key="mongodb-db.port">27017</prop>
    <prop key="mongodb-db.username">xxx</prop>
    <prop key="mongodb-db.password">xxx</prop>
    </util:properties>
    </beans>
    
    <beans profile="cloud">
    <cloud:service-properties id="serviceProperties"/>
    </beans>
    
    $ vmc apps
    +--------------+----+---------+-------------------------------+------------+
    | Application  | #  | Health  | URLS                          | Services   |
    +--------------+----+---------+-------------------------------+------------+
    | petclinicroo | 1  | RUNNING | petclinicroo.cloudfoundry.com |            |
    | restgrid     | 1  | RUNNING | restgrid.cloudfoundry.com     | mongodb-db |
    +--------------+----+---------+-------------------------------+------------+
    $ vmc services
    ============== System Services ==============
    +----------+---------+-------------------------------+
    | Service  | Version | Description                   |
    +----------+---------+-------------------------------+
    | mongodb  | 1.8     | MongoDB NoSQL store           |
    | mysql    | 5.1     | MySQL database service        |
    | rabbitmq | 2.4     | RabbitMQ messaging service    |
    | redis    | 2.2     | Redis key-value store service |
    +----------+---------+-------------------------------+
    =========== Provisioned Services ============
    +------------+---------+
    | Name       | Service |
    +------------+---------+
    | mongodb-db | mongodb |
    +------------+---------+
    

    Update 09/2011 I'd like to share a project (that recently deployed to the cloud) from post which plots in a graph histogram for given datasets (you can select multiple rows to view combined results)
    https://rest-stats.cloudfoundry.com
    And the respective System.getProperties() + System.getenv() could be seen here Cheers

    0 comments: