Upgrade to asynchbase 1.3.0.

asynchbase 1.3.0 depends on Guava, so add that too.

Change-Id: Iae0fe53448528b4670ca5b4a1a0056cab577f698
Add new stats from HBaseClient as of 1.3.0.

Change-Id: I4cfabae36f20e32cdb62dbcdec54f96dff548438
Stop accepting new connections when shutting down.

This fixes #69.

Change-Id: I1162bb573f42b9b9620cea35dd6778b1ce2f3e33
Handle failure to flush the compaction queue when shutting down.

This fixes #111.

Change-Id: I3b1eab3fc1f884d960d4ac9c8fdc46edf1bfdea9
Update the browser history each time we refresh the graph.

This change is the first in a series to implement feature request #38.

Change-Id: I2d9a8ea406c509173798dc2da0a42af53d78e157
Parse the start and end dates, and `wxh' on page load.

Based on a couple patches from Will Moss.

Change-Id: I7f86eba47312bd0d2304617d8fe9d280047bad38
Listen to history events to handle forward / back.

Change-Id: I1069d6e64119e1016a19ea0ef9b899bf49feb6c6
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Factor out a function to add metric forms.

Change-Id: I4b8d7ce3334e8bc5184ba40eca34c757570d5f7f
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Fill in the metric and tags forms from history.

Change-Id: I48d84a9a0a1dfa5bc5fb51b37e96d59e107c9ad8
Properly clear out all metric forms.

Change-Id: If91dd6609527a408f55904ea6ed434f100be4088
Handle the "Right Axis" checkbox.

Change-Id: I7d85ecd2524475ee0d61baa19e5762fbff281d43
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Parse the `Axis' box from history.

Change-Id: I85a5f16504eda5aec9dabf383dca4111f4bcd5df
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Add a method to get the first value of a query string parameter.

Change-Id: I65a8285671223a9e5693703e69b2f25be2f3d317
Parse the key side box.

Change-Id: Idb42ecc4b4aff441f8d9a45b23927af39782ea48
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Add autoreload to the URL.

Change-Id: Iaac3ed557472d69d6d81ac9db4f381d437d1449a
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Redirect graph requests with no type to the home page.

When a graph request comes in with no `&png', `&json', or `&ascii', we
used to show a basic, static HTML page with an <img> of the graph in it.
This wasn't very useful.  Now that the home page can reload its state
from the URL fragment, redirect to it with the right fragment so that
the graph appears with the form pre-populated properly.  This way it
becomes very easy to edit a graph.  Take an URL to an image from TSD,
drop the `&png' from it, load it in your browser, and voilà, you can
edit someone else's graph super easily!

Change-Id: If8316aaf5126a2e9ca918ba044bdef65f39c6405
Add a `getHash' method to DataPoints and Query.

This allows the code to quickly hash those objects, which will be used
for improved caching.  We don't override Java's built-in `hashCode'
method because it only returns a 32-bit hash.  Here we use 64 bits.

Change-Id: I928c310e739aa4ac0e149ce4f2de79f055d2f613
Significantly improve query caching.

This change contains public API changes.
This change completely invalidates any existing TSD cache.  It is
recommended (but not required) to purge it before restarting the TSD.

Previously, only 2 exactly identical queries would lead to a disk cache
hit.  If any aesthetic parameter changed (such as changing some style
setting), the TSD would retrieve the data points again from HBase and
store them twice in the disk cache.  This was because the entire query
was hashed and this was used as the key in the cache.  Any change, even
if not relevant to the data to retrieve, led to a different cache key.

Now each time series retrieved from HBase is stored in a file using its
own cache key.  We now store an extra file in the cache, a `.map' file,
that associates the hash of the query to the hashes of the time series
matched by that query.  When a new query comes in, we hash it and check
to see if we already saw that query.  Note that unlike the previous code
we don't hash the aesthetic aspects of the query, only what is relevant
to the data points returned by the query.  If there's a cache hit, we
simply generate a new Gnuplot script and re-use the already cached time
series data.  The cache hit could also be partial, where the user is
requesting data for say 3 time series and we already have the cached
results for 2 of them.  In this case we scan HBase only for the 3rd
query for which we don't have cached results.

The bottom line of this change is that little aesthetic customizations
in the UI are almost free, because now the TSD no longer scans HBase
again, it only runs Gnuplot again.

Public API changes:
  - graph.Plot.dumpToFiles(String) has been replaced with
    graph.Plot.dumpToFiles(String, String)
  - graph.Plot.add(DataPoints, String) has been replaced with
    graph.Plot.add(DataPoints, long, String)

Since I don't believe anyone wrote code against those APIs, and since
OpenTSDB is still beta software, I'm taking the liberty to change these
public APIs without starting to carry the @Deprecated burden.

This change also modifies the on-disk layout of the cache to use the
common 2-directory level hierarchy where each level has up to 256
directories `00' through `FF'.  Directories are created lazily.  And
in addition to this change, hashes used as cache keys are now all on
64 bits (vs 32 bits previously), which helps prevent collisions.

Change-Id: Icdda5036a7383b99f5ced9b43bb9a5233322d0f5