util: fix a few issues related to timeline times encoding

In TimeRangeSampleProcessor#processSamples, operate only on epoch
to do time comparisons, to avoid time zones issues (TimelineTimes.unixSeconds()
will convert to GMT).

In TimelineChunkAccumulator, make sure deepCopy() doesn't hold a reference
to the original stream.

In TimelineCoder#compressTimes(), allow for repeated samples. I don't believe
the collector code prevents receiving two samples at the same time
(TimelineHostEventAccumulator#addHostSamples() will just check that any new event
has not strictly happened before any other samples received).

In TimelineCoder#writeRepeatedDelta(), handle 1-time "repeated" delta.

These changes make the TestCollectorEventProcessor#testCache() pass again. I've also added
TestSampleCoder and enhanced TestTimelineCoder tests to verify these fixes.

Fix a regression introduced in 32ee3810b9e45e0205dc0034b8aac661e66ed3e8 for
TestTimelineChunkAndTimes#testToString test.

I've also slightly refactored TimelineEventHandler#getInMemoryTimelineChunkAndTimes().

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
pom.xml: fix build issue

Define jdbi's version in the parent pom.xml to avoid versions conflicts.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: make rat ignore TimelineAggregatorDAO.sql.stg

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Merge remote-tracking branch 'origin/dev-dstryker' into collector-ng

Conflicts:
	collector/src/main/java/com/ning/arecibo/collector/persistent/TimelineEventHandler.java

To make unit tests pass:

* Fixed TimelineTimesBinder to support eventCategory
* Add aggregation_level and not_valid in selected fields of getTimelineTimesAggregationCandidates()
* Fix insertNewInvalidTimelineTimes() statement

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: make sure to replay files in order

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: fix broken lifecycle integration

* Add support for ANNOUNCE and UNANNOUNCE events
* Make sure the STOP event works (timelines weren't committed before)

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: add 2 healthcheck endpoints

Add a healthcheck for the DAO and the TimelineEventHandler.

This required to make the EmbeddedJettyJerseyModule accept urlpatterns,
as the MetricsServlet doesn't go through Guice.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: remove most joins in TimelineDAO

Make all queries take host_id, sample_kind_id as parameters instead
of host_name and sample_kind.
This removes most joins from the queries.

This is a large change as most tests had to be updated.
I've also added TestDefaultTimelineDAO that performs simple tests using
an embedded MySQL instance.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: fix broken EmbeddedJettyJerseyModule

dfb3053859f2137c520f6bf2dc926e097f121301 broke the /rest/1.0 endpoints.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: fix dashboard query if no sampleKind is specified

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
util: configure BoneCP  keepAlive delay

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: fix logger name in TimelineEventHandlerHealthCheck

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: refactor the HostDataResource

Make it easier to unit test and add a test for the in-memory samples.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: cleanup HostDataResource error handling

* Return 400 if no host is specified.
* Don't add WebApplicationException in the logs and the Warning header
as it's not useful.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: add host parameter to /sample_kinds resource

/rest/1.0/sample_kinds?host=hostA&host=hostB will now return
the union of all sample kinds used by hostA and hostB.

This will be useful for the dashboard to present meaningful choices to
the user.

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
collector: be more precise in HTTP return codes

Return 4xx for CacheLoader.InvalidCacheLoadException exceptions.

This also fixes a regression in WebApplicationExceptionMapper in the
response building code (extra build() call).

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Improve logging in TimelineAggregator, and fix a bug: when looping over the TimelineTimes chunks, remember the eventCategory