Package org.jmule.core.jkad

Examples of org.jmule.core.jkad.Int128


  public synchronized void removeSearch(SearchQuery searchRequest) {
    server_search_request_queue.remove(searchRequest);
    kad_search_request_queue.remove(searchRequest);
    if (kad_searches.containsKey(searchRequest)) {
      synchronized (kad_searches) {
        Int128 searchID = kad_searches.get(searchRequest);
        jkad_search.cancelSearch(searchID);
      }
    }
    if (searchRequest.getQueryType() == SearchQueryType.KAD) {
      processKadSearchRequest();
View Full Code Here


                                      // from
                                      // queue
                                      // after
                                      // complete
                                      // search
    Int128 keyword_id;
    try {
      keyword_id = jkad_search.searchKeyword(kad_search_request
          .getQuery(),
          new org.jmule.core.jkad.search.SearchResultListener() {
            SearchQuery searchquery = (SearchQuery) kad_search_request
View Full Code Here

    int count = data.getInt(0);
   
    for(int i=0;i<count;i++) {
      data = getByteBuffer(16);
      channel.read(data);
      Int128 key_id = new Int128(data.array());
      data = getByteBuffer(4);
      channel.read(data);
      Index index = new Index(key_id);
      int source_count = data.getInt(0);
   
View Full Code Here

   
    return singleton;
  }
 
  private RoutingTable() {
    root = new Node(null, new Int128(), 0, new KBucket());
   
    maintenanceTask = new Task() {
      private LookupTask lookup_new_contacts = null;
      public void run() {
        if (getTotalContacts() < ROUTING_TABLE_DIFICIT_CONTACTS) {
          if ((lookup_new_contacts == null)||(!lookup_new_contacts.isLookupStarted())) {
           
            Int128 fake_target = new Int128(Utils.getRandomInt128());
            lookup_new_contacts = new LookupTask(RequestType.FIND_NODE, fake_target, JKadConstants.toleranceZone) {
              public void lookupTimeout() {
              }

              public void stopLookupEvent() {
View Full Code Here

     
    Timer.getSingleton().removeTask(contact_checker);
   
    tree_nodes.clear();
    notifyAllContactsRemoved();
    root = new Node(null, new Int128(), 0, new KBucket());
    is_started = false;
  }
View Full Code Here

   
    newContacts++;
   
    contact.setContactType(JustAdded);
   
    Int128 contact_distance = contact.getContactDistance();
   
    Node node = root;
    while(!node.isLeaf()) {
      int node_level = node.getLevel();
      boolean direction = contact_distance.getBit(node_level);
      if (direction) {
        node = node.getRight();
      }
      else {
        node = node.getLeft();
View Full Code Here

   * @return
   */
  public List<KadContact> getNearestContacts(Int128 searchTarget, int contactCount) {
    Node node = root;
   
    Int128 target = Utils.XOR(searchTarget, _jkad_manager.getClientID());
   
    while(!node.isLeaf()) {
      int node_level = node.getLevel();
      boolean direction = target.getBit(node_level);
      if (direction)
        node = node.getRight();
      else
        node = node.getLeft();
    }
View Full Code Here

  public void storeContacts() {
    NodesDat.writeFile(NODES_DAT, tree_nodes);
  }

  private void removeNode(KadContact contact) {
    Int128 contactDistance = contact.getContactDistance();
    Node node = root;
    while(!node.isLeaf()) {
      int node_level = node.getLevel();
      boolean direction = contactDistance.getBit(node_level);
      if (direction)
        node = node.getRight();
      else
        node = node.getLeft();
    }
View Full Code Here

 


 
  public static boolean inToleranceZone(Int128 target, Int128 source, long toleranceZone) {
    Int128 xorValue = XOR(target,source);
    if (xorValue.get32Bit(0) > toleranceZone)
      return false;
    return true;
  }
View Full Code Here

  }
 
  public static Int128 XOR(Int128 a, Int128 b) {
    BitSet xor_bit_set = (BitSet) a.getBitSet().clone();
    xor_bit_set.xor(b.getBitSet());
    return new Int128(xor_bit_set);
  }
View Full Code Here

TOP

Related Classes of org.jmule.core.jkad.Int128

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.