Package org.gudy.azureus2.core3.peer

Examples of org.gudy.azureus2.core3.peer.PEPeerManager$StatsReceiver


     
      PeerManager pm = download.getPeerManager();
           
      if ( pm != null ){
     
        PEPeerManager core_pm = PluginCoreUtils.unwrap( pm );
       
        if ( core_pm != null && core_pm.getHiddenBytes() > 0 ){
         
          is_complete = false;
        }
      }
    }
View Full Code Here


      return;
    }

    DiskManagerPiece[] dm_pieces = null;

    PEPeerManager pm = dlm.getPeerManager();

    DiskManager dm = dlm.getDiskManager();

    if (pm == null || dm == null) {
      canvas.redraw();
      return;
    }

    dm_pieces = dm.getPieces();

    if (dm_pieces == null || dm_pieces.length == 0) {
      canvas.redraw();
      return;
    }

    int numPieces = dm_pieces.length;

    if (imgHaveAll == null || imgHaveAll.isDisposed()) {
      imgHaveAll = new Image(canvas.getDisplay(), BLOCK_SIZE, BLOCK_SIZE);
      GC gc = new GC(imgHaveAll);
      try {
        try {
          gc.setAntialias(SWT.ON);
        } catch (Exception e) {
          // ignore
        }
        gc.setBackground(canvas.getBackground());
        gc.fillRectangle(imgHaveAll.getBounds());

        gc.setBackground(blockColors[BLOCKCOLOR_HAVEALL]);
        gc.fillRoundRectangle(1, 1, BLOCK_FILLSIZE, BLOCK_FILLSIZE,
            BLOCK_FILLSIZE, BLOCK_FILLSIZE);
      } finally {
        gc.dispose();
      }
    }

    if (imgNoHave == null || imgNoHave.isDisposed()) {
      imgNoHave = new Image(canvas.getDisplay(), BLOCK_SIZE, BLOCK_SIZE);
      GC gc = new GC(imgNoHave);
      try {
        try {
          gc.setAntialias(SWT.ON);
        } catch (Exception e) {
          // ignore
        }
        gc.setBackground(canvas.getBackground());
        gc.fillRectangle(imgNoHave.getBounds());

        gc.setBackground(blockColors[BLOCKCOLOR_NOHAVE]);
        gc.fillRoundRectangle(1, 1, BLOCK_FILLSIZE, BLOCK_FILLSIZE,
            BLOCK_FILLSIZE, BLOCK_FILLSIZE);
      } finally {
        gc.dispose();
      }
    }

    boolean clearImage = img == null || img.isDisposed()
        || img.getBounds().width != bounds.width
        || img.getBounds().height != bounds.height;
    if (clearImage) {
      if (img != null && !img.isDisposed()) {
        img.dispose();
      }
      //System.out.println("clear " + img);
      img = new Image(canvas.getDisplay(), bounds.width, bounds.height);
      squareCache = null;
    }

    PEPiece[] currentDLPieces = dlm.getCurrentPieces();
    Arrays.sort(currentDLPieces, compFindPEPiece);

    // find upload pieces
    ArrayList currentULPieces = new ArrayList();
    ArrayList futureULPieces = new ArrayList();
    PEPeer[] peers = (PEPeer[]) pm.getPeers().toArray(new PEPeer[0]);
    for (int i = 0; i < peers.length; i++) {
      PEPeer peer = peers[i];
      int[] peerRequestedPieces = peer.getIncomingRequestedPieceNumbers();
      if (peerRequestedPieces != null && peerRequestedPieces.length > 0) {
        currentULPieces.add(new Long(peerRequestedPieces[0]));
        for (int j = 1; j < peerRequestedPieces.length; j++) {
          futureULPieces.add(new Long(peerRequestedPieces[j]));
        }
      }

      // we'll have duplicates
      Collections.sort(currentULPieces);
      Collections.sort(futureULPieces);
    }

    int iNumCols = bounds.width / BLOCK_SIZE;
    int iNumRows = bounds.height / BLOCK_SIZE;
    int numSquares = onePiecePerBlock ? numPieces : iNumCols * iNumRows;
    double numPiecesPerSquare = numPieces / (double) numSquares;
    //System.out.println("numPiecesPerSquare=" + numPiecesPerSquare);

    if (squareCache == null || squareCache.length != numSquares) {
      squareCache = new double[numSquares];
      Arrays.fill(squareCache, -1);
    }

    int[] availability = pm.getAvailability();
   
    int numRedraws = 0;

    GC gc = new GC(img);
    try {
View Full Code Here

      return;
    }

    DiskManagerPiece[] dm_pieces = null;

    PEPeerManager pm = peer.getManager();

    DiskManager dm = pm.getDiskManager();

    dm_pieces = dm.getPieces();

    int iNumCols = bounds.width / BLOCK_SIZE;
    int iNeededHeight = (((dm.getNbPieces() - 1) / iNumCols) + 1)
        * BLOCK_SIZE;
    if (sc.getMinHeight() != iNeededHeight) {
      sc.setMinHeight(iNeededHeight);
      sc.layout(true, true);
      bounds = peerInfoCanvas.getClientArea();
    }
   
    img = new Image(peerInfoCanvas.getDisplay(), bounds.width, iNeededHeight);
    GC gcImg = new GC(img);
   
    try {
      // use advanced capabilities for faster drawText
      gcImg.setAdvanced(true);
     
      gcImg.setBackground(peerInfoCanvas.getBackground());
      gcImg.fillRectangle(0, 0, bounds.width, iNeededHeight);

      int[] availability = pm.getAvailability();

      int iNextDLPieceID = -1;
      int iDLPieceID = -1;
      int[] ourRequestedPieces = peer.getOutgoingRequestedPieceNumbers();
      if (ourRequestedPieces != null) {
View Full Code Here

    String sText = "";
    DownloadManager dm = (DownloadManager)cell.getDataSource();
    if (dm == null)
      return;

    PEPeerManager pm = dm.getPeerManager();
    if (pm != null) {
      float f = pm.getMinAvailability();
      if (!cell.setSortValue((long)(f * 1000)) && cell.isValid())
        return;
     
        sText = String.valueOf((int)(f * iTimesBy));
        if (numZeros - sText.length() > 0)
View Full Code Here

   
    List<DownloadManager> dms = global_manager.getDownloadManagers();
   
    for ( DownloadManager dm: dms ){
     
      PEPeerManager pm = dm.getPeerManager();
     
      if ( pm != null ){
       
        total_data_queued += pm.getBytesQueuedForUpload();
       
        total_connections += pm.getNbPeers() + pm.getNbSeeds();
       
        total_con_queued   += pm.getNbPeersWithUploadQueued();
        total_con_blocked  += pm.getNbPeersWithUploadBlocked();
       
        total_con_unchoked += pm.getNbPeersUnchoked();
      }
     
    }
   
    Messages.setLanguageText(
View Full Code Here

    String sText = "";
    DownloadManager dm = (DownloadManager)cell.getDataSource();
    if (dm == null)
      return;

    PEPeerManager pm = dm.getPeerManager();
    if (pm != null) {
       float f =pm.getAvgAvail();
      if (!cell.setSortValue((long)(f * 1000)) && cell.isValid())
        return;
     
        sText = String.valueOf((int)(f * iTimesBy));
        if (numZeros - sText.length() > 0)
View Full Code Here

    int average = -1;

    DownloadManager dm = (DownloadManager)cell.getDataSource();
   
    if( dm != null ) {
      PEPeerManager pm = dm.getPeerManager();
     
      if( pm != null ) {
        average = pm.getAverageCompletionInThousandNotation();
      }
    }

    if( !cell.setSortValue( average ) && cell.isValid() ) {
      return;
View Full Code Here

          continue;
        }
       
        DownloadManager  core_download = PluginCoreUtils.unwrap( download );
       
        PEPeerManager pm = core_download.getPeerManager();
       
        DownloadStats  stats = download.getStats();
       
        JSONObject torrent = new JSONObject();
       
        torrents.add( torrent );
       
        int  peers_from_us   = 0;
        int  peers_to_us    = 0;
       
        if ( pm != null ){
         
          List<PEPeer> peers = pm.getPeers();
         
          for ( PEPeer peer: peers ){
           
            PEPeerStats pstats = peer.getStats();
           
            if ( pstats.getDataReceiveRate() > 0 ){
             
              peers_to_us++;
            }
           
            if ( pstats.getDataSendRate() > 0 ){
             
              peers_from_us++;
            }
          }
        }
       
        for ( String field: fields ){
         
          Object  value = null;
         
          if ( field.equals( "addedDate" )){
            value = new Long(core_download.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME)/1000);
          }else if ( field.equals( "announceURL" )){ 
            value = t.getAnnounceURL().toExternalForm();
          }else if ( field.equals( "comment" )){ 
            value = t.getComment();
          }else if ( field.equals( "creator" )){ 
            value = t.getCreatedBy();
          }else if ( field.equals( "dateCreated" )){ 
            value = new Long( t.getCreationDate());
          }else if ( field.equals( "downloadedEver" )){
            value = new Long( stats.getDownloaded() + stats.getDiscarded() + stats.getHashFails());
          }else if ( field.equals( "error" )){
            String str = download.getErrorStateDetails();
           
              // o = none, 1=tracker warn,2=tracker error,2=other
            if ( str != null && str.length() > 0 ){
              value = new Long(3);
            }else{
              value = ZERO;
              TRTrackerAnnouncer tracker_client = core_download.getTrackerClient();
             
              if ( tracker_client != null ){
                TRTrackerAnnouncerResponse x = tracker_client.getBestAnnouncer().getLastResponse();
                if ( x != null ){
                  if ( x.getStatus() == TRTrackerAnnouncerResponse.ST_REPORTED_ERROR ){
                    value = new Long(2);
                  }
                }
              }else{
                DownloadScrapeResult x = download.getLastScrapeResult();
                if ( x != null ){
                  if ( x.getResponseType() == DownloadScrapeResult.RT_ERROR ){
                    String status = x.getStatus();
                   
                    if ( status != null && status.length() > 0 ){
                   
                      value = new Long(2);
                    }
                  }
                }
              }
            }
          }else if ( field.equals( "errorString" )){ 
            String str = download.getErrorStateDetails();
           
            if ( str != null && str.length() > 0 ){
              value = str;
            }else{
              value = "";
              TRTrackerAnnouncer tracker_client = core_download.getTrackerClient();
             
              if ( tracker_client != null ){
                TRTrackerAnnouncerResponse x = tracker_client.getBestAnnouncer().getLastResponse();
                if ( x != null ){
                  if ( x.getStatus() == TRTrackerAnnouncerResponse.ST_REPORTED_ERROR ){
                    value = x.getStatusString();
                  }
                }
              }else{
                DownloadScrapeResult x = download.getLastScrapeResult();
                if ( x != null ){
                  if ( x.getResponseType() == DownloadScrapeResult.RT_ERROR ){
                    value = x.getStatus();
                  }
                }
              }
            }
          }else if ( field.equals( "eta" )){
              // infinite -> 215784000
            long eta_secs = stats.getETASecs();
           
            eta_secs = Math.min( eta_secs, 215784000 );
           
            value = new Long( eta_secs );
          }else if ( field.equals( "hashString" )){ 
            value = ByteFormatter.encodeString( t.getHash());
          }else if ( field.equals( "haveUnchecked" )){ 
            value = ZERO;
          }else if ( field.equals( "haveValid" )){
            value = new Long( stats.getDownloaded());
          }else if ( field.equals( "id" )){   
            value = new Long( getID( download ));
          }else if ( field.equals( "trackerSeeds" )){
            DownloadScrapeResult scrape = download.getLastScrapeResult();
            value = new Long( scrape==null?0:scrape.getSeedCount());
          }else if ( field.equals( "trackerLeechers" )){
            DownloadScrapeResult scrape = download.getLastScrapeResult();
            value = new Long( scrape==null?0:scrape.getNonSeedCount());
          }else if ( field.equals( "leechers" )){ 
            if ( pm == null ){
              value = new Long(0);
            }else{
              value = new Long( pm.getNbPeers());
            }
          }else if ( field.equals( "leftUntilDone" )){ 
            value = new Long( stats.getRemaining());
          }else if ( field.equals( "name" )){ 
            value = download.getName();
          }else if ( field.equals( "peersConnected" )){ 
            if ( pm == null ){
              value = new Long(0);
            }else{
              value = new Long( pm.getNbPeers() + pm.getNbSeeds());
            }
          }else if ( field.equals( "peersGettingFromUs" )){ 
            value = new Long( peers_from_us );
          }else if ( field.equals( "peersSendingToUs" )){
            value = new Long( peers_to_us );
          }else if ( field.equals( "isPrivate" )){
            value = t.isPrivate()?TRUE:FALSE;
          }else if ( field.equals( "rateDownload" )){ 
            value = new Long( stats.getDownloadAverage());
          }else if ( field.equals( "rateUpload" )){
            value = new Long( stats.getUploadAverage());
          }else if ( field.equals( "speedLimitDownload" )){ 
            value = new Long( download.getDownloadRateLimitBytesPerSecond());
          }else if ( field.equals( "speedLimitUpload" )){
            value = new Long( download.getUploadRateLimitBytesPerSecond());
          }else if ( field.equals( "seeders" )){
            if ( pm == null ){
              value = new Long(-1);
            }else{
              value = new Long( pm.getNbSeeds());
            }
          }else if ( field.equals( "sizeWhenDone" )){ 
            value = new Long( t.getSize())// TODO: excluded DND
          }else if ( field.equals( "status" )){ 
              // 1 - waiting to verify
View Full Code Here

  {
    super("publish", null, "Publishing");
  }

  protected boolean performCommand(ConsoleInput ci, DownloadManager dm, List args) {
    TOTorrent torrent = dm.getTorrent();
        if (torrent != null) {
          try {
          TRHost  host = ci.azureus_core.getTrackerHost();
         
          TRHostTorrent  existing = host.getHostTorrent( torrent );
View Full Code Here

            StringBuffer sb = new StringBuffer();
            Object[] selectedDataSources = tv.getSelectedDataSources(true);
            for (Object ds : selectedDataSources) {
              if (ds instanceof DownloadManager) {
                DownloadManager dm = (DownloadManager) ds;
                TOTorrent torrent = dm.getTorrent();
                if (torrent != null) {
                  try {
                    sb.append(torrent.getHashWrapper().toBase32String());
                    sb.append('\n');
                  } catch (TOTorrentException e) {
                  }
                }
              } else if (ds instanceof DiskManagerFileInfo) {
                DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
                DownloadManager dm = fileInfo.getDownloadManager();
                TOTorrent torrent = dm.getTorrent();
                if (torrent != null) {
                  try {
                    sb.append(torrent.getHashWrapper().toBase32String());
                    sb.append(';');
                    sb.append(fileInfo.getIndex());
                    sb.append('\n');
                    onlyDMs = false;
                  } catch (TOTorrentException e) {
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.peer.PEPeerManager$StatsReceiver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.