Cloud Zone is brought to you in partnership with:

Mitch Pronschinske is a Senior Content Analyst at DZone. That means he writes and searches for the finest developer content in the land so that you don't have to. He often eats peanut butter and bananas, likes to make his own ringtones, enjoys card and board games, and is married to an underwear model. Mitch is a DZone Zone Leader and has posted 2574 posts at DZone. You can read more from them at their website. View Full User Profile

Jclouds Gets Friendly With Clojure

05.05.2010
| 7601 views |
  • submit to reddit
jclouds 1.0 beta 5 is out now with various new features including support for Clojure.  Along with some new features for cloud provisioning, the fifth beta also includes a polished ComputeService API, location compatibility across ComputeService and BlobStore, and more supported services.  jclouds currently has complete support for 9 out of the 18 supported services listed on their google code page.  jclouds is an open source framework that lets developers use their Java and Clojure development skills along with portable abstractions or cloud-specific features on a large number of cloud services.

Clojure Power!
The jclouds team has ambitions of making their multi-cloud framework "the" Clojure cloud library.  The fifth beta, which is the first version to feature Clojure support, is a major step toward this goal.  jclouds is now compatible with Clojure versions 1.1 and 1.2.  Here's an example of what Clojure can now do in jclouds:
(use 'org.jclouds.compute)
(use 'org.jclouds.aws.ebs)

(def compute
(compute-service "ec2" "access" "secret" :ssh))

;; create a node authorized to your current id_rsa and attach a 250G EBS volume to it
(with-compute-service [compute]
(def node (run-node "couchdb"))
(create-volume :node node :size 250 :device "/dev/sdj"))

(use 'org.jclouds.blobstore)
(use 'clojure.contrib.pprint)

(with-blobstore ["s3" "access" "secret"]
(pprint (locations))
(pprint (containers))
(pprint (list-container "my-bucket" :in-directory "dir")))
Visit the pallet project to explore more Clojure features automating, controlling, and provisioning cloud server instances.

ComputeService API Improvments
The Compute API now provides jclouds with a more predictable method for determining the user that is selected for logging on to a compute node.  Exception handling has also been improved so that using the ComputeService or BlobStore ContextFactory can throw an AuthorizationException if your credentials are incorrect.  There is also a new feature for launching scripts on existing nodes.  

There's another exception that can repair instances that had errors during boot-up:
     try {
template.getOptions().runScript(bootstrapScript);
Set newNodes = client.runNodesWithTag(tag, 2, template);
} catch (RunNodesException e) {
Map runningButBrokeNodes = e.getNodeErrors();
Set okNodes = e.getSuccessfulNodes();
}

Standardized Locations Across Compute and BlobStore
jcloud users can now collect resources using the new standardized location information.  The new functionality lets users track the path of an object all the way back to the service that created it - from availability zone, to region, to the service provider (EC2 for example):
 // where can I create containers?
Set containerLocations = blobstore.listAssignableLocations();

// where's my node
Location closestLocation = node.getLocation();


// find the closest place to create a new container
while (!containerLocations.contains(closestLocation) && closestLocation.getParent() != null)
closestLocation = closestLocation.getParent();

// create a container in this closest location, or choose null to have
// the service choose a location for you.
if (containerLocations.contains(closestLocation))
blobstore.createContainerInLocation(closestLocation, "my-chef-repository");
else
blobstore.createContainerInLocation(null, "my-chef-repository");

jclouds now has complete support for GoGrid along with experimental support for BlueLock and vCloud. The developers also added and the SouthEast Asian regions of Amazon EC2.  The next version will support portable volume management, across EBS and vCloud at least.  To vote on more features, go here.

Comments

Rob Al replied on Tue, 2010/06/08 - 4:34pm

Have you also looked at libclouds (free) and deltacloud (Red Hat commercial offering) - see bit.ly/9pLiJs

Abhishek Choudhary replied on Thu, 2013/09/19 - 11:45pm

Since Clojure is a dynamic programming language targets Java Virtual Machine , I found Jelastic worked preety awesome with the same. Each and every feature of clojure is supported by jelastic.

This link gives the entire details about clojure in jelastic-

http://jelastic.com/docs/clojure

Try once.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.