net.opentsdb.core
Interface WritableDataPoints

All Superinterfaces:
DataPoints, Iterable<DataPoint>

public interface WritableDataPoints
extends DataPoints

Represents a mutable sequence of continuous data points.

Implementations of this interface aren't expected to be synchronized.


Method Summary
 Deferred<Object> addPoint(long timestamp, float value)
          Appends a float data point to this sequence.
 Deferred<Object> addPoint(long timestamp, long value)
          Adds a long data point to the TSDB.
 void setBatchImport(boolean batchornot)
          Specifies whether or not this is a batch import.
 void setBufferingTime(short time)
          Specifies for how long to buffer edits, in milliseconds.
 void setSeries(String metric, Map<String,String> tags)
          Sets the metric name and tags of the series.
 
Methods inherited from interface net.opentsdb.core.DataPoints
aggregatedSize, doubleValue, getAggregatedTags, getTags, isInteger, iterator, longValue, metricName, size, timestamp
 

Method Detail

setSeries

void setSeries(String metric,
               Map<String,String> tags)
Sets the metric name and tags of the series.

This method can be called multiple times on the same instance to start adding data points to another time series without having to create a new instance.

Parameters:
metric - A non-empty string.
tags - The tags on this series. This map must be non-empty.
Throws:
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.

addPoint

Deferred<Object> addPoint(long timestamp,
                          long value)
Adds a long data point to the TSDB.

The data point is immediately persisted unless setBufferingTime(short) is used. Data points must be added in chronological order.

Parameters:
timestamp - The timestamp associated with the value.
value - The value of the data point.
Returns:
A deferred object that indicates the completion of the request. The 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.
Throws:
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.
org.hbase.async.HBaseException - (deferred) if there was a problem while persisting data.

addPoint

Deferred<Object> addPoint(long timestamp,
                          float value)
Appends a float data point to this sequence.

The data point is immediately persisted unless setBufferingTime(short) is used. Data points must be added in chronological order.

Parameters:
timestamp - The timestamp associated with the value.
value - The value of the data point.
Returns:
A deferred object that indicates the completion of the request. The 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.
Throws:
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 value is NaN or Infinite.
org.hbase.async.HBaseException - (deferred) if there was a problem while persisting data.

setBufferingTime

void setBufferingTime(short time)
Specifies for how long to buffer edits, in milliseconds.

By calling this method, you're allowing new data points to be buffered before being sent to HBase. 0 (the default) means data points are persisted immediately.

Buffering improves performance, reduces the number of RPCs sent to HBase, but can cause data loss if we die before we get a chance to send buffered edits to HBase. It also entails that buffered data points aren't visible to other applications using the TSDB until they're flushed to HBase.

Parameters:
time - The approximate maximum number of milliseconds for which data points should be buffered before being sent to HBase. This deadline will be honored on a "best effort" basis.

setBatchImport

void setBatchImport(boolean batchornot)
Specifies whether or not this is a batch import.

It is preferred that this method be called for anything importing a batch of data points (as opposed to streaming in new data points in real time).

Calling this method changes a few important things:

Parameters:
batchornot - if true, then this is a batch import.