Package org.kairosdb.client
Class HttpClient
- java.lang.Object
-
- org.kairosdb.client.HttpClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Client
public class HttpClient extends Object implements Client
HTTP implementation of a client.
-
-
Constructor Summary
Constructors Constructor Description HttpClient(String url)Creates a client to talk to the host on the specified port.HttpClient(org.apache.http.impl.client.CloseableHttpClient client, String url)HttpClient(org.apache.http.impl.client.HttpClientBuilder builder, String url)Creates a client to talk to the host on the specified port.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()RollupTaskcreateRollupTask(RollupBuilder builder)Create a new roll-up.voiddelete(QueryBuilder builder)Deletes data in KairosDB using the query built by the builder.voiddeleteMetric(String name)Deletes a metric.voiddeleteRollupTask(String id)Delete the roll-up.ClassgetDataPointValueClass(String groupType)Returns the data point value class for the given group type or null if one is not registered for the group typeList<String>getMetricNames()Returns a list of all metric names.RollupTaskgetRollupTask(String id)Returns the roll-up.List<RollupTask>getRollupTasks()Returns a list of all roll-up tasks.List<String>getStatus()Returns status of Kairos Instance.intgetStatusCheck()Returns a status code fo 204 if all is healthy.DataPointTypeRegistrygetTypeRegistry()StringgetVersion()Returns the version string for the KairosDB server.voidpushMetrics(MetricBuilder builder)Sends metrics from the builder to the KairosDB server.QueryResponsequery(QueryBuilder builder)Queries KairosDB using the query built by the builder.<T> Tquery(QueryBuilder builder, JsonResponseHandler<T> handler)Queries KairosDB using the query built by the builder.QueryTagResponsequeryTags(QueryTagBuilder builder)Queries KairosDB tags using the query built by the builder.<T> TqueryTags(QueryTagBuilder builder, JsonResponseHandler<T> handler)Queries KairosDB tags using the query built by the builder.voidregisterCustomDataType(String groupType, Class dataPointClass)Registers a new custom data type.
-
-
-
Constructor Detail
-
HttpClient
public HttpClient(String url) throws MalformedURLException
Creates a client to talk to the host on the specified port.- Parameters:
url- url to the KairosDB server- Throws:
MalformedURLException- if url is malformed
-
HttpClient
public HttpClient(org.apache.http.impl.client.HttpClientBuilder builder, String url) throws MalformedURLExceptionCreates a client to talk to the host on the specified port. This version of the constructor exposes the HttpClientBuilder that can be used to set various properties on the client.- Parameters:
builder- client builder.url- url to the KairosDB server- Throws:
MalformedURLException- if the url is malformed
-
HttpClient
public HttpClient(org.apache.http.impl.client.CloseableHttpClient client, String url) throws MalformedURLException- Throws:
MalformedURLException
-
-
Method Detail
-
registerCustomDataType
public void registerCustomDataType(String groupType, Class dataPointClass)
Description copied from interface:ClientRegisters a new custom data type. The assumption is that this data type already exists on the server. The dataPointValueClass is used to serialize and deserialize the custom type. This is simply a POJO.- Specified by:
registerCustomDataTypein interfaceClient- Parameters:
groupType- type used to deserialize the json on the clientdataPointClass- class that is the value of a data point
-
getDataPointValueClass
public Class getDataPointValueClass(String groupType)
Description copied from interface:ClientReturns the data point value class for the given group type or null if one is not registered for the group type- Specified by:
getDataPointValueClassin interfaceClient- Parameters:
groupType- group type- Returns:
- data point class associated with the group type
-
getTypeRegistry
public DataPointTypeRegistry getTypeRegistry()
-
createRollupTask
public RollupTask createRollupTask(RollupBuilder builder)
Description copied from interface:ClientCreate a new roll-up.- Specified by:
createRollupTaskin interfaceClient- Parameters:
builder- roll-up builder- Returns:
- newly created roll-up task
-
getRollupTasks
public List<RollupTask> getRollupTasks()
Description copied from interface:ClientReturns a list of all roll-up tasks.- Specified by:
getRollupTasksin interfaceClient- Returns:
- list of roll-up tasks
-
getRollupTask
public RollupTask getRollupTask(String id)
Description copied from interface:ClientReturns the roll-up.- Specified by:
getRollupTaskin interfaceClient- Parameters:
id- roll-up identifier- Returns:
- roll-up or null if no roll-ups match the specified identifier
-
deleteRollupTask
public void deleteRollupTask(String id)
Description copied from interface:ClientDelete the roll-up. Throws an exception if the delete fails.- Specified by:
deleteRollupTaskin interfaceClient- Parameters:
id- identifier of the roll-up
-
getMetricNames
public List<String> getMetricNames()
Description copied from interface:ClientReturns a list of all metric names.- Specified by:
getMetricNamesin interfaceClient- Returns:
- list of all metric names
-
getStatus
public List<String> getStatus()
Description copied from interface:ClientReturns status of Kairos Instance.
-
getStatusCheck
public int getStatusCheck()
Description copied from interface:ClientReturns a status code fo 204 if all is healthy.- Specified by:
getStatusCheckin interfaceClient- Returns:
- status of Kairos instance
-
getVersion
public String getVersion()
Description copied from interface:ClientReturns the version string for the KairosDB server.- Specified by:
getVersionin interfaceClient- Returns:
- KairosDB version
-
query
public <T> T query(QueryBuilder builder, JsonResponseHandler<T> handler)
Description copied from interface:ClientQueries KairosDB using the query built by the builder.
-
query
public QueryResponse query(QueryBuilder builder)
Description copied from interface:ClientQueries KairosDB using the query built by the builder.
-
queryTags
public QueryTagResponse queryTags(QueryTagBuilder builder)
Description copied from interface:ClientQueries KairosDB tags using the query built by the builder.
-
queryTags
public <T> T queryTags(QueryTagBuilder builder, JsonResponseHandler<T> handler)
Description copied from interface:ClientQueries KairosDB tags using the query built by the builder.
-
pushMetrics
public void pushMetrics(MetricBuilder builder)
Description copied from interface:ClientSends metrics from the builder to the KairosDB server.- Specified by:
pushMetricsin interfaceClient- Parameters:
builder- metrics builder
-
deleteMetric
public void deleteMetric(String name)
Description copied from interface:ClientDeletes a metric. This is the metric and all its data points. An exception is thrown if this operation fails.- Specified by:
deleteMetricin interfaceClient- Parameters:
name- the metric to delete
-
delete
public void delete(QueryBuilder builder)
Description copied from interface:ClientDeletes data in KairosDB using the query built by the builder. An exception is thrown if this operation fails.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-