Examples of DHTRouterContact


Examples of com.aelitis.azureus.core.dht.router.DHTRouterContact

         
          Set  sorted_contacts = new sortedTransportContactSet( router.getID(), true ).getSet();

          for (int i=0;i<old_contacts.size();i++){
           
            DHTRouterContact  contact = (DHTRouterContact)old_contacts.get(i);
         
            if ( !Arrays.equals( old_router_id, contact.getID())){
             
              if ( contact.isAlive()){
               
                DHTTransportContact  t_contact = ((DHTControlContactImpl)contact.getAttachment()).getTransportContact();

                sorted_contacts.add( t_contact );
              }
            }
          }
         
            // fill up with non-alive ones to lower limit in case this is a start-of-day
            // router change and we only have imported contacts in limbo state
         
          for (int i=0;sorted_contacts.size() < 32 && i<old_contacts.size();i++){
           
            DHTRouterContact  contact = (DHTRouterContact)old_contacts.get(i);
         
            if ( !Arrays.equals( old_router_id, contact.getID())){
             
              if ( !contact.isAlive()){
               
                DHTTransportContact  t_contact = ((DHTControlContactImpl)contact.getAttachment()).getTransportContact();

                sorted_contacts.add( t_contact );
              }
            }
          }
   
          Iterator  it = sorted_contacts.iterator();
         
          int  added = 0;
         
            // don't add them all otherwise we can skew the smallest-subtree. better
            // to seed with some close ones and then let the normal seeding process
            // populate it correctly
         
          while( it.hasNext() && added < 128 ){
           
            DHTTransportContact  contact = (DHTTransportContact)it.next();
           
            router.contactAlive( contact.getID(), new DHTControlContactImpl( contact ));
           
            added++;
          }
         
          seed( false );
        }
       
        public void
        resetNetworkPositions()
        {
          List<DHTRouterContact>  contacts = router.getAllContacts();
         
          for (int i=0;i<contacts.size();i++){
                       
            DHTRouterContact  rc = contacts.get(i);

            if ( !router.isID( rc.getID())){
             
              ((DHTControlContactImpl)rc.getAttachment()).getTransportContact().createNetworkPositions( false );
            }
          }
        }
       
        public void
View Full Code Here

Examples of com.aelitis.azureus.core.dht.router.DHTRouterContact

   
    //System.out.println( "Exporting" );
   
    for (int i=0;i<contacts.size();i++){
   
      DHTRouterContact  contact = (DHTRouterContact)contacts.get(i);
     
      Object[]  imported = (Object[])imported_state.get( new HashWrapper( contact.getID()));
     
      if ( imported != null ){

        if ( contact.isAlive()){
         
            // definitely want to keep this one
         
          to_save.add( contact );
         
        }else if ( !contact.isFailing()){
         
            // dunno if its still good or not, however its got to be better than any
            // new ones that we didn't import who aren't known to be alive
         
          reserves.add( contact );
        }
      }
    }
   
    //System.out.println( "    initial to_save = " + to_save.size() + ", reserves = " + reserves.size());
   
      // now pull out any live ones
   
    for (int i=0;i<contacts.size();i++){
     
      DHTRouterContact  contact = (DHTRouterContact)contacts.get(i);
   
      if ( contact.isAlive() && !to_save.contains( contact )){
       
        to_save.add( contact );
      }
    }
   
    //System.out.println( "    after adding live ones = " + to_save.size());
   
      // now add any reserve ones
   
    for (int i=0;i<reserves.size();i++){
     
      DHTRouterContact  contact = (DHTRouterContact)reserves.get(i);
   
      if ( !to_save.contains( contact )){
       
        to_save.add( contact );
      }
    }
   
    //System.out.println( "    after adding reserves = " + to_save.size());

      // now add in the rest!
   
    for (int i=0;i<contacts.size();i++){
     
      DHTRouterContact  contact = (DHTRouterContact)contacts.get(i);
   
      if (!to_save.contains( contact )){
       
        to_save.add( contact );
      }
    } 
   
      // and finally remove the invalid ones
   
    Iterator  it = to_save.iterator();
   
    while( it.hasNext()){
     
      DHTRouterContact  contact  = (DHTRouterContact)it.next();
     
      DHTTransportContact  t_contact = ((DHTControlContactImpl)contact.getAttachment()).getTransportContact();
     
      if ( !t_contact.isValid()){
       
        it.remove();
      }
    }
 
    //System.out.println( "    finally = " + to_save.size());

    int  num_to_write = Math.min( max, to_save.size());
   
    daos.writeInt( num_to_write );
       
    for (int i=0;i<num_to_write;i++){
     
      DHTRouterContact  contact = (DHTRouterContact)to_save.get(i);
     
      //System.out.println( "export:" + contact.getString());
     
      daos.writeLong( contact.getTimeAlive());
     
      DHTTransportContact  t_contact = ((DHTControlContactImpl)contact.getAttachment()).getTransportContact();
     
      try{
                 
        t_contact.exportContact( daos );
       
View Full Code Here

Examples of com.aelitis.azureus.core.dht.router.DHTRouterContact

   
    List  res = new ArrayList( contacts.size());
   
    for (int i=0;i<contacts.size();i++){
     
      DHTRouterContact  rc = (DHTRouterContact)contacts.get(i);
     
      res.add( rc.getAttachment());
    }
   
    return( res );
  }
View Full Code Here

Examples of com.aelitis.azureus.core.dht.router.DHTRouterContact

   
    for (int i=0;i<contacts.size();i++){
     
      sem.reserve();
     
      DHTRouterContact  rc = (DHTRouterContact)contacts.get(i);

      ((DHTControlContactImpl)rc.getAttachment()).getTransportContact().sendPing(
          new DHTTransportReplyHandlerAdapter()
          {
            public void
            pingReply(
              DHTTransportContact _contact )
View Full Code Here

Examples of com.aelitis.azureus.core.dht.router.DHTRouterContact

          next_node = current_node.getRight();
        }
       
        if ( next_node == null ){
   
          DHTRouterContact  existing_contact = current_node.updateExistingNode( node_id, attachment, known_to_be_alive );
         
          if ( existing_contact != null ){
           
            return( existing_contact );
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.