net.opentsdb.meta
public final class TSMeta extends Object
When you call syncToStorage(net.opentsdb.core.TSDB, boolean)
on this object, it will verify that the
associated UID objects this meta data is linked with still exist. Then it
will fetch the existing data and copy changes, overwriting the user fields if
specific (e.g. via a PUT command). If overwriting is not called for (e.g. a
POST was issued), then only the fields provided by the user will be saved,
preserving all of the other fields in storage. Hence the need for the
changed
hash map and the syncMeta(net.opentsdb.meta.TSMeta, boolean)
method.
The metric and tag UIDMeta objects may be loaded from their respective locations in the data storage system if requested. Note that this will cause at least 3 extra storage calls when loading.
Constructor and Description |
---|
TSMeta()
Default constructor necessary for POJO de/serialization
|
TSMeta(byte[] tsuid,
long created)
Constructor for new timeseries that initializes the created and
last_received times to the current system time
|
TSMeta(String tsuid)
Constructor for RPC timeseries parsing that will not set the timestamps
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
COUNTER_QUALIFIER() |
static com.stumbleupon.async.Deferred<Boolean> |
counterExistsInStorage(TSDB tsdb,
byte[] tsuid)
Determines if the counter column exists for the TSUID.
|
com.stumbleupon.async.Deferred<Object> |
delete(TSDB tsdb)
Attempts to delete the meta object from storage
|
static byte[] |
FAMILY() |
long |
getCreated() |
Map<String,String> |
getCustom() |
String |
getDataType() |
String |
getDescription() |
String |
getDisplayName() |
long |
getLastReceived() |
double |
getMax() |
UIDMeta |
getMetric() |
double |
getMin() |
String |
getNotes() |
int |
getRetention() |
List<UIDMeta> |
getTags() |
long |
getTotalDatapoints() |
static com.stumbleupon.async.Deferred<TSMeta> |
getTSMeta(TSDB tsdb,
String tsuid)
Attempts to fetch the timeseries meta data and associated UIDMeta objects
from storage.
|
String |
getTSUID() |
String |
getUnits() |
static com.stumbleupon.async.Deferred<Long> |
incrementAndGetCounter(TSDB tsdb,
byte[] tsuid)
Increments the tsuid datapoint counter or creates a new counter.
|
static byte[] |
META_QUALIFIER() |
static com.stumbleupon.async.Deferred<Boolean> |
metaExistsInStorage(TSDB tsdb,
String tsuid)
Determines if an entry exists in storage or not.
|
static com.stumbleupon.async.Deferred<TSMeta> |
parseFromColumn(TSDB tsdb,
org.hbase.async.KeyValue column,
boolean load_uidmetas)
Parses a TSMeta object from the given column, optionally loading the
UIDMeta objects
|
void |
setCreated(long created) |
void |
setCustom(Map<String,String> custom) |
void |
setDataType(String data_type) |
void |
setDescription(String description) |
void |
setDisplayName(String display_name) |
void |
setMax(double max) |
void |
setMin(double min) |
void |
setNotes(String notes) |
void |
setRetention(int retention) |
void |
setUnits(String units) |
com.stumbleupon.async.Deferred<Boolean> |
storeNew(TSDB tsdb)
Attempts to store a new, blank timeseries meta object via a CompareAndSet
Note: This should not be called by user accessible methods as it will
overwrite any data already in the column.
|
com.stumbleupon.async.Deferred<Boolean> |
syncToStorage(TSDB tsdb,
boolean overwrite)
Attempts a CompareAndSet storage call, loading the object from storage,
synchronizing changes, and attempting a put.
|
String |
toString() |
public TSMeta()
public TSMeta(String tsuid)
tsuid
- The UID of the timeseriespublic TSMeta(byte[] tsuid, long created)
tsuid
- The UID of the timeseriespublic String toString()
public com.stumbleupon.async.Deferred<Object> delete(TSDB tsdb)
tsdb
- The TSDB to use for access to storageorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if data was missing (uid and type)public com.stumbleupon.async.Deferred<Boolean> syncToStorage(TSDB tsdb, boolean overwrite)
tsdb
- The TSDB to use for storage accessoverwrite
- When the RPC method is PUT, will overwrite all user
accessible fieldsorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if parsing failedNoSuchUniqueId
- If any of the UID name mappings do not existIllegalStateException
- if the data hasn't changed. This is OK!JSONException
- if the object could not be serializedpublic com.stumbleupon.async.Deferred<Boolean> storeNew(TSDB tsdb)
tsdb
- The TSDB to use for storage accessorg.hbase.async.HBaseException
- if there was an issue fetchingIllegalArgumentException
- if parsing failedJSONException
- if the object could not be serializedpublic static com.stumbleupon.async.Deferred<TSMeta> getTSMeta(TSDB tsdb, String tsuid)
See getFromStorage(TSDB, byte[])
for details.
tsdb
- The TSDB to use for storage accesstsuid
- The UID of the meta to fetchorg.hbase.async.HBaseException
- if there was an issue fetchingIllegalArgumentException
- if parsing failedJSONException
- if the data was corruptedNoSuchUniqueName
- if one of the UIDMeta objects does not existpublic static com.stumbleupon.async.Deferred<TSMeta> parseFromColumn(TSDB tsdb, org.hbase.async.KeyValue column, boolean load_uidmetas)
tsdb
- The TSDB to use for storage accesscolumn
- The KeyValue column to parseload_uidmetas
- Whether or not UIDmeta objects should be loadedNoSuchUniqueName
- if one of the UIDMeta objects does not existJSONException
- if the data was corruptedpublic static com.stumbleupon.async.Deferred<Boolean> metaExistsInStorage(TSDB tsdb, String tsuid)
tsdb
- The TSDB to use for storage accesstsuid
- The UID of the meta to verifyorg.hbase.async.HBaseException
- if there was an issue fetchingpublic static com.stumbleupon.async.Deferred<Boolean> counterExistsInStorage(TSDB tsdb, byte[] tsuid)
tsdb
- The TSDB to use for storage accesstsuid
- The UID of the meta to verifyorg.hbase.async.HBaseException
- if there was an issue fetchingpublic static com.stumbleupon.async.Deferred<Long> incrementAndGetCounter(TSDB tsdb, byte[] tsuid)
tsdb
- The TSDB to use for storage accesstsuid
- The TSUID to increment or createorg.hbase.async.HBaseException
- if there was a storage issueJSONException
- if the data was corruptedNoSuchUniqueName
- if one of the UIDMeta objects does not existpublic static byte[] META_QUALIFIER()
public static byte[] COUNTER_QUALIFIER()
public static byte[] FAMILY()
public final String getTSUID()
public final UIDMeta getMetric()
public final List<UIDMeta> getTags()
public final String getDisplayName()
public final String getDescription()
public final String getNotes()
public final long getCreated()
public final Map<String,String> getCustom()
public final String getUnits()
public final String getDataType()
public final int getRetention()
public final double getMax()
public final double getMin()
public final long getLastReceived()
public final long getTotalDatapoints()
public final void setDisplayName(String display_name)
display_name
- an optional name for the timeseriespublic final void setDescription(String description)
description
- an optional descriptionpublic final void setNotes(String notes)
notes
- optional notespublic final void setCreated(long created)
created
- the created timestamp Unix epoch in secondspublic final void setCustom(Map<String,String> custom)
custom
- optional key/value mappublic final void setUnits(String units)
units
- optional units designationpublic final void setDataType(String data_type)
data_type
- optional type of data, e.g. "counter", "gauge"public final void setRetention(int retention)
retention
- optional rentention in days, 0 = indefinitepublic final void setMax(double max)
max
- optional max value for the timeseries, NaN is the defaultpublic final void setMin(double min)
min
- optional min value for the timeseries, NaN is the default