Called after the super class has written the headers and created any associated stream objects.
@param compressor The compressor associated with the stream identified by {@code streamId}.
@param streamId The stream id for which the headers were written.
558540
private void bindCompressorToStream(EmbeddedChannel compressor, int streamId) {
        if (compressor != null) {
            Http2Stream stream = connection().stream(streamId);
            if (stream != null) {
                stream.setProperty(propertyKey, compressor);
            }
        }
    }
1350904
private boolean isStreamPresentAndWritable(int streamId) {
        final Http2Stream stream = encoder.connection().stream(streamId);
        if (stream == null) {
            return false;
        }

        switch (stream.state()) {
            case RESERVED_LOCAL:
            case OPEN:
            case HALF_CLOSED_REMOTE:
                return true;
            default:
                // The response has been sent already.
                return false;
        }
    }
996675
public static void serialize(SerializationStreamWriter streamWriter, CmsUUID instance)
    throws SerializationException {

        streamWriter.writeString(instance.toString());
    }
1185888
public void encode(OutputStream out) throws IOException {
         DerOutputStream tmp = new DerOutputStream();
         if (extensionValue == null) {
             this.extensionId = PKIXExtensions.BasicConstraints_Id;
             if (ca) {
                 critical = true;
             } else {
                 critical = false;
             }
             encodeThis();
         }
         super.encode(tmp);

         out.write(tmp.toByteArray());
     }
1036437
void cleanup(Http2Stream stream, EmbeddedChannel compressor) {
        if (compressor.finish()) {
            for (;;) {
                final ByteBuf buf = compressor.readOutbound();
                if (buf == null) {
                    break;
                }

                buf.release();
            }
        }
        stream.removeProperty(propertyKey);
    }
906841
public <T> void registerWriter(JsonWriterI<T> writer, Class<?>... cls) {
		for (Class<?> c : cls)
			data.put(c, writer);
	}

	/**
	 * Write a Key : value entry to a stream
	 */
	public static void writeJSONKV(String key, Object value, Appendable out, JSONStyle compression) throws IOException {
		if (key == null)
			out.append("null");
		else if (!compression.mustProtectKey(key))
			out.append(key);
		else {
			out.append('"');
			JSONValue.escape(key, out, compression);
			out.append('"');
		}
		compression.objectEndOfKey(out);
		if (value instanceof String) {
			compression.writeString(out, (String) value);
		} else
			JSONValue.writeJSONString(value, out, compression);
		compression.objectElmStop(out);
	}
224190
public static void encodeHeaderByte(IoBuffer out, byte headerSize, int channelId) {
        if (channelId <= 63) {
            out.put((byte) ((headerSize << 6) + channelId));
        } else if (channelId <= 319) {
            out.put((byte) (headerSize << 6));
            out.put((byte) (channelId - 64));
        } else {
            out.put((byte) ((headerSize << 6) | 1));
            channelId -= 64;
            out.put((byte) (channelId & 0xff));
            out.put((byte) (channelId >> 8));
        }
    }
1012229
@NotThreadsafe
    private void initFileStreams(int chunkId) {
        /**
         * {@link Set#add(Object)} returns false if the element already existed in the set.
         * This ensures we initialize the resources for each chunk only once.
         */
        if (chunksHandled.add(chunkId)) {
            try {
                this.indexFileSizeInBytes[chunkId] = 0L;
                this.valueFileSizeInBytes[chunkId] = 0L;
                this.checkSumDigestIndex[chunkId] = CheckSum.getInstance(checkSumType);
                this.checkSumDigestValue[chunkId] = CheckSum.getInstance(checkSumType);
                this.position[chunkId] = 0;
                this.taskIndexFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf),
                                                           getStoreName() + "."
                                                                   + Integer.toString(chunkId) + "_"
                                                                   + this.taskId + INDEX_FILE_EXTENSION
                                                                   + fileExtension);
                this.taskValueFileName[chunkId] = new Path(FileOutputFormat.getOutputPath(conf),
                                                           getStoreName() + "."
                                                                   + Integer.toString(chunkId) + "_"
                                                                   + this.taskId + DATA_FILE_EXTENSION
                                                                   + fileExtension);
                if(this.fs == null)
                    this.fs = this.taskIndexFileName[chunkId].getFileSystem(conf);
                if(isValidCompressionEnabled) {
                    this.indexFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskIndexFileName[chunkId]),
                                                                                                                       DEFAULT_BUFFER_SIZE)));
                    this.valueFileStream[chunkId] = new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(fs.create(this.taskValueFileName[chunkId]),
                                                                                                                       DEFAULT_BUFFER_SIZE)));

                } else {
                    this.indexFileStream[chunkId] = fs.create(this.taskIndexFileName[chunkId]);
                    this.valueFileStream[chunkId] = fs.create(this.taskValueFileName[chunkId]);

                }
                fs.setPermission(this.taskIndexFileName[chunkId],
                                 new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION));
                logger.info("Setting permission to 755 for " + this.taskIndexFileName[chunkId]);
                fs.setPermission(this.taskValueFileName[chunkId],
                                 new FsPermission(HadoopStoreBuilder.HADOOP_FILE_PERMISSION));
                logger.info("Setting permission to 755 for " + this.taskValueFileName[chunkId]);

                logger.info("Opening " + this.taskIndexFileName[chunkId] + " and "
                                    + this.taskValueFileName[chunkId] + " for writing.");
            } catch(IOException e) {
                throw new RuntimeException("Failed to open Input/OutputStream", e);
            }
        }
    }
937357
private void write(IRTMPEvent event, Number streamId) {
        log.trace("write to stream id: {} channel: {}", streamId, id);
        final Header header = new Header();
        final Packet packet = new Packet(header, event);
        // set the channel id
        header.setChannelId(id);
        int ts = event.getTimestamp();
        if (ts != 0) {
            header.setTimer(event.getTimestamp());
        }
        header.setStreamId(streamId);
        header.setDataType(event.getDataType());
        // should use RTMPConnection specific method.. 
        //log.trace("Connection type for write: {}", connection.getClass().getName());
        connection.write(packet);
    }
305436
public void compress(Stream<Path> paths) throws IOException
    {
        boolean first = true;
        Iterator<Path> it = paths.iterator();
        while (it.hasNext())
        {
            Path p = it.next();
            if (Files.isRegularFile(path))
            {
                setFilename(p.getFileName().toString());
                setLastModified(Files.getLastModifiedTime(p));
                if (!first)
                {
                    nextOutput();
                }
                first = false;
                OutputStream os = Channels.newOutputStream(this);
                Files.copy(p, os);
            }
            else
            {
                throw new IOException(p+" is not a regular file");
            }
        }
        close();
    }
850130
public void write_compressed(final OtpErlangObject o, final int level) {
        @SuppressWarnings("resource")
        final OtpOutputStream oos = new OtpOutputStream(o);
        /*
         * similar to erts_term_to_binary() in external.c: We don't want to
         * compress if compression actually increases the size. Since
         * compression uses 5 extra bytes (COMPRESSED tag + size), don't
         * compress if the original term is smaller.
         */
        if (oos.size() < 5) {
            // fast path for small terms
            try {
                oos.writeToAndFlush(this);
                // if the term is written as a compressed term, the output
                // stream is closed, so we do this here, too
                close();
            } catch (final IOException e) {
                throw new java.lang.IllegalArgumentException(
                        "Intermediate stream failed for Erlang object " + o);
            }
        } else {
            final int startCount = super.count;
            // we need destCount bytes for an uncompressed term
            // -> if compression uses more, use the uncompressed term!
            final int destCount = startCount + oos.size();
            fixedSize = destCount;
            final Deflater def = new Deflater(level);
            final java.util.zip.DeflaterOutputStream dos = new java.util.zip.DeflaterOutputStream(
                    this, def);
            try {
                write1(OtpExternal.compressedTag);
                write4BE(oos.size());
                oos.writeTo(dos);
                dos.close(); // note: closes this, too!
            } catch (final IllegalArgumentException e) {
                /*
                 * Discard further un-compressed data (if not called, there may
                 * be memory leaks).
                 *
                 * After calling java.util.zip.Deflater.end(), the deflater
                 * should not be used anymore, not even the close() method of
                 * dos. Calling dos.close() before def.end() is prevented since
                 * an unfinished DeflaterOutputStream will try to deflate its
                 * unprocessed data to the (fixed) byte array which is prevented
                 * by ensureCapacity() and would also unnecessarily process
                 * further data that is discarded anyway.
                 *
                 * Since we are re-using the byte array of this object below, we
                 * must not call close() in e.g. a finally block either (with or
                 * without a call to def.end()).
                 */
                def.end();
                // could not make the value smaller than originally
                // -> reset to starting count, write uncompressed
                super.count = startCount;
                try {
                    oos.writeTo(this);
                    // if the term is written as a compressed term, the output
                    // stream is closed, so we do this here, too
                    close();
                } catch (final IOException e2) {
                    throw new java.lang.IllegalArgumentException(
                            "Intermediate stream failed for Erlang object " + o);
                }
            } catch (final IOException e) {
                throw new java.lang.IllegalArgumentException(
                        "Intermediate stream failed for Erlang object " + o);
            } finally {
                fixedSize = Integer.MAX_VALUE;
            }
        }
    }
385061
public static void compressTar(Resource[] sources, Resource target, int mode) throws IOException {
	compressTar(sources, IOUtil.toBufferedOutputStream(target.getOutputStream()), mode);
    }
275950
@Override
  public Compressor createCompressor() {
    if (!isNativeCodeLoaded()) {
      throw new RuntimeException("native lz4 library not available");
    }
    int bufferSize = conf.getInt(
        IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_KEY,
        IO_COMPRESSION_CODEC_LZ4_BUFFERSIZE_DEFAULT);
    boolean useLz4HC = conf.getBoolean(
        IO_COMPRESSION_CODEC_LZ4_USELZ4HC_KEY,
        IO_COMPRESSION_CODEC_LZ4_USELZ4HC_DEFAULT); 
    return new Lz4Compressor(bufferSize, useLz4HC);
  }
206661
protected void updateHighestStreamId(int proposedHighestStreamId) throws ProtocolException {
        if ((proposedHighestStreamId & 1) == 0) { // even number, server-initialized stream
            if (proposedHighestStreamId > highestLocalStreamId) {
                highestLocalStreamId = proposedHighestStreamId;
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "highestLocalStreamId set to stream-id: " + proposedHighestStreamId);
                }
            } else if (proposedHighestStreamId < highestLocalStreamId) {
                throw new ProtocolException("received a new stream with a lower ID than previous; "
                                            + "current stream-id: " + proposedHighestStreamId + " highest stream-id: "
                                            + highestLocalStreamId);
            }
        } else {
            if (proposedHighestStreamId > highestClientStreamId) {
                highestClientStreamId = proposedHighestStreamId;
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "highestClientStreamId set to stream-id: " + proposedHighestStreamId);
                }
            } else if (proposedHighestStreamId < highestClientStreamId) {
                throw new ProtocolException("received a new stream with a lower ID than previous; "
                                            + "current stream-id: " + proposedHighestStreamId + " highest stream-id: "
                                            + highestClientStreamId);
            }
        }
    }
1153444
private static void _compressBZip2(InputStream source, OutputStream target) throws IOException {

	InputStream is = IOUtil.toBufferedInputStream(source);
	OutputStream os = new BZip2CompressorOutputStream(IOUtil.toBufferedOutputStream(target));
	IOUtil.copy(is, os, true, true);
    }
692371
protected OutputStream createOutputStream (File target)
        throws IOException
    {
        JarOutputStream jout = new JarOutputStream(new FileOutputStream(target));
        jout.setLevel(Deflater.BEST_COMPRESSION);
        return jout;
    }
1352313
public OutputStream createOutputStream(Number streamId) {
        int channelId = getChannelIdForStreamId(streamId);
        if (log.isTraceEnabled()) {
            log.trace("Create output - stream id: {} channel id: {}", streamId, channelId);
        }
        final Channel data = getChannel(channelId++);
        final Channel video = getChannel(channelId++);
        final Channel audio = getChannel(channelId++);
        if (log.isTraceEnabled()) {
            log.trace("Output stream - data: {} video: {} audio: {}", data, video, audio);
        }
        return new OutputStream(video, audio, data);
    }