Package org.ardverk.dht.rsrc

Examples of org.ardverk.dht.rsrc.Key


   
    File dir = new File("data/test");
    Index index = DefaultIndex.create(dir);
   
    Set<KUID> dst = new TreeSet<KUID>();
    Key key = KeyFactory.parseKey("ardverk:///hello/world");
    for (int i = 0; i < count; i++) {
      KUID valueId = KUID.createRandom(key.getId());
      Context context = new Context();
      context.addHeader("X-Index", Integer.toString(i));
     
      index.add(key, context, valueId);
      dst.add(valueId);
View Full Code Here


public class KeyFactoryTest {

  @Test
  public void equals() {
    Key key1 = KeyFactory.parseKey("ardverk:///key1");
    Key key2 = KeyFactory.parseKey("ardverk:///key1");
   
    Key key3 = KeyFactory.parseKey("ardverk:///key2");
   
    TestCase.assertEquals(key1, key2);
    TestCase.assertFalse(key1.equals(key3));
  }
View Full Code Here

          keys = new Keys();
         
          do {
            String uri = rs.getString(1);
           
            Key key = DefaultKey.valueOf(uri);
            List<KUID> values = listValueIds(key);
           
            if (values != null) {
              keys.put(key, values);
            }
View Full Code Here

  @Override
  public ResponseMessage handleRequest(RequestMessage message) throws IOException {
    ValueRequest request = (ValueRequest)message;
   
    Contact src = request.getContact();
    Key key = request.getKey();
    Value value = datastore.get(src, key);
   
    MessageFactory factory = getMessageFactory();
    ResponseMessage response = null;
   
    if (value != null) {
      response = factory.createValueResponse(request, value);
    } else {
      Contact[] contacts = routeTable.select(key.getId());
      response = factory.createNodeResponse(request, contacts);
    }
   
    return response;
  }
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

  }
 
  private ValueRequest readValueRequest(MessageId messageId,
      Contact contact, SocketAddress address) throws IOException {
   
    Key key = readKey();
    return new DefaultValueRequest(messageId, contact, address, key);
  }
View Full Code Here

  }
 
  private StoreRequest readStoreRequest(MessageId messageId,
      Contact contact, SocketAddress address) throws IOException {
   
    Key key = readKey();
    Value value = readValue();
    return new DefaultStoreRequest(messageId, contact,
        address, key, value);
  }
View Full Code Here

TOP

Related Classes of org.ardverk.dht.rsrc.Key

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.