Full class name: com.aliyun.hitsdb.client.TSDBClient

java.lang.Object: com.aliyun.hitsdb.client.TSDBClient

Implemented interfaces: TSDB, Closeable, and AutoCloseable
public class TSDBClient extends Objectimplements TSDB

Constructor

Constructor and description

TSDBClient(TSDBConfig config)

Constructor details

TSDBClient

public TSDBClient(TSDBConfig config) throws HttpClientInitException

Exception thrown: HttpClientInitException

Methods

Qualifier and type Method and description
void close(): shuts down a Time Series Database (TSDB) client. For more information, see Shut down a TSDB client.
void close(boolean force): shuts down a TSDB client. For more information, see Shut down a TSDB client.
void delete(Query query): deletes data. For more information, see Delete data.
Notice This method is unavailable.
void delete(String metric, long startTime, long endTime): deletes data of the specified metric in the specified time range. For more information, see Delete data.
void deleteMeta(String metric, Map<String,String> tags): deletes a timeline and all data that is related to the timeline. For more information, see Delete a timeline.
void deleteMeta(Timeline timeline): deletes a timeline and all data that is related to the timeline. For more information, see Delete a timeline.
List<TagResult> dumpMeta(String tagkey, String tagValuePrefix, int max): queries tags. For more information, see Query tags.
List<QueryResult> last(Query query,int num): queries data. For more information, see Query data.
<QueryResult> lastdp(Collection<Timeline> timelines): queries the last data point in the specified timeline. For more information, see Query the last data point in the specified timeline.
List<LastDPValue> lastdp(Timeline… timelines): queries the last data point in the specified timeline. For more information, see Query the last data point in the specified timeline.
void put(Point… points): asynchronously writes data points to TSDB. For more information, see Asynchronously write data points to TSDB.
void put(Point point): asynchronously write a data point to TSDB. For more information, see Asynchronously write data points to TSDB.
<T extends Result>T putSync(Class<T> resultType, Collection<Point> points): synchronously writes data points to TSDB. For more information, see Synchronously write data points to TSDB.
<T extends Result>T putSync(Class<T> resultType, Point… points): synchronously writes data points to TSDB. For more information, see Synchronously write data points to TSDB.
Result putSync(Class<T> resultType, Point… points): synchronously writes data points to TSDB. For more information, see Synchronously write data points to TSDB.
<T extends Result>T putSync(Collection<Point> points, Class<T> resultType): synchronously writes data points to TSDB. For more information, see Synchronously write data points to TSDB.
Result putSync(Point… points): synchronously writes data points to TSDB. For more information, see Synchronously write data points to TSDB.
List<QueryResult> query(Query query): queries data. For more information, see Query data.
void query(Query query, QueryCallback callback): queries data. For more information, see Query data.
List<String> suggest(Suggest type, String prefix, int max): queries the metrics that meet the specified conditions. For more information, see Query the metrics that meet the specified conditions.
int ttl(): retrieves a time-to-live (TTL) value. Unit: seconds. For more information, see Query a TTL value.
void ttl(int lifetime): sets a TTL value. Unit: seconds. For more information, see Query a TTL value.
void ttl(int lifetime,TimeUnit unit): retrieves a TTL value. Unit: seconds. For more information, see Query a TTL value.

Shut down a TSDB client

  • close

    public void close() throws IOException
    Exception thrown:
    IOException
  • close

    public void close(boolean force) throws IOException
    Description: shuts down a TSDB client. You can call this method before you exit the program.
    Parameters:
    force - true or false
    Exception thrown:
    IOException - exception

Delete data

  • delete

    public void delete(Query query) throws HttpUnknowStatusException
    Description: deletes data. This method is unavailable.
    Parameters:
    query - query
    Exception thrown:
    HttpUnknowStatusException - Exception
  • deleteData

    public void deleteData(String metric, Date startDate, Date endDate)
    Description: deletes data of the specified metric in the specified time range.
    Parameters:
    metric - metric name
    startDate - start date
    endDate - end date
  • deleteData

    public void deleteData(String metric, long startTime, long endTime)
    Parameters:
    metric - metric
    startTime - start timestamp
    endTime - end timestamp

Delete a timeline

  • deleteMeta

    public void deleteMeta(String metric,Map<String,String> tags)
    Description: deletes timeline data.
    Parameters:
    metric- the name of the metric
    tags - the tag key-value pairs in the map format
  • deleteMeta

    public void deleteMeta(Timeline timeline)
    Description: deletes timeline data.
    Parameters:
    timeline - the instance of the Timeline class

Query tags

dumpMeta

public List<TagResult> dumpMeta(String tagkey, String tagValuePrefix, int max)
Description: queries tags that meet the specified conditions.
Parameters:
tagkey - the key of the tag
tagValuePrefix - the prefix of the tag value
max - the maximum value
Response:
the List of the TagResult

Query data

last

public List<QueryResult> last(Query query, int num) throws HttpUnknowStatusException
Parameters:
query- the instance of the Query class
num - the number of last data points in the timeline
Response:
A list of results
Exception thrown:
HttpUnknowStatusException - Exception

Query the last data point in the specified timeline

  • lastdp

    public List<LastDPValue> lastdp(Collection<Timeline> timelines) throws HttpUnknowStatusException
    Description: queries the last data point in the specified timeline.
    Parameters:
    timelines- the instance of the Timelines class
    Response:
    List
    Exception thrown:
    HttpUnknowStatusException - Exception
  • lastdp

    public List<LastDPValue> lastdp(Timeline… timelines)                        throws HttpUnknowStatusException
    Description: queries the last data point in the specified timeline.
    Parameters:
    timelines - the instance of the Timelines class
    Response:
    List
    Exception thrown:
    HttpUnknowStatusException - Exception

Asynchronously write data points to TSDB

  • put

    public void put(Point… points)
    Description: asynchronously writes data points to TSDB.
    Parameters:
    points - a collection of data points
  • put

    public void put(Point point)
    Description: asynchronously writes a data point to TSDB.
    Parameters:
    point - the data point

Synchronously write data points to TSDB

  • putSync

    public <T extends Result> T putSync(Collection<Point> points, Class<T> resultType)
    Description: synchronously writes data points to TSDB.
    Type parameter:
    T - Result.class, SummaryResult.class, DetailsResult.class
    Parameters:
    points - a collection of data points
    resultType - the type of the result
    Response:
    A Result instance
  • putSync

    public <T extends Result> T putSync(Class<T> resultType,                                Point… points)
    Description: synchronously writes data points to TSDB.
    Type parameter:
    T - Result.class, SummaryResult.class, DetailsResult.class
    Parameters:
    resultType - the type of the result
    points - a collection of data points
    Response:
    Result
  • putSync

    public Result putSync(Collection<Point> points)
    Description: synchronously writes data points to TSDB.
    Parameters:
    points - the number of data points
    Response:
    A Result instance. This object is used only to indicate that the method returns a result.
  • putSync

    public <T extends Result> T putSync(Class<T> resultType,                                Collection<Point> points)
    Description: synchronously writes data points to TSDB.
    Type parameter:
    T - Result.class, SummaryResult.class, DetailsResult.class
    Parameters:
    resultType - the type of the result
    points - a collection of data points
    Response:
    Result
  • putSync

    public Result putSync(Point… points)
    Description: synchronously writes data points to TSDB.
    Parameters:
    points - a collection of data points
    Response:
    Result

Query data

  • query

    public List<QueryResult> query(Query query)
    Description: queries data.
    Parameters:
    query- the instance of the Query class
    Response:
    An instance of the QueryResult class
  • query

    public void query(Query query, QueryCallback callback)
    Description: asynchronously queries data. The data is returned in a callback.
    Parameters:
    query- the instance of the Query class
    callback - the instance of the QueryCallback class. The data is asynchronously returned in a callback.

Query the metrics that meet the specified conditions

  • suggest

    public List<String> suggest(Suggest type, String prefix, int max)
    Description: queries metrics.
    Parameters:
    type - the data type
    prefix - the prefix
    max - the maximum value
    Response:
    result

Query a TTL value

  • ttl

    public int ttl()
    Description: queries a TTL value. Unit: seconds.
    Response:
    The TTL value. Unit: seconds.
  • ttl

    public void ttl(int lifetime)
    Description: sets a TTL value.
    Parameters:
    lifetime - the TTL value. Unit: seconds.
  • ttl

    public void ttl(int lifetime, TimeUnit unit)
    Parameters:
    lifetime - the TTL value
    unit - the unit of the TTL value