我试图发送纯文本数据石墨服务器用下面的代码:石墨服务器不显示从Java
try (
Socket socket = new Socket("companyHost", 2003);
Writer writer = new OutputStreamWriter(socket.getOutputStream());) {
Long timestamp = System.currentTimeMillis()/1000;
System.out.println(timestamp);
String sentMessage = "graphite.carbon.local.test.showone 1 " + timestamp;
System.out.println(sentMessage);
writer.write(sentMessage);
writer.flush();
} catch (IOException e) {
e.printStackTrace();
}
但是当我检查companyHost下的碳服务器:在端口我的网络浏览器,我的数据不存在,graphite.carbon.local下没有任何内容。我错过了什么?
我在控制台输出似乎确定(没有错误/例外):
1409233165
graphite.carbon.local.test.showone 1 1409233165
我会尽量必要时应提供更多的信息。
仅供参考,这里是我如何格式化消息'字符串消息=前缀+ metricName + “” + metricValue + “” +(长)数学.round(System.currentTimeMillis()/ 1000.0d)+“\ n”; ' – AngerClown 2015-08-06 16:11:04