Java Code Examples for org.agrona.MutableDirectBuffer#getShort()

The following examples show how to use org.agrona.MutableDirectBuffer#getShort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExclusivePublication.java    From aeron with Apache License 2.0 6 votes vote down vote up
private void checkFirstFrame(final MutableDirectBuffer buffer, final int offset)
{
    final int frameType = HDR_TYPE_DATA;
    final int blockTermOffset = buffer.getInt(offset + TERM_OFFSET_FIELD_OFFSET, LITTLE_ENDIAN);
    final int blockSessionId = buffer.getInt(offset + SESSION_ID_FIELD_OFFSET, LITTLE_ENDIAN);
    final int blockStreamId = buffer.getInt(offset + STREAM_ID_FIELD_OFFSET, LITTLE_ENDIAN);
    final int blockTermId = buffer.getInt(offset + TERM_ID_FIELD_OFFSET, LITTLE_ENDIAN);
    final int blockFrameType = buffer.getShort(offset + TYPE_FIELD_OFFSET, LITTLE_ENDIAN) & 0xFFFF;

    if (blockTermOffset != termOffset ||
        blockSessionId != sessionId ||
        blockStreamId != streamId ||
        blockTermId != termId ||
        frameType != blockFrameType)
    {
        throw new IllegalArgumentException("improperly formatted block:" +
            " termOffset=" + blockTermOffset + " (expected=" + termOffset + ")," +
            " sessionId=" + blockSessionId + " (expected=" + sessionId + ")," +
            " streamId=" + blockStreamId + " (expected=" + streamId + ")," +
            " termId=" + blockTermId + " (expected=" + termId + ")," +
            " frameType=" + blockFrameType + " (expected=" + frameType + ")");
    }
}
 
Example 2
Source File: DriverEventDissector.java    From aeron with Apache License 2.0 4 votes vote down vote up
static int frameType(final MutableDirectBuffer buffer, final int termOffset)
{
    return buffer.getShort(FrameDescriptor.typeOffset(termOffset), LITTLE_ENDIAN) & 0xFFFF;
}