llquantize() dreams of JNI
#905 will introduce llquantize() support to DTrace using code contributed by Joyent. However, Joyent didn't add support for this aggregating action to libdtrace_jni, the Java interface to DTrace used by tools such as Chime and D-Light and, more directly for us, used by the test suite to verify libdtrace_jni is functional (most tests are run using both dtrace(1) and the Java API).
Rather than excepting the llquantize() action from testing under the Java API, it's reasonable simple to just add support for llquantize to libdtrace_jni and jdtrace (the Java test wrapper).
Updated by Rich Lowe over 9 years ago
The major problem with adding this support is that the Distribution implementation was not really written with new kinds of distribution in mind, and is somewhat strange in its operation in general.
There is the implicit assumption that the distribution buckets can be set out based solely on arguments passed to the constructor of Distribution, which takes only low and step arguments (for the sake of LinearDistribution). Thanks to the fact it then calls back into its subclasses from its own constructor, we have no access to our own slots during the majority of initialization (as we haven't assigned them yet!). This leaves us with the options:
- Add several LogLinear specific arguments to the Distribution constructor
- Add a new LogLinear specific Distribution constructor, and use it
- Use the 'step' argument to hold the full packed set of options as we receive them from DTrace itself for the JNI interface, but provide more tasteful constructors for everyone else.
- Completely re-design the Distribution interface to be much more flexible.
I chose the 3rd option, on the grounds of simplicity and safety. The Distribution classes are both Serializable (in the specific sense of that Java interface name), and serializable (via Java Beans and thence XML). The former is well known for its habit of leaking implementation details, which makes the generally correct choice, the re-implementation of Distribution, considerably more hairy.