Examples of PipedOutputStream


Examples of java.io.PipedOutputStream

      onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), state, context);
      return;
    }

    PipedInputStream pipeIn = null;
    PipedOutputStream pipeOut = null;
    try {
      output = finalResult.getOutputStream();
      // Decompress
      if(decompressors != null) {
        if(logMINOR) Logger.minor(this, "Decompressing...");
        pipeIn = new PipedInputStream();
        pipeOut = new PipedOutputStream(pipeIn);
        decompressorManager = new DecompressorThreadManager(pipeIn, decompressors, maxLen);
        pipeIn = decompressorManager.execute();
        ClientGetWorkerThread worker = new ClientGetWorkerThread(new BufferedInputStream(pipeIn), output, null, null, null, false, null, null, null, context.linkFilterExceptionProvider);
        worker.start();
        streamGenerator.writeTo(pipeOut, context);
        worker.waitFinished();
        // If this throws, we want the whole request to fail.
        pipeOut.close(); pipeOut = null;
      } else {
          streamGenerator.writeTo(output, context);
          // If this throws, we want the whole request to fail.
          output.close(); output = null;
      }
View Full Code Here

Examples of java.io.PipedOutputStream

   
    @Override
    public void onSuccess(StreamGenerator streamGenerator, ClientMetadata clientMetadata, List<? extends Compressor> decompressors, ClientGetState state, ClientContext context) {
      OutputStream output = null;
      PipedInputStream pipeIn = new PipedInputStream();
      PipedOutputStream pipeOut = new PipedOutputStream();
      Bucket data = null;
      // FIXME not strictly correct and unnecessary - archive size already checked against ctx.max*Length inside SingleFileFetcher
      long maxLen = Math.min(ctx.maxTempLength, ctx.maxOutputLength);
      try {
        data = context.getBucketFactory(persistent).makeBucket(maxLen);
        output = data.getOutputStream();
        if(decompressors != null) {
          if(logMINOR) Logger.minor(this, "decompressing...");
          pipeOut.connect(pipeIn);
          DecompressorThreadManager decompressorManager =  new DecompressorThreadManager(pipeIn, decompressors, maxLen);
          pipeIn = decompressorManager.execute();
          ClientGetWorkerThread worker = new ClientGetWorkerThread(new BufferedInputStream(pipeIn), output, null, null, null, false, null, null, null, context.linkFilterExceptionProvider);
          worker.start();
          streamGenerator.writeTo(pipeOut, context);
          decompressorManager.waitFinished();
          worker.waitFinished();
        } else streamGenerator.writeTo(output, context);
        // We want to see anything thrown when these are closed.
        output.close(); output = null;
        pipeOut.close(); pipeOut = null;
        pipeIn.close(); pipeIn = null;
      } catch (Throwable t) {
        Logger.error(this, "Caught "+t, t);
        onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), state, context);
        return;
View Full Code Here

Examples of java.io.PipedOutputStream

        ClientMetadata clientMetadata,
        List<? extends Compressor> decompressors, ClientGetState state,
        ClientContext context) {
      OutputStream output = null;
      PipedInputStream pipeIn = new PipedInputStream();
      PipedOutputStream pipeOut = new PipedOutputStream();
      Bucket data = null;
      long maxLen = Math.max(ctx.maxTempLength, ctx.maxOutputLength);
      try {
        data = context.getBucketFactory(false).makeBucket(maxLen);
        output = data.getOutputStream();
        if(decompressors != null) {
          if(logMINOR) Logger.minor(this, "decompressing...");
          pipeOut.connect(pipeIn);
          DecompressorThreadManager decompressorManager =  new DecompressorThreadManager(pipeIn, decompressors, maxLen);
          pipeIn = decompressorManager.execute();
          ClientGetWorkerThread worker = new ClientGetWorkerThread(new BufferedInputStream(pipeIn), output, null, null, null, false, null, null, null, context.linkFilterExceptionProvider);
          worker.start();
          streamGenerator.writeTo(pipeOut, context);
          decompressorManager.waitFinished();
          worker.waitFinished();
        } else streamGenerator.writeTo(output, context);

        output.close();
        pipeOut.close();
        pipeIn.close();
        output = null;
        pipeOut = null;
        pipeIn = null;
       
View Full Code Here

Examples of java.io.PipedOutputStream

   
    @Override
    public void onSuccess(StreamGenerator streamGenerator, ClientMetadata clientMetadata, List<? extends Compressor> decompressors, ClientGetState state, ClientContext context) {
      OutputStream output = null;
      PipedInputStream pipeIn = new PipedInputStream();
      PipedOutputStream pipeOut = new PipedOutputStream();
      Bucket finalData = null;
      // does matter only on pre-1255 keys (1255 keys have top block sizes)
      // FIXME would save at most few tics on decompression
      // and block allocation;
      // To be effective should try guess minimal possible size earlier by the number of segments
View Full Code Here

Examples of java.io.PipedOutputStream

        }

        @Override
        protected FileListProvider openFileList(String targetName) throws IOException {
            final PipedInputStream remoteStdin = new PipedInputStream();
            final PipedOutputStream remoteStdout = new PipedOutputStream();
            final PipedOutputStream upstream = new PipedOutputStream(remoteStdin);
            final PipedInputStream downstream = new PipedInputStream(remoteStdout);

            final Future<Void> future = Executors.newFixedThreadPool(1).submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
View Full Code Here

Examples of java.io.PipedOutputStream

                String targetName,
                String batchId,
                String jobflowId,
                String executionId) throws IOException {
            final PipedInputStream remoteStdin = new PipedInputStream();
            final PipedOutputStream remoteStdout = new PipedOutputStream();
            final PipedOutputStream upstream = new PipedOutputStream(remoteStdin);
            final PipedInputStream downstream = new PipedInputStream(remoteStdout);

            final Future<Void> future = Executors.newFixedThreadPool(1).submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
View Full Code Here

Examples of java.io.PipedOutputStream

        ClientSession session = client.connect("localhost", port).await().getSession();
        session.authPassword("smx", "smx").await().isSuccess();
        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);

        ByteArrayOutputStream sent = new ByteArrayOutputStream();
        PipedOutputStream pipedIn = new PipedOutputStream();
        channel.setIn(new PipedInputStream(pipedIn));
        OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel.setOut(out);
View Full Code Here

Examples of java.io.PipedOutputStream

        session.authPassword("smx", "smx").await().isSuccess();
        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);


        ByteArrayOutputStream sent = new ByteArrayOutputStream();
        PipedOutputStream pipedIn = new PipedOutputStream();
        OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
        channel.setIn(new PipedInputStream(pipedIn));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel.setOut(out);
View Full Code Here

Examples of java.io.PipedOutputStream

        client.start();
        ClientSession session = client.connect("localhost", port).await().getSession();
        session.authPassword("smx", "smx");
        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
        ByteArrayOutputStream sent = new ByteArrayOutputStream();
        PipedOutputStream pipedIn = new PipedOutputStream();
        OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
        channel.setIn(new PipedInputStream(pipedIn));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel.setOut(out);
View Full Code Here

Examples of java.io.PipedOutputStream

        ClientSession session = client.connect("localhost", port).await().getSession();
        session.authPassword("smx", "smx").await().isSuccess();
        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
        session.close(false);

        PipedOutputStream pipedIn = new PipedOutputStream();
        channel.setIn(new PipedInputStream(pipedIn));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayOutputStream err = new ByteArrayOutputStream();
        channel.setOut(out);
        channel.setErr(err);
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.