Package freenet.client

Examples of freenet.client.InsertBlock


      HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
      FreenetURI uri = new FreenetURI("KSK@" + uid + "-" + dateFormat.format(today.getTime()));
      System.out.println("PUSHING " + uri);
     
      try {
        InsertBlock block = new InsertBlock(data, new ClientMetadata(), uri);
        t1 = System.currentTimeMillis();
        client.insert(block, false, null);
        t2 = System.currentTimeMillis();
       
        System.out.println("PUSH-TIME-" + ":" + (t2 - t1));
View Full Code Here


     
      client = node.clientCore.makeClient((short) 0, false, false);

      System.err.println("Inserting single block 3 times");
     
      InsertBlock block = new InsertBlock(single, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
     
      FreenetURI uri = null;
     
      int successes = 0;
     
      for(int i=0;i<3;i++) {
        System.err.println("Inserting single block, try #"+i);
        try {
          t1 = System.currentTimeMillis();
          FreenetURI thisURI = client.insert(block, false, null);
          if(uri != null && !thisURI.equals(uri)) {
            System.err.println("URI "+i+" is "+thisURI+" but previous is "+uri);
            System.exit(EXIT_DIFFERENT_URI);
          }
          uri = thisURI;
          t2 = System.currentTimeMillis();
         
          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1)+" for "+uri+" for single block");
          csvLine.add(String.valueOf(t2 - t1));
          csvLine.add(uri.toASCIIString());
          successes++;
        } catch (InsertException e) {
          e.printStackTrace();
          csvLine.add(InsertException.getShortMessage(e.getMode()));
          csvLine.add("N/A");
          System.out.println("INSERT FAILED: "+e+" for insert "+i+" for single block");
        }
      }
     
      if(successes == 3)
        System.err.println("All inserts succeeded for single block: "+successes);
      else if(successes != 0)
        System.err.println("Some inserts succeeded for single block: "+successes);
      else
        System.err.println("NO INSERTS SUCCEEDED FOR SINGLE BLOCK: "+successes);
     
      uri = null;
     
      // Insert 3 blocks
     
      for(int i=0;i<3;i++) {
        System.err.println("Inserting MHK #"+i);
        uri = null;
        block = new InsertBlock(mhks[i], new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
        try {
          t1 = System.currentTimeMillis();
          FreenetURI thisURI = client.insert(block, false, null);
          uri = thisURI;
          t2 = System.currentTimeMillis();
View Full Code Here

    if(bucket == null) return;
    synchronized(this) {
      if(hasResolvedBase) return;
      hasResolvedBase = true;
    }
    InsertBlock block;
    block = new InsertBlock(bucket, null, targetURI);
    try {
      rootMetaPutHandler = new MetaPutHandler(this, null, block);

      if(logMINOR) Logger.minor(this, "Inserting main metadata: "+rootMetaPutHandler+" for "+baseMetadata);
      rootMetaPutHandler.start(context);
View Full Code Here

        private static final long serialVersionUID = 1L;

        private ExternPutHandler(BaseManifestPutter bmp, PutHandler parent, String name, RandomAccessBucket data, ClientMetadata cm2) {
      super(bmp, parent, name, cm2, runningPutHandlers);
      InsertBlock block = new InsertBlock(data, cm, FreenetURI.EMPTY_CHK_URI);
      this.origSFI = new SingleFileInserter(this, this, block, false, ctx, realTimeFlag, false, true, null, null, false, null, false, persistent(), 0, 0, null, cryptoAlgorithm, forceCryptoKey, -1);
    }
View Full Code Here

          }
         
        });

        try {
          InsertBlock block = new InsertBlock(data, new ClientMetadata(), uri);
          t1 = System.currentTimeMillis();
          client.insert(block, false, null);
          t2 = System.currentTimeMillis();

          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1));
View Full Code Here

    private MetaPutHandler(BaseManifestPutter smp, PutHandler parent, Metadata toResolve, BucketFactory bf) throws MetadataUnresolvedException, IOException {
      super(smp, parent, null, null, runningPutHandlers);
      RandomAccessBucket b = toResolve.toBucket(bf);
      metadata = toResolve;
      // Treat as splitfile for purposes of determining number of reinserts.
      InsertBlock ib = new InsertBlock(b, null, FreenetURI.EMPTY_CHK_URI);
      this.origSFI = new SingleFileInserter(this, this, ib, true, ctx, realTimeFlag, false, false, toResolve, null, true, null, true, persistent(), 0, 0, null, cryptoAlgorithm, null, -1);
      if(logMINOR) Logger.minor(this, "Inserting subsidiary metadata: "+origSFI+" for "+toResolve);
    }
View Full Code Here

          metaInsertSuccess = true;
        }
        cb.onMetadata(metadataBucket, state, context);
        return;
      }
      InsertBlock newBlock = new InsertBlock(metadataBucket, m, block.desiredURI);
      synchronized(this) {
          // Only the bottom layer in a multi-level splitfile pyramid has randomised keys. The rest are unpredictable anyway, and this ensures we only need to supply one key when reinserting.
          metadataPutter = new SingleFileInserter(parent, this, newBlock, true, ctx, realTimeFlag, false, false, token, archiveType, true, metaPutterTargetFilename, true, persistent, origDataLength, origCompressedDataLength, origHashes, cryptoAlgorithm, forceCryptoKey, metadataThreshold);
          if(origHashes != null) {
              // It gets passed on, and the last one deletes it.
View Full Code Here

   
    synchronized(this) {
      if(finished) return;
    }
   
    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.
     
      // Can we just insert it, and not bother with a redirect to it?
      // Thereby exploiting implicit manifest support, which will pick up on .metadata??
      // We ought to be able to !!
      block = new InsertBlock(outputBucket, new ClientMetadata(mimeType), targetURI);
    } catch (IOException e) {
      fail(new InsertException(InsertExceptionMode.BUCKET_ERROR, e, null), context);
      return;
    } finally {
      Closer.close(os);
View Full Code Here

    } finally {
        os.close();
    }
        System.err.println("Inserting test data.");
        HighLevelSimpleClient client = node.clientCore.makeClient((short)0, false, false);
        InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
        long startInsertTime = System.currentTimeMillis();
        FreenetURI uri;
        try {
      uri = client.insert(block, false, null);
    } catch (InsertException e) {
View Full Code Here

       
        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

TOP

Related Classes of freenet.client.InsertBlock

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.