Search in sources :

Example 1 with BalancerContext

use of org.mobicents.tools.sip.balancer.BalancerContext in project load-balancer by RestComm.

the class RingingFailoverTest method testViaHeaderRewrite.

@Test
public void testViaHeaderRewrite() throws Exception, ParseException {
    CallIDAffinityBalancerAlgorithm algorithm = new CallIDAffinityBalancerAlgorithm();
    Response response = SipFactory.getInstance().createMessageFactory().createResponse(ringing);
    String node = "1.2.3.4";
    Integer port = 1234;
    Node adNode = new Node(node, node);
    adNode.getProperties().put("udpPort", "" + port);
    algorithm.balancerContext = new BalancerContext();
    algorithm.balancerContext.algorithmClassName = CallIDAffinityBalancerAlgorithm.class.getName();
    algorithm.balancerContext.smppToNodeAlgorithmClassName = SmppToNodeRoundRobinAlgorithm.class.getName();
    algorithm.balancerContext.smppToProviderAlgorithmClassName = SmppToProviderRoundRobinAlgorithm.class.getName();
    algorithm.setConfiguration(new LoadBalancerConfiguration());
    InvocationContext ctx = new InvocationContext("0", algorithm.balancerContext);
    ctx.sipNodeMap(false).put(new KeySip(adNode, false), adNode);
    algorithm.invocationContext = ctx;
    algorithm.processExternalResponse(response, false);
    algorithm.stop();
    assertTrue(response.toString().contains(node + ":" + port));
}
Also used : Response(javax.sip.message.Response) SmppToNodeRoundRobinAlgorithm(org.mobicents.tools.smpp.multiplexer.SmppToNodeRoundRobinAlgorithm) Node(org.mobicents.tools.heartbeat.api.Node) LoadBalancerConfiguration(org.mobicents.tools.configuration.LoadBalancerConfiguration) CallIDAffinityBalancerAlgorithm(org.mobicents.tools.sip.balancer.CallIDAffinityBalancerAlgorithm) BalancerContext(org.mobicents.tools.sip.balancer.BalancerContext) SmppToProviderRoundRobinAlgorithm(org.mobicents.tools.smpp.multiplexer.SmppToProviderRoundRobinAlgorithm) Test(org.junit.Test)

Aggregations

Response (javax.sip.message.Response)1 Test (org.junit.Test)1 LoadBalancerConfiguration (org.mobicents.tools.configuration.LoadBalancerConfiguration)1 Node (org.mobicents.tools.heartbeat.api.Node)1 BalancerContext (org.mobicents.tools.sip.balancer.BalancerContext)1 CallIDAffinityBalancerAlgorithm (org.mobicents.tools.sip.balancer.CallIDAffinityBalancerAlgorithm)1 SmppToNodeRoundRobinAlgorithm (org.mobicents.tools.smpp.multiplexer.SmppToNodeRoundRobinAlgorithm)1 SmppToProviderRoundRobinAlgorithm (org.mobicents.tools.smpp.multiplexer.SmppToProviderRoundRobinAlgorithm)1