Package net.tomp2p.rpc

Examples of net.tomp2p.rpc.DigestInfo


      this.key = key;
    }

    @Override
    public DigestInfo digest(Number640 from, Number640 to, int limit, boolean ascending) {
      DigestInfo digestInfo = new DigestInfo();
      digestInfo.put(key, Number160.ZERO);
      return digestInfo;
    }
View Full Code Here


            exceptions.put(taskKey, string);
        }
    }

    public DigestInfo digest() {
        return new DigestInfo(executor.getQueue().size());
    }
View Full Code Here

  /* (non-Javadoc)
   * @see net.tomp2p.dht.DigestStorage#digest(net.tomp2p.peers.Number640, net.tomp2p.peers.Number640, int, boolean)
   */
  @Override
    public DigestInfo digest(Number640 from, Number640 to, int limit, boolean ascending) {
    DigestInfo digestInfo = new DigestInfo();
    KeyLock<?>.RefCounterLock lock = findAndLock(from, to);
    try {
      Map<Number640, Data> tmp = backend.subMap(from, to, limit, ascending);
      for (Map.Entry<Number640, Data> entry : tmp.entrySet()) {
        if (!entry.getValue().hasPrepareFlag()) {
          digestInfo.put(entry.getKey(), entry.getValue().basedOnSet());
        }
      }
      return digestInfo;
    } finally {
      lock.unlock();
View Full Code Here

   * @see net.tomp2p.dht.DigestStorage#digest(net.tomp2p.peers.Number320, net.tomp2p.rpc.SimpleBloomFilter, net.tomp2p.rpc.SimpleBloomFilter, int, boolean, boolean)
   */
  @Override
    public DigestInfo digest(Number320 locationAndDomainKey, SimpleBloomFilter<Number160> keyBloomFilter,
          SimpleBloomFilter<Number160> contentBloomFilter, int limit, boolean ascending, boolean isBloomFilterAnd) {
    DigestInfo digestInfo = new DigestInfo();
    KeyLock<Number320>.RefCounterLock lock = dataLock320.lock(locationAndDomainKey);
    try {
      Number640 from = new Number640(locationAndDomainKey, Number160.ZERO, Number160.ZERO);
      Number640 to = new Number640(locationAndDomainKey, Number160.MAX_VALUE, Number160.MAX_VALUE);
      Map<Number640, Data> tmp = backend.subMap(from, to, limit, ascending);
      for (Map.Entry<Number640, Data> entry : tmp.entrySet()) {
        if (isBloomFilterAnd) {
          if (keyBloomFilter == null || keyBloomFilter.contains(entry.getKey().contentKey())) {
            if (contentBloomFilter == null || contentBloomFilter.contains(entry.getValue().hash())) {
              if (!entry.getValue().hasPrepareFlag()) {
                digestInfo.put(entry.getKey(), entry.getValue().basedOnSet());
              }
            }
          }
        } else {
          if (keyBloomFilter == null || !keyBloomFilter.contains(entry.getKey().contentKey())) {
            if (contentBloomFilter == null || !contentBloomFilter.contains(entry.getValue().hash())) {
              if (!entry.getValue().hasPrepareFlag()) {
                digestInfo.put(entry.getKey(),entry.getValue().basedOnSet());
              }
            }
          }
        }
      }
View Full Code Here

  /* (non-Javadoc)
   * @see net.tomp2p.dht.DigestStorage#digest(java.util.Collection)
   */
  @Override
    public DigestInfo digest(Collection<Number640> number640s) {
    DigestInfo digestInfo = new DigestInfo();
    for (Number640 number640 : number640s) {
      KeyLock<Number640>.RefCounterLock lock = dataLock640.lock(number640);
      try {
        if (backend.contains(number640)) {
          Data data = getInternal(number640);
          if (data != null) {
            digestInfo.put(number640, data.basedOnSet());
          }
        }
      } finally {
        lock.unlock();
      }
View Full Code Here

    TrackerData trackerData = dataMap.get(new Number320(locationKey, domainKey));
    if(trackerData!=null) {
      if(contentKey!=null) {
        Map.Entry<PeerStatistic, Data> entry = trackerData.get(contentKey);
        if(entry!=null) {
          return new DigestInfo(Number160.ZERO, contentKey, 1);
        }
      } else {
        for(PeerStatistic peerStatatistic: trackerData.peerAddresses().keySet()) {
          contentDigest = contentDigest.xor(peerStatatistic.peerAddress().peerId());
          counter++;
        }
      }
    }
    return new DigestInfo(Number160.ZERO, contentKey, counter);
    }
View Full Code Here

    Number640 key = new Number640(locationKey, domainKey, contentKey, Number160.ZERO);
    final Map<Number640, Data> result = storageLayer.getLatestVersion(key);
    responseMessage.setDataMap(new DataMap(result));

    if (withDigest) {
      final DigestInfo digestInfo = storageLayer.digest(key.minVersionKey(), key.maxVersionKey(), -1, true);
      responseMessage.keyMap640Keys(new KeyMap640Keys(digestInfo.digests()));
    }

    return responseMessage;
  }
View Full Code Here

          final Map<Number640, Data> result = doGet(locationKey, domainKey, contentKeys, contentBloomFilter,
                    versionBloomFilter, limit, ascending, isRange, isCollection, isBloomFilterAnd);
          DataMap dataMap = new DataMap(result, true);
          responseMessage.setDataMap(dataMap);
        } else {
          final DigestInfo digestInfo = doDigest(locationKey, domainKey, contentKeys, contentBloomFilter,
              versionBloomFilter, limit, ascending, isRange, isCollection, isBloomFilterAnd);
          if (isReturnBloomfilter) {
                responseMessage.bloomFilter(digestInfo.contentKeyBloomFilter(factory));
                responseMessage.bloomFilter(digestInfo.versionKeyBloomFilter(factory));
            } else {
                responseMessage.keyMap640Keys(new KeyMap640Keys(digestInfo.digests()));
            }
        }
        return responseMessage;

    }
View Full Code Here

  private DigestInfo doDigest(
            final Number160 locationKey, final Number160 domainKey, final KeyCollection contentKeys,
            final SimpleBloomFilter<Number160> contentBloomFilter,
            final SimpleBloomFilter<Number160> versionBloomFilter, final int limit, final boolean ascending,
            final boolean isRange, final boolean isCollection, final boolean isBloomFilterAnd) {
      final DigestInfo digestInfo;
        if (isCollection) {
            digestInfo = storageLayer.digest(contentKeys.keys());
        } else if (isRange) {
            // get min/max
            Iterator<Number640> iterator = contentKeys.keys().iterator();
View Full Code Here

                from = new Number640(routingBuilder.locationKey(), routingBuilder.domainKey(),
                        routingBuilder.contentKey(), Number160.ZERO);
                to = new Number640(routingBuilder.locationKey(), routingBuilder.domainKey(),
                        routingBuilder.contentKey(), Number160.MAX_VALUE);
            }
            DigestInfo digestBean = peerBean.digestStorage().digest(from, to, -1, true);
            if (digestBean.size() > 0) {
                directHits.put(peerBean.serverPeerAddress(), digestBean);
            }
        } else if (type == Type.REQUEST_3 && !randomSearch && peerBean.digestTracker() != null) {
            DigestInfo digestInfo = peerBean.digestTracker().digest(routingBuilder.locationKey(),
                    routingBuilder.domainKey(), routingBuilder.contentKey());
            // we always put ourselfs to the tracker list, so we need to check
            // if we know also other peers on our trackers.
            if (digestInfo.size() > 0) {
                directHits.put(peerBean.serverPeerAddress(), digestInfo);
            }
        }
       
        final FutureRouting futureRouting = new FutureRouting();
View Full Code Here

TOP

Related Classes of net.tomp2p.rpc.DigestInfo

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.