XD-236: Ported aggregate counter code from kodiak.

Added query method based on Joda time interval.
Currently only supports minute resolution.
XD-236: Rewrite aggregate count test with interval queries.