com.codahale.metrics.graphite.Graphite.isConnected()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中com.codahale.metrics.graphite.Graphite.isConnected()方法的一些代码示例,展示了Graphite.isConnected()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphite.isConnected()方法的具体详情如下:
包路径:com.codahale.metrics.graphite.Graphite
类名称:Graphite
方法名:isConnected

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);
    }
  }
}

相关文章