net.opentsdb.core
public final class TSDB extends Object
This class is the central class of OpenTSDB. You use it to add new data points or query the database.
Modifier and Type | Method and Description |
---|---|
com.stumbleupon.async.Deferred<Object> |
addPoint(String metric,
long timestamp,
double value,
Map<String,String> tags)
Adds a double precision floating-point value data point in the TSDB.
|
com.stumbleupon.async.Deferred<Object> |
addPoint(String metric,
long timestamp,
float value,
Map<String,String> tags)
Adds a single floating-point value data point in the TSDB.
|
com.stumbleupon.async.Deferred<Object> |
addPoint(String metric,
long timestamp,
long value,
Map<String,String> tags)
Adds a single integer value data point in the TSDB.
|
byte[] |
assignUid(String type,
String name)
Attempts to assign a UID to a name for the given type
Used by the UniqueIdRpc call to generate IDs for new metrics, tagks or
tagvs.
|
com.stumbleupon.async.Deferred<ArrayList<Object>> |
checkNecessaryTablesExist()
Verifies that the data and UID tables exist in HBase and optionally the
tree and meta data tables if the user has enabled meta tracking or tree
building
|
void |
collectStats(StatsCollector collector)
Collects the stats and metrics tracked by this instance.
|
byte[] |
dataTable() |
void |
deleteAnnotation(Annotation note)
Delete the annotation object from the search index
|
void |
deleteTSMeta(String tsuid)
Delete the timeseries meta object from the search index
|
void |
deleteUIDMeta(UIDMeta meta)
Delete the UID meta object from the search index
|
void |
dropCaches()
Discards all in-memory caches.
|
com.stumbleupon.async.Deferred<SearchQuery> |
executeSearch(SearchQuery query)
Executes a search query using the search plugin
|
com.stumbleupon.async.Deferred<Object> |
flush()
Forces a flush of any un-committed in memory data.
|
org.hbase.async.HBaseClient |
getClient()
Returns the configured HBase client
|
Config |
getConfig()
Getter that returns the configuration object
|
Histogram |
getPutLatencyHistogram()
Returns a latency histogram for Put RPCs used to store data points.
|
Histogram |
getScanLatencyHistogram()
Returns a latency histogram for Scan RPCs used to fetch data points.
|
byte[] |
getUID(UniqueId.UniqueIdType type,
String name)
Attempts to find the UID matching a given name
|
com.stumbleupon.async.Deferred<String> |
getUidName(UniqueId.UniqueIdType type,
byte[] uid)
Attempts to find the name for a unique identifier given a type
|
void |
indexAnnotation(Annotation note)
Index the given Annotation object via the configured search plugin
|
void |
indexTSMeta(TSMeta meta)
Index the given timeseries meta object via the configured search plugin
|
void |
indexUIDMeta(UIDMeta meta)
Index the given UID meta object via the configured search plugin
|
void |
initializePlugins(boolean init_rpcs)
Should be called immediately after construction to initialize plugins and
objects that rely on such.
|
byte[] |
metaTable() |
static short |
metrics_width() |
WritableDataPoints |
newDataPoints()
Returns a new
WritableDataPoints instance suitable for this TSDB. |
Query |
newQuery()
Returns a new
Query instance suitable for this TSDB. |
com.stumbleupon.async.Deferred<Boolean> |
processTSMetaThroughTrees(TSMeta meta)
Processes the TSMeta through all of the trees if configured to do so
|
com.stumbleupon.async.Deferred<Object> |
shutdown()
Gracefully shuts down this TSD instance.
|
List<String> |
suggestMetrics(String search)
Given a prefix search, returns a few matching metric names.
|
List<String> |
suggestMetrics(String search,
int max_results)
Given a prefix search, returns matching metric names.
|
List<String> |
suggestTagNames(String search)
Given a prefix search, returns a few matching tag names.
|
List<String> |
suggestTagNames(String search,
int max_results)
Given a prefix search, returns matching tagk names.
|
List<String> |
suggestTagValues(String search)
Given a prefix search, returns a few matching tag values.
|
List<String> |
suggestTagValues(String search,
int max_results)
Given a prefix search, returns matching tag values.
|
static short |
tagk_width() |
static short |
tagv_width() |
byte[] |
treeTable() |
int |
uidCacheHits()
Number of cache hits during lookups involving UIDs.
|
int |
uidCacheMisses()
Number of cache misses during lookups involving UIDs.
|
int |
uidCacheSize()
Number of cache entries currently in RAM for lookups involving UIDs.
|
byte[] |
uidTable() |
public TSDB(Config config)
config
- An initialized configuration objectpublic void initializePlugins(boolean init_rpcs)
init_rpcs
- Whether or not to initialize RPC plugins as wellRuntimeException
- if the plugin path could not be processedIllegalArgumentException
- if a plugin could not be initializedpublic final org.hbase.async.HBaseClient getClient()
public final Config getConfig()
public com.stumbleupon.async.Deferred<String> getUidName(UniqueId.UniqueIdType type, byte[] uid)
type
- The type of UIDuid
- The UID to search forIllegalArgumentException
- if the type is not validNoSuchUniqueId
- if the UID was not foundpublic byte[] getUID(UniqueId.UniqueIdType type, String name)
type
- The type of UIDname
- The name to search forIllegalArgumentException
- if the type is not validNoSuchUniqueName
- if the name was not foundpublic com.stumbleupon.async.Deferred<ArrayList<Object>> checkNecessaryTablesExist()
TableNotFoundException
public int uidCacheHits()
public int uidCacheMisses()
public int uidCacheSize()
public void collectStats(StatsCollector collector)
collector
- The collector to use.public Histogram getPutLatencyHistogram()
public Histogram getScanLatencyHistogram()
public static short metrics_width()
public static short tagk_width()
public static short tagv_width()
public WritableDataPoints newDataPoints()
WritableDataPoints
instance suitable for this TSDB.
If you want to add a single data-point, consider using addPoint(java.lang.String, long, long, java.util.Map
instead.
public com.stumbleupon.async.Deferred<Object> addPoint(String metric, long timestamp, long value, Map<String,String> tags)
metric
- A non-empty string.timestamp
- The timestamp associated with the value.value
- The value of the data point.tags
- The tags on this series. This map must be non-empty.Object
has not special meaning and can be null
(think
of it as Deferred<Void>
). But you probably want to attach at
least an errback to this Deferred
to handle failures.IllegalArgumentException
- if the timestamp is less than or equal
to the previous timestamp added or 0 for the first timestamp, or if the
difference with the previous timestamp is too large.IllegalArgumentException
- if the metric name is empty or contains
illegal characters.IllegalArgumentException
- if the tags list is empty or one of the
elements contains illegal characters.org.hbase.async.HBaseException
- (deferred) if there was a problem while persisting
data.public com.stumbleupon.async.Deferred<Object> addPoint(String metric, long timestamp, double value, Map<String,String> tags)
metric
- A non-empty string.timestamp
- The timestamp associated with the value.value
- The value of the data point.tags
- The tags on this series. This map must be non-empty.Object
has not special meaning and can be null
(think
of it as Deferred<Void>
). But you probably want to attach at
least an errback to this Deferred
to handle failures.IllegalArgumentException
- if the timestamp is less than or equal
to the previous timestamp added or 0 for the first timestamp, or if the
difference with the previous timestamp is too large.IllegalArgumentException
- if the metric name is empty or contains
illegal characters.IllegalArgumentException
- if the value is NaN or infinite.IllegalArgumentException
- if the tags list is empty or one of the
elements contains illegal characters.org.hbase.async.HBaseException
- (deferred) if there was a problem while persisting
data.public com.stumbleupon.async.Deferred<Object> addPoint(String metric, long timestamp, float value, Map<String,String> tags)
metric
- A non-empty string.timestamp
- The timestamp associated with the value.value
- The value of the data point.tags
- The tags on this series. This map must be non-empty.Object
has not special meaning and can be null
(think
of it as Deferred<Void>
). But you probably want to attach at
least an errback to this Deferred
to handle failures.IllegalArgumentException
- if the timestamp is less than or equal
to the previous timestamp added or 0 for the first timestamp, or if the
difference with the previous timestamp is too large.IllegalArgumentException
- if the metric name is empty or contains
illegal characters.IllegalArgumentException
- if the value is NaN or infinite.IllegalArgumentException
- if the tags list is empty or one of the
elements contains illegal characters.org.hbase.async.HBaseException
- (deferred) if there was a problem while persisting
data.public com.stumbleupon.async.Deferred<Object> flush() throws org.hbase.async.HBaseException
For instance, any data point not persisted will be sent to HBase.
Deferred
that will be called once all the un-committed
data has been successfully and durably stored. The value of the deferred
object return is meaningless and unspecified, and can be null
.org.hbase.async.HBaseException
- (deferred) if there was a problem sending
un-committed data to HBase. Please refer to the HBaseException
hierarchy to handle the possible failures. Some of them are easily
recoverable by retrying, some are not.public com.stumbleupon.async.Deferred<Object> shutdown()
The method must call shutdown()
on all plugins as well as flush the
compaction queue.
Deferred
that will be called once all the un-committed
data has been successfully and durably stored, and all resources used by
this instance have been released. The value of the deferred object
return is meaningless and unspecified, and can be null
.org.hbase.async.HBaseException
- (deferred) if there was a problem sending
un-committed data to HBase. Please refer to the HBaseException
hierarchy to handle the possible failures. Some of them are easily
recoverable by retrying, some are not.public List<String> suggestMetrics(String search)
search
- A prefix to search.public List<String> suggestMetrics(String search, int max_results)
search
- A prefix to search.max_results
- Maximum number of results to return.public List<String> suggestTagNames(String search)
search
- A prefix to search.public List<String> suggestTagNames(String search, int max_results)
search
- A prefix to search.max_results
- Maximum number of results to return.public List<String> suggestTagValues(String search)
search
- A prefix to search.public List<String> suggestTagValues(String search, int max_results)
search
- A prefix to search.max_results
- Maximum number of results to return.public void dropCaches()
public byte[] assignUid(String type, String name)
type
- The type of uid to assign, metric, tagk or tagvname
- The name of the uid objectIllegalArgumentException
- if the name is invalid or it already
existspublic byte[] uidTable()
public byte[] dataTable()
public byte[] treeTable()
public byte[] metaTable()
public void indexTSMeta(TSMeta meta)
meta
- The meta data object to indexpublic void deleteTSMeta(String tsuid)
tsuid
- The TSUID to deletepublic void indexUIDMeta(UIDMeta meta)
meta
- The meta data object to indexpublic void deleteUIDMeta(UIDMeta meta)
meta
- The UID meta object to deletepublic void indexAnnotation(Annotation note)
note
- The annotation object to indexpublic void deleteAnnotation(Annotation note)
note
- The annotation object to deletepublic com.stumbleupon.async.Deferred<Boolean> processTSMetaThroughTrees(TSMeta meta)
meta
- The meta data to processpublic com.stumbleupon.async.Deferred<SearchQuery> executeSearch(SearchQuery query)
query
- The query to executeIllegalStateException
- if the search plugin has not been enabled or
configured