logger.log(Level.WARNING,
"clb.sip.failed_to_route_incoming_request", ex.getMessage());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "clb.caught_an_exception", ex);
}
SipServletResponseImpl errorResponse =
req.createTerminatingResponse(503);
if (errorResponse != null) {
errorResponse.popDispatcher().dispatch(errorResponse);
}
return;
}
//Check if request is send by backend to be forwarded to
//client.
//Such a request will have a topmost route with parameter
//"felb".
Header routeHeader = req.getRawHeader(Header.ROUTE);
ListIterator<Address> routeIterator = null;
try {
if(routeHeader != null){
routeIterator = routeHeader.getAddressValues();
}
} catch (ServletParseException ex) {
logger.log(Level.WARNING,
"clb.sip.failed_to_route_incoming_request", ex.getMessage());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "clb.caught_an_exception", ex);
}
SipServletResponseImpl errorResponse =
req.createTerminatingResponse(503);
if (errorResponse != null) {
errorResponse.popDispatcher().dispatch(errorResponse);
}
return;
}
if(routeIterator != null && routeIterator.hasNext()){
Address topRoute = routeIterator.next();
String feParam = topRoute.getURI().getParameter(CLBConstants.FE_LB_PARAM);
if(feParam != null){
//remove topmost route
boolean readOnly = routeHeader.isReadOnly();
routeHeader.setReadOnly(false);
routeIterator.remove();
routeHeader.setReadOnly(readOnly);
TargetTuple tt = null;
try{
tt = TargetResolver.getInstance().resolveRequest(
req, req.getContentLength());
}catch(Exception ex){
logger.log(Level.WARNING,
"clb.sip.failed_to_route_incoming_request", ex.getMessage());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "clb.caught_an_exception", ex);
}
SipServletResponseImpl errorResponse =
req.createTerminatingResponse(503);
if (errorResponse != null) {
errorResponse.popDispatcher().dispatch(errorResponse);
}
return;
}
req.setResolvedRemote(tt);
LayerHelper.resetDispatcher(req, NetworkManager.getInstance());
req.popDispatcher().dispatch(req);
return;
}
}
SipRequestGroup sipRequestGroup =
(SipRequestGroup) controller.getRequestGroup(null);
if (sipRequestGroup != null) {
try {
boolean localServer =
sipRequestGroup.handleIncomingRequest(req);
if (localServer) {
// Continue on this server
req.pushTransactionDispatcher(this);
req.pushApplicationDispatcher(this);
LayerHelper.next(req, this, nextLayer);
} else {
//proxy request to the BE
req.popDispatcher().dispatch(req);
}
} catch (SipRoutingException e) {
if (clbMonitoringManager.isCLBMonitoringEnabled()) {
clbMonitoringManager.getCLBStatsUpdater().
incrementTotalErrorSipResponsesAtCLBLayerFE();
}
logger.log(Level.WARNING,
"clb.sip.failed_to_route_incoming_request", e.getMessage());
if(logger.isLoggable(Level.FINE)){
logger.log(Level.FINE, "clb.caught_an_exception", e);
}
SipServletResponseImpl errorResponse =
req.createTerminatingResponse(503);
if (errorResponse != null) {
errorResponse.popDispatcher().dispatch(errorResponse);
}
}
} else {
if (clbMonitoringManager.isCLBMonitoringEnabled()) {
clbMonitoringManager.getCLBStatsUpdater().