@Override public void write(OutputStream outputStream) throws WebApplicationException { Exception e = null; CountingOutputStream os = new CountingOutputStream(outputStream); try { // json serializer will always close the yielder jsonWriter.writeValue(os, yielder); os.flush(); // Some types of OutputStream suppress flush errors in the .close() method. os.close(); } catch (Exception ex) { e = ex; log.error(ex, "Unable to send query response."); throw Throwables.propagate(ex); } finally { Thread.currentThread().setName(currThreadName); queryLifecycle.emitLogsAndMetrics(e, req.getRemoteAddr(), os.getCount()); if (e == null) { successfulQueryCount.incrementAndGet(); } else { failedQueryCount.incrementAndGet(); } } } },
@Override public void flush() throws IOException { countingOutputStream.flush(); }
@Override public void flush() throws IOException { countingOutputStream.flush(); }
@Override public void write(OutputStream outputStream) throws IOException, WebApplicationException { Exception e = null; CountingOutputStream os = new CountingOutputStream(outputStream); try { // json serializer will always close the yielder jsonWriter.writeValue(os, yielder); os.flush(); // Some types of OutputStream suppress flush errors in the .close() method. os.close(); } catch (Exception ex) { e = ex; log.error(ex, "Unable to send query response."); throw Throwables.propagate(ex); } finally { Thread.currentThread().setName(currThreadName); queryLifecycle.emitLogsAndMetrics(e, req.getRemoteAddr(), os.getCount()); if (e == null) { successfulQueryCount.incrementAndGet(); } else { failedQueryCount.incrementAndGet(); } } } },
@Override public void write(OutputStream outputStream) throws WebApplicationException { Exception e = null; CountingOutputStream os = new CountingOutputStream(outputStream); try { // json serializer will always close the yielder jsonWriter.writeValue(os, yielder); os.flush(); // Some types of OutputStream suppress flush errors in the .close() method. os.close(); } catch (Exception ex) { e = ex; log.error(ex, "Unable to send query response."); throw Throwables.propagate(ex); } finally { Thread.currentThread().setName(currThreadName); queryLifecycle.emitLogsAndMetrics(e, req.getRemoteAddr(), os.getCount()); if (e == null) { successfulQueryCount.incrementAndGet(); } else { failedQueryCount.incrementAndGet(); } } } },
@Override protected void encode(OutputStream out) { if (packer != null && deduplicator != null) { CountingOutputStream counting = new CountingOutputStream(out); OutputStream output = counting; try { ObjectFunnel funnel; funnel = ObjectFunnels.newFunnel(output, DataStreamSerializationFactoryV1.INSTANCE); packer.write(funnel, want, have, false, deduplicator); counting.flush(); funnel.close(); } catch (Exception e) { throw new RuntimeException(e); } finally { deduplicator.release(); } } }
public void write(InputStream is) throws IOException { CRCInputStream crc = new CRCInputStream(is); GZIPHeader gzHeader = new GZIPHeader(); // TODO: add fields... gzHeader.writeBytes(out); Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); DeflaterOutputStream deflateOut = new DeflaterOutputStream(out,deflater); StreamCopy.copy(crc, deflateOut); deflateOut.finish(); GZIPFooter gzFooter = new GZIPFooter(crc.getCRCValue(), crc.getByteCount()); gzFooter.writeBytes(out); out.flush(); }
public void write(InputStream is) throws IOException { CRCInputStream crc = new CRCInputStream(is); GZIPHeader gzHeader = new GZIPHeader(); // TODO: add fields... gzHeader.writeBytes(out); Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); DeflaterOutputStream deflateOut = new DeflaterOutputStream(out,deflater); StreamCopy.copy(crc, deflateOut); deflateOut.finish(); GZIPFooter gzFooter = new GZIPFooter(crc.getCRCValue(), crc.getByteCount()); gzFooter.writeBytes(out); out.flush(); }
public void write(InputStream is) throws IOException { CRCInputStream crc = new CRCInputStream(is); GZIPHeader gzHeader = new GZIPHeader(); // TODO: add fields... gzHeader.writeBytes(out); Deflater deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true); DeflaterOutputStream deflateOut = new DeflaterOutputStream(out,deflater); StreamCopy.copy(crc, deflateOut); deflateOut.finish(); GZIPFooter gzFooter = new GZIPFooter(crc.getCRCValue(), crc.getByteCount()); gzFooter.writeBytes(out); out.flush(); }
break; countingStream.flush(); long serializationTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - serializationStart); pm.setSerializationTime(serializationTime);