Examples of ClientContext


Examples of freenet.client.async.ClientContext

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(erab);
        oos.close();
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ClientContext context = new ClientContext(0, null, null, null, null, null, null, null, null,
                null, r, null, null, null, null, null, null, null, null, null, null, null, null,
                null, null, null);
        context.setPersistentMasterSecret(secret);
        ObjectInputStream ois = new ObjectInputStream(dis);
        EncryptedRandomAccessBucket restored = (EncryptedRandomAccessBucket) ois.readObject();
        restored.onResume(context);
        assertEquals(buf.length, restored.size());
        assertEquals(erab, restored);
View Full Code Here

Examples of freenet.client.async.ClientContext

            memoryLimitedJobRunner.waitForShutdown();
            System.out.println("FEC decoding threads finished.");
        }
       
    });
    clientContext = new ClientContext(node.bootID, clientLayerPersister, node.executor,
            archiveManager, persistentTempBucketFactory, tempBucketFactory,
            persistentTempBucketFactory, healingQueue, uskManager, random, node.fastWeakRandom,
            node.getTicker(), memoryLimitedJobRunner, tempFilenameGenerator, persistentFilenameGenerator, tempBucketFactory,
            persistentRAFFactory, tempBucketFactory.getUnderlyingRAFFactory(), persistentDiskChecker,
            compressor, storeChecker, fcpPersistentRoot, cryptoSecretTransient, toadlets, defaultFetchContext, defaultInsertContext);
View Full Code Here

Examples of freenet.client.async.ClientContext

        DataOutputStream dos = new DataOutputStream(baos);
        eraf.storeTo(dos);
        dos.close();
        eraf.close();
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ClientContext context = new ClientContext(0, null, null, null, null, null, null, null, null,
                null, r, null, null, null, null, null, null, null, null, null, null, null, null,
                null, null, null);
        context.setPersistentMasterSecret(secret);
        EncryptedRandomAccessBuffer restored = (EncryptedRandomAccessBuffer) BucketTools.restoreRAFFrom(dis, context.persistentFG, context.persistentFileTracker, secret);
        assertEquals(buf.length, restored.size());
        //assertEquals(rafw, restored);
        tmp = new byte[buf.length];
        restored.pread(0, tmp, 0, buf.length);
View Full Code Here

Examples of freenet.client.async.ClientContext

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(eraf);
        oos.close();
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(baos.toByteArray()));
        ClientContext context = new ClientContext(0, null, null, null, null, null, null, null, null,
                null, r, null, null, null, null, null, null, null, null, null, null, null, null,
                null, null, null);
        context.setPersistentMasterSecret(secret);
        ObjectInputStream ois = new ObjectInputStream(dis);
        EncryptedRandomAccessBuffer restored = (EncryptedRandomAccessBuffer) ois.readObject();
        restored.onResume(context);
        assertEquals(buf.length, restored.size());
        assertEquals(eraf, restored);
View Full Code Here

Examples of freenet.client.async.ClientContext

    @Override
    public ClientRequest migrate(PersistentRequestClient newClient, ObjectContainer container,
            NodeClientCore core) throws IdentifierCollisionException, NotAllowedException,
            IOException, MetadataUnresolvedException, ResumeFailedException {
        ClientContext context = core.clientContext;
        if(targetURI != null)
            container.activate(targetURI, Integer.MAX_VALUE);
        if(uri != null)
            container.activate(uri, Integer.MAX_VALUE);
        container.activate(ctx, Integer.MAX_VALUE);
        ctx.onResume();
        File f = origFilename;
        if(f != null) {
            container.activate(f, Integer.MAX_VALUE);
            f = new File(f.toString());
            if(!f.exists()) {
                Logger.error(this, "Not migrating insert as data has been deleted");
                return null;
            }
        }
        container.activate(clientMetadata, Integer.MAX_VALUE);
        RandomAccessBucket data;
        if(this.data != null) {
            container.activate(this.data, Integer.MAX_VALUE);
            if(this.data.size() == 0) {
                Logger.error(this, "No data migrating insert: "+this.data);
                return null;
            }
            this.data.onResume(context);
            data = BucketTools.toRandomAccessBucket(this.data, context.getBucketFactory(true));
        } else {
            Logger.error(this, "Not migrating insert as data has been deleted (or very old download?)");
            return null;
        }
        byte[] overrideSplitfileKey = null;
View Full Code Here

Examples of freenet.client.async.ClientContext

            new freenet.clients.fcp.ClientGet(newClient, uri, fctx.localRequestOnly, fctx.ignoreStore,
                fctx.filterData, fctx.maxSplitfileBlockRetries, fctx.maxNonSplitfileRetries,
                fctx.maxOutputLength, ReturnType.getByCode(returnType), false, identifier, verbosity, priorityClass,
                f, charset, fctx.canWriteClientCache, realTime, binaryBlob, core);
        if(finished) {
            ClientContext context = core.clientContext;
            if(getFailedMessage != null) {
                container.activate(getFailedMessage, Integer.MAX_VALUE);
                if(getFailedMessage.expectedMimeType != null)
                    this.foundDataMimeType = getFailedMessage.expectedMimeType;
            }
View Full Code Here

Examples of freenet.client.async.ClientContext

 
    @Override
    public ClientRequest migrate(PersistentRequestClient newClient, ObjectContainer container,
            NodeClientCore core) throws IdentifierCollisionException, NotAllowedException,
            IOException, ResumeFailedException, TooManyFilesInsertException {
        ClientContext context = core.clientContext;
        container.activate(manifestElements, Integer.MAX_VALUE);
        migrateManifestElements(manifestElements, context.getBucketFactory(true), context);
        container.activate(uri, Integer.MAX_VALUE);
        container.activate(ctx, Integer.MAX_VALUE);
        freenet.clients.fcp.ClientPutDir put =
            new freenet.clients.fcp.ClientPutDir(newClient, uri, identifier, verbosity,
                priorityClass, Persistence.FOREVER, clientToken, ctx.getCHKOnly, ctx.dontCompress,
View Full Code Here

Examples of juzu.request.ClientContext

        }
      }
      contextualArguments.putAll(request.bridge.getContextualArguments(contextualArguments.keySet()));

      //
      ClientContext clientContext = request.bridge.getClientContext();
      if (clientContext != null) {
        String contentType = clientContext.getContentType();
        if (contentType != null) {
          Spliterator i = new Spliterator(contentType, ';');

          //
          String mediaType;
View Full Code Here

Examples of org.apache.hadoop.hdfs.ClientContext

      int readOffset, String readingUser, Configuration conf,
      boolean legacyShortCircuitFails)
      throws IOException, InterruptedException {
    // Ensure short circuit is enabled
    DistributedFileSystem fs = getFileSystem(readingUser, uri, conf);
    ClientContext getClientContext = ClientContext.getFromConf(conf);
    if (legacyShortCircuitFails) {
      assertFalse(getClientContext.getDisableLegacyBlockReaderLocal());
    }
   
    FSDataInputStream stm = fs.open(name);
    byte[] actual = new byte[expected.length-readOffset];
    stm.readFully(readOffset, actual);
    checkData(actual, readOffset, expected, "Read 2");
    stm.close();
    // Now read using a different API.
    actual = new byte[expected.length-readOffset];
    stm = fs.open(name);
    IOUtils.skipFully(stm, readOffset);
    //Read a small number of bytes first.
    int nread = stm.read(actual, 0, 3);
    nread += stm.read(actual, nread, 2);
    //Read across chunk boundary
    nread += stm.read(actual, nread, 517);
    checkData(actual, readOffset, expected, nread, "A few bytes");
    //Now read rest of it
    while (nread < actual.length) {
      int nbytes = stm.read(actual, nread, actual.length - nread);
      if (nbytes < 0) {
        throw new EOFException("End of file reached before reading fully.");
      }
      nread += nbytes;
    }
    checkData(actual, readOffset, expected, "Read 3");
   
    if (legacyShortCircuitFails) {
      assertTrue(getClientContext.getDisableLegacyBlockReaderLocal());
    }
    stm.close();
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.ClientContext

      int readOffset, String readingUser, Configuration conf,
      boolean legacyShortCircuitFails)
      throws IOException, InterruptedException {
    // Ensure short circuit is enabled
    DistributedFileSystem fs = getFileSystem(readingUser, uri, conf);
    ClientContext clientContext = ClientContext.getFromConf(conf);
    if (legacyShortCircuitFails) {
      assertTrue(clientContext.getDisableLegacyBlockReaderLocal());
    }
   
    HdfsDataInputStream stm = (HdfsDataInputStream)fs.open(name);

    ByteBuffer actual = ByteBuffer.allocateDirect(expected.length - readOffset);

    IOUtils.skipFully(stm, readOffset);

    actual.limit(3);

    //Read a small number of bytes first.
    int nread = stm.read(actual);
    actual.limit(nread + 2);
    nread += stm.read(actual);

    // Read across chunk boundary
    actual.limit(Math.min(actual.capacity(), nread + 517));
    nread += stm.read(actual);
    checkData(arrayFromByteBuffer(actual), readOffset, expected, nread,
        "A few bytes");
    //Now read rest of it
    actual.limit(actual.capacity());
    while (actual.hasRemaining()) {
      int nbytes = stm.read(actual);

      if (nbytes < 0) {
        throw new EOFException("End of file reached before reading fully.");
      }
      nread += nbytes;
    }
    checkData(arrayFromByteBuffer(actual), readOffset, expected, "Read 3");
    if (legacyShortCircuitFails) {
      assertTrue(clientContext.getDisableLegacyBlockReaderLocal());
    }
    stm.close();
  }
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.