Package dijjer.io.xfer

Examples of dijjer.io.xfer.InputStreamBlockReceiver


public class InputStreamBlockReceiverTest extends TestCase {
  public void testISBR() throws Exception {
    byte[] ba1 = new byte[1000];
    ByteArrayInputStream bais = new ByteArrayInputStream(ba1);
    PartiallyReceivedBlock prb1 = new PartiallyReceivedBlock(100, 10);
    InputStreamBlockReceiver isbr1 = new InputStreamBlockReceiver(prb1, bais);
    isbr1.start();
    assertTrue(prb1.allReceived());
    byte[] ba2 = prb1.getBlock();
    for(int x=0; x<ba2.length; x++) {
      assertEquals(ba1[x], ba2[x]);
    }
   
    bais.reset();
    PartiallyReceivedBlock prb2 = new PartiallyReceivedBlock(100, 11);
    InputStreamBlockReceiver isbr2 = new InputStreamBlockReceiver(prb2, bais);
    isbr2.start();
   
    byte[] ba3 = prb2.getBlock();
    for (int x=0; x<ba1.length; x++) {
      assertEquals(ba1[x], ba3[x]);
    }
View Full Code Here


          continue;
        }
     
      //Stuff below here is only executed once
      InputStream is = uc.getInputStream();
      InputStreamBlockReceiver isrb = new InputStreamBlockReceiver(_prb, is);
      isrb.start();
      break;
    }
  }
View Full Code Here

    boolean cached = false;
    Logger.info("Dispatcher: Retrieving " + bi + " at ttl " + ttl);
    // See if we have it in our local store
    byte[] data = _ds.getDataForBlock(bi.getHashKey());
    if (data != null) {
      (new InputStreamBlockReceiver(prb, new ByteArrayInputStream(data))).start();
      if (requestor != null) {
        forwardData(requestor, prb, uid, forwarders, true);
      }
      return true;
    }
View Full Code Here

TOP

Related Classes of dijjer.io.xfer.InputStreamBlockReceiver

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.