graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #03431
Re: [Question #214183]: Feeding data to carbon server via batch mode in Java
Question #214183 on Graphite changed:
https://answers.launchpad.net/graphite/+question/214183
Status: Open => Solved
Magnus confirmed that the question is solved:
Solved by using Jython and the following code
try{
Socket s = null;
try{
s = new Socket("debian-srv", 2004);
}catch(UnknownHostException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
if (s == null) {
return -1;
}
PyTuple t = new PyTuple(new PyString("Test.brange-debian.mojo"), new PyTuple(new PyInteger(1352975858), new PyInteger(56)));
PyTuple t2 = new PyTuple(new PyString("Test.brange-debian.mojo"), new PyTuple(new PyInteger(1352975858-60), new PyInteger(43)));
PyTuple t3 = new PyTuple(new PyString("Test.brange-debian.mojo"), new PyTuple(new PyInteger(1352975858-2*+60),new PyInteger(65)));
PyList list = new PyList();
list.append(t);
list.append(t2);
list.append(t3);
PyString payload = cPickle.dumps(list);
byte[] bytes =
ByteBuffer.allocate(4).putInt(payload.__len__()).array();
s.getOutputStream().write(bytes);
s.getOutputStream().write(payload.toBytes());
s.getOutputStream().flush();
s.close();
}
catch (Exception e) {
e.printStackTrace();
}
--
You received this question notification because you are a member of
graphite-dev, which is an answer contact for Graphite.