コード例 #1
0
 public static String getVersionKeysFromMap(Map<Number640, Data> dataMap) {
   String result = "";
   for (Number640 key : dataMap.keySet()) {
     result += key.versionKey() + " ";
   }
   return result;
 }
コード例 #2
0
  public boolean remove(Number640 key) {
    long startTime = System.currentTimeMillis();
    FutureRemove remove =
        peerDHT
            .remove(key.locationKey())
            .contentKey(key.contentKey())
            .domainKey(key.domainKey())
            .versionKey(key.versionKey())
            .routingConfiguration(routingConfig)
            .requestP2PConfiguration(requestConfig)
            .start()
            .awaitUninterruptibly();
    putStats.report(System.currentTimeMillis() - startTime, remove.isSuccess());
    LOG.debug("Remove is success {}. Reason: {}", remove.isSuccess(), remove.failedReason());

    return remove.isSuccess();
  }
コード例 #3
0
  public Data get(Number640 key) {
    long startTime = System.currentTimeMillis();
    FutureGet futureGet =
        peerDHT
            .get(key.locationKey())
            .contentKey(key.contentKey())
            .domainKey(key.domainKey())
            .versionKey(key.versionKey())
            .routingConfiguration(routingConfig)
            .requestP2PConfiguration(requestConfig)
            .start()
            .awaitUninterruptibly();
    putStats.report(System.currentTimeMillis() - startTime, futureGet.isSuccess());
    LOG.debug("Get is success {}. Reason: {}", futureGet.isSuccess(), futureGet.failedReason());

    if (futureGet.data() != null) {
      return futureGet.data();
    } else {
      return null;
    }
  }
コード例 #4
0
  public boolean put(Number640 key) {
    Data data = generateRandomData();
    long startTime = System.currentTimeMillis();
    FuturePut futurePut =
        peerDHT
            .put(key.locationKey())
            .domainKey(key.domainKey())
            .versionKey(key.versionKey())
            .data(key.contentKey(), data)
            .routingConfiguration(routingConfig)
            .requestP2PConfiguration(requestConfig)
            .start()
            .awaitUninterruptibly();
    putStats.report(System.currentTimeMillis() - startTime, futurePut.isSuccess());

    LOG.debug(
        "Put of {} bytes is success = {}. Reason: {}",
        data.length(),
        futurePut.isSuccess(),
        futurePut.failedReason());
    return futurePut.isSuccess();
  }