@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); ObjectOutputStream oout = null; try { bout.write(LENGTH_PLACEHOLDER); oout = new CompactObjectOutputStream(bout); oout.writeObject(msg); oout.flush(); } finally { if (oout != null) { oout.close(); } else { bout.close(); } } int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }
protected static void encodeRow( final ByteBufOutputStream out, final GeoWaveRedisPersistedRow row, final boolean visibilityEnabled) throws IOException { out.writeByte(row.getDataId().length); out.writeByte(row.getFieldMask().length); if (visibilityEnabled) { out.writeByte(row.getVisibility().length); } Varint.writeUnsignedVarInt(row.getValue().length, out); out.writeByte(row.getNumDuplicates()); out.write(row.getDataId()); out.write(row.getFieldMask()); if (visibilityEnabled) { out.write(row.getVisibility()); } out.write(row.getValue()); }
@SneakyThrows(IOException.class) private void writeMessage(AppendBlock block, ByteBuf out) { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); bout.writeInt(block.getType().getCode()); bout.write(LENGTH_PLACEHOLDER); block.writeFields(bout); bout.flush(); bout.close(); int endIdx = out.writerIndex(); int fieldsSize = endIdx - startIdx - TYPE_PLUS_LENGTH_SIZE; out.setInt(startIdx + TYPE_SIZE, fieldsSize + currentBlockSize); }
@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); ObjectOutputStream oout = null; try { bout.write(LENGTH_PLACEHOLDER); oout = new CompactObjectOutputStream(bout); oout.writeObject(msg); oout.flush(); } finally { if (oout != null) { oout.close(); } else { bout.close(); } } int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }
@SneakyThrows(IOException.class) private int writeMessage(WireCommand msg, ByteBuf out) { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); bout.writeInt(msg.getType().getCode()); bout.write(LENGTH_PLACEHOLDER); msg.writeFields(bout); bout.flush(); bout.close(); int endIdx = out.writerIndex(); int fieldsSize = endIdx - startIdx - TYPE_PLUS_LENGTH_SIZE; out.setInt(startIdx + TYPE_SIZE, fieldsSize); return endIdx - startIdx; }
@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); ObjectOutputStream oout = null; try { bout.write(LENGTH_PLACEHOLDER); oout = new CompactObjectOutputStream(bout); oout.writeObject(msg); oout.flush(); } finally { if (oout != null) { oout.close(); } else { bout.close(); } } int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }
@Override public void write(byte[] b, int offset, int len) throws IOException { this.out.write(b, offset, len); }
@Override public void write(byte[] b, int offset, int len) throws IOException { this.out.write(b, offset, len); }
@Override public void write(int b) throws IOException { this.out.write(b); }
@Override public void write(int b) throws IOException { this.out.write(b); }
@Override public void write(byte[] b) throws IOException { this.out.write(b); }
@Override public void write(int b) throws IOException { this.out.write(b); } }
@Override public void write(byte[] b, int offset, int len) throws IOException { this.out.write(b, offset, len); }
@Override public void write(int b) throws IOException { m_bufoutputstream.write(b); }
@Override public void write(byte[] b) throws IOException { this.out.write(b); }
@Override public void write(byte[] b) throws IOException { this.out.write(b); }
@Override public void write(int b) throws IOException { this.out.write(b); }
@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); ObjectOutputStream oout = null; try { bout.write(LENGTH_PLACEHOLDER); oout = new CompactObjectOutputStream(bout); oout.writeObject(msg); oout.flush(); } finally { if (oout != null) { oout.close(); } else { bout.close(); } } int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }
public void encode(final ByteBuf out, final Object message) throws IOException { ByteBufOutputStream bout = new ByteBufOutputStream(out); bout.write(LENGTH_PLACEHOLDER); KryoSerialization kryoSerialization = new KryoSerialization(kyroFactory); kryoSerialization.serialize(bout, message); }
@Override protected void encode(ChannelHandlerContext ctx, Serializable msg, ByteBuf out) throws Exception { int startIdx = out.writerIndex(); ByteBufOutputStream bout = new ByteBufOutputStream(out); bout.write(LENGTH_PLACEHOLDER); // ObjectOutputStream oout = new CompactObjectOutputStream(bout); // oout.writeObject(msg); // oout.flush(); // oout.close(); HessianOutput hout = new HessianOutput(bout); hout.setSerializerFactory(SerializerFactoryUtil.getSerializerFactory()); hout.writeObject(msg); int endIdx = out.writerIndex(); out.setInt(startIdx, endIdx - startIdx - 4); } }