Package dijjer.io.xfer.http

Examples of dijjer.io.xfer.http.HttpBlockReceiver


  private void handleHashVerificationFailure(VeryLongInteger retrievedHash, VeryLongInteger actualHash, BlockInfo bi) {
    // Find out what the hash should be
    PartiallyReceivedBlock prb = new PartiallyReceivedBlock(Dijjer.PACKETS_IN_BLOCK, Dijjer.PACKET_SIZE);
    try {
      (new HttpBlockReceiver(bi, prb)).start();
    } catch (Exception e) {
      Logger.warning("Exception while trying to deal with hash verification failure", e);
    }
    VeryLongInteger confirmHash = new VeryLongInteger(prb.getBlock());
    boolean dataHashFailure = !confirmHash.equals(actualHash);
View Full Code Here


      best = _rt.findClosest(bi.getHashKey(), exclude);
      // If the ttl has run out, there is nowhere to route, or if the next hop is further away in hash-space from
      // the data, we download it ourselves.
      // TODO: Make this robust against download failure
      if ((ttl < 1) || (best == null) || bi.getHashKey().closerTo(_rt.getPeer().getHash(), best.getHash())) {
        HttpBlockReceiver hbr = new HttpBlockReceiver(bi, prb);
        if (requestor != null) {
          new Thread() {

            public void run() {
              forwardData(requestor, prb, uid, forwarders, false);
              /*
               * Only add the block to the DS if we didn't request it, this helps to prevent the datastore
               * getting "flushed" every time we do a request
               */
              try {
                _ds.addDataAsBlock(bi.getHashKey(), prb.getBlock());
              } catch (IOException e) {
                throw new RuntimeException(e);
              }
            }
          }.start();
        }
        hbr.start();
        return false;
      }
      // Ok, we are going to ask another peer for the data, first construct our request
      // And send it to our best guess
      if (!forwarders.contains(_rt.getPeer())) {
View Full Code Here

          Logger.info("Ignoring corruptionNotification because we don't have the data in our DataStore");
          return;
        }
        VeryLongInteger myHash = new VeryLongInteger(localData);
        PartiallyReceivedBlock prb = new PartiallyReceivedBlock(Dijjer.PACKETS_IN_BLOCK, Dijjer.PACKET_SIZE);
        (new HttpBlockReceiver(bi, prb)).start();
        VeryLongInteger actualHash = new VeryLongInteger(prb.getBlock());
        if (actualHash.equals(myHash)) {
          Logger.warning("Received bogus corruptionNotification from " + source + ", dropping from RT");
          LinkedList r = new LinkedList();
          r.add(source);
View Full Code Here

    }
  }

  protected VeryLongInteger retrieveHashFromServer(BlockInfo bi) throws RetrievalException {
    PartiallyReceivedBlock prb = new PartiallyReceivedBlock(Dijjer.PACKETS_IN_BLOCK, Dijjer.PACKET_SIZE);
    HttpBlockReceiver hbr = new HttpBlockReceiver(bi, prb);
    try {
      hbr.start();
    } catch (IOException e) {
      throw new RetrievalException(RetrievalException.IO_ERROR, e.getMessage());
    }
    return new VeryLongInteger(prb.getBlock());
  }
View Full Code Here

TOP

Related Classes of dijjer.io.xfer.http.HttpBlockReceiver

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.