public class Graphite extends Object implements GraphiteSender
Constructor and Description |
---|
Graphite(InetSocketAddress address)
Creates a new client which connects to the given address using the default
SocketFactory . |
Graphite(InetSocketAddress address,
SocketFactory socketFactory)
Creates a new client which connects to the given address and socket factory.
|
Graphite(InetSocketAddress address,
SocketFactory socketFactory,
Charset charset)
Creates a new client which connects to the given address and socket factory using the given
character set.
|
Graphite(String hostname,
int port)
Creates a new client which connects to the given address using the default
SocketFactory . |
Graphite(String hostname,
int port,
SocketFactory socketFactory)
Creates a new client which connects to the given address and socket factory.
|
Graphite(String hostname,
int port,
SocketFactory socketFactory,
Charset charset)
Creates a new client which connects to the given address and socket factory using the given
character set.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
connect()
Connects to the server.
|
void |
flush()
Flushes buffer, if applicable
|
int |
getFailures()
Returns the number of failed writes to the server.
|
boolean |
isConnected()
Returns true if ready to send data
|
protected String |
sanitize(String s) |
void |
send(String name,
String value,
long timestamp)
Sends the given measurement to the server.
|
public Graphite(String hostname, int port)
SocketFactory
.hostname
- The hostname of the Carbon serverport
- The port of the Carbon serverpublic Graphite(String hostname, int port, SocketFactory socketFactory)
hostname
- The hostname of the Carbon serverport
- The port of the Carbon serversocketFactory
- the socket factorypublic Graphite(String hostname, int port, SocketFactory socketFactory, Charset charset)
hostname
- The hostname of the Carbon serverport
- The port of the Carbon serversocketFactory
- the socket factorycharset
- the character set used by the serverpublic Graphite(InetSocketAddress address)
SocketFactory
.address
- the address of the Carbon serverpublic Graphite(InetSocketAddress address, SocketFactory socketFactory)
address
- the address of the Carbon serversocketFactory
- the socket factorypublic Graphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset)
address
- the address of the Carbon serversocketFactory
- the socket factorycharset
- the character set used by the serverpublic void connect() throws IllegalStateException, IOException
GraphiteSender
connect
in interface GraphiteSender
IllegalStateException
- if the client is already connectedIOException
- if there is an error connectingpublic boolean isConnected()
GraphiteSender
isConnected
in interface GraphiteSender
public void send(String name, String value, long timestamp) throws IOException
GraphiteSender
send
in interface GraphiteSender
name
- the name of the metricvalue
- the value of the metrictimestamp
- the timestamp of the metricIOException
- if there was an error sending the metricpublic int getFailures()
GraphiteSender
getFailures
in interface GraphiteSender
public void flush() throws IOException
GraphiteSender
flush
in interface GraphiteSender
IOException
- if there was an error during flushing metrics to the socketpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2017. All Rights Reserved.