core/src/main/java/org/mobicents/ha/javax/sip/LoadBalancerHeartBeatingServiceImpl.java
protected ArrayList<SIPNode> getReachableSIPNodeInfo(SipLoadBalancer balancer, ArrayList<SIPNode> info) {
		InetAddress balancerAddr = balancer.getAddress();
		if (balancerAddr.isLoopbackAddress()) {
			return info;
		}

		ArrayList<SIPNode> rv = new ArrayList<SIPNode>();
		for(SIPNode node: info) {
			if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
				logger.logTrace("Checking if " + node + " is reachable");
			}
			try {
				NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getByName(node.getIp()));
				// FIXME How can I determine the ttl?
				boolean b = balancerAddr.isReachable(ni, 5, 900);
				if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
					logger.logTrace(node + " is reachable ? " + b);
				}
				if(b) {
					if(balancer.getCustomInfo() != null && !balancer.getCustomInfo().isEmpty()) {
						for(Entry<Object, Object> entry : balancer.getCustomInfo().entrySet()) {
							if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
								logger.logDebug("Adding custom info with key " + (String)entry.getKey() + " and value " + (String)entry.getValue());
							}
							node.getProperties().put((String)entry.getKey(), (String)entry.getValue());
						}
					}
					rv.add(node);
				}
			} catch (IOException e) {
				logger.logError("IOException", e);
			}
		}
		
		if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
			logger.logTrace("Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]");
		}
		
		return rv;
	}
protected ArrayList<SIPNode> getReachableSIPNodeInfo(SipLoadBalancer balancer, ArrayList<SIPNode> info) {
		InetAddress balancerAddr = balancer.getAddress();
		if (balancerAddr.isLoopbackAddress()) {
			return info;
		}

		ArrayList<SIPNode> rv = new ArrayList<SIPNode>();
		for(SIPNode node: info) {
			if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
				logger.logTrace("Checking if " + node + " is reachable");
			}
			try {
				NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getByName(node.getIp()));
				// FIXME How can I determine the ttl?
				boolean b = balancerAddr.isReachable(ni, 5, 900);
				if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
					logger.logTrace(node + " is reachable ? " + b);
				}
				if(b) {
					if(balancer.getCustomInfo() != null && !balancer.getCustomInfo().isEmpty()) {
						for(Entry<Object, Object> entry : balancer.getCustomInfo().entrySet()) {
							if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
								logger.logDebug("Adding custom info with key " + (String)entry.getKey() + " and value " + (String)entry.getValue());
							}
							node.getProperties().put((String)entry.getKey(), (String)entry.getValue());
						}
					}
					rv.add(node);
				}
			} catch (IOException e) {
				logger.logError("IOException", e);
			}
		}
		
		if(logger.isLoggingEnabled(StackLogger.TRACE_TRACE)) {
			logger.logTrace("Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]");
		}
		
		return rv;
	}
protected ArrayList < SIPNode > getReachableSIPNodeInfo ( SipLoadBalancer balancer , ArrayList < SIPNode > info ) { InetAddress balancerAddr = balancer . getAddress ( ) ; if ( balancerAddr . isLoopbackAddress ( ) ) { return info ; } ArrayList < SIPNode > rv = new ArrayList < SIPNode > ( ) ; for ( SIPNode node : info ) { if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Checking if " + node + " is reachable" ) ; } try { NetworkInterface ni = NetworkInterface . getByInetAddress ( InetAddress . getByName ( node . getIp ( ) ) ) ; // FIXME How can I determine the ttl? boolean b = balancerAddr . isReachable ( ni , 5 , 900 ) ; if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( node + " is reachable ? " + b ) ; } if ( b ) { if ( balancer . getCustomInfo ( ) != null && ! balancer . getCustomInfo ( ) . isEmpty ( ) ) { for ( Entry < Object , Object > entry : balancer . getCustomInfo ( ) . entrySet ( ) ) { if ( logger . isLoggingEnabled ( StackLogger . TRACE_DEBUG ) ) { logger . logDebug ( "Adding custom info with key " + ( String ) entry . getKey ( ) + " and value " + ( String ) entry . getValue ( ) ) ; } node . getProperties ( ) . put ( ( String ) entry . getKey ( ) , ( String ) entry . getValue ( ) ) ; } } rv . add ( node ) ; } } catch ( IOException e ) { logger . logError ( "IOException" , e ) ; } } if ( logger . isLoggingEnabled ( StackLogger . TRACE_TRACE ) ) { logger . logTrace ( "Reachable SIP Node:[balancer=" + balancerAddr + "],[node info=" + rv + "]" ) ; } return rv ; }
Contribution from Naoki Nishihara from OKI for Issue 1806 (SIP LB can not forward when node is listening on 0.0.0.0)
Useful for a multi homed address, tries to reach a given load balancer from the list of ip addresses given in param
@param balancerAddr the load balancer to try to reach
@param info the list of node info from which we try to access the load balancer
@return the list stripped from the nodes not able to reach the load balancer
Contribution from Naoki Nishihara from OKI for Issue 1806 ( SIP LB can not forward when node is listening on 0 . 0 . 0 . 0 ) Useful for a multi homed address tries to reach a given load balancer from the list of ip addresses given in param