Search in sources :

Example 1 with LBShutdownRequestPacket

use of org.mobicents.tools.heartbeat.packets.LBShutdownRequestPacket in project load-balancer by RestComm.

the class Server method sendPacket.

@Override
public void sendPacket(String command, String host, int port) {
    this.nioClientSocketChannelFactory = new NioClientSocketChannelFactory(executor, executor);
    this.clientBootstrap = new ClientBootstrap(nioClientSocketChannelFactory);
    this.clientBootstrap.setPipelineFactory(new ClientPipelineFactory(serverListener));
    future = clientBootstrap.connect(new InetSocketAddress(host, port));
    switch(command) {
        case Protocol.STOP:
            packet = new LBShutdownRequestPacket(lbAddress.getHostAddress(), lbPort);
            break;
    }
    future.awaitUninterruptibly();
    future.getChannel().write(createRequest(command));
}
Also used : NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) InetSocketAddress(java.net.InetSocketAddress) LBShutdownRequestPacket(org.mobicents.tools.heartbeat.packets.LBShutdownRequestPacket) ClientPipelineFactory(org.mobicents.tools.heartbeat.client.ClientPipelineFactory)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)1 NioClientSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory)1 ClientPipelineFactory (org.mobicents.tools.heartbeat.client.ClientPipelineFactory)1 LBShutdownRequestPacket (org.mobicents.tools.heartbeat.packets.LBShutdownRequestPacket)1