FileDocCategorySizeDatePackage
AZOtherInstanceImpl.javaAPI DocAzureus 3.0.3.44189Mon Jul 17 13:14:22 BST 2006com.aelitis.azureus.core.instancemanager.impl

AZOtherInstanceImpl

public class AZOtherInstanceImpl extends AZInstanceImpl

Fields Summary
private String
id
private List
internal_addresses
private InetAddress
external_address
private int
tcp_port
private int
udp_port
private int
udp_non_data_port
private long
alive_time
Constructors Summary
protected AZOtherInstanceImpl(String _id, InetAddress _internal_address, InetAddress _external_address, int _tcp_port, int _udp_port, int _udp_non_data_port)



	
	
							
						
						
								
								
								 
	
		id					= _id;
		
		internal_addresses.add( _internal_address );
		
		external_address	= _external_address;
		tcp_port			= _tcp_port;
		udp_port			= _udp_port;
		udp_non_data_port	= _udp_non_data_port;
		
		alive_time	= SystemTime.getCurrentTime();
	
Methods Summary
protected static com.aelitis.azureus.core.instancemanager.impl.AZOtherInstanceImpldecode(java.net.InetAddress internal_address, java.util.Map map)

		String	id			= new String((byte[])map.get( "id" ));
		String	int_ip		= new String((byte[])map.get( "iip" ));
		String	ext_ip		= new String((byte[])map.get( "eip" ));
		int		tcp			= ((Long)map.get("tp" )).intValue();
		int		udp			= ((Long)map.get("dp" )).intValue();
		
		Long	l_udp_other = (Long)map.get("dp2" );
		
		int		udp_other	= l_udp_other==null?udp:l_udp_other.intValue();
			
		try{
			if ( !int_ip.equals("0.0.0.0")){
				
				internal_address = InetAddress.getByName( int_ip );
			}

			InetAddress	external_address = InetAddress.getByName( ext_ip );
			
			return( new AZOtherInstanceImpl(id, internal_address, external_address, tcp, udp, udp_other ));
			
		}catch( Throwable e ){
			
			Debug.printStackTrace(e);
		}
		
		return( null );
	
protected longgetAliveTime()

		long	now = SystemTime.getCurrentTime();
		
		if ( now < alive_time ){
			
			alive_time	= now;
		}
		
		return( alive_time );
	
public java.net.InetAddressgetExternalAddress()

		return( external_address );
	
public java.lang.StringgetID()

		return( id );
	
public java.net.InetAddressgetInternalAddress()

		return((InetAddress)internal_addresses.get(0));
	
protected java.util.ListgetInternalAddresses()

		return( internal_addresses );
	
public intgetTCPListenPort()

		return( tcp_port );
	
public intgetUDPListenPort()

		return( udp_port );
	
public intgetUDPNonDataListenPort()

		return( udp_non_data_port );
	
protected booleanupdate(com.aelitis.azureus.core.instancemanager.impl.AZOtherInstanceImpl new_inst)

		
		alive_time	= SystemTime.getCurrentTime();
		
		InetAddress	new_address = new_inst.getInternalAddress();
		
		boolean	same = true;
		
		if ( !internal_addresses.contains( new_address )){
			
			same	= false;
			
			List	new_addresses = new ArrayList( internal_addresses );
			
			new_addresses.add( 0, new_address );
			
			internal_addresses	= new_addresses;
		}
		
		same	 = 	same && 
					external_address.equals( new_inst.external_address ) &&
					tcp_port == new_inst.tcp_port  &&
					udp_port == new_inst.udp_port;
		
		
		external_address	= new_inst.external_address;
		tcp_port			= new_inst.tcp_port;
		udp_port			= new_inst.udp_port;
	
		return( !same );