This checkin fully encaches hosts, event categories and sample kinds
at startup, and kepts the caches updated across operations that create
new ones.

This checkin also fixes a problem with bulk timeline insertion: that
insertion cannot use auto increment columns.  Instead, use an
AtomicLong in DefaultTimelineDAO to supply chunk ids.

util/src/main/java/com/ning/arecibo/util/timeline/HostIdAndSampleKindId.java:
util/src/main/java/com/ning/arecibo/util/timeline/HostIdAndSampleKindIdMapper.java:

    New units used by the new TimelineDAO method,
    getSampleKindIdsForAllHosts.

collector/src/main/java/com/ning/arecibo/collector/persistent/TimelineAggregator.java:

    The initial value of the sampleTimelineId should be 0, not -1.

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

    Make getInMemoryTimelineChunks() be synchronized.

    In getInMemoryTimelineChunks(), for each host event collector, do
    the times compression once, not once for each chunk.

collector/src/main/java/com/ning/arecibo/collector/persistent/TimelineHostEventAccumulator.java:

    When creating pendingChunkMaps, for each host event collector, do
    the times compression once, not once for each chunk.

    Fix typos in error messages.

collector/src/main/resources/collector.sql:

    Remove auto_increment in the sample_timeline_id for
    timeline_chunks.

collector/src/main/resources/com/ning/arecibo/collector/persistent/TimelineAggregatorDAO.sql.stg:

    Add currently unused templates that might provide a more efficient
    way to query for agregation candidates.

util/src/main/java/com/ning/arecibo/util/timeline/TimelineDAO.java:

    Change insertTimelineChunk to return a Long, and change
    bulkInsertTimelineChunks to return List<Long>.

    Add method getSampleKindIdsForAllHosts().

collector/src/test/java/com/ning/arecibo/collector/MockTimelineDAO.java:

    Maintain a Map<Integer, Set<Integer>> to keep records of the
    correspondence between hosts and the sampleKindIds they support.

    Conform to TimelineDAO method return value changes, and implement
    the new method.

util/src/main/java/com/ning/arecibo/util/timeline/DefaultTimelineDAO.java:

    Since the auto increment stuff can't work when there are
    operations like bulkInsertTimelineChunks that need to insert
    multiple records, instead maintain a chunk id counter which is
    initialized with the highest chunk id in the timeline_chunks
    table.

    Change the methods that insert into timeline_chunks to get the
    ids from the new counter.

    Remove unneeded method-level synchronize operations.

    Conform to TimelineDAO method changes.

util/src/main/java/com/ning/arecibo/util/timeline/CachingTimelineDAO.java:

    Eliminate all the LoadableCaches, because we don't ever want to
    evict hosts, event categories, sample kinds and timeline host
    accumulators.  Replace them with BiMaps and Maps, and synchronize
    the methods that access the maps.  At startup, load up the maps
    with _all_ values, and update the maps as new hosts, event
    categories and sample kinds are encountered.

    Conform to TimelineDAO method changes.

util/src/main/java/com/ning/arecibo/util/timeline/TimelineChunkAccumulator.java:

    Remove now-unreferenced overloading of
    extractTimelineChunkAndReset().

util/src/main/java/com/ning/arecibo/util/timeline/TimelineChunkBinder.java:

    We already have the time and samples bytes, so don't create them
    again.

util/src/main/java/com/ning/arecibo/util/timeline/persistent/TimelineDAOQueries.java:
util/src/main/resources/com/ning/arecibo/util/timeline/persistent/TimelineDAOQueries.sql.stg:

    Add getSampleKindIdsForAllHosts().

util/src/test/java/com/ning/arecibo/util/timeline/TestSampleCompression.java:

    Compress bytes so before calling
    accum.extractTimelinechunkAndReset().
Rename sampleTimelineId to chunkId, and sample_timeline_id to chunk_id.
Check in small fix for getInMemoryChunks()
This checkin reverts explicit setting of chunk ids in
bulkInsertTimelineChunks(), because none of the callers actually care
about the ids.  With this checkin, timeline aggregation seems to
work properly, but in-memory samples are broken for some reason.

collector/src/main/resources/collector.sql:

    Restore auto_increment treatment of chunk_id.

util/src/main/java/com/ning/arecibo/util/timeline/TimelineDAO.java:
util/src/main/java/com/ning/arecibo/util/timeline/CachingTimelineDAO.java:
collector/src/test/java/com/ning/arecibo/collector/MockTimelineDAO.java:

    Change bulkInsertTimelineChunks to have a void return value.

util/src/main/java/com/ning/arecibo/util/timeline/DefaultTimelineDAO.java:

    Eliminate the AtomicLong used to initialize chunkIds, and don't
    use it when inserting TimlineChunks.

    Change bulkInsertTimelineChunks to have a void return value.

util/src/main/java/com/ning/arecibo/util/timeline/TimelineChunkBinder.java:

    Eliminate a check for 0 chunkIds - - 0 is the normal case; only
    tests make it non-zero.