net.opentsdb.meta
public final class UIDMeta extends Object
Users are allowed to edit the following fields:
name
, uid
, type
and created
fields can
only be modified by the system and are usually done so on object creation.
When you call syncToStorage(net.opentsdb.core.TSDB, boolean)
on this object, it will verify that the
UID object this meta data is linked with still exists. 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.UIDMeta, boolean)
method.
Note that the HBase specific storage code will be removed once we have a DAL
Constructor and Description |
---|
UIDMeta()
Default constructor
Initializes the the changed map
|
UIDMeta(UniqueId.UniqueIdType type,
byte[] uid,
String name)
Constructor used by TSD only to create a new UID with the given data and
the current system time for
createdd |
UIDMeta(UniqueId.UniqueIdType type,
String uid)
Constructor used for overwriting.
|
Modifier and Type | Method and Description |
---|---|
com.stumbleupon.async.Deferred<Object> |
delete(TSDB tsdb)
Attempts to delete the meta object from storage
|
long |
getCreated() |
Map<String,String> |
getCustom() |
String |
getDescription() |
String |
getDisplayName() |
String |
getName() |
String |
getNotes() |
UniqueId.UniqueIdType |
getType() |
String |
getUID() |
static com.stumbleupon.async.Deferred<UIDMeta> |
getUIDMeta(TSDB tsdb,
UniqueId.UniqueIdType type,
byte[] uid)
Verifies the UID object exists, then attempts to fetch the meta from
storage and if not found, returns a default object.
|
static com.stumbleupon.async.Deferred<UIDMeta> |
getUIDMeta(TSDB tsdb,
UniqueId.UniqueIdType type,
String uid)
Convenience overload of
getUIDMeta(TSDB, UniqueIdType, byte[]) |
void |
setCreated(long created) |
void |
setCustom(Map<String,String> custom) |
void |
setDescription(String description) |
void |
setDisplayName(String display_name) |
void |
setNotes(String notes) |
com.stumbleupon.async.Deferred<Object> |
storeNew(TSDB tsdb)
Attempts to store a blank, new UID meta object in the proper location.
|
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 UIDMeta()
public UIDMeta(UniqueId.UniqueIdType type, String uid)
type
- Type of UID objectuid
- UID of the objectpublic UIDMeta(UniqueId.UniqueIdType type, byte[] uid, String name)
createdd
type
- Type of UID objectuid
- UID of the objectname
- Name of the UIDpublic String toString()
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 issue fetchingIllegalArgumentException
- if parsing failedNoSuchUniqueId
- If the UID does not existIllegalStateException
- if the data hasn't changed. This is OK!JSONException
- if the object could not be serializedpublic com.stumbleupon.async.Deferred<Object> storeNew(TSDB tsdb)
tsdb
- The TSDB to use for callsorg.hbase.async.HBaseException
- if there was an issue writing to storageIllegalArgumentException
- if data was missingJSONException
- if the object could not be serializedpublic 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 static com.stumbleupon.async.Deferred<UIDMeta> getUIDMeta(TSDB tsdb, UniqueId.UniqueIdType type, String uid)
getUIDMeta(TSDB, UniqueIdType, byte[])
tsdb
- The TSDB to use for storage accesstype
- The type of UID to fetchuid
- The ID of the meta to fetchorg.hbase.async.HBaseException
- if there was an issue fetchingNoSuchUniqueId
- If the UID does not existpublic static com.stumbleupon.async.Deferred<UIDMeta> getUIDMeta(TSDB tsdb, UniqueId.UniqueIdType type, byte[] uid)
The reason for returning a default object (with the type, uid and name set)
is due to users who may have just enabled meta data or have upgraded; we
want to return valid data. If they modify the entry, it will write to
storage. You can tell it's a default if the created
value is 0. If
the meta was generated at UID assignment or updated by the meta sync CLI
command, it will have a valid created timestamp.
tsdb
- The TSDB to use for storage accesstype
- The type of UID to fetchuid
- The ID of the meta to fetchorg.hbase.async.HBaseException
- if there was an issue fetchingNoSuchUniqueId
- If the UID does not existpublic String getUID()
public UniqueId.UniqueIdType getType()
public String getName()
public String getDisplayName()
name
if emptypublic String getDescription()
public String getNotes()
public long getCreated()
public void setDisplayName(String display_name)
display_name
- an optional descriptive name for the UIDpublic void setDescription(String description)
description
- an optional description of the UIDpublic void setNotes(String notes)
notes
- optional notespublic final void setCreated(long created)
created
- the created timestamp Unix epoch in seconds