FileDocCategorySizeDatePackage
BadIpsImpl.javaAPI DocAzureus 3.0.3.42908Sat Sep 18 13:19:08 BST 2004org.gudy.azureus2.core3.ipfilter.impl

BadIpsImpl

public class BadIpsImpl extends Object implements org.gudy.azureus2.core3.ipfilter.BadIps
author
Olivier

Fields Summary
private static org.gudy.azureus2.core3.ipfilter.BadIps
instance
private static AEMonitor
class_mon
private Map
bad_ip_map
private AEMonitor
bad_ip_map_mon
Constructors Summary
public BadIpsImpl()

    bad_ip_map = new HashMap();
  
Methods Summary
public intaddWarningForIp(java.lang.String ip)

    try{
    	bad_ip_map_mon.enter(); 
    
    	BadIpImpl	bad_ip = (BadIpImpl)bad_ip_map.get( ip );
    	
    	if ( bad_ip == null ){
    		
    		bad_ip = new BadIpImpl(ip);
    		
    		bad_ip_map.put( ip, bad_ip );
    	}
    	
    	return( bad_ip.incrementWarnings());
    	
    }finally{
    	
    	bad_ip_map_mon.exit();
    }
  
public voidclearBadIps()

    try{
    	bad_ip_map_mon.enter();
  
    	bad_ip_map.clear();
    	
    }finally{
        
        bad_ip_map_mon.exit();
    }
  
public org.gudy.azureus2.core3.ipfilter.BadIp[]getBadIps()

    try{
    	bad_ip_map_mon.enter();
    	
  		BadIp[]	res = new BadIp[bad_ip_map.size()];
  		
  		bad_ip_map.values().toArray( res );
  		
  		return( res );
    }finally{
        
       	bad_ip_map_mon.exit();
    }
  
public static org.gudy.azureus2.core3.ipfilter.BadIpsgetInstance()

  
     
   
  
  	try{
  		class_mon.enter();
  	
  		if( instance == null ){
    
  			instance = new BadIpsImpl();
  		}
    
  		return( instance );
  		
  	}finally{
  		
  		class_mon.exit();
  	}
  
public intgetNbBadIps()

  	return( bad_ip_map.size());
  
public intgetNbWarningForIp(java.lang.String ip)

    try{
    	bad_ip_map_mon.enter();
    	
        BadIpImpl bad_ip = (BadIpImpl) bad_ip_map.get(ip);
      
      if(bad_ip == null) {
      	
        return 0;
        
      }else{
      	
        return bad_ip.getNumberOfWarnings();
      }
    }finally{
    
    	bad_ip_map_mon.exit();
    }