Methods Summary |
---|
public void | destroy()
factory.destroy( this );
|
protected int | getNetwork()
return( network );
|
protected com.aelitis.net.udp.uc.PRUDPPacketHandler | getPacketHandler()
return( packet_handler );
|
protected DHTUDPRequestHandler | getRequestHandler()
return( request_handler );
|
public DHTUDPPacketHandlerStats | getStats()
return( stats );
|
protected void | receive(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)
// incoming request
if ( test_network_alive ){
request.setAddress( AddressUtils.adjustDHTAddress( request.getAddress(), false ));
// an alien request is one that originates from a peer that we haven't recently
// talked to
boolean alien = !bloom1.contains( request.getAddress().getAddress().getAddress());
stats.packetReceived( request.getSerialisedSize());
request_handler.process( request, alien );
}
|
public void | send(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request, java.net.InetSocketAddress destination_address)
destination_address = AddressUtils.adjustDHTAddress( destination_address, true );
// one way send (no matching reply expected )
try{
request.setNetwork( network );
if ( test_network_alive ){
packet_handler.send( request, destination_address );
}
}catch( PRUDPPacketHandlerException e ){
throw( new DHTUDPPacketHandlerException( e ));
}finally{
stats.packetSent( request.getSerialisedSize() );
}
|
public void | send(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketReply reply, java.net.InetSocketAddress destination_address)
destination_address = AddressUtils.adjustDHTAddress( destination_address, true );
// send reply to a request
try{
reply.setNetwork( network );
// outgoing request
if ( test_network_alive ){
packet_handler.send( reply, destination_address );
}
}catch( PRUDPPacketHandlerException e ){
throw( new DHTUDPPacketHandlerException( e ));
}finally{
stats.packetSent( reply.getSerialisedSize());
}
|
public void | sendAndReceive(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request, java.net.InetSocketAddress destination_address, DHTUDPPacketReceiver receiver, long timeout, int priority)
// send and receive pair
destination_address = AddressUtils.adjustDHTAddress( destination_address, true );
try{
request.setNetwork( network );
if ( test_network_alive ){
long diff = SystemTime.getCurrentTime() - last_bloom_rotation_time;
if( diff < 0 || diff > BLOOM_ROTATION_PERIOD ) {
// System.out.println( "bloom rotate: entries = " + bloom1.getEntryCount() + "/" + bloom2.getEntryCount());
bloom1 = bloom2;
bloom2 = BloomFilterFactory.createAddOnly( BLOOM_FILTER_SIZE );
last_bloom_rotation_time = SystemTime.getCurrentTime();
}
byte[] address_bytes = destination_address.getAddress().getAddress();
bloom1.add( address_bytes );
bloom2.add( address_bytes );
packet_handler.sendAndReceive(
request,
destination_address,
new PRUDPPacketReceiver()
{
public void
packetReceived(
PRUDPPacketHandlerRequest request,
PRUDPPacket packet,
InetSocketAddress from_address )
{
DHTUDPPacketReply reply = (DHTUDPPacketReply)packet;
stats.packetReceived( reply.getSerialisedSize() );
if ( reply.getNetwork() == network ){
receiver.packetReceived(reply, from_address, request.getElapsedTime());
}else{
Debug.out( "Non-matching network reply received" );
receiver.error( new DHTUDPPacketHandlerException( new Exception( "Non-matching network reply received" )));
}
}
public void
error(
PRUDPPacketHandlerException e )
{
receiver.error( new DHTUDPPacketHandlerException( e ));
}
},
timeout,
priority );
}else{
receiver.error( new DHTUDPPacketHandlerException( new Exception( "Test network disabled" )));
}
}catch( PRUDPPacketHandlerException e ){
throw( new DHTUDPPacketHandlerException(e ));
}finally{
stats.packetSent( request.getSerialisedSize() );
}
|
public void | setDelays(int send_delay, int receive_delay, int queued_request_timeout)
// TODO: hmm
packet_handler.setDelays( send_delay, receive_delay, queued_request_timeout );
|
public void | testNetworkAlive(boolean alive)
test_network_alive = alive;
|