Examples of BlockTransmitter


Examples of dijjer.io.xfer.BlockTransmitter

    byte[] block = new byte[1024 * 256];
    for (int x = 0; x < block.length; x++) {
      block[x] = (byte) x;
    }
    PartiallyReceivedBlock prb1 = new PartiallyReceivedBlock(256, 1024, block);
    final BlockTransmitter bt = new BlockTransmitter(usm1, p2, 0, prb1);
    (new Thread() {

      public void run() {
        try {
          bt.send();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }).start();
    PartiallyReceivedBlock prb2 = new PartiallyReceivedBlock(256, 1024);
    final BlockReceiver br = new BlockReceiver(usm2, p1, 0, prb2);
    final BlockTransmitter bt2 = new BlockTransmitter(usm2, p3, 0, prb2);
    PartiallyReceivedBlock prb3 = new PartiallyReceivedBlock(256, 1024);
    final BlockReceiver br2 = new BlockReceiver(usm3, p2, 0, prb3);
    (new Thread() {

      public void run() {
        try {
          br.receive();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }).start();
    (new Thread() {

      public void run() {
        try {
          bt2.send();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }).start();
View Full Code Here

Examples of dijjer.io.xfer.BlockTransmitter

    }
  }

  protected void forwardData(Peer dest, PartiallyReceivedBlock prb, int uid, LinkedList forwarders, boolean wasCached) {
    _usm.send(dest, DMT.createRequestSuccessful(uid, _rt.getPeer(), wasCached));
    BlockTransmitter bt = new BlockTransmitter(_usm, dest, uid, prb);
    bt.send();
    synchronized (forwarders) {
      for (Iterator i = forwarders.iterator(); i.hasNext();) {
        Peer p = (Peer) i.next();
        _rt.addPeer(p);
      }
View Full Code Here

Examples of freenet.io.xfer.BlockTransmitter

      }
      Message df = DMT.createFNPCHKDataFound(uid, block.getRawHeaders());
      source.sendAsync(df, null, senderCounter);
          PartiallyReceivedBlock prb =
            new PartiallyReceivedBlock(Node.PACKETS_IN_BLOCK, Node.PACKET_SIZE, block.getRawData());
          final BlockTransmitter bt =
            new BlockTransmitter(node.usm, node.getTicker(), source, uid, prb, senderCounter, BlockTransmitter.NEVER_CASCADE,
                new BlockTransmitterCompletion() {

          @Override
          public void blockTransferFinished(boolean success) {
            tag.unlockHandler();
          }
         
        }, realTimeFlag, node.nodeStats);
          node.executor.execute(new PrioRunnable() {

        @Override
        public int getPriority() {
          return NativeThread.HIGH_PRIORITY;
        }

        @Override
        public void run() {
          bt.sendAsync();
        }
           
          }, "CHK offer sender");
    }
  }
View Full Code Here

Examples of freenet.io.xfer.BlockTransmitter

      Message df = DMT.createFNPCHKDataFound(uid, rs.getHeaders());
      source.sendAsync(df, null, this);

      PartiallyReceivedBlock prb = rs.getPRB();
      bt =
        new BlockTransmitter(node.usm, node.getTicker(), source, uid, prb, this, new ReceiverAbortHandler() {

          @Override
          public boolean onAbort() {
            RequestSender rs = RequestHandler.this.rs;
            if(rs != null && rs.uid != RequestHandler.this.uid) {
View Full Code Here

Examples of freenet.io.xfer.BlockTransmitter

      node.nodeStats.remoteRequest(true, true, true, htl, key.toNormalizedDouble(), realTimeFlag, false);
    } else if(block instanceof CHKBlock) {
      Message df = DMT.createFNPCHKDataFound(uid, block.getRawHeaders());
      PartiallyReceivedBlock prb =
        new PartiallyReceivedBlock(Node.PACKETS_IN_BLOCK, Node.PACKET_SIZE, block.getRawData());
      BlockTransmitter bt =
        new BlockTransmitter(node.usm, node.getTicker(), source, uid, prb, this, BlockTransmitter.NEVER_CASCADE,
            new BlockTransmitterCompletion() {

          @Override
          public void blockTransferFinished(boolean success) {
            if(success) {
              // for byte logging
              status = RequestSender.SUCCESS;
              // We've fetched it from our datastore, so there won't be a downstream noderef.
              // But we want to send at least an FNPOpennetCompletedAck, otherwise the request source
              // may have to timeout waiting for one. That will be the terminal message.
              try {
                finishOpennetNoRelay();
              } catch (NotConnectedException e) {
                Logger.normal(this, "requestor gone, could not start request handler wait");
                tag.handlerThrew(e);
              }
            } else {
              //also for byte logging, since the block is the 'terminal' message.
              applyByteCounts();
              unregisterRequestHandlerWithNode();
            }
            node.nodeStats.remoteRequest(false, success, true, htl, key.toNormalizedDouble(), realTimeFlag, false);
          }
         
        }, realTimeFlag, node.nodeStats);
      tag.handlerTransferBegins();
      source.sendAsync(df, null, this);
      bt.sendAsync();
    } else
      throw new IllegalStateException();
  }
View Full Code Here

Examples of freenet.io.xfer.BlockTransmitter

   
    BackgroundTransfer(final PeerNode pn, PartiallyReceivedBlock prb, InsertTag thisTag) {
      this.pn = pn;
      this.uid = CHKInsertSender.this.uid;
      this.thisTag = thisTag;
      bt = new BlockTransmitter(node.usm, node.getTicker(), pn, uid, prb, CHKInsertSender.this, BlockTransmitter.NEVER_CASCADE,
          new BlockTransmitterCompletion() {

        @Override
        public void blockTransferFinished(boolean success) {
          if(logMINOR) Logger.minor(this, "Transfer completed: "+success+" for "+this);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.