Package org.ardverk.dht.routing

Examples of org.ardverk.dht.routing.Contact


    return new DefaultValueRequest(messageId, localhost, address, key);
  }

  @Override
  public ValueResponse createValueResponse(LookupRequest request, Value value) {
    Contact dst = request.getContact();
    SocketAddress address = dst.getRemoteAddress();
    MessageId messageId = request.getMessageId();
    return new DefaultValueResponse(messageId, localhost, address, value);
  }
View Full Code Here


        address, key, value);
  }

  @Override
  public StoreResponse createStoreResponse(StoreRequest request, Value value) {
    Contact dst = request.getContact();
    SocketAddress address = dst.getRemoteAddress();
    MessageId messageId = request.getMessageId();
    return new DefaultStoreResponse(messageId, localhost, address, value);
  }
View Full Code Here

   
    this.datastore = datastore;
  }

  private Value store(StoreRequest request) {
    Contact src = request.getContact();
    Key key = request.getKey();
    Value value = request.getValue();
    return datastore.store(src, key, value);
  }
View Full Code Here

  public DefaultMessageHandler(RouteTable routeTable) {
    this.routeTable = routeTable;
  }
 
  public void handleRequest(RequestMessage request) throws IOException {
    Contact src = request.getContact();
    routeTable.add(src);
  }
View Full Code Here

 
  @Override
  public boolean handleResponse(RequestEntity entity,
      ResponseMessage response, long time, TimeUnit unit) throws IOException {
   
    Contact src = response.getContact();
   
    if (src instanceof RoundTripTime) {
      ((RoundTripTime)src).setRoundTripTime(time, unit);
    }
   
View Full Code Here

   
    return true;
  }
 
  public void handleLateResponse(ResponseMessage response) throws IOException {
    Contact src = response.getContact();
    routeTable.add(src);
  }
View Full Code Here

      throw new IOException("version=" + version);
    }
   
    OpCode opcode = readEnum(OpCode.class);
    MessageId messageId = readMessageId();
    Contact contact = readSender(opcode.isRequest()
        ? Contact.Type.UNSOLICITED : Contact.Type.SOLICITED, src);
    SocketAddress address = readSocketAddress();
   
    switch (opcode) {
      case PING_REQUEST:
View Full Code Here

  }
 
  private synchronized void processNodeResponse(NodeResponse response,
      long time, TimeUnit unit) throws IOException {
   
    Contact src = response.getContact();
    Contact[] contacts = response.getContacts();
    processContacts(src, contacts, time, unit);
  }
View Full Code Here

      = new BencodeMessageCodec();
   
    MessageId messageId = MessageId.createRandom(20);
    KUID contactId = KUID.createRandom(20);
   
    Contact contact = new DefaultContact(Type.SOLICITED,
        contactId, 0, false,
        new InetSocketAddress("localhost", 6666));
   
    SocketAddress address = new InetSocketAddress("localhost", 6666);
    PingRequest request = new DefaultPingRequest(messageId, contact, address);
View Full Code Here

        if (lookupManager.hasNext(true)) {
          long boostTimeout = config.getBoostTimeoutInMillis();
         
          if (boostTimeout >= 0L && getLastResponseTimeInMillis() >= boostTimeout) {
            try {
              Contact contact = lookupManager.next();
             
              lookup(contact);
              lookupCounter.increment(true);
            } finally {
              postProcess();
View Full Code Here

TOP

Related Classes of org.ardverk.dht.routing.Contact

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.