Examples of RandomAccessBucket


Examples of freenet.support.api.RandomAccessBucket

    }
   
    InsertBlock block;
    OutputStream os = null;
    try {
        RandomAccessBucket outputBucket = context.getBucketFactory(persistent).makeBucket(-1);
      os = new BufferedOutputStream(outputBucket.getOutputStream());
      String mimeType = (archiveType == ARCHIVE_TYPE.TAR ?
        createTarBucket(os) :
        createZipBucket(os));
      os = null; // create*Bucket closes os
      if(logMINOR)
        Logger.minor(this, "Archive size is "+outputBucket.size());
     
      if(logMINOR) Logger.minor(this, "We are using "+archiveType);
     
      // Now we have to insert the Archive we have generated.
     
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));

      // Create four CHKs
     
      RandomAccessBucket single = randomData(node);
      RandomAccessBucket[] mhks = new RandomAccessBucket[3];
     
      for(int i=0;i<mhks.length;i++) mhks[i] = randomData(node);
     
      client = node.clientCore.makeClient((short) 0, false, false);
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

      System.exit(exitCode);
    }
  } 
 
  private static RandomAccessBucket randomData(Node node) throws IOException {
      RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
    OutputStream os = data.getOutputStream();
    try {
    byte[] buf = new byte[4096];
    for (long written = 0; written < TEST_SIZE;) {
      node.fastWeakRandom.nextBytes(buf);
      int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

    if (!TestUtil.waitForNodes(node)) {
      node.park();
      System.exit(EXIT_FAILED_TARGET);
    }
        System.err.println("Creating test data: "+TEST_SIZE+" bytes.");
        RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
        OutputStream os = data.getOutputStream();
    try {
        byte[] buf = new byte[4096];
        for(long written = 0; written < TEST_SIZE;) {
          node.fastWeakRandom.nextBytes(buf);
          int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

        try {
          buf = value.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
          throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
        } // FIXME some other encoding?
        RandomAccessBucket b = new SimpleReadOnlyArrayBucket(buf);
        parts.put(parameterValues.getKey(), b);
        if(logMINOR)
          Logger.minor(this, "Added as part: name="+parameterValues.getKey()+" value="+value);
      }
    } else {
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

        line = lis.readLine(100, 100, false);
      }

      boundary = "\r\n" + boundary;

      RandomAccessBucket filedata = null;
      String name = null;
      String filename = null;
      String contentType = null;

      while(is.available() > 0) {
        name = null;
        filename = null;
        contentType = null;
        // chomp headers
        while((line = lis.readLine(200, 200, true)) /* should be UTF-8 as we told the browser to send UTF-8 */ != null) {
          if(line.length() == 0)
            break;

          String[] lineparts = line.split(":");
          if(lineparts == null || lineparts.length == 0)
            continue;
          String hdrname = lineparts[0].trim();

          if(hdrname.equalsIgnoreCase("Content-Disposition")) {
            if(lineparts.length < 2)
              continue;
            String[] valueparts = lineparts[1].split(";");

            for(int i = 0; i < valueparts.length; i++) {
              String[] subparts = valueparts[i].split("=");
              if(subparts.length != 2)
                continue;
              String fieldname = subparts[0].trim();
              String value = subparts[1].trim();
              if(value.startsWith("\"") && value.endsWith("\""))
                value = value.substring(1, value.length() - 1);
              if(fieldname.equalsIgnoreCase("name"))
                name = value;
              else if(fieldname.equalsIgnoreCase("filename"))
                filename = value;
            }
          }
          else if(hdrname.equalsIgnoreCase("Content-Type")) {
            contentType = lineparts[1].trim();
            if(logMINOR)
              Logger.minor(this, "Parsed type: " + contentType);
          }
          else {
          // Do nothing, irrelevant header
          }
        }

        if(name == null)
          continue;

        // we should be at the data now. Start reading it in, checking for the
      // boundary string

        // we can only give an upper bound for the size of the bucket
        filedata = this.bucketfactory.makeBucket(is.available());
        bucketos = filedata.getOutputStream();
        // buffer characters that match the boundary so far
      // FIXME use whatever charset was used
        byte[] bbound = boundary.getBytes("UTF-8"); // ISO-8859-1? boundary should be in US-ASCII
        int offset = 0;
        while((is.available() > 0) && (offset < bbound.length)) {
          byte b = (byte) is.read();

          if(b == bbound[offset])
            offset++;
          else if((b != bbound[offset]) && (offset > 0)) {
            // offset bytes matched, but no more
          // write the bytes that matched, then the non-matching byte
            bucketos.write(bbound, 0, offset);
            offset = 0;
            if(b == bbound[0])
              offset = 1;
            else
              bucketos.write(b);
          }
          else
            bucketos.write(b);
        }

        bucketos.close();
        bucketos = null;
     
        parts.put(name, filedata);
        if(logMINOR)
          Logger.minor(this, "Name = " + name + " length = " + filedata.size() + " filename = " + filename);
        if(filename != null)
          uploadedFiles.put(name, new HTTPUploadedFileImpl(filename, contentType, filedata));
      }
    }
    finally {
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

     
      for(int i=0;i<INSERTED_BLOCKS;i++) {
       
        System.err.println("Inserting block "+i);
       
        RandomAccessBucket single = randomData(node);
       
        InsertBlock block = new InsertBlock(single, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
       
        batch.startInsert(block);
       
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

      System.exit(exitCode);
    }
  } 
 
  private static RandomAccessBucket randomData(Node node) throws IOException {
      RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
    OutputStream os = data.getOutputStream();
    try {
    byte[] buf = new byte[4096];
    for (long written = 0; written < TEST_SIZE;) {
      node.fastWeakRandom.nextBytes(buf);
      int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

     
      FreenetURI todaysInsert = null;

      // PUSH N+1 BLOCKS
      for (int i = 0; i <= MAX_N; i++) {
          RandomAccessBucket data = randomData(node);
        HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
        System.out.println("PUSHING " + i);

        try {
          InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
          t1 = System.currentTimeMillis();
          FreenetURI uri = client.insert(block, false, null);
          if(i == 0) todaysInsert = uri;
          t2 = System.currentTimeMillis();

          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1)+" for "+uri);
          csvLine.add(String.valueOf(t2 - t1));
          csvLine.add(uri.toASCIIString());
        } catch (InsertException e) {
          e.printStackTrace();
          csvLine.add("N/A");
          csvLine.add("N/A");
        }

        data.free();
      }

      node.park();

      // Node 2
View Full Code Here

Examples of freenet.support.api.RandomAccessBucket

      fis.close();
    }
  }

  private static RandomAccessBucket randomData(Node node) throws IOException {
      RandomAccessBucket data = node.clientCore.tempBucketFactory.makeBucket(TEST_SIZE);
    OutputStream os = data.getOutputStream();
    try {
    byte[] buf = new byte[4096];
    for (long written = 0; written < TEST_SIZE;) {
      node.fastWeakRandom.nextBytes(buf);
      int toWrite = (int) Math.min(TEST_SIZE - written, buf.length);
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.