public class HttpDashboardProvider extends java.lang.Object implements DashboardProvider
DashboardProvider interface that provides communication with Graphite
instance via HTTP API for common dashboard operations like create/update, load, delete, find.
HttpDashboardProvider uses Apache HttpClient as http client and gson library for parsing
Graphite responses.
Provider use authentication with username and password parameters if both are set. If username and password not set provider will operate without authentication.
| Constructor and Description |
|---|
HttpDashboardProvider(java.lang.String graphiteHost,
int connectTimeout,
int readTimeout)
Create new instance of
HttpDashboardProvider for communication with Graphite instance with
specified host and connection parameters, without authentication. |
HttpDashboardProvider(java.lang.String graphiteHost,
java.lang.String username,
java.lang.String password,
int connectTimeout,
int readTimeout)
Create new instance of
HttpDashboardProvider for communication with Graphite instance with
specified host, connection parameters and authentication credentials. |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(java.lang.String name)
Delete dashboard from Graphite instance.
|
java.util.List<java.lang.String> |
find(java.lang.String query)
Find dashboards in Graphite instance that match query.
|
java.lang.String |
load(java.lang.String name)
Load dashboard with specified name from Graphite instance.
|
org.ametiste.gdc.data.dashboard.Dashboard |
load(java.lang.String name,
com.google.gson.JsonDeserializer<org.ametiste.gdc.data.dashboard.Dashboard> deserializer)
Load dashboard with specified name from Graphite instance.
|
void |
save(java.lang.String name,
java.lang.String dashboard)
Save dashboard in Graphite instance or create new if dashboard with target name not exists.
|
public HttpDashboardProvider(java.lang.String graphiteHost,
int connectTimeout,
int readTimeout)
HttpDashboardProvider for communication with Graphite instance with
specified host and connection parameters, without authentication.graphiteHost - host of target Graphite instance. Must be valid URL.connectTimeout - connection timeout in milliseconds.readTimeout - read timeout in milliseconds.public HttpDashboardProvider(java.lang.String graphiteHost,
java.lang.String username,
java.lang.String password,
int connectTimeout,
int readTimeout)
HttpDashboardProvider for communication with Graphite instance with
specified host, connection parameters and authentication credentials.graphiteHost - host of target Graphite instance. Must be valid URL.username - username for authentication on graphite host.password - password for authentication on graphite host.connectTimeout - connection timeout in milliseconds.readTimeout - read timeout in milliseconds.public void save(java.lang.String name,
java.lang.String dashboard)
throws GraphiteOperationException
DashboardProvidersave in interface DashboardProvidername - dashboard name.dashboard - dashboard description. Must be valid json structure that describe dashboard structure.GraphiteOperationException - when error occurred during communication with Graphite instance or
Graphite return error response.public java.lang.String load(java.lang.String name)
throws GraphiteOperationException
DashboardProviderload in interface DashboardProvidername - name of target dashboard.GraphiteOperationException - when error occurred during communication with Graphite instance
or Graphite returns response with error massage (in most cases that dashboard not found).
In last case exception contains message from response.public org.ametiste.gdc.data.dashboard.Dashboard load(java.lang.String name,
com.google.gson.JsonDeserializer<org.ametiste.gdc.data.dashboard.Dashboard> deserializer)
throws GraphiteOperationException
DashboardProviderload in interface DashboardProvidername - name of target dashboard.deserializer - JsonDeserializer object that helps deserialize string description to
Dashboard object.Dashboard object that represents json description.GraphiteOperationException - when error occurred during communication with Graphite instance
or Graphite returns response with error massage (in most cases that dashboard not found).
In last case exception contains message from response. Also exception may be throws when returned json string
has wrong syntax.public void delete(java.lang.String name)
throws GraphiteOperationException
DashboardProviderdelete in interface DashboardProvidername - name of dashboard to delete.GraphiteOperationException - when error occurred during communication with Graphite instance or
if dashboard with specified name not exists.public java.util.List<java.lang.String> find(java.lang.String query)
throws GraphiteOperationException
DashboardProviderfind in interface DashboardProviderquery - query string for filtering search result. Query contains phrases separated by whitespace.
Result list will contain only those dashboards that contains all phases from query.List of dashboards names that match query. If no dashboards match method returns
empty list.GraphiteOperationException - when error occurred during communication with Graphite instance.