FileDocCategorySizeDatePackage
SuperSeedPiece.javaAPI DocAzureus 3.0.3.42916Tue Sep 21 06:36:26 BST 2004org.gudy.azureus2.core3.peer.impl.control

SuperSeedPiece

public class SuperSeedPiece extends Object
author
Olivier

Fields Summary
private int
pieceNumber
private int
level
private long
timeFirstDistributed
private org.gudy.azureus2.core3.peer.PEPeer
firstReceiver
private int
timeToReachAnotherPeer
private static AEMonitor
class_mon
Constructors Summary
public SuperSeedPiece(org.gudy.azureus2.core3.peer.impl.PEPeerControl manager, int _pieceNumber)

  
  
      
    Ignore.ignore( manager );
    pieceNumber = _pieceNumber;
    level = 0;
  
Methods Summary
public intgetLevel()

    return level;
  
public intgetPieceNumber()

return
Returns the pieceNumber.

    return pieceNumber;
  
public voidpeerHasPiece(org.gudy.azureus2.core3.peer.PEPeer peer)

  	try{
  		class_mon.enter();
  	
	    if(level < 2) {
	      firstReceiver = peer;
	      timeFirstDistributed = SystemTime.getCurrentTime();
	      //numberOfPeersWhenFirstReceived = manager.getNbPeers();
	    } else {
	      if(peer != null && firstReceiver != null) {
	        timeToReachAnotherPeer = (int) (SystemTime.getCurrentTime() - timeFirstDistributed);
	        firstReceiver.setUploadHint(timeToReachAnotherPeer);
	      }
	    }
	    level = 2;
  	}finally{
  		
  		class_mon.exit();
  	}
  
public voidpeerLeft()

    if(level == 1)
      level = 0;
  
public voidpieceRevealedToPeer()

  	try{
  		class_mon.enter();
  
  		level = 1;
  	}finally{
  		
  		class_mon.exit();
  	}
  
public voidupdateTime()

    if(level < 2)
      return;
    if(timeToReachAnotherPeer > 0)
      return;
    if(firstReceiver == null)
      return;
    int timeToSend = (int) (SystemTime.getCurrentTime() - timeFirstDistributed);
    if(timeToSend > firstReceiver.getUploadHint())
      firstReceiver.setUploadHint(timeToSend);