net.opentsdb.meta
public final class Annotation extends Object implements Comparable<Annotation>
Annotations may be associated with a specific timeseries, in which case the tsuid must be configured with a valid TSUID. If no TSUID is provided, the annotation is considered a "global" note that applies to everything stored in OpenTSDB. Global annotations are stored in the rows [ 0, 0, 0, <timestamp>] in the same manner as local annotations and timeseries data.
The description field should store a very brief line of information
about the event. GUIs can display the description in their "main" view
where multiple annotations may appear. Users of the GUI could then click
or hover over the description for more detail including the notes
field.
Custom data can be stored in the custom hash map for user specific information. For example, you could add a "reporter" key with the name of the person who recorded the note.
Constructor and Description |
---|
Annotation()
Default constructor, initializes the change map
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Annotation note)
Compares the
#start_time of this annotation to the given note |
com.stumbleupon.async.Deferred<Object> |
delete(TSDB tsdb)
Attempts to mark an Annotation object for deletion.
|
static com.stumbleupon.async.Deferred<Annotation> |
getAnnotation(TSDB tsdb,
byte[] tsuid,
long start_time)
Attempts to fetch a global or local annotation from storage
|
static com.stumbleupon.async.Deferred<Annotation> |
getAnnotation(TSDB tsdb,
long start_time)
Attempts to fetch a global annotation from storage
|
static com.stumbleupon.async.Deferred<Annotation> |
getAnnotation(TSDB tsdb,
String tsuid,
long start_time)
Attempts to fetch a global or local annotation from storage
|
Map<String,String> |
getCustom() |
String |
getDescription() |
long |
getEndTime() |
static com.stumbleupon.async.Deferred<List<Annotation>> |
getGlobalAnnotations(TSDB tsdb,
long start_time,
long end_time)
Scans through the global annotation storage rows and returns a list of
parsed annotation objects.
|
String |
getNotes() |
long |
getStartTime() |
String |
getTSUID() |
static byte |
PREFIX() |
void |
setCustom(Map<String,String> custom) |
void |
setDescription(String description) |
void |
setEndTime(long end_time) |
void |
setNotes(String notes) |
void |
setStartTime(long start_time) |
void |
setTSUID(String tsuid) |
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 String toString()
public int compareTo(Annotation note)
#start_time
of this annotation to the given notecompareTo
in interface Comparable<Annotation>
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 fields
True if the storage call was successful, false if the object was
modified in storage during the CAS call. If false, retry the call. Other
failures will result in an exception being thrown.org.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if required data was missing such as the
#start_time
IllegalStateException
- if the data hasn't changed. This is OK!JSONException
- if the object could not be serializedpublic com.stumbleupon.async.Deferred<Object> delete(TSDB tsdb)
tsdb
- The TSDB to use for storage accesspublic static com.stumbleupon.async.Deferred<Annotation> getAnnotation(TSDB tsdb, long start_time)
tsdb
- The TSDB to use for storage accessstart_time
- The start time as a Unix epoch timestamppublic static com.stumbleupon.async.Deferred<Annotation> getAnnotation(TSDB tsdb, String tsuid, long start_time)
tsdb
- The TSDB to use for storage accesstsuid
- The TSUID as a string. May be empty if retrieving a global
annotationstart_time
- The start time as a Unix epoch timestamppublic static com.stumbleupon.async.Deferred<Annotation> getAnnotation(TSDB tsdb, byte[] tsuid, long start_time)
tsdb
- The TSDB to use for storage accesstsuid
- The TSUID as a byte array. May be null if retrieving a global
annotationstart_time
- The start time as a Unix epoch timestamppublic static com.stumbleupon.async.Deferred<List<Annotation>> getGlobalAnnotations(TSDB tsdb, long start_time, long end_time)
tsdb
- The TSDB to use for storage accessstart_time
- Start time to scan from. May be 0end_time
- End time to scan to. Must be greater than 0IllegalArgumentException
- if the end timestamp has not been set or
the end time is less than the start timepublic static byte PREFIX()
public final String getTSUID()
public final long getStartTime()
public final long getEndTime()
public final String getDescription()
public final String getNotes()
public void setTSUID(String tsuid)
tsuid
- the tsuid to storepublic void setStartTime(long start_time)
start_time
- the start_time, required for every annotationpublic void setEndTime(long end_time)
end_time
- the end_time, optionalpublic void setDescription(String description)
description
- the description, required for every annotationpublic void setNotes(String notes)
notes
- the notes to set