use of org.mobicents.tools.sip.balancer.NodesInfoObject in project load-balancer by RestComm.
the class HttpRequestHandler method writeInfoResponse.
private void writeInfoResponse(MessageEvent e) {
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.setPrettyPrinting().create();
JsonElement je = gson.toJsonTree(new NodesInfoObject(balancerRunner));
JsonObject jo = new JsonObject();
jo.add("Nodes info", je);
String output = jo.toString();
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
ChannelBuffer buf = ChannelBuffers.copiedBuffer(output, Charset.forName("UTF-8"));
response.setContent(buf);
ChannelFuture future = e.getChannel().write(response);
future.addListener(ChannelFutureListener.CLOSE);
}
Aggregations