Search in sources :

Example 1 with ClientPipelineFactory

use of org.mobicents.tools.heartbeat.client.ClientPipelineFactory in project load-balancer by RestComm.

the class Client method start.

@Override
public void start() {
    this.nioClientSocketChannelFactory = new NioClientSocketChannelFactory(executor, executor);
    this.clientBootstrap = new ClientBootstrap(nioClientSocketChannelFactory);
    this.clientBootstrap.setPipelineFactory(new ClientPipelineFactory(clientListener));
    this.isa = new InetSocketAddress(lbAddress, lbPort);
}
Also used : NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) InetSocketAddress(java.net.InetSocketAddress) ClientPipelineFactory(org.mobicents.tools.heartbeat.client.ClientPipelineFactory)

Example 2 with ClientPipelineFactory

use of org.mobicents.tools.heartbeat.client.ClientPipelineFactory 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)

Example 3 with ClientPipelineFactory

use of org.mobicents.tools.heartbeat.client.ClientPipelineFactory in project load-balancer by RestComm.

the class Client method switchover.

@Override
public void switchover(String fromJvmRoute, String toJvmRoute) {
    Packet packet = new SwitchoverRequestPacket(fromJvmRoute, toJvmRoute);
    ClientBootstrap clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(executor, executor));
    clientBootstrap.setPipelineFactory(new ClientPipelineFactory(clientListener));
    ChannelFuture future = clientBootstrap.connect(new InetSocketAddress(lbAddress, lbPort));
    future.awaitUninterruptibly();
    future.getChannel().write(createRequest(Protocol.SWITCHOVER, packet));
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) NodeStopRequestPacket(org.mobicents.tools.heartbeat.api.NodeStopRequestPacket) NodeShutdownRequestPacket(org.mobicents.tools.heartbeat.api.NodeShutdownRequestPacket) StartRequestPacket(org.mobicents.tools.heartbeat.api.StartRequestPacket) Packet(org.mobicents.tools.heartbeat.api.Packet) SwitchoverRequestPacket(org.mobicents.tools.heartbeat.packets.SwitchoverRequestPacket) HeartbeatRequestPacket(org.mobicents.tools.heartbeat.api.HeartbeatRequestPacket) NioClientSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory) ClientBootstrap(org.jboss.netty.bootstrap.ClientBootstrap) InetSocketAddress(java.net.InetSocketAddress) SwitchoverRequestPacket(org.mobicents.tools.heartbeat.packets.SwitchoverRequestPacket) ClientPipelineFactory(org.mobicents.tools.heartbeat.client.ClientPipelineFactory)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)3 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)3 NioClientSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory)3 ClientPipelineFactory (org.mobicents.tools.heartbeat.client.ClientPipelineFactory)3 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 HeartbeatRequestPacket (org.mobicents.tools.heartbeat.api.HeartbeatRequestPacket)1 NodeShutdownRequestPacket (org.mobicents.tools.heartbeat.api.NodeShutdownRequestPacket)1 NodeStopRequestPacket (org.mobicents.tools.heartbeat.api.NodeStopRequestPacket)1 Packet (org.mobicents.tools.heartbeat.api.Packet)1 StartRequestPacket (org.mobicents.tools.heartbeat.api.StartRequestPacket)1 LBShutdownRequestPacket (org.mobicents.tools.heartbeat.packets.LBShutdownRequestPacket)1 SwitchoverRequestPacket (org.mobicents.tools.heartbeat.packets.SwitchoverRequestPacket)1