Opposable Thumbs

Trying To Get Back

Things have been crazy lately. My company got bought (more about that later) and I’ll be out of a job soon. Thankfully I’m on the transition team, so at least I’ve got time to look for things (and there have been some interesting possibilities presenting themselves).

I’ve got a couple things I’m hoping to write up here soon, and I’ve got a ton of things I need to fix on this blog. I’ve just noticed that a bunch of content is missing: some of it is historical/archival and I just need to restore the old posts and get them properly formatted; some of it is stuff that I started to add and then never finished. I’m also trying to tweak the layout a bit (meaning, stealing heavily from people who actually know what they’re doing).

I already have my next post planned, so hopefully I can get to work on that later today. I also need to post about the talk (“Harnessing Java with Scala”) that Trenton Lipscomb and I gave at OSCON 2010. It was far from perfect, though we did get some favorable feedback.


RESTful Java With JAX-RS Review

I’d say that everywhere you look these days a new REST API is popping up. If Twitter came along and added a SOAP API, I imagine you’d get pretty much universal gaffaws from the development crowd. For those of you who are relying on the ecosystem of the JVM and, in particular, Java, the official standard for REST-based development has been laid down in the creatively named JSR 311. It also goes by the slightly less sci-fi sounding name JAX-RS.

Bill Burke has written what will likely be the defacto book on the topic: RESTful Java with JAX-RS. What follows is a review I recently wrote for this book:

No one really enjoys reading specs, particularly not JSRs (Java Specification Requests, for those of you who are lucky enough not to have encountered these fun-filled documents). For those of you doing Java web development and looking for a good way to build RESTful applications, this might have been a sore spot when trying to understand JAX-RS – the Java specification that outlines an API for building REST apps using annotations.

While both Jersey and RESTeasy, two popular implementations of JAX-RS, do provide fairly helpful user guides, the specification provides a wide-ranging set of capabilities and neither sufficiently conveyed the breadth of these, in my opinion. But now there is a new resource in the form of Bill Burke’s RESTful Java with JAX-RS. Bill is the creator of JBoss’ RESTeasy framework so he knows the specification well and it shows in this book.

The book explores building a RESTful web app from the ground up and includes a full workbook in the second section with complete examples. The examples are included with the download of RESTeasy, which was not immediately obvious on my first read through. Each chapter of the workbook matches a chapter from earlier in the book giving the reader the opportunity to try out the ideas they’ve just read about. This feels like a good format for a book like this – a motivated reader can charge through the content of the book to get a cohesive view of the API, while not getting too bogged down in the details of setting up each example.

Some of the most interesting material that’s harder to get from the users guides and online tutorials is covered in the material on content negotiation in chapter eight and content marshalling in chapter six. The content marshalling chapter not only explains the built in marshalling capabilities and the use of JAXB but also details how to add in custom handlers. While I don’t know how much this will get used in practice given the ubiquity of JSON and XML, I suspect for those few who really need to supply their own data formats or who want to replace the built-in handlers will be more than happy to see it covered here.

I have to say that I felt like some items were not covered which would have been useful. For instance, I would love to see some examples of integrating with existing web apps and frameworks. It’s not immediately clear what the best route is here and searching online turns up few, if any, best practices or war stories. Similarly it seems that a section on testing REST-based applications would have been called for, even if it isn’t strictly part of the specification. I guess the book tries to stick to outlining JAX-RS within the context of the spec, but this feels to me a bit too limiting in scope. In general, some guidelines on best practices, common integration and usage scenarios and other “real world” content would have been a welcome addition.

Despite these minor complaints, this book is clearly a must have if you’re venturing down the path of RESTful Java development. The existing documentation is far too-limited and this book is an easy and even enjoyable read.


Pardon The Dust

Just doing a bit of cleanup here and there, trying to get the blog back into shape. I’d love to make it halfway interesting to read and all that. But at this point, I’d settle for making it usable for me so I have somewhere to post random notes and thoughts again. We’ll see what becomes of this. I am on vacation, after all, so there’s no time like now to get this done.


Running Cloudera Hadoop VM on VirtualBox (revisited)

Running Cloudera Hadoop VM on VirtualBox (revisited) In an earlier post I talked about getting the Cloudera training VM running under VirtualBox. Unfortunately, while the instructions were pretty straightforward for someone experienced with dealing with the various low level details of virtual machines, they perhaps weren’t exactly detailed and direct. So here’s an attempt to right that wrong.

Note: I’ve sinced installed VirtualBox 3.0 which was released shortly before I prepared this post. I’ll try to redo the screenshots at some point using the new version if I find that they differ significantly enough to justify it.


Running Cloudera Hadoop VM on VirtualBox

So, I’ve been keeping an eye on Hadoop for a while now. The whole idea of MapReduce is pretty cool and the fact that there is a free implementation of it is even cooler. Of course, as a busy developer, not to mention my many other duties as sysadmin, build engineer, etc. that seem to come into play on a daily basis, I haven’t had time to really dig into it.

Then Hadoop got even more attention this last week when Amazon announced their new Elastic MapReduce offering. Basically, they give you a nice API for quickly spinning up new EC2 instances running Hadoop. You upload your data to S3 and point your jobs at them. It’s brilliant really – I’m still trying to find an excuse to play with it.

Anyway… I was getting to something here… what was it? Oh yes, Cloudera. The Cloudera folks have very generously produced this excellent series of tutorials on running and developing for Hadoop. As a part of all this, they also created a rather spiffy prebuilt Hadoop VM to play with along with the tutorials. (The VM, by the way, is available for download along side the tutorials – I’m not going to link directly to it here in case my link goes out of date.)

There’s one problem with all this – they built the VM as a VMware image. I don’t really care for VMware much these days (long story, nothing personal, just my own preferences). I run KVM on my workstation and VirtualBox on my laptop. Both are really excellent options and I highly recommend them. But in order to work through their examples, I really wanted to spin up this VM and see what it was all about.

Thankfully, VirtualBox is very good at running VMware virtual machines. Here’s how to get it working:

  1. Obviously, the first step is to download and extract the archive somewhere.
  2. Once you’ve got the VM somewhere convenient, start up VirtualBox and go to the ‘File > Virtual Media Manager’ menu. From here, you can click ‘Add’ and point it at the file ‘cloudera-training-0.2.vmdk’ in the folder where you extracted the Cloudera archive. Then close that window.
  3. Back in the main VirtualBox interface, click the ‘New’ button to create a new VM. Select the OS as ‘Linux’ and version as ‘Ubuntu’. Set the memory to 512MB. When you get to the boot disk screen, it should have auto-selected the new drive you added earlier. If not, select it and hit ‘next’, then ‘Finish’.
  4. Select the VM you just created and click the ‘Settings’ button. Select ‘Network’ in the settings control panel and go to the MAC Address field. You’ll need to open the file ‘cloudera-training-0.2.vmx’ back in the folder you extracted earlier. Find the line labelled ‘ethernet0.generatedAddress’ and grab the MAC address that’s given there. You’ll need to remove the colons and then insert that into this field. This might not be strictly necessary, but it makes sure the linux image still has the MAC address it expects.
  5. Next select the ‘General’ control panel and then the ‘Advanced’ tab. Check the ‘Enable PAE/NX’ box and then click the ‘OK’ button.

That’s it. You should now be able to run the VM just fine. You might want to install the Guest Additions package, too, but you’ll need to do a quick “sudo apt-get update; sudo apt-get install build-essential linux-headers-2.6.27-11-server” in the VM first. Good luck and happy MapReducing!