public static String propertiesToString(Properties props) throws IOException { String result = ""; if (props != null) { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); props.store(dataOut, ""); result = new String(dataOut.getData(), 0, dataOut.size()); dataOut.close(); } return result; }
private static byte[] createEofBatchAndLocationRecord() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(EOF_INT); os.writeByte(EOF_EOT); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create eof header.", e); } }
private static byte[] createBatchControlRecordHeader() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(BATCH_CONTROL_RECORD_SIZE); os.writeByte(BATCH_CONTROL_RECORD_TYPE); os.write(BATCH_CONTROL_RECORD_MAGIC); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create batch control record header.", e); } }
public synchronized byte[] getEncodedXidBytes() { if (encodedXidBytes == null) { outputStream = new DataByteArrayOutputStream(XID_PREFIX_SIZE + globalTransactionId.length + branchQualifier.length); outputStream.position(10); outputStream.writeInt(formatId); // global length outputStream.writeShort(globalTransactionId.length); try { outputStream.write(globalTransactionId); outputStream.write(branchQualifier); } catch (IOException fatal) { throw new RuntimeException(this + ", failed to encode:", fatal); } encodedXidBytes = outputStream.getData(); } return encodedXidBytes; }
public ByteSequence toByteSequence(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); return os.toByteSequence(); }
private static byte[] createEmptyBatchControlRecordHeader() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(BATCH_CONTROL_RECORD_SIZE); os.writeByte(BATCH_CONTROL_RECORD_TYPE); os.write(BATCH_CONTROL_RECORD_MAGIC); os.writeInt(0); os.writeLong(0l); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create empty batch control record header.", e); } }
/** * Creates a new ByteSequence that represents the marshaled form of the given Journal Command. * * @param command * The Journal Command that should be marshaled to bytes for writing. * * @return the byte representation of the given journal command. * * @throws IOException if an error occurs while serializing the command. */ protected ByteSequence toByteSequence(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); return os.toByteSequence(); }
private Location store(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); Location location = journal.write(os.toByteSequence(), true); journal.setLastAppendLocation(location); return location; }
DataByteArrayOutputStream out = new DataByteArrayOutputStream(pageSize); page.write(out); write(page, out.getData());
StompReadStream(StompTransport transport, final StompWireFormat wireFormat) { this.transport = transport; this.wireFormat = wireFormat; dataOut = new DataByteArrayOutputStream(); lock = new ReentrantLock(); }
StompReadStream(StompTransport transport, final StompWireFormat wireFormat) { this.transport = transport; this.wireFormat = wireFormat; dataOut = new DataByteArrayOutputStream(); lock = new ReentrantLock(); }
public static String propertiesToString(Properties props) throws IOException { String result = ""; if (props != null) { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); props.store(dataOut, ""); result = new String(dataOut.getData(), 0, dataOut.size()); dataOut.close(); } return result; }
public static String propertiesToString(Properties props) throws IOException { String result = ""; if (props != null) { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); props.store(dataOut, ""); result = new String(dataOut.getData(), 0, dataOut.size()); dataOut.close(); } return result; }
private static byte[] createEofBatchAndLocationRecord() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(EOF_INT); os.writeByte(EOF_EOT); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create eof header.", e); } }
private static byte[] createEofBatchAndLocationRecord() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(EOF_INT); os.writeByte(EOF_EOT); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create eof header.", e); } }
private static byte[] createBatchControlRecordHeader() { try (DataByteArrayOutputStream os = new DataByteArrayOutputStream();) { os.writeInt(BATCH_CONTROL_RECORD_SIZE); os.writeByte(BATCH_CONTROL_RECORD_TYPE); os.write(BATCH_CONTROL_RECORD_MAGIC); ByteSequence sequence = os.toByteSequence(); sequence.compact(); return sequence.getData(); } catch (IOException e) { throw new RuntimeException("Could not create batch control record header.", e); } }
public ByteSequence toByteSequence(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); return os.toByteSequence(); }
public ByteSequence toByteSequence(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); return os.toByteSequence(); }
private Location store(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); Location location = journal.write(os.toByteSequence(), true); journal.setLastAppendLocation(location); return location; }
private Location store(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); Location location = journal.write(os.toByteSequence(), true); journal.setLastAppendLocation(location); return location; }