Package net.tomp2p.storage

Examples of net.tomp2p.storage.Data


    FutureDHT request;
    try {
      request = p.get(hash).setRequestP2PConfiguration(reqParam).setAll()
          .start();
      request.awaitUninterruptibly();
      Data f = request.getData();
      if (!request.isSuccess() || f == null) {
        logger.debug(String.format("Got no triple in key \"%s\" (%s)",
            locationKey, hash));
        return new ArrayList<Triple>(0);
      }
View Full Code Here


        locationKey), 10);
    final Number160 hash = Number160.createHash(locationKey);
    final Number160 contentKey = Number160.createHash(t.toString());
    FutureDHT request;
    try {
      Data valueToAdd;
      if (usingDebugObject)
        valueToAdd = new Data(new TomP2P_Item<Triple>(locationKey, t));
      else
        valueToAdd = new Data(t);
      request = p.put(hash).setData(contentKey, valueToAdd)
          .setRequestP2PConfiguration(reqParam).start();
      request.awaitUninterruptibly();
      logger.debug(String.format("Insert triple %s in key %s (%s)", t,
          locationKey, hash));
View Full Code Here

  @Override
  public void addAll(String locationKey, Triple... values) {
    final Number160 hash = Number160.createHash(locationKey);
    Map<Number160, Data> map = new HashMap<Number160, Data>();
    for (Triple t : values) {
      Data valueToAdd = null;
      final Number160 contentKey = Number160.createHash(t.toString());
      try {
        if (usingDebugObject)
          valueToAdd = new Data(new TomP2P_Item<Triple>(locationKey,
              t));
        else
          valueToAdd = new Data(t);
      } catch (IOException e) {
        e.printStackTrace();
      }
      map.put(contentKey, valueToAdd);
    }
View Full Code Here

  @Deprecated
  public void old_addAll(String locationKey, Triple... values) {
    final Number160 hash = Number160.createHash(locationKey);
    Set<Data> list = new HashSet<Data>();
    for (Triple t : values) {
      Data valueToAdd = null;
      try {
        if (usingDebugObject)
          valueToAdd = new Data(new TomP2P_Item<Triple>(locationKey,
              t));
        else
          valueToAdd = new Data(t);
      } catch (IOException e) {
        e.printStackTrace();
      }
      list.add(valueToAdd);
    }
View Full Code Here

        data.setBasedOnKey(content.get(i - 1).getVersionKey());
      }
      content.add(data);

      p2.put(Number160.createHash(locationKey))
          .setData(Number160.createHash(contentKey), new Data(data))
          .setVersionKey(data.getVersionKey()).start().awaitUninterruptibly();
    }

    FutureGet future = p1
        .get(Number160.createHash(locationKey))
View Full Code Here

    List<Long> shuffledTimeStamps = new ArrayList<Long>(timeStamps);
    Collections.shuffle(shuffledTimeStamps);
    for (Long timeStamp : shuffledTimeStamps) {
      Number160 contentKey = new Number160(timeStamp);
      logger.debug("{}, {}", timeStamp, contentKey);
      p2.put(lKey).setData(contentKey, new Data(timeStamp)).setDomainKey(dKey).start()
          .awaitUninterruptibly();
    }

    // fetch time stamps from network, respectively the implicit queue
    List<Long> downloadedTimestamps = new ArrayList<Long>();
View Full Code Here

        data.setBasedOnKey(content.get(i - 1).getVersionKey());
      }
      content.add(data);

      p2.put(Number160.createHash(locationKey))
          .setData(Number160.createHash(contentKey), new Data(data))
          .setVersionKey(data.getVersionKey()).start().awaitUninterruptibly();
    }

    FutureRemove futureRemove = p1
        .remove(Number160.createHash(locationKey))
View Full Code Here

        data.setBasedOnKey(content.get(i - 1).getVersionKey());
      }
      content.add(data);

      p2.put(Number160.createHash(locationKey))
          .setData(Number160.createHash(contentKey), new Data(data))
          .setVersionKey(data.getVersionKey()).start().awaitUninterruptibly();
    }

    FutureRemove futureRemove = p1
        .remove(Number160.createHash(locationKey))
View Full Code Here

    String contentKey = "content";

    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());
    data.generateVersionKey();

    p2.put(Number160.createHash(locationKey)).setData(Number160.createHash(contentKey), new Data(data))
        .setVersionKey(data.getVersionKey()).start().awaitUninterruptibly();

    FutureRemove futureRemove = p1.remove(Number160.createHash(locationKey)).setDomainKey(Number160.ZERO)
        .contentKey(Number160.createHash(contentKey)).setVersionKey(data.getVersionKey()).start();
    futureRemove.awaitUninterruptibly();
View Full Code Here

    Number160 dKey = Number160.createHash("domain");
    Number160 cKey = Number160.createHash("content");

    H2HTestData data = new H2HTestData(NetworkTestUtil.randomString());

    p2.put(lKey).setData(cKey, new Data(data)).setDomainKey(dKey).start().awaitUninterruptibly();

    FutureRemove futureRemove = p1.remove(lKey).setDomainKey(dKey).contentKey(cKey).start();
    futureRemove.awaitUninterruptibly();

    // check with a normal digest
View Full Code Here

TOP

Related Classes of net.tomp2p.storage.Data

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.