FileDocCategorySizeDatePackage
PeerItemFactory.javaAPI DocAzureus 3.0.3.43493Fri Dec 29 10:32:08 GMT 2006com.aelitis.azureus.core.peermanager.peerdb

PeerItemFactory

public class PeerItemFactory extends Object

Fields Summary
public static final byte
PEER_SOURCE_TRACKER
public static final byte
PEER_SOURCE_DHT
public static final byte
PEER_SOURCE_PEER_EXCHANGE
public static final byte
PEER_SOURCE_PLUGIN
public static final byte
PEER_SOURCE_INCOMING
public static final byte
HANDSHAKE_TYPE_PLAIN
public static final byte
HANDSHAKE_TYPE_CRYPTO
public static final byte
CRYPTO_LEVEL_1
public static final byte
CRYPTO_LEVEL_2
public static final byte
CRYPTO_LEVEL_CURRENT
private static final WeakHashMap
peer_items
private static final org.gudy.azureus2.core3.util.AEMonitor
item_mon
Constructors Summary
Methods Summary
public static PeerItemcreatePeerItem(java.lang.String address, int tcp_port, byte source, byte handshake_type, int udp_port, byte crypto_level, int up_speed)
Create a peer item using the given peer address and port information.

param
address of peer
param
port of peer
param
source this peer info was obtained from
return
peer

  
  
                                   
     
   
	 	 
	 	 
	 	 
	 	 
	 	 
	 	
			 
  
  
    return getLightweight( new PeerItem( address, tcp_port, source, handshake_type, udp_port, crypto_level, up_speed ) );
  
public static PeerItemcreatePeerItem(byte[] serialization, byte source, byte handshake_type, int udp_port)
Create a peer item using the given peer raw byte serialization (address and port).

param
serialization bytes
param
source this peer info was obtained from
return
peer

    return getLightweight( new PeerItem( serialization, source, handshake_type, udp_port ) );
  
private static PeerItemgetLightweight(PeerItem key)

    try{  item_mon.enter();
      WeakReference ref = (WeakReference)peer_items.get( key );

      if( ref == null ) {
        peer_items.put( key, new WeakReference( key ) );
        return key;
      }
 
      PeerItem item = (PeerItem)ref.get();
    
      if( item == null ) {
        Debug.out( "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPS: ref.get() == null" );
        peer_items.put( key, new WeakReference( key ) );
        return key;
      }

      return item;
    }
    finally{  item_mon.exit();  }