io.aeron.cluster.codecs.JoinLogEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aeron-agent Show documentation
Show all versions of aeron-agent Show documentation
Efficient reliable UDP unicast, UDP multicast, and IPC transport protocol.
/* Generated SBE (Simple Binary Encoding) message codec. */
package io.aeron.cluster.codecs;
import org.agrona.MutableDirectBuffer;
import org.agrona.DirectBuffer;
/**
* Consensus Module instructing a service to join a log.
*/
@SuppressWarnings("all")
public final class JoinLogEncoder
{
public static final int BLOCK_LENGTH = 36;
public static final int TEMPLATE_ID = 40;
public static final int SCHEMA_ID = 111;
public static final int SCHEMA_VERSION = 11;
public static final String SEMANTIC_VERSION = "5.4";
public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.LITTLE_ENDIAN;
private final JoinLogEncoder parentMessage = this;
private MutableDirectBuffer buffer;
private int initialOffset;
private int offset;
private 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 initialOffset()
{
return initialOffset;
}
public int offset()
{
return offset;
}
public JoinLogEncoder wrap(final MutableDirectBuffer buffer, final int offset)
{
if (buffer != this.buffer)
{
this.buffer = buffer;
}
this.initialOffset = offset;
this.offset = offset;
limit(offset + BLOCK_LENGTH);
return this;
}
public JoinLogEncoder 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 logPositionId()
{
return 1;
}
public static int logPositionSinceVersion()
{
return 0;
}
public static int logPositionEncodingOffset()
{
return 0;
}
public static int logPositionEncodingLength()
{
return 8;
}
public static String logPositionMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static long logPositionNullValue()
{
return -9223372036854775808L;
}
public static long logPositionMinValue()
{
return -9223372036854775807L;
}
public static long logPositionMaxValue()
{
return 9223372036854775807L;
}
public JoinLogEncoder logPosition(final long value)
{
buffer.putLong(offset + 0, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int maxLogPositionId()
{
return 2;
}
public static int maxLogPositionSinceVersion()
{
return 0;
}
public static int maxLogPositionEncodingOffset()
{
return 8;
}
public static int maxLogPositionEncodingLength()
{
return 8;
}
public static String maxLogPositionMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static long maxLogPositionNullValue()
{
return -9223372036854775808L;
}
public static long maxLogPositionMinValue()
{
return -9223372036854775807L;
}
public static long maxLogPositionMaxValue()
{
return 9223372036854775807L;
}
public JoinLogEncoder maxLogPosition(final long value)
{
buffer.putLong(offset + 8, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int memberIdId()
{
return 3;
}
public static int memberIdSinceVersion()
{
return 0;
}
public static int memberIdEncodingOffset()
{
return 16;
}
public static int memberIdEncodingLength()
{
return 4;
}
public static String memberIdMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int memberIdNullValue()
{
return -2147483648;
}
public static int memberIdMinValue()
{
return -2147483647;
}
public static int memberIdMaxValue()
{
return 2147483647;
}
public JoinLogEncoder memberId(final int value)
{
buffer.putInt(offset + 16, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int logSessionIdId()
{
return 4;
}
public static int logSessionIdSinceVersion()
{
return 0;
}
public static int logSessionIdEncodingOffset()
{
return 20;
}
public static int logSessionIdEncodingLength()
{
return 4;
}
public static String logSessionIdMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int logSessionIdNullValue()
{
return -2147483648;
}
public static int logSessionIdMinValue()
{
return -2147483647;
}
public static int logSessionIdMaxValue()
{
return 2147483647;
}
public JoinLogEncoder logSessionId(final int value)
{
buffer.putInt(offset + 20, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int logStreamIdId()
{
return 5;
}
public static int logStreamIdSinceVersion()
{
return 0;
}
public static int logStreamIdEncodingOffset()
{
return 24;
}
public static int logStreamIdEncodingLength()
{
return 4;
}
public static String logStreamIdMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int logStreamIdNullValue()
{
return -2147483648;
}
public static int logStreamIdMinValue()
{
return -2147483647;
}
public static int logStreamIdMaxValue()
{
return 2147483647;
}
public JoinLogEncoder logStreamId(final int value)
{
buffer.putInt(offset + 24, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int isStartupId()
{
return 6;
}
public static int isStartupSinceVersion()
{
return 0;
}
public static int isStartupEncodingOffset()
{
return 28;
}
public static int isStartupEncodingLength()
{
return 4;
}
public static String isStartupMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public JoinLogEncoder isStartup(final BooleanType value)
{
buffer.putInt(offset + 28, value.value(), java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int roleId()
{
return 7;
}
public static int roleSinceVersion()
{
return 0;
}
public static int roleEncodingOffset()
{
return 32;
}
public static int roleEncodingLength()
{
return 4;
}
public static String roleMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int roleNullValue()
{
return -2147483648;
}
public static int roleMinValue()
{
return -2147483647;
}
public static int roleMaxValue()
{
return 2147483647;
}
public JoinLogEncoder role(final int value)
{
buffer.putInt(offset + 32, value, java.nio.ByteOrder.LITTLE_ENDIAN);
return this;
}
public static int logChannelId()
{
return 8;
}
public static String logChannelCharacterEncoding()
{
return java.nio.charset.StandardCharsets.US_ASCII.name();
}
public static String logChannelMetaAttribute(final MetaAttribute metaAttribute)
{
if (MetaAttribute.PRESENCE == metaAttribute)
{
return "required";
}
return "";
}
public static int logChannelHeaderLength()
{
return 4;
}
public JoinLogEncoder putLogChannel(final DirectBuffer src, final int srcOffset, final int length)
{
if (length > 1073741824)
{
throw new IllegalStateException("length > maxValue for type: " + length);
}
final int headerLength = 4;
final int limit = parentMessage.limit();
parentMessage.limit(limit + headerLength + length);
buffer.putInt(limit, length, java.nio.ByteOrder.LITTLE_ENDIAN);
buffer.putBytes(limit + headerLength, src, srcOffset, length);
return this;
}
public JoinLogEncoder putLogChannel(final byte[] src, final int srcOffset, final int length)
{
if (length > 1073741824)
{
throw new IllegalStateException("length > maxValue for type: " + length);
}
final int headerLength = 4;
final int limit = parentMessage.limit();
parentMessage.limit(limit + headerLength + length);
buffer.putInt(limit, length, java.nio.ByteOrder.LITTLE_ENDIAN);
buffer.putBytes(limit + headerLength, src, srcOffset, length);
return this;
}
public JoinLogEncoder logChannel(final String value)
{
final int length = null == value ? 0 : value.length();
if (length > 1073741824)
{
throw new IllegalStateException("length > maxValue for type: " + length);
}
final int headerLength = 4;
final int limit = parentMessage.limit();
parentMessage.limit(limit + headerLength + length);
buffer.putInt(limit, length, java.nio.ByteOrder.LITTLE_ENDIAN);
buffer.putStringWithoutLengthAscii(limit + headerLength, value);
return this;
}
public JoinLogEncoder logChannel(final CharSequence value)
{
final int length = null == value ? 0 : value.length();
if (length > 1073741824)
{
throw new IllegalStateException("length > maxValue for type: " + length);
}
final int headerLength = 4;
final int limit = parentMessage.limit();
parentMessage.limit(limit + headerLength + length);
buffer.putInt(limit, length, java.nio.ByteOrder.LITTLE_ENDIAN);
buffer.putStringWithoutLengthAscii(limit + headerLength, value);
return this;
}
public String toString()
{
if (null == buffer)
{
return "";
}
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(final StringBuilder builder)
{
if (null == buffer)
{
return builder;
}
final JoinLogDecoder decoder = new JoinLogDecoder();
decoder.wrap(buffer, initialOffset, BLOCK_LENGTH, SCHEMA_VERSION);
return decoder.appendTo(builder);
}
}