Port code to pure Java.

Mostly straight-forward; features should still all be the same.
Metrics-related APIs are a little bit hackier now, but this code
is still very much unstable (mostly because there's a lot of churn
in Spark's API around that area right now).

Code depends on Spark 1.2.0 now, because of some needed Java APIs.