public Frame with(ByteBuf newBody) { return new Frame(header, newBody); }
public Frame decompress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); int uncompressedLength = ((input[0] & 0xFF) << 24) | ((input[1] & 0xFF) << 16) | ((input[2] & 0xFF) << 8) | ((input[3] & 0xFF)); ByteBuf output = CBUtil.allocator.heapBuffer(uncompressedLength); try { int read = decompressor.decompress(input, INTEGER_BYTES, output.array(), output.arrayOffset(), uncompressedLength); if (read != input.length - INTEGER_BYTES) throw new IOException("Compressed lengths mismatch"); output.writerIndex(uncompressedLength); return frame.with(output); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } } }
channel.flush(); for (FlushItem item : flushed) item.sourceFrame.release();
results.add(Frame.create(message.type, message.getStreamId(), version, flags, body));
public Frame decompress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); int uncompressedLength = ((input[0] & 0xFF) << 24) | ((input[1] & 0xFF) << 16) | ((input[2] & 0xFF) << 8) | ((input[3] & 0xFF)); ByteBuf output = CBUtil.allocator.heapBuffer(uncompressedLength); try { int read = decompressor.decompress(input, INTEGER_BYTES, output.array(), output.arrayOffset(), uncompressedLength); if (read != input.length - INTEGER_BYTES) throw new IOException("Compressed lengths mismatch"); output.writerIndex(uncompressedLength); return frame.with(output); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } } }
channel.flush(); for (FlushItem item : flushed) item.sourceFrame.release();
flags.add(Frame.Header.Flag.USE_BETA); results.add(Frame.create(message.type, message.getStreamId(), responseVersion, flags, body));
public Frame decompress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); int uncompressedLength = ((input[0] & 0xFF) << 24) | ((input[1] & 0xFF) << 16) | ((input[2] & 0xFF) << 8) | ((input[3] & 0xFF)); ByteBuf output = CBUtil.allocator.heapBuffer(uncompressedLength); try { int read = decompressor.decompress(input, INTEGER_BYTES, output.array(), output.arrayOffset(), uncompressedLength); if (read != input.length - INTEGER_BYTES) throw new IOException("Compressed lengths mismatch"); output.writerIndex(uncompressedLength); return frame.with(output); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } } }
public Frame with(ByteBuf newBody) { return new Frame(header, newBody); }
channel.flush(); for (FlushItem item : flushed) item.sourceFrame.release();
flags.add(Frame.Header.Flag.USE_BETA); results.add(Frame.create(message.type, message.getStreamId(), responseVersion, flags, body));
public Frame compress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); ByteBuf output = CBUtil.allocator.heapBuffer(Snappy.maxCompressedLength(input.length)); try { int written = Snappy.compress(input, 0, input.length, output.array(), output.arrayOffset()); output.writerIndex(written); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } return frame.with(output); }
public Frame with(ByteBuf newBody) { return new Frame(header, newBody); }
channel.flush(); for (FlushItem item : flushed) item.sourceFrame.release();
flags.add(Frame.Header.Flag.USE_BETA); results.add(Frame.create(message.type, message.getStreamId(), responseVersion, flags, body));
public Frame compress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); ByteBuf output = CBUtil.allocator.heapBuffer(Snappy.maxCompressedLength(input.length)); try { int written = Snappy.compress(input, 0, input.length, output.array(), output.arrayOffset()); output.writerIndex(written); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } return frame.with(output); }
public Frame with(ByteBuf newBody) { return new Frame(header, newBody); }
public Frame compress(Frame frame) throws IOException { byte[] input = CBUtil.readRawBytes(frame.body); ByteBuf output = CBUtil.allocator.heapBuffer(Snappy.maxCompressedLength(input.length)); try { int written = Snappy.compress(input, 0, input.length, output.array(), output.arrayOffset()); output.writerIndex(written); } catch (final Throwable e) { output.release(); throw e; } finally { //release the old frame frame.release(); } return frame.with(output); }
public static Frame create(Message.Type type, int streamId, ProtocolVersion version, EnumSet<Header.Flag> flags, ByteBuf body) { Header header = new Header(version, flags, streamId, type); return new Frame(header, body); }