public long lowSequenceNumberLogout( final int msgSeqNo, final int expectedSeqNo, final int receivedSeqNo, final int sequenceIndex, final int lastMsgSeqNumProcessed) { lowSequenceNumber .with(expectedSeqNo) .with(receivedSeqNo); final long position = logout( msgSeqNo, lowSequenceNumber.value(), lowSequenceNumber.length(), sequenceIndex, lastMsgSeqNumProcessed); lowSequenceNumber.clear(); return position; }
@Test public void shouldFormatIntegers() { final String format = "ab%sc%s"; final AsciiFormatter formatter = new AsciiFormatter(format) .with("D".getBytes(US_ASCII)) .with(123); assertFormatsTo("abDc123", formatter); }
@Test public void shouldClearFormatter() { final String format = "ab%sc%s"; final AsciiFormatter formatter = new AsciiFormatter(format) .with("D".getBytes(US_ASCII)) .with("E".getBytes(US_ASCII)) .clear() .with("F".getBytes(US_ASCII)) .with("G".getBytes(US_ASCII)); assertFormatsTo("abFcG", formatter); }
public AsciiFormatter with(final byte[] field) { return with(field, field.length); }
public SessionProxy( final MutableAsciiBuffer buffer, final GatewayPublication gatewayPublication, final SessionIdStrategy sessionIdStrategy, final SessionCustomisationStrategy customisationStrategy, final EpochClock clock, final long connectionId, final int libraryId) { this.gatewayPublication = gatewayPublication; this.sessionIdStrategy = sessionIdStrategy; this.customisationStrategy = customisationStrategy; this.clock = clock; this.connectionId = connectionId; this.libraryId = libraryId; this.buffer = buffer; lowSequenceNumber = new AsciiFormatter("MsgSeqNum too low, expecting %s but received %s"); timestampEncoder.initialise(clock.time()); }
@Test public void shouldFormatTwoFields() { final String format = "ab%sc%s"; final AsciiFormatter formatter = new AsciiFormatter(format) .with("D".getBytes(US_ASCII)) .with("E".getBytes(US_ASCII)); assertFormatsTo("abDcE", formatter); }
public AsciiFormatter with(final int number) { final int length = numberFlyweight.putIntAscii(0, number); return with(numberBuffer, length); }
@Test public void shouldFormatNoFields() { final String format = "abc"; final AsciiFormatter formatter = new AsciiFormatter(format); assertFormatsTo(format, formatter); }
@Test public void shouldSupportLongFormatString() { final String format = "MsgSeqNum too low, expecting %s but received %s"; final AsciiFormatter formatter = new AsciiFormatter(format) .with("0".getBytes(US_ASCII)) .with("1".getBytes(US_ASCII)); assertFormatsTo("MsgSeqNum too low, expecting 0 but received 1", formatter); }
public AsciiFormatter clear() { encodedSoFar = 0; index = 0; append(segments[0]); return this; }
@Test public void shouldFormatSingleField() { final String format = "ab%sc"; final AsciiFormatter formatter = new AsciiFormatter(format) .with("D".getBytes(US_ASCII)); assertFormatsTo("abDc", formatter); }
private void append(final byte[] toAppend) { append(toAppend, toAppend.length); }
public AsciiFormatter(final CharSequence formatString) { final String[] splitFormatString = PATTERN.split(formatString); final int numberOfSegments = splitFormatString.length; segments = new byte[numberOfSegments][]; for (int i = 0; i < numberOfSegments; i++) { segments[i] = splitFormatString[i].getBytes(US_ASCII); } append(segments[0]); }