PeerItemFactorypublic 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 |
Methods Summary |
---|
public static PeerItem | createPeerItem(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.
return getLightweight( new PeerItem( address, tcp_port, source, handshake_type, udp_port, crypto_level, up_speed ) );
| public static PeerItem | createPeerItem(byte[] serialization, byte source, byte handshake_type, int udp_port)Create a peer item using the given peer raw byte serialization (address and port).
return getLightweight( new PeerItem( serialization, source, handshake_type, udp_port ) );
| private static PeerItem | getLightweight(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(); }
|
|