use of org.mobicents.tools.sip.balancer.AppServer in project load-balancer by RestComm.
the class RegisterWithNexmoPropertyTest method setUp.
@Before
public void setUp() throws Exception {
shootist = new Shootist(ListeningPoint.TCP, 5060);
balancer = new BalancerRunner();
LoadBalancerConfiguration lbConfig = new LoadBalancerConfiguration();
lbConfig.getSipConfiguration().getInternalLegConfiguration().setTcpPort(5065);
lbConfig.getSipConfiguration().getExternalLegConfiguration().setTcpPort(5060);
lbConfig.getSipConfiguration().getAlgorithmConfiguration().setAlgorithmClass(UserBasedAlgorithm.class.getCanonicalName());
lbConfig.getSipConfiguration().getAlgorithmConfiguration().setSipHeaderAffinityKey("From");
lbConfig.getSipConfiguration().setIsUseWithNexmo(true);
lbConfig.getSipConfiguration().setSendTrying(false);
balancer.start(lbConfig);
for (int q = 0; q < servers.length; q++) {
servers[q] = new AppServer("node" + q, 4060 + q, "127.0.0.1", 2000, 5060, 5065, "0", ListeningPoint.TCP, 2222 + q);
servers[q].start();
}
Thread.sleep(3000);
}
use of org.mobicents.tools.sip.balancer.AppServer in project load-balancer by RestComm.
the class RollingUpgradeTest method testCallDoesntGoBackToOriginalButUpgradedNode.
@Test
public void testCallDoesntGoBackToOriginalButUpgradedNode() {
EventListener failureEventListener = new EventListener() {
@Override
public void uasAfterResponse(int statusCode, AppServer source) {
}
@Override
public void uasAfterRequestReceived(String method, AppServer source) {
if (method.equals("INVITE")) {
inviteServer = source;
} else if (method.equals("ACK")) {
ackServer = source;
ackServer.stop();
ackServer.version = "2";
ackServer.start();
boolean keepOneOldVersionAlive = true;
for (AppServer srv : servers) {
if (srv != ackServer) {
if (keepOneOldVersionAlive && !srv.getNode().getProperties().get("udpPort").toString().endsWith("0")) {
// make sure it is not the first one to avoid some errors
keepOneOldVersionAlive = false;
oldVersionServer = srv;
System.out.println("We kept alive " + oldVersionServer);
} else {
// everyone else move to new version
srv.stop();
srv.version = "2";
srv.start();
}
}
}
} else {
byeServer = source;
}
}
@Override
public void uacAfterRequestSent(String method, AppServer source) {
// TODO Auto-generated method stub
}
@Override
public void uacAfterResponse(int statusCode, AppServer source) {
}
};
for (AppServer as : servers) as.setEventListener(failureEventListener);
for (BalancerRunner balancer : balancers) {
balancer.setNodeExpiration(15000);
}
shootist.peerHostPort = "127.0.0.1:9988";
shootist.callerSendsBye = true;
shootist.sendInitialInvite();
// servers[0].sendHeartbeat = false;
Helper.sleep(20000);
try {
shootist.sendBye();
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Helper.sleep(2000);
assertEquals(3, externalIpLoadBalancer.sipMessageWithoutRetrans.size());
assertNotSame(inviteServer, byeServer);
assertSame(inviteServer, ackServer);
assertSame(byeServer, oldVersionServer);
// not same because invite server was upgraded before bye
assertNotSame(byeServer.version, inviteServer.version);
// same because not upgraded before ack
assertEquals(ackServer.version, inviteServer.version);
assertNotNull(byeServer);
assertNotNull(ackServer);
}
use of org.mobicents.tools.sip.balancer.AppServer in project load-balancer by RestComm.
the class SprayTwoPureConsistentHashTest method testSprayingRoundRobinSIPLBsUASCallConsistentHash.
@Test
public void testSprayingRoundRobinSIPLBsUASCallConsistentHash() throws Exception {
EventListener failureEventListener = new EventListener() {
@Override
public void uasAfterResponse(int statusCode, AppServer source) {
}
@Override
public void uasAfterRequestReceived(String method, AppServer source) {
if (method.equals("INVITE")) {
inviteServer = source;
} else if (method.equals("ACK")) {
ackServer = source;
} else {
byeServer = source;
}
}
@Override
public void uacAfterRequestSent(String method, AppServer source) {
// TODO Auto-generated method stub
}
@Override
public void uacAfterResponse(int statusCode, AppServer source) {
}
};
for (AppServer as : servers) as.setEventListener(failureEventListener);
for (BalancerRunner balancer : balancers) {
balancer.setNodeExpiration(15000);
}
Thread.sleep(1000);
shootist.peerHostPort = "127.0.0.1:9988";
shootist.callerSendsBye = true;
shootist.sendInitialInvite();
// servers[0].sendHeartbeat = false;
Thread.sleep(15000);
shootist.sendBye();
Thread.sleep(2000);
assertEquals(3, externalIpLoadBalancer.sipMessageWithoutRetrans.size());
assertSame(inviteServer, byeServer);
assertSame(inviteServer, ackServer);
assertNotNull(byeServer);
assertNotNull(ackServer);
}
use of org.mobicents.tools.sip.balancer.AppServer in project load-balancer by RestComm.
the class SprayTwoPureConsistentHashTest method setUp.
@Before
public void setUp() throws Exception {
shootist = new Shootist();
String externalIpLBString = "";
String internalIpLBString = "";
for (int q = 0; q < numBalancers; q++) {
balancers[q] = prepBalancer(q);
externalIpLBString += "127.0.0.1:" + 5 + q + "60,";
internalIpLBString += "127.0.0.1:" + 5 + q + "65,";
}
for (int q = 0; q < servers.length; q++) {
servers[q] = new AppServer("node" + q, 4060 + q, "127.0.0.1", 2000, 5060, 5065, "0", ListeningPoint.UDP, 2222 + q);
servers[q].setBalancers(loadbalancers);
servers[q].start();
}
externalIpLoadBalancer = new UDPPacketForwarder(9988, externalIpLBString, "127.0.0.1");
externalIpLoadBalancer.start();
internalIpLoadBalancer = new UDPPacketForwarder(9922, internalIpLBString, "127.0.0.1");
internalIpLoadBalancer.start();
Thread.sleep(5000);
}
use of org.mobicents.tools.sip.balancer.AppServer in project load-balancer by RestComm.
the class SprayingLoadBalancersWithNoInternalPortTest method testSprayingRoundRobinSIPLBsUASCallConsistentHash.
@Test
public void testSprayingRoundRobinSIPLBsUASCallConsistentHash() {
EventListener failureEventListener = new EventListener() {
@Override
public void uasAfterResponse(int statusCode, AppServer source) {
}
@Override
public void uasAfterRequestReceived(String method, AppServer source) {
if (method.equals("INVITE")) {
inviteServer = source;
} else if (method.equals("ACK")) {
ackServer = source;
} else {
byeServer = source;
}
}
@Override
public void uacAfterRequestSent(String method, AppServer source) {
// TODO Auto-generated method stub
}
@Override
public void uacAfterResponse(int statusCode, AppServer source) {
}
};
for (AppServer as : servers) as.setEventListener(failureEventListener);
shootist.peerHostPort = "127.0.0.1:9988";
shootist.callerSendsBye = true;
shootist.sendInitialInvite();
// servers[0].sendHeartbeat = false;
Helper.sleep(10000);
try {
shootist.sendBye();
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Helper.sleep(2200);
assertEquals(3, externalIpLoadBalancer.sipMessageWithoutRetrans.size());
assertSame(inviteServer, byeServer);
assertSame(inviteServer, ackServer);
assertNotNull(byeServer);
assertNotNull(ackServer);
}
Aggregations