public static void close() {
client.releaseExternalResources();
}
public static void insertData(String content) {
Channel channel = null;
HttpRequest request;
ChannelBuffer buffer;
try {
channel = client
.connect(new InetSocketAddress("localhost", httpPort))
.awaitUninterruptibly().getChannel();
request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.POST, "/insert");
buffer = ChannelBuffers.copiedBuffer(content,
Charset.defaultCharset());
request.addHeader(
org.jboss.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH,
buffer.readableBytes());
request.setContent(buffer);
channel.write(request).awaitUninterruptibly().getChannel()
.getCloseFuture().awaitUninterruptibly();
} catch (Exception e) {// Catch exception if any
System.err.println("Error: " + e.getMessage());
}
channel.getCloseFuture().awaitUninterruptibly();
}