Package java.net

Examples of java.net.InetAddress$CacheEntry


           
          Enumeration addresses = ni.getInetAddresses();
         
          while( addresses.hasMoreElements()){
           
            InetAddress address = (InetAddress)addresses.nextElement();
           
            if ( address.isLoopbackAddress() || address instanceof Inet6Address ){
             
              continue;
            }
           
            return( address );
View Full Code Here


    if ( Constants.isCVSVersion()){
   
        // allow local addresses for testing
     
      try{
        InetAddress ia = InetAddress.getByName( host );
     
        return( ia.isLoopbackAddress() || ia.isLinkLocalAddress() || ia.isSiteLocalAddress());
       
      }catch( Throwable e ){
      }
    }
   
View Full Code Here

    boolean                  upnp_map,
    NetworkAdminProgressListener      listener )
 
    throws NetworkAdminException
  {
    InetAddress bind_ip = address==null?null:address.getAddress();
   
    NetworkAdminProtocolTester  tester;
   
    if ( type == PT_HTTP ){
     
      tester = new NetworkAdminHTTPTester( core, listener );
     
    }else if ( type == PT_TCP ){
     
      tester = new NetworkAdminTCPTester( core, listener );

    }else{
     
      tester = new NetworkAdminUDPTester( core, listener );
    }
   
    InetAddress  res;
   
    if ( port <= 0 ){
     
      res = tester.testOutbound( bind_ip, 0 );
     
View Full Code Here

  {

    int  pos = bgp_prefix.indexOf('/');
   
    try{
      InetAddress  start = InetAddress.getByName( bgp_prefix.substring(0,pos));
     
      int  cidr_mask = Integer.parseInt( bgp_prefix.substring( pos+1 ));
     
      int  rev_mask = 0;
     
      for (int i=0;i<32-cidr_mask;i++){
       
     
        rev_mask = ( rev_mask << 1 ) | 1;
      }
     
      byte[]  bytes = start.getAddress();
     
      bytes[0] |= (rev_mask>>24)&0xff;
      bytes[1] |= (rev_mask>>16)&0xff;
      bytes[2] |= (rev_mask>>8)&0xff;
      bytes[3] |= (rev_mask)&0xff;
View Full Code Here

        return( true );
      }
     
        // allow local addresses for testing purposes
     
      InetAddress iad = InetAddress.getByName(host);
     
      if (   iad.isLoopbackAddress() ||
          iad.isLinkLocalAddress() ||
          iad.isSiteLocalAddress()){
       
        return( true );
      }
    }catch( Throwable e ){
    }
View Full Code Here

     
      return( false );
    }
   
    try{
      InetAddress  start  = getCIDRStartAddress();
      InetAddress  end    = getCIDREndAddress();
     
      long  l_start = PRHelpers.addressToLong( start );
      long  l_end  = PRHelpers.addressToLong( end );
     
      long  test = PRHelpers.addressToLong( address );
View Full Code Here

    InetSocketAddress  address,
    byte        protocol_version )
 
    throws DHTTransportException
  {   
    InetAddress ia = address.getAddress();
   
    if ( ia == null ){
     
      // Debug.out( "Address '" + address + "' is unresolved" );
     
      throw( new DHTTransportException( "Address '" + address + "' is unresolved" ));
     
    }else{
     
      String  key;
     
      if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_RESTRICT_ID3 ){
       
        byte[] bytes = ia.getAddress();
       
        if ( bytes.length == 4 ){
         
          //final long K0  = Long.MAX_VALUE; 
          //final long K1  = Long.MAX_VALUE; 
         
            // restrictions suggested by UoW researchers as effective at reducing Sybil opportunity but
            // not so restrictive as to impact DHT performance
         
          final long K2  = 2500;
          final long K3  = 50;
          final long K4  = 5;

          long  result = address.getPort() % K4;
         
          result = ((((long)bytes[3] << 8 ) &0x000000ff00L ) | result ) % K3;
          result = ((((long)bytes[2] << 16 )&0x0000ff0000L ) | result ) % K2;
          result = ((((long)bytes[1] << 24 )&0x00ff000000L ) | result ); // % K1;
          result = ((((long)bytes[0] << 32 )&0xff00000000L ) | result ); // % K0;

          key = String.valueOf( result );
                   
        }else{

            // stick with existing approach for IPv6 at the moment
         
          key = ia.getHostAddress() + ":" + ( address.getPort() % 8 );
        }
      }else if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_RESTRICT_ID_PORTS2 ){

          // more draconian limit, analysis shows that of 500,000 node addresses only
          // 0.01% had >= 8 ports active. ( 1% had 2 ports, 0.1% 3)
          // Having > 1 node with the same ID doesn't actually cause too much grief
   
        key = ia.getHostAddress() + ":" + ( address.getPort() % 8 );
       
      }else if ( protocol_version >= DHTTransportUDP.PROTOCOL_VERSION_RESTRICT_ID_PORTS ){

          // limit range to around 2000 (1999 is prime)

        key = ia.getHostAddress() + ":" + ( address.getPort() % 1999 );
       
      }else{
     
        key = ia.getHostAddress() + ":" + address.getPort();
      }
     
      synchronized( node_id_history ){
       
        byte[]  res = node_id_history.get( key );
View Full Code Here

*/
public class LeastRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (lruCacheEntry == null) {
                lruCacheEntry = cacheEntry;
            } else if (lruCacheEntry.getLastAccessed() > cacheEntry.getLastAccessed()) {
                lruCacheEntry = cacheEntry;
            }
        }
        if (lruCacheEntry != null) {
            cache.evict(lruCacheEntry.getKey());
View Full Code Here

*/
public class MostRecentlyUsedEvictionAlgorithm implements EvictionAlgorithm {

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry mruCacheEntry = null;
        for (Object o : cache.getAll()) {
            CacheEntry cacheEntry = (CacheEntry) o;
            if (mruCacheEntry == null) {
                mruCacheEntry = cacheEntry;
            } else if (mruCacheEntry.getLastAccessed() < cacheEntry.getLastAccessed()) {
                mruCacheEntry = cacheEntry;
            }
        }
        if (mruCacheEntry != null) {
            cache.evict(mruCacheEntry.getKey());
View Full Code Here

public class RandomEvictionAlgorithm implements EvictionAlgorithm {
    private static Random random = new Random();

    @SuppressWarnings("unchecked")
    public void evict(CacheImpl cache) {
        CacheEntry lruCacheEntry = null;
        Collection all = cache.getAll();
        int evictionIndex = random.nextInt(all.size());
        int index = 0;

        for (Object anAll : all) {
            CacheEntry cacheEntry = (CacheEntry) anAll;
            if (index == evictionIndex) {
                lruCacheEntry = cacheEntry;
                break;
            }
            index++;
View Full Code Here

TOP

Related Classes of java.net.InetAddress$CacheEntry

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.