List of usage examples for com.google.common.io CountingOutputStream CountingOutputStream
public CountingOutputStream(OutputStream out)
From source file:com.google.cloud.dataflow.sdk.runners.worker.DataflowApiUtils.java
/** * Determines the serialized size (in bytes) of the {@link GenericJson} object that will be * serialized and sent to the Google Cloud Dataflow service API. * * <p>Uses only constant memory./*from w w w .ja v a 2 s. c o m*/ */ public static long computeSerializedSizeBytes(GenericJson object) throws IOException { JsonFactory factory = object.getFactory(); if (factory == null) { factory = Transport.getJsonFactory(); } CountingOutputStream stream = new CountingOutputStream(ByteStreams.nullOutputStream()); JsonGenerator generator = null; try { generator = factory.createJsonGenerator(stream, StandardCharsets.UTF_8); generator.serialize(object); generator.close(); // also closes the stream. } finally { if (generator != null) { generator.close(); } } return stream.getCount(); }
From source file:ua.pp.msk.yum.createrepoutils.OutputXmlStream.java
OutputXmlStream(final OutputStream stream) throws NoSuchAlgorithmException, IOException { compressedDigestStream = new DigestOutputStream(stream, MessageDigest.getInstance("SHA-256")); compressedSizeStream = new CountingOutputStream(compressedDigestStream); openDigestStream = new DigestOutputStream(new GZIPOutputStream(compressedSizeStream), MessageDigest.getInstance("SHA-256")); openSizeStream = new CountingOutputStream(openDigestStream); }
From source file:io.airlift.slice.OutputStreamSliceOutput.java
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") public OutputStreamSliceOutput(OutputStream outputStream) { checkNotNull(outputStream, "outputStream is null"); countingOutputStream = new CountingOutputStream(outputStream); dataOutputStream = new LittleEndianDataOutputStream(countingOutputStream); }
From source file:com.netflix.servo.example.BaseHandler.java
public void handle(HttpExchange exchange) throws IOException { CountingInputStream input = new CountingInputStream(exchange.getRequestBody()); CountingOutputStream output = new CountingOutputStream(exchange.getResponseBody()); exchange.setStreams(input, output);/*from ww w.java 2 s. c o m*/ Stopwatch stopwatch = latency.start(); try { handleImpl(exchange); } finally { stopwatch.stop(); bytesReceived.increment(input.getCount()); bytesSent.increment(output.getCount()); } }
From source file:io.druid.segment.data.ByteBufferWriter.java
public void open() throws IOException { headerOut = new CountingOutputStream(ioPeon.makeOutputStream(makeFilename("header"))); valueOut = new CountingOutputStream(ioPeon.makeOutputStream(makeFilename("value"))); }
From source file:org.gradle.cache.internal.btree.ByteOutput.java
/** * Starts writing to the given offset. Can be beyond the current length of the file. */// w w w. j a va 2 s.c om public DataOutputStream start(long offset) throws IOException { file.seek(offset); bufferedOutputStream.clear(); countingOutputStream = new CountingOutputStream(bufferedOutputStream); return new DataOutputStream(countingOutputStream); }
From source file:org.apache.hadoop.hive.ql.io.slice.OutputStreamSliceOutput.java
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed") public OutputStreamSliceOutput(OutputStream outputStream) { countingOutputStream = new CountingOutputStream(outputStream); dataOutputStream = new LittleEndianDataOutputStream(countingOutputStream); }
From source file:io.druid.segment.data.VSizeIndexedIntsWriter.java
@Override public void open() throws IOException { valuesOut = new CountingOutputStream(ioPeon.makeOutputStream(valueFileName)); }
From source file:io.druid.segment.data.EntireLayoutLongSupplierSerializer.java
@Override public void open() throws IOException { valuesOut = new CountingOutputStream(ioPeon.makeOutputStream(valueFile)); writer.setOutputStream(valuesOut);// w ww. ja v a2 s. c om }
From source file:io.druid.segment.data.EntireLayoutFloatSupplierSerializer.java
@Override public void open() throws IOException { valuesOut = new CountingOutputStream(ioPeon.makeOutputStream(valueFile)); }