Package freenet.io.xfer

Examples of freenet.io.xfer.PartiallyReceivedBulk


      } catch(IOException e) {
          Logger.error(this, "Peer " + source + " asked us for the blob file for the "+name+" jar, we have downloaded it but can't read the file on disk!: " + e, e);
          return;
      }
     
      final PartiallyReceivedBulk prb;
      long length;
      length = raf.size();
      prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length,
              Node.PACKET_SIZE, raf, true);
     
      try {
        bt = new BulkTransmitter(prb, source, uid, false, updateManager.ctr, true);
      } catch(DisconnectedException e) {
View Full Code Here


   * or it restarts.
   */
  private boolean innerSendOpennetRef(long xferUID, byte[] padded, PeerNode peer, ByteCounter ctr, AllSentCallback cb) throws NotConnectedException {
    ByteArrayRandomAccessBuffer raf = new ByteArrayRandomAccessBuffer(padded);
    raf.setReadOnly();
    PartiallyReceivedBulk prb =
      new PartiallyReceivedBulk(node.usm, padded.length, Node.PACKET_SIZE, raf, true);
    try {
      BulkTransmitter bt =
        new BulkTransmitter(prb, peer, xferUID, true, ctr, true, cb);
      return bt.send();
    } catch (DisconnectedException e) {
View Full Code Here

  }

  static byte[] innerWaitForOpennetNoderef(long xferUID, int paddedLength, int realLength, PeerNode source, boolean isReply, long uid, boolean sendReject, ByteCounter ctr, Node node) {
    byte[] buf = new byte[paddedLength];
    ByteArrayRandomAccessBuffer raf = new ByteArrayRandomAccessBuffer(buf);
    PartiallyReceivedBulk prb = new PartiallyReceivedBulk(node.usm, buf.length, Node.PACKET_SIZE, raf, false);
    BulkReceiver br = new BulkReceiver(prb, source, xferUID, ctr);
    if (logMINOR) {
      Logger.minor(OpennetManager.class, "Receiving noderef (reply="+isReply+") as bulk transfer for request uid "+uid+" with transfer "+xferUID+" from "+source);
    }
    if (!br.receive()) {
      if (source.isConnected()) {
        String msg = "Failed to receive noderef bulk transfer : "
          +RetrievalException.getErrString(prb.getAbortReason())+" : "
          +prb.getAbortDescription()+" from "+source;
        if (prb.getAbortReason() != RetrievalException.SENDER_DISCONNECTED) {
          Logger.warning(OpennetManager.class, msg);
        } else {
          Logger.normal(OpennetManager.class, msg);
        }
        if (sendReject) rejectRef(uid, source, DMT.NODEREF_REJECTED_TRANSFER_FAILED, ctr);
View Full Code Here

        return;
      }
      byte[] data = baos.toByteArray();
      long uid = node.fastWeakRandom.nextLong();
      RandomAccessBuffer raf = new ByteArrayRandomAccessBuffer(data);
      PartiallyReceivedBulk prb = new PartiallyReceivedBulk(node.usm, data.length, Node.PACKET_SIZE, raf, true);
      try {
        sendAsync(DMT.createFNPMyFullNoderef(uid, data.length), null, node.nodeStats.foafCounter);
      } catch (NotConnectedException e1) {
        // Ignore
        synchronized(this) {
View Full Code Here

      receivingFullNoderef = true;
    }
    try {
      final byte[] data = new byte[length];
      RandomAccessBuffer raf = new ByteArrayRandomAccessBuffer(data);
      PartiallyReceivedBulk prb = new PartiallyReceivedBulk(node.usm, length, Node.PACKET_SIZE, raf, false);
      final BulkReceiver br = new BulkReceiver(prb, this, uid, node.nodeStats.foafCounter);
      node.executor.execute(new Runnable() {

        @Override
        public void run() {
View Full Code Here

        data = new FileRandomAccessBuffer(dest, size, false);
      } catch (IOException e) {
        // Impossible
        throw new Error("Impossible: FileNotFoundException opening with RAF with rw! "+e, e);
      }
      prb = new PartiallyReceivedBulk(node.usm, size, Node.PACKET_SIZE, data, false);
      receiver = new BulkReceiver(prb, DarknetPeerNode.this, uid, null);
      // FIXME make this persistent
      node.executor.execute(new Runnable() {
        @Override
        public void run() {
View Full Code Here

      }
      data.close();
    }

    public void send() throws DisconnectedException {
      prb = new PartiallyReceivedBulk(node.usm, size, Node.PACKET_SIZE, data, true);
      transmitter = new BulkTransmitter(prb, DarknetPeerNode.this, uid, false, node.nodeStats.nodeToNodeCounter, false);
      if(logMINOR)
        Logger.minor(this, "Sending "+uid);
      node.executor.execute(new Runnable() {
        @Override
View Full Code Here

      return true;
    }

    final long uid = m.getLong(DMT.UID);

    final PartiallyReceivedBulk prb;
    long length;
    length = data.size();
    prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length,
            Node.PACKET_SIZE, data, true);

    final BulkTransmitter bt;
    try {
      bt = new BulkTransmitter(prb, source, uid, false, updateManager.ctr, true);
View Full Code Here

    synchronized(this) {
      nodesSayKeyRevokedTransferring.add(source);
      nodesSayKeyRevoked.remove(source);
    }
   
    PartiallyReceivedBulk prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length,
      Node.PACKET_SIZE, raf, false);

    final BulkReceiver br = new BulkReceiver(prb, source, uid, updateManager.ctr);

    updateManager.node.executor.execute(new Runnable() {
View Full Code Here

            } catch(IOException e) {
                Logger.error(this, "Peer " + source + " asked us for the blob file for the "+name+" jar, we have downloaded it but can't read the file due to a disk I/O error: " + e, e);
                return;
      }
     
      final PartiallyReceivedBulk prb;
      long length;
      length = raf.size();
      prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length,
              Node.PACKET_SIZE, raf, true);
     
      try {
        bt = new BulkTransmitter(prb, source, uid, false, updateManager.ctr, true);
      } catch(DisconnectedException e) {
View Full Code Here

TOP

Related Classes of freenet.io.xfer.PartiallyReceivedBulk

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.