Package org.gudy.azureus2.core3.logging

Examples of org.gudy.azureus2.core3.logging.LogEvent


    try{
      stats_writer = new GlobalManagerStatsWriter( core );
     
    }catch( Throwable e ){
     
      Logger.log(new LogEvent(LOGID, "Stats unavailable", e ));
    }

    // Wait at least a few seconds before loading existing torrents.
    // typically the UI will call loadExistingTorrents before this runs
    // This is here in case the UI is stupid or forgets
    if (existingTorrentLoadDelay > 0) {
      loadTorrentsDelay = new DelayedEvent("GM:tld", existingTorrentLoadDelay,
          new AERunnable() {
            public void runSupport() {
              loadExistingTorrentsNow(false); // already async
            }
          });
    } else {
      // run sync
      loadDownloads();
    }

    if (progress_listener != null){
      progress_listener.reportCurrentTask(MessageText.getString("splash.initializeGM"));
    }
   
    // Initialize scraper after loadDownloads so that we can merge scrapes
    // into one request per tracker
    trackerScraper = TRTrackerScraperFactory.getSingleton();
   
    trackerScraper.setClientResolver(
      new TRTrackerScraperClientResolver()
    {
        public int
      getStatus(
        HashWrapper  torrent_hash )
        {
             DownloadManager  dm = getDownloadManager(torrent_hash);
         
          if ( dm == null ){

            return( TRTrackerScraperClientResolver.ST_NOT_FOUND );
          }
                   
          int  dm_state = dm.getState();
         
          if (   dm_state == DownloadManager.STATE_QUEUED ){
           
            return( TRTrackerScraperClientResolver.ST_QUEUED );
           
          }else if (   dm_state == DownloadManager.STATE_DOWNLOADING ||
                dm_state == DownloadManager.STATE_SEEDING ){
           
            return( TRTrackerScraperClientResolver.ST_RUNNING );
          }
         
          return( TRTrackerScraperClientResolver.ST_OTHER );
        }
       
        public boolean
      isNetworkEnabled(
        HashWrapper  hash,
        URL      url )
        {
             DownloadManager  dm = getDownloadManager(hash);
         
          if ( dm == null ){
           
            return( false );
          }
         
          String  nw = AENetworkClassifier.categoriseAddress( url.getHost());
         
          String[]  networks = dm.getDownloadState().getNetworks();
         
          for (int i=0;i<networks.length;i++){
           
            if ( networks[i] ==  nw ){
             
              return( true );
            }
          }
         
          return( false );
        }
       
        public int[]
        getCachedScrape(
          HashWrapper hash )
        {
          DownloadManager  dm = getDownloadManager(hash);
         
          if ( dm == null ){
           
            return( null );
          }
               
        long cache = dm.getDownloadState().getLongAttribute( DownloadManagerState.AT_SCRAPE_CACHE );
       
        if ( cache == -1 ){
         
          return( null );
         
        }else{
         
          int seeds     = (int)((cache>>32)&0x00ffffff);
          int leechers   = (int)(cache&0x00ffffff);
         
          return( new int[]{ seeds, leechers });
        }
        }
       
        public Object[]
        getExtensions(
          HashWrapper  hash )
        {
           DownloadManager  dm = getDownloadManager(hash);
         
           Character  state;
           String    ext;
          
          if ( dm == null ){
           
            ext    = "";
               state  = TRTrackerScraperClientResolver.FL_NONE;
              
          }else{
         
            ext = dm.getDownloadState().getTrackerClientExtensions();
         
            if ( ext == null ){
             
              ext = "";
            }
           
            boolean  comp = dm.isDownloadComplete( false );
                        
            int  dm_state = dm.getState();
           
              // treat anything not stopped or running as queued as we need to be "optimistic"
              // for torrents at the start-of-day
           
            if (   dm_state == DownloadManager.STATE_ERROR ||
                dm_state == DownloadManager.STATE_STOPPED ||
                ( dm_state == DownloadManager.STATE_STOPPING && dm.getSubState() != DownloadManager.STATE_QUEUED )){
             
                 state  = comp?TRTrackerScraperClientResolver.FL_COMPLETE_STOPPED:TRTrackerScraperClientResolver.FL_INCOMPLETE_STOPPED;
               
            }else if dm_state == DownloadManager.STATE_DOWNLOADING ||
                  dm_state == DownloadManager.STATE_SEEDING ){
               
                state  = comp?TRTrackerScraperClientResolver.FL_COMPLETE_RUNNING:TRTrackerScraperClientResolver.FL_INCOMPLETE_RUNNING;
                               
            }else{
           
              state  = comp?TRTrackerScraperClientResolver.FL_COMPLETE_QUEUED:TRTrackerScraperClientResolver.FL_INCOMPLETE_QUEUED;
            }
          }
         
          return( new Object[]{ ext, state });
        }
       
        public boolean
        redirectTrackerUrl(
          HashWrapper    hash,
          URL        old_url,
          URL        new_url )
        {
             DownloadManager  dm = getDownloadManager(hash);
           
             if ( dm == null || dm.getTorrent() == null ){
              
               return( false );
             }
            
             return( TorrentUtils.replaceAnnounceURL( dm.getTorrent(), old_url, new_url ));
        }
    });
   
    trackerScraper.addListener(
      new TRTrackerScraperListener() {
        public void scrapeReceived(TRTrackerScraperResponse response) {
          HashWrapper  hash = response.getHash();
         
           DownloadManager manager = (DownloadManager)manager_map.get( hash );
           if ( manager != null ) {
             manager.setTrackerScrapeResponse( response );
          }
        }
      });
   
    try
      host_support = new GlobalManagerHostSupport( this );

    }catch( Throwable e ){
     
      Logger.log(new LogEvent(LOGID, "Hosting unavailable", e));
    }
   
    checker = new Checker();  
        
    checker.start();
   
    torrent_folder_watcher = new TorrentFolderWatcher( this );
   
   
    TRTrackerUtils.addListener(
      new TRTrackerUtilsListener()
      {
        public void
        announceDetailsChanged()
        { 
        Logger.log( new LogEvent(LOGID, "Announce details have changed, updating trackers" ));

        List  managers = managers_cow;
       
        for (int i=0;i<managers.size();i++){
         
View Full Code Here


      }
     
      return( download_manager );
    }
    else {
      Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR,
        "Tried to add a DownloadManager after shutdown of GlobalManager."));
      return( null );
    }
  }
View Full Code Here

          }
          catch (UnsupportedEncodingException e1) {
            //Do nothing and process next.
          }
          catch (Throwable e) {
            Logger.log(new LogEvent(LOGID,
                "Error while loading downloads.  " +
                "One download may not have been added to the list.", e));
          }
        }
 
        // This is set to true by default, but once the downloads have been loaded, we have no reason to ever
        // to do this check again - we only want to do it once to upgrade the state of existing downloads
        // created before this code was around.
        COConfigurationManager.setParameter("Set Completion Flag For Completed Downloads On Start", false);
 
        //load pause/resume state
        ArrayList pause_data = (ArrayList)map.get( "pause_data" );
        if( pause_data != null ) {
          try paused_list_mon.enter();
          for( int i=0; i < pause_data.size(); i++ ) {
            Object  pd = pause_data.get(i);
 
            byte[]    key;
            boolean    force;
 
            if ( pd instanceof byte[]){
              // old style, migration purposes
              key   = (byte[])pause_data.get( i );
              force  = false;
            }else{
              Map  m = (Map)pd;
 
              key   = (byte[])m.get("hash");
              force   = ((Long)m.get("force")).intValue() == 1;
            }
            paused_list.add( new Object[]{ new HashWrapper( key ), new Boolean( force )} );
          }
          }
          finally paused_list_mon.exit()}
        }
 
 
        // Someone could have mucked with the config file and set weird positions,
        // so fix them up.
        fixUpDownloadManagerPositions();
        Logger.log(new LogEvent(LOGID, "Loaded " + managers_cow.size()
            + " torrents"));
 
      }catch( Throwable e ){
        // there's been problems with corrupted download files stopping AZ from starting
        // added this to try and prevent such foolishness
View Full Code Here

              - ((DownloadManager) b).getPosition();
        }
      });
   
      if (Logger.isEnabled())
        Logger.log(new LogEvent(LOGID, "Saving Download List ("
            + managers_cow.size() + " items)"));
      Map map = new HashMap();
      List list = new ArrayList(managers_cow.size());
      for (int i = 0; i < managers_cow.size(); i++) {
        DownloadManager dm = (DownloadManager) managers_cow.get(i);
View Full Code Here

   
    if ( exists != force_start_non_seed_exists ){
     
      force_start_non_seed_exists = exists;
     
      Logger.log(new LogEvent(LOGID, "Force start download " + (force_start_non_seed_exists?"exists":"doesn't exist") + ", modifying download weighting" ));
     
      //System.out.println( "force_start_exists->" + force_start_non_seed_exists );
     
      PeerControlSchedulerFactory.overrideWeightedPriorities( force_start_non_seed_exists  );
    }
View Full Code Here

  setStateDownloading()
  { 
    if (getState() == DownloadManager.STATE_SEEDING) {
      setState(DownloadManager.STATE_DOWNLOADING, true);
    } else if (getState() != DownloadManager.STATE_DOWNLOADING) {
      Logger.log(new LogEvent(this, LogIDs.CORE, LogEvent.LT_WARNING,
          "Trying to set state to downloading when state is not seeding"));
    }
  }
View Full Code Here

      int  hit_count = bloom.add( address_bytes );
     
      if ( hit_count > 5 ){
       
        Logger.log(
            new LogEvent(
              this,
              LogIDs.CORE,
              LogEvent.LT_WARNING,
              "Activate request for " + getDisplayName() + " from " + address + " denied as too many recently received" ));

        return( false );
      }
     
      Logger.log(new LogEvent(this, LogIDs.CORE, "Activate request for " + getDisplayName() + " from " + address ));

      long  now = SystemTime.getCurrentTime();

        // we don't really care about the bloom filter filling up and giving false positives
        // as activation events should be fairly rare
View Full Code Here

    try
      last_response_informed = new TRTrackerAnnouncerResponseImpl( null, _torrent.getHashWrapper(), TRTrackerAnnouncerResponse.ST_OFFLINE, TRTrackerAnnouncer.REFRESH_MINIMUM_SECS, "Initialising" );
     
    }catch( TOTorrentException e ){
     
      Logger.log(new LogEvent( _torrent, LOGID, "Torrent hash retrieval fails", e));
     
      throw( new TRTrackerAnnouncerException( "TRTrackerAnnouncer: URL encode fails"))
    }

    networks  = _networks;
View Full Code Here

              }
            }
          }finally{
           
            if (Logger.isEnabled()) {
              Logger.log(new LogEvent(getTorrent(), LOGID, "Deactivating " + getString( a.getAnnounceSets())));
            }

            activated.remove( a );
                       
            a.destroy();
          }
        }
      }
     
      a_it = new_announcers.iterator();
     
      while( a_it.hasNext()){
       
        TRTrackerAnnouncerHelper a = a_it.next();
       
        if ( !announcers.contains( a )){
         
          announcers.add( a );
        }
      }
     
      if ( !is_manual && announcers.size() > 0 ){
       
        if ( activated.size() == 0 ){
         
          TRTrackerAnnouncerHelper a = announcers.get(0);
         
          if (Logger.isEnabled()) {
            Logger.log(new LogEvent(getTorrent(), LOGID, "Activating " + getString( a.getAnnounceSets())));
          }

          activated.add( a );
         
          last_activation_time = SystemTime.getMonotonousTime();
View Full Code Here

          for ( TRTrackerAnnouncerHelper a: announcers ){
           
            if ( !activated.contains( a )){
             
              if (Logger.isEnabled()) {
                Logger.log(new LogEvent(getTorrent(), LOGID, "Activating " + getString( a.getAnnounceSets())));
              }
             
              activated.add( a );
             
              last_activation_time = SystemTime.getMonotonousTime();
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.core3.logging.LogEvent

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.