public class PickledGraphite extends Object implements GraphiteSender
Constructor and Description |
---|
PickledGraphite(InetSocketAddress address)
Creates a new client which connects to the given address using the default
SocketFactory . |
PickledGraphite(InetSocketAddress address,
int batchSize)
Creates a new client which connects to the given address using the default
SocketFactory . |
PickledGraphite(InetSocketAddress address,
SocketFactory socketFactory,
Charset charset,
int batchSize)
Creates a new client which connects to the given address and socket factory using the given character set.
|
PickledGraphite(InetSocketAddress address,
SocketFactory socketFactory,
int batchSize)
Creates a new client which connects to the given address and socket factory.
|
PickledGraphite(String hostname,
int port)
Creates a new client which connects to the given address using the default
SocketFactory . |
PickledGraphite(String hostname,
int port,
int batchSize)
Creates a new client which connects to the given address using the default
SocketFactory . |
PickledGraphite(String hostname,
int port,
SocketFactory socketFactory,
Charset charset,
int batchSize)
Creates a new client which connects to the given address and socket factory using the given character set.
|
PickledGraphite(String hostname,
int port,
SocketFactory socketFactory,
int batchSize)
Creates a new client which connects to the given address and socket factory.
|
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)
Convert the metric to a python tuple of the form:
(timestamp, (name, value))
And add it to the list of metrics.
|
public PickledGraphite(InetSocketAddress address)
SocketFactory
. This defaults
to a batchSize of 100address
- the address of the Carbon serverpublic PickledGraphite(InetSocketAddress address, int batchSize)
SocketFactory
.address
- the address of the Carbon serverbatchSize
- how many metrics are bundled into a single pickle request to graphitepublic PickledGraphite(InetSocketAddress address, SocketFactory socketFactory, int batchSize)
address
- the address of the Carbon serversocketFactory
- the socket factorybatchSize
- how many metrics are bundled into a single pickle request to graphitepublic PickledGraphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset, int batchSize)
address
- the address of the Carbon serversocketFactory
- the socket factorycharset
- the character set used by the serverbatchSize
- how many metrics are bundled into a single pickle request to graphitepublic PickledGraphite(String hostname, int port)
SocketFactory
. This defaults
to a batchSize of 100hostname
- the hostname of the Carbon serverport
- the port of the Carbon serverpublic PickledGraphite(String hostname, int port, int batchSize)
SocketFactory
.hostname
- the hostname of the Carbon serverport
- the port of the Carbon serverbatchSize
- how many metrics are bundled into a single pickle request to graphitepublic PickledGraphite(String hostname, int port, SocketFactory socketFactory, int batchSize)
hostname
- the hostname of the Carbon serverport
- the port of the Carbon serversocketFactory
- the socket factorybatchSize
- how many metrics are bundled into a single pickle request to graphitepublic PickledGraphite(String hostname, int port, SocketFactory socketFactory, Charset charset, int batchSize)
hostname
- the hostname of the Carbon serverport
- the port of the Carbon serversocketFactory
- the socket factorycharset
- the character set used by the serverbatchSize
- how many metrics are bundled into a single pickle request to graphitepublic 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
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 void flush() throws IOException
GraphiteSender
flush
in interface GraphiteSender
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public int getFailures()
GraphiteSender
getFailures
in interface GraphiteSender
Copyright © 2014. All Rights Reserved.