private void doRollback(boolean interrupted) { if (interrupted) LOG.warn("Thread is interrupted. Can't guarantee complete message, so not committing"); // zero out all contents... for (long i = position; i <= wire.bytes().writePosition(); i++) wire.bytes().writeByte(i, (byte) 0); position = lastPosition; wire.bytes().writePosition(position); ((AbstractWire) wire).forceNotInsideHeader(); }
@Override public void write(Bytes out, @NotNull Boolean toWrite) { out.writeByte((byte) (toWrite ? 'Y' : 0)); }
public static void setCharAt(@NotNull Appendable sb, int index, char ch) throws IllegalArgumentException, BufferOverflowException { if (sb instanceof StringBuilder) ((StringBuilder) sb).setCharAt(index, ch); else if (sb instanceof Bytes) ((Bytes) sb).writeByte(index, ch); else throw new IllegalArgumentException("" + sb.getClass()); }
default void read(@NotNull Bytes bytes, int length) { int len2 = (int) Math.min(length, readRemaining()); for (int i = 0; i < len2; i++) bytes.writeByte(readByte()); }
private void writePayload(Bytes payload, Bytes destination) { destination.writeByte(BOOTSTRAP_TIME_HUNK); destination.write(payload, payload.readPosition(), payload.readRemaining()); }
@Override public void write(Bytes out, @NotNull HistogramKey toWrite) { int accumulatorKeySize = 5; out.writeByte(toWrite.granularityOrdinal); out.writeInt(toWrite.binId); accumulatorKeySize += 2 + toWrite.metric.length(); writeString(out, toWrite.metric); accumulatorKeySize += 2 + (toWrite.source == null ? 0 : toWrite.source.length()); writeString(out, toWrite.source); short numTags = toWrite.tags == null ? 0 : (short) toWrite.tags.length; accumulatorKeySize += 2; out.writeShort(numTags); for (short i = 0; i < numTags; ++i) { accumulatorKeySize += 2 + (toWrite.tags[i] == null ? 0 : toWrite.tags[i].length()); writeString(out, toWrite.tags[i]); } accumulatorKeySizes.update(accumulatorKeySize); } }
@Override public void write(Bytes out, @NotNull HistogramKey toWrite) { int accumulatorKeySize = 5; out.writeByte(toWrite.granularityOrdinal); out.writeInt(toWrite.binId); accumulatorKeySize += 2 + toWrite.metric.length(); writeString(out, toWrite.metric); accumulatorKeySize += 2 + (toWrite.source == null ? 0 : toWrite.source.length()); writeString(out, toWrite.source); short numTags = toWrite.tags == null ? 0 : (short) toWrite.tags.length; accumulatorKeySize += 2; out.writeShort(numTags); for (short i = 0; i < numTags; ++i) { accumulatorKeySize += 2 + (toWrite.tags[i] == null ? 0 : toWrite.tags[i].length()); writeString(out, toWrite.tags[i]); } accumulatorKeySizes.update(accumulatorKeySize); } }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = s.segmentBytesForWrite(); segmentBytes.writePosition(replicationBytesOffset); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
private void doRollback(boolean interrupted) { if (interrupted) LOG.warn("Thread is interrupted. Can't guarantee complete message, so not committing"); // zero out all contents... for (long i = position; i <= wire.bytes().writePosition(); i++) wire.bytes().writeByte(i, (byte) 0); position = lastPosition; wire.bytes().writePosition(position); ((AbstractWire) wire).forceNotInsideHeader(); }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(replicationBytesOffset()); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
void updateReplicationState(byte identifier, long timestamp) { initDelayedUpdateChecksum(true); Bytes segmentBytes = this.segmentBytesForWriteGuarded(); segmentBytes.writePosition(replicationBytesOffset()); segmentBytes.writeLong(timestamp); segmentBytes.writeByte(identifier); }
default void readWithLength(Bytes bytes) { bytes.clear(); int length = Maths.toUInt31(readStopBit()); int i; for (i = 0; i < length - 7; i++) bytes.writeLong(readLong()); for (; i < length; i++) bytes.writeByte(readByte()); }
@org.jetbrains.annotations.NotNull public static Bytes fromHexString(@org.jetbrains.annotations.NotNull String s) { try { Bytes in = Bytes.from(s); Bytes out = Bytes.elasticByteBuffer(); OUTER: while (in.readRemaining() > 0) { in.parseHexLong(); for (int i = 0; i < 16; i++) { if (in.peekUnsignedByte() == ' ') { in.readSkip(1); if (in.peekUnsignedByte() == ' ') break OUTER; } long value = in.parseHexLong(); out.writeByte((byte) value); } if (in.readByte(in.readPosition() - 1) <= ' ') in.readSkip(-1); in.skipTo(StopCharTesters.CONTROL_STOP); } return out; } catch (BufferUnderflowException | BufferOverflowException e) { throw new AssertionError(e); } }