本文整理了Java中com.codahale.metrics.graphite.Graphite.isConnected()
方法的一些代码示例,展示了Graphite.isConnected()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphite.isConnected()
方法的具体详情如下:
包路径:com.codahale.metrics.graphite.Graphite
类名称:Graphite
方法名:isConnected
暂无
代码示例来源:origin: com.opentable.components/otj-metrics-core
@Override
public synchronized boolean isConnected() {
// If it's not already connected, don't accidentally cause a connection attempt
return delegate.isConnected();
}
代码示例来源:origin: io.dropwizard.metrics/metrics-graphite
@Override
public void connect() throws IllegalStateException, IOException {
if (isConnected()) {
throw new IllegalStateException("Already connected");
}
InetSocketAddress address = this.address;
if (address == null) {
address = new InetSocketAddress(hostname, port);
}
if (address.getAddress() == null) {
// retry lookup, just in case the DNS changed
address = new InetSocketAddress(address.getHostName(), address.getPort());
if (address.getAddress() == null) {
throw new UnknownHostException(address.getHostName());
}
}
this.socket = socketFactory.createSocket(address.getAddress(), address.getPort());
this.writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), charset));
}
代码示例来源:origin: aseigneurin/kafka-sandbox
public void send(CounterMetric metric) {
try {
if (!graphite.isConnected()) {
graphite.connect();
}
graphite.send(metric.getName() + ".count", Long.toString(metric.getValue()), metric.getTimestampInMillis());
graphite.flush();
} catch (IOException e) {
LOGGER.warn("Unable to report to Graphite", graphite, e);
try {
graphite.close();
} catch (IOException e1) {
LOGGER.warn("Error closing Graphite", graphite, e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!