Package org.gudy.azureus2.core3.download

Examples of org.gudy.azureus2.core3.download.DownloadManager


                if ( wait_sem.reserve( 500 )){
                 
                  break;
                }
               
                DownloadManager dm = core_file.getDownloadManager();
               
                if ( dm.isDestroyed()){
                 
                  throw( new Exception( "Download has been removed" ));
                 
                }else{
                 
                  int  state = dm.getState();
                 
                  if ( state == DownloadManager.STATE_ERROR || state == DownloadManager.STATE_STOPPED ){
                   
                    long  now = SystemTime.getMonotonousTime();
                   
View Full Code Here


    download    = _download;
    plugin_file    = _plugin_file;
   
    core_file    = plugin_file.getCore();

    DownloadManager core_download = core_file.getDownloadManager();
   
    if ( core_download.getTorrent() == null ){
     
      throw( new DownloadException( "Torrent invalid" ));
    }
   
    if ( core_download.isDestroyed()){
     
      Debug.out( "Download has been removed" );
     
      throw( new DownloadException( "Download has been removed" ));
    }
   
    synchronized( DiskManagerChannelImpl.class ){
     
      channel_id = channel_id_next++;
    }
       
    TOTorrentFile  tf = core_file.getTorrentFile();
   
    TOTorrent   torrent = tf.getTorrent();
   
    TOTorrentFile[]  tfs = torrent.getFiles();

    rtas  = new long[torrent.getNumberOfPieces()];
   
    core_download.addPeerListener( this );
     
    for (int i=0;i<core_file.getIndex();i++){
       
      file_offset_in_torrent += tfs[i].getLength();
    }
View Full Code Here

  {
    List  managers = gm.getDownloadManagers();
   
    for (int i=0;i<managers.size();i++){
     
      DownloadManager  dm = (DownloadManager)managers.get(i);
     
      TOTorrent t = dm.getTorrent();
     
      if ( t != null ){
       
        try{
          if ( Arrays.equals( hash, t.getHash())){
View Full Code Here

          if (dmHash != null) {
            AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
              public void azureusCoreRunning(AzureusCore core) {
                GlobalManager gm = core.getGlobalManager();
                HashWrapper hw = new HashWrapper(Base32.decode(dmHash));
                DownloadManager dm = gm.getDownloadManager(hw);
                if (dm != null) {
                  fEntry.setDatasource(dm);
                }
              }
            });
          } else {
            final List listHashes = MapUtils.getMapList(autoOpenInfo, "dms",
                null);
            if (listHashes != null) {
              AzureusCoreFactory.addCoreRunningListener(new AzureusCoreRunningListener() {
                public void azureusCoreRunning(AzureusCore core) {
                  List<DownloadManager> listDMS = new ArrayList<DownloadManager>(
                      1);
                  GlobalManager gm = core.getGlobalManager();
                  for (Object oDM : listHashes) {
                    if (oDM instanceof String) {
                      String hash = (String) oDM;
                      DownloadManager dm = gm.getDownloadManager(new HashWrapper(
                          Base32.decode(hash)));
                      if (dm != null) {
                        listDMS.add(dm);
                      }
                    }
View Full Code Here

          {
            List  dms = getGlobalManager().getDownloadManagers();
           
            Iterator  it = dms.iterator();
           
            DownloadManager  matching_dm = null;
           
            try{
              while( it.hasNext()){
               
                DownloadManager  dm = (DownloadManager)it.next();
               
                TOTorrent  torrent = dm.getTorrent();
               
                if ( torrent == null ){
                 
                  continue;
                }
               
                byte[]  sha1_hash = (byte[])dm.getData( "AZInstanceManager::sha1_hash" );
               
                if ( sha1_hash == null ){     

                  sha1_hash  = new SHA1Simple().calculateHash( torrent.getHash());
                 
                  dm.setData( "AZInstanceManager::sha1_hash", sha1_hash );
                }
               
                if ( Arrays.equals( hash, sha1_hash )){
                 
                  matching_dm  = dm;
View Full Code Here

     
      long now  = SystemTime.getCurrentTime();

      for (int i=0;i<downloads.size();i++){
       
        DownloadManager  dm = (DownloadManager)downloads.get(i);
       
        Long  last_announce_l = (Long)dm.getUserData( DM_ANNOUNCE_KEY );
       
        long  last_announce  = last_announce_l==null?create_time:last_announce_l.longValue();
       
        TRTrackerAnnouncer an = dm.getTrackerClient();
       
        if ( an != null ){
         
          TRTrackerAnnouncerResponse last_announce_response = an.getLastResponse();
         
          if (   now - last_announce > 15*60*1000 ||
              last_announce_response == null ||
              last_announce_response.getStatus() == TRTrackerAnnouncerResponse.ST_OFFLINE ||
              force ){
 
            dm.setUserData( DM_ANNOUNCE_KEY, new Long( now ));
           
            Logger.lognew LogEvent(LOGID, "    updating tracker for " + dm.getDisplayName()));
 
            dm.requestTrackerAnnounce( true );
          }
        }
      }
    }
   
View Full Code Here

     
      while( it.hasNext()){
       
        Map.Entry<DownloadManager, byte[]> entry = it.next();
       
        DownloadManager  download = entry.getKey();
       
        try{
          String hash = ByteFormatter.encodeString( download.getTorrent().getHash());
         
          download_hashes += ( download_hashes.length()==0?"":"," ) + hash;
         
          new_offline_downloads.put( hash, download );
         
        }catch( Throwable e ){
         
          log( download, "Failed to get download hash", e );
         
          it.remove();
        }
      }
     
      try{
        String[] set_dl_results = service.setDownloads( client_id, download_hashes );
       
        String  set_dl_result  = set_dl_results[0].trim();
        String  set_dl_status   = set_dl_results[1];
       
        if ( !set_dl_status.equals( "OK" )){
         
          error_status = MessageText.getString( "device.od.error.opfailstatus", new String[]{ "SetDownloads", set_dl_status });

          throw( new Exception( "Failing result returned: " + set_dl_status ));
        }
       
        String[]  bits = Constants.PAT_SPLIT_COMMA.split(set_dl_result);
       
        int  num_bits = set_dl_result.length()==0?0:bits.length;
       
        if ( num_bits != entries.size()){
         
          log( "SetDownloads returned an invalid number of results (hashes=" + new_offline_downloads.size() + ",result=" + set_dl_result + ")");
         
        }else{
         
          it = entries.iterator();
         
          int  pos = 0;
         
          while( it.hasNext()){
           
            Map.Entry<DownloadManager, byte[]> entry = it.next();
           
            DownloadManager  download = entry.getKey();
           
            try{
              TOTorrent torrent = download.getTorrent();
 
              String hash_str = ByteFormatter.encodeString( torrent.getHash());
             
              int  status = Integer.parseInt( bits[ pos++ ]);
   
View Full Code Here

        xfer_cache.put( current_transfer.getHash(), m );
       
        setPersistentMapProperty( PP_OD_XFER_CACHE, xfer_cache );
      }
     
      DownloadManager  download = current_transfer.getDownload();
     
      int  data_port = current_transfer.getDataPort();
     
      if ( data_port <= 0 ){
               
View Full Code Here

         
          if ( hash_str != null ){
           
            byte[] hash = Base32.decode( hash_str );
           
            DownloadManager dm = gm.getDownloadManager( new HashWrapper( hash ));
           
            if ( dm != null ){
             
              log( "Adding existing association on first read for '" + dm.getDisplayName());
             
              subs.addAssociation( hash );
            }
          }
        }catch( Throwable e ){
View Full Code Here

   
      for (int i=0;i<selected_dls.size();i++){
       
        Download download = (Download)selected_dls.get( i );
       
        DownloadManager  core_download = PluginCoreUtils.unwrap( download );
       
        Torrent torrent = download.getTorrent();
       
        String  hash_str = Base32.encode( torrent.getHash());
       
        pw.println( "<item>" );
       
        pw.println( "<title>" + escape( download.getName()) + "</title>" );
       
        pw.println( "<guid>" + hash_str + "</guid>" );
       
        long added = core_download.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
       
        pw.println"<pubDate>" + TimeFormatter.getHTTPDate( added ) + "</pubDate>" );
       
        pw.println"<vuze:size>" + torrent.getSize()+ "</vuze:size>" );
        pw.println"<vuze:assethash>" + hash_str + "</vuze:assethash>" );
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.download.DownloadManager

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.