All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zeebe.clustering.gossip.GossipEventEncoder Maven / Gradle / Ivy

There is a newer version: 0.16.4
Show newest version
/* Generated SBE (Simple Binary Encoding) message codec */
package io.zeebe.clustering.gossip;

import org.agrona.MutableDirectBuffer;
import org.agrona.DirectBuffer;
import org.agrona.sbe.*;

/**
 * ping probe request
 */
@SuppressWarnings("all")
public class GossipEventEncoder implements MessageEncoderFlyweight
{
    public static final int BLOCK_LENGTH = 5;
    public static final int TEMPLATE_ID = 0;
    public static final int SCHEMA_ID = 3;
    public static final int SCHEMA_VERSION = 1;
    public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.LITTLE_ENDIAN;

    private final GossipEventEncoder parentMessage = this;
    private MutableDirectBuffer buffer;
    protected int offset;
    protected int limit;

    public int sbeBlockLength()
    {
        return BLOCK_LENGTH;
    }

    public int sbeTemplateId()
    {
        return TEMPLATE_ID;
    }

    public int sbeSchemaId()
    {
        return SCHEMA_ID;
    }

    public int sbeSchemaVersion()
    {
        return SCHEMA_VERSION;
    }

    public String sbeSemanticType()
    {
        return "";
    }

    public MutableDirectBuffer buffer()
    {
        return buffer;
    }

    public int offset()
    {
        return offset;
    }

    public GossipEventEncoder wrap(final MutableDirectBuffer buffer, final int offset)
    {
        this.buffer = buffer;
        this.offset = offset;
        limit(offset + BLOCK_LENGTH);

        return this;
    }

    public GossipEventEncoder wrapAndApplyHeader(
        final MutableDirectBuffer buffer, final int offset, final MessageHeaderEncoder headerEncoder)
    {
        headerEncoder
            .wrap(buffer, offset)
            .blockLength(BLOCK_LENGTH)
            .templateId(TEMPLATE_ID)
            .schemaId(SCHEMA_ID)
            .version(SCHEMA_VERSION);

        return wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH);
    }

    public int encodedLength()
    {
        return limit - offset;
    }

    public int limit()
    {
        return limit;
    }

    public void limit(final int limit)
    {
        this.limit = limit;
    }

    public static int eventTypeId()
    {
        return 0;
    }

    public static int eventTypeSinceVersion()
    {
        return 0;
    }

    public static int eventTypeEncodingOffset()
    {
        return 0;
    }

    public static int eventTypeEncodingLength()
    {
        return 1;
    }

    public static String eventTypeMetaAttribute(final MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case EPOCH: return "";
            case TIME_UNIT: return "";
            case SEMANTIC_TYPE: return "";
            case PRESENCE: return "required";
        }

        return "";
    }

    public GossipEventEncoder eventType(final GossipEventType value)
    {
        buffer.putByte(offset + 0, (byte)value.value());
        return this;
    }

    public static int senderIdId()
    {
        return 1;
    }

    public static int senderIdSinceVersion()
    {
        return 0;
    }

    public static int senderIdEncodingOffset()
    {
        return 1;
    }

    public static int senderIdEncodingLength()
    {
        return 2;
    }

    public static String senderIdMetaAttribute(final MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case EPOCH: return "";
            case TIME_UNIT: return "";
            case SEMANTIC_TYPE: return "";
            case PRESENCE: return "required";
        }

        return "";
    }

    public static int senderIdNullValue()
    {
        return 65535;
    }

    public static int senderIdMinValue()
    {
        return 0;
    }

    public static int senderIdMaxValue()
    {
        return 65534;
    }

    public GossipEventEncoder senderId(final int value)
    {
        buffer.putShort(offset + 1, (short)value, java.nio.ByteOrder.LITTLE_ENDIAN);
        return this;
    }


    public static int probeMemberIdId()
    {
        return 2;
    }

    public static int probeMemberIdSinceVersion()
    {
        return 0;
    }

    public static int probeMemberIdEncodingOffset()
    {
        return 3;
    }

    public static int probeMemberIdEncodingLength()
    {
        return 2;
    }

    public static String probeMemberIdMetaAttribute(final MetaAttribute metaAttribute)
    {
        switch (metaAttribute)
        {
            case EPOCH: return "";
            case TIME_UNIT: return "";
            case SEMANTIC_TYPE: return "";
            case PRESENCE: return "required";
        }

        return "";
    }

    public static int probeMemberIdNullValue()
    {
        return 65535;
    }

    public static int probeMemberIdMinValue()
    {
        return 0;
    }

    public static int probeMemberIdMaxValue()
    {
        return 65534;
    }

    public GossipEventEncoder probeMemberId(final int value)
    {
        buffer.putShort(offset + 3, (short)value, java.nio.ByteOrder.LITTLE_ENDIAN);
        return this;
    }


    private final MembershipEventsEncoder membershipEvents = new MembershipEventsEncoder();

    public static long membershipEventsId()
    {
        return 3;
    }

    public MembershipEventsEncoder membershipEventsCount(final int count)
    {
        membershipEvents.wrap(parentMessage, buffer, count);
        return membershipEvents;
    }

    public static class MembershipEventsEncoder
    {
        public static final int HEADER_SIZE = 3;
        private final GroupSizeEncodingEncoder dimensions = new GroupSizeEncodingEncoder();
        private GossipEventEncoder parentMessage;
        private MutableDirectBuffer buffer;
        private int count;
        private int index;
        private int offset;

        public void wrap(
            final GossipEventEncoder parentMessage, final MutableDirectBuffer buffer, final int count)
        {
            if (count < 0 || count > 254)
            {
                throw new IllegalArgumentException("count outside allowed range: count=" + count);
            }

            this.parentMessage = parentMessage;
            this.buffer = buffer;
            dimensions.wrap(buffer, parentMessage.limit());
            dimensions.blockLength((int)19);
            dimensions.numInGroup((short)count);
            index = -1;
            this.count = count;
            parentMessage.limit(parentMessage.limit() + HEADER_SIZE);
        }

        public static int sbeHeaderSize()
        {
            return HEADER_SIZE;
        }

        public static int sbeBlockLength()
        {
            return 19;
        }

        public MembershipEventsEncoder next()
        {
            if (index + 1 >= count)
            {
                throw new java.util.NoSuchElementException();
            }

            offset = parentMessage.limit();
            parentMessage.limit(offset + sbeBlockLength());
            ++index;

            return this;
        }

        public static int eventTypeId()
        {
            return 4;
        }

        public static int eventTypeSinceVersion()
        {
            return 0;
        }

        public static int eventTypeEncodingOffset()
        {
            return 0;
        }

        public static int eventTypeEncodingLength()
        {
            return 1;
        }

        public static String eventTypeMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public MembershipEventsEncoder eventType(final MembershipEventType value)
        {
            buffer.putByte(offset + 0, (byte)value.value());
            return this;
        }

        public static int gossipEpochId()
        {
            return 5;
        }

        public static int gossipEpochSinceVersion()
        {
            return 0;
        }

        public static int gossipEpochEncodingOffset()
        {
            return 1;
        }

        public static int gossipEpochEncodingLength()
        {
            return 8;
        }

        public static String gossipEpochMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static long gossipEpochNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long gossipEpochMinValue()
        {
            return 0x0L;
        }

        public static long gossipEpochMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public MembershipEventsEncoder gossipEpoch(final long value)
        {
            buffer.putLong(offset + 1, value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }


        public static int gossipHeartbeatId()
        {
            return 6;
        }

        public static int gossipHeartbeatSinceVersion()
        {
            return 0;
        }

        public static int gossipHeartbeatEncodingOffset()
        {
            return 9;
        }

        public static int gossipHeartbeatEncodingLength()
        {
            return 8;
        }

        public static String gossipHeartbeatMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static long gossipHeartbeatNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long gossipHeartbeatMinValue()
        {
            return 0x0L;
        }

        public static long gossipHeartbeatMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public MembershipEventsEncoder gossipHeartbeat(final long value)
        {
            buffer.putLong(offset + 9, value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }


        public static int memberIdId()
        {
            return 7;
        }

        public static int memberIdSinceVersion()
        {
            return 0;
        }

        public static int memberIdEncodingOffset()
        {
            return 17;
        }

        public static int memberIdEncodingLength()
        {
            return 2;
        }

        public static String memberIdMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static int memberIdNullValue()
        {
            return 65535;
        }

        public static int memberIdMinValue()
        {
            return 0;
        }

        public static int memberIdMaxValue()
        {
            return 65534;
        }

        public MembershipEventsEncoder memberId(final int value)
        {
            buffer.putShort(offset + 17, (short)value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }

    }

    private final CustomEventsEncoder customEvents = new CustomEventsEncoder();

    public static long customEventsId()
    {
        return 9;
    }

    public CustomEventsEncoder customEventsCount(final int count)
    {
        customEvents.wrap(parentMessage, buffer, count);
        return customEvents;
    }

    public static class CustomEventsEncoder
    {
        public static final int HEADER_SIZE = 3;
        private final GroupSizeEncodingEncoder dimensions = new GroupSizeEncodingEncoder();
        private GossipEventEncoder parentMessage;
        private MutableDirectBuffer buffer;
        private int count;
        private int index;
        private int offset;

        public void wrap(
            final GossipEventEncoder parentMessage, final MutableDirectBuffer buffer, final int count)
        {
            if (count < 0 || count > 254)
            {
                throw new IllegalArgumentException("count outside allowed range: count=" + count);
            }

            this.parentMessage = parentMessage;
            this.buffer = buffer;
            dimensions.wrap(buffer, parentMessage.limit());
            dimensions.blockLength((int)18);
            dimensions.numInGroup((short)count);
            index = -1;
            this.count = count;
            parentMessage.limit(parentMessage.limit() + HEADER_SIZE);
        }

        public static int sbeHeaderSize()
        {
            return HEADER_SIZE;
        }

        public static int sbeBlockLength()
        {
            return 18;
        }

        public CustomEventsEncoder next()
        {
            if (index + 1 >= count)
            {
                throw new java.util.NoSuchElementException();
            }

            offset = parentMessage.limit();
            parentMessage.limit(offset + sbeBlockLength());
            ++index;

            return this;
        }

        public static int senderGossipEpochId()
        {
            return 10;
        }

        public static int senderGossipEpochSinceVersion()
        {
            return 0;
        }

        public static int senderGossipEpochEncodingOffset()
        {
            return 0;
        }

        public static int senderGossipEpochEncodingLength()
        {
            return 8;
        }

        public static String senderGossipEpochMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static long senderGossipEpochNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long senderGossipEpochMinValue()
        {
            return 0x0L;
        }

        public static long senderGossipEpochMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public CustomEventsEncoder senderGossipEpoch(final long value)
        {
            buffer.putLong(offset + 0, value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }


        public static int senderGossipHeartbeatId()
        {
            return 11;
        }

        public static int senderGossipHeartbeatSinceVersion()
        {
            return 0;
        }

        public static int senderGossipHeartbeatEncodingOffset()
        {
            return 8;
        }

        public static int senderGossipHeartbeatEncodingLength()
        {
            return 8;
        }

        public static String senderGossipHeartbeatMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static long senderGossipHeartbeatNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long senderGossipHeartbeatMinValue()
        {
            return 0x0L;
        }

        public static long senderGossipHeartbeatMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public CustomEventsEncoder senderGossipHeartbeat(final long value)
        {
            buffer.putLong(offset + 8, value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }


        public static int senderIdId()
        {
            return 12;
        }

        public static int senderIdSinceVersion()
        {
            return 0;
        }

        public static int senderIdEncodingOffset()
        {
            return 16;
        }

        public static int senderIdEncodingLength()
        {
            return 2;
        }

        public static String senderIdMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "";
                case TIME_UNIT: return "";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static int senderIdNullValue()
        {
            return 65535;
        }

        public static int senderIdMinValue()
        {
            return 0;
        }

        public static int senderIdMaxValue()
        {
            return 65534;
        }

        public CustomEventsEncoder senderId(final int value)
        {
            buffer.putShort(offset + 16, (short)value, java.nio.ByteOrder.LITTLE_ENDIAN);
            return this;
        }


        public static int eventTypeId()
        {
            return 14;
        }

        public static String eventTypeCharacterEncoding()
        {
            return "UTF-8";
        }

        public static String eventTypeMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "unix";
                case TIME_UNIT: return "nanosecond";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static int eventTypeHeaderLength()
        {
            return 2;
        }

        public CustomEventsEncoder putEventType(final DirectBuffer src, final int srcOffset, final int length)
        {
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, src, srcOffset, length);

            return this;
        }

        public CustomEventsEncoder putEventType(final byte[] src, final int srcOffset, final int length)
        {
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, src, srcOffset, length);

            return this;
        }

        public CustomEventsEncoder eventType(final String value)
        {
            final byte[] bytes;
            try
            {
                bytes = value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8");
            }
            catch (final java.io.UnsupportedEncodingException ex)
            {
                throw new RuntimeException(ex);
            }

            final int length = bytes.length;
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, bytes, 0, length);

            return this;
        }

        public static int payloadId()
        {
            return 15;
        }

        public static String payloadCharacterEncoding()
        {
            return "UTF-8";
        }

        public static String payloadMetaAttribute(final MetaAttribute metaAttribute)
        {
            switch (metaAttribute)
            {
                case EPOCH: return "unix";
                case TIME_UNIT: return "nanosecond";
                case SEMANTIC_TYPE: return "";
                case PRESENCE: return "required";
            }

            return "";
        }

        public static int payloadHeaderLength()
        {
            return 2;
        }

        public CustomEventsEncoder putPayload(final DirectBuffer src, final int srcOffset, final int length)
        {
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, src, srcOffset, length);

            return this;
        }

        public CustomEventsEncoder putPayload(final byte[] src, final int srcOffset, final int length)
        {
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, src, srcOffset, length);

            return this;
        }

        public CustomEventsEncoder payload(final String value)
        {
            final byte[] bytes;
            try
            {
                bytes = value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8");
            }
            catch (final java.io.UnsupportedEncodingException ex)
            {
                throw new RuntimeException(ex);
            }

            final int length = bytes.length;
            if (length > 65534)
            {
                throw new IllegalStateException("length > maxValue for type: " + length);
            }

            final int headerLength = 2;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + headerLength + length);
            buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN);
            buffer.putBytes(limit + headerLength, bytes, 0, length);

            return this;
        }
    }


    public String toString()
    {
        return appendTo(new StringBuilder(100)).toString();
    }

    public StringBuilder appendTo(final StringBuilder builder)
    {
        GossipEventDecoder writer = new GossipEventDecoder();
        writer.wrap(buffer, offset, BLOCK_LENGTH, SCHEMA_VERSION);

        return writer.appendTo(builder);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy