Search in sources :

Example 1 with MembersDecoder

use of io.zeebe.clustering.management.InvitationRequestDecoder.MembersDecoder in project zeebe by zeebe-io.

the class InvitationRequest method wrap.

@Override
public void wrap(final DirectBuffer buffer, int offset, final int length) {
    final int frameEnd = offset + length;
    headerDecoder.wrap(buffer, offset);
    offset += headerDecoder.encodedLength();
    bodyDecoder.wrap(buffer, offset, headerDecoder.blockLength(), headerDecoder.version());
    partitionId = bodyDecoder.partitionId();
    term = bodyDecoder.term();
    members.clear();
    final Iterator<MembersDecoder> iterator = bodyDecoder.members().iterator();
    while (iterator.hasNext()) {
        final MembersDecoder decoder = iterator.next();
        final SocketAddress member = new SocketAddress();
        member.port(decoder.port());
        final MutableDirectBuffer hostBuffer = member.getHostBuffer();
        final int hostLength = decoder.hostLength();
        member.hostLength(hostLength);
        decoder.getHost(hostBuffer, 0, hostLength);
        members.add(member);
    }
    final int topicNameLength = bodyDecoder.topicNameLength();
    final int topicNameOffset = bodyDecoder.limit() + topicNameHeaderLength();
    topicName.wrap(buffer, topicNameOffset, topicNameLength);
    // skip topic name in decoder
    bodyDecoder.limit(topicNameOffset + topicNameLength);
    assert bodyDecoder.limit() == frameEnd : "Decoder read only to position " + bodyDecoder.limit() + " but expected " + frameEnd + " as final position";
}
Also used : MembersDecoder(io.zeebe.clustering.management.InvitationRequestDecoder.MembersDecoder) SocketAddress(io.zeebe.transport.SocketAddress) MutableDirectBuffer(org.agrona.MutableDirectBuffer)

Aggregations

MembersDecoder (io.zeebe.clustering.management.InvitationRequestDecoder.MembersDecoder)1 SocketAddress (io.zeebe.transport.SocketAddress)1 MutableDirectBuffer (org.agrona.MutableDirectBuffer)1