Package io.aeron.protocol
Class ResolutionEntryFlyweight
java.lang.Object
org.agrona.AbstractMutableDirectBuffer
org.agrona.concurrent.UnsafeBuffer
io.aeron.protocol.HeaderFlyweight
io.aeron.protocol.ResolutionEntryFlyweight
- All Implemented Interfaces:
Comparable<DirectBuffer>,AtomicBuffer,DirectBuffer,MutableDirectBuffer
Flyweight for Resolution Entry header.
Protocol Specification wiki page.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intOffset in the frame at which the IP address field begins.static final intLength of an IPv4 address in bytes.static final intLength of an IPv6 address in bytes.static final intOffset in the frame at which the age field begins.static final intMaximum length allowed for a name.static final intOffset in the frame at which the res-flags field begins.static final intOffset in the frame at which the res-type (resolution type) field begins.static final byteResolution type field flag for IPv4.static final byteResolution type field flag for IPv6.static final short(S) - Self flag.static final intOffset in the frame at which the UDP port field begins.Fields inherited from class io.aeron.protocol.HeaderFlyweight
CURRENT_VERSION, FLAGS_FIELD_OFFSET, FRAME_LENGTH_FIELD_OFFSET, HDR_TYPE_ATS_DATA, HDR_TYPE_ATS_SETUP, HDR_TYPE_ATS_SM, HDR_TYPE_DATA, HDR_TYPE_ERR, HDR_TYPE_EXT, HDR_TYPE_NAK, HDR_TYPE_PAD, HDR_TYPE_RES, HDR_TYPE_RSP_SETUP, HDR_TYPE_RTTM, HDR_TYPE_SETUP, HDR_TYPE_SM, MIN_HEADER_LENGTH, TYPE_FIELD_OFFSET, VERSION_FIELD_OFFSETFields inherited from class org.agrona.concurrent.UnsafeBuffer
ALIGNMENT, DISABLE_BOUNDS_CHECKS_PROP_NAME, SHOULD_BOUNDS_CHECKFields inherited from class org.agrona.AbstractMutableDirectBuffer
addressOffset, byteArray, capacityFields inherited from interface org.agrona.concurrent.AtomicBuffer
STRICT_ALIGNMENT_CHECKS, STRICT_ALIGNMENT_CHECKS_PROP_NAMEFields inherited from interface org.agrona.DirectBuffer
DISABLE_ARRAY_CONTENT_PRINTOUT_PROP_NAME, STR_HEADER_LEN -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which can later be used to wrap a frame.ResolutionEntryFlyweight(ByteBuffer buffer) Construct the flyweight over a frame.ResolutionEntryFlyweight(UnsafeBuffer buffer) Construct the flyweight over a frame. -
Method Summary
Modifier and TypeMethodDescriptionstatic intaddressLength(byte resType) Get the length of the address given a resolution type.intageInMs()Get the age of the entry based on last observed activity.ageInMs(int ageInMs) Set the age of the entry based on last observed activity.voidappendAddress(Appendable appendable) Append the address to the providedAppendablein ASCII format.voidappendName(StringBuilder appendable) Append the name to the providedAppendablein ASCII format.intTotal length of the entry in bytes.static intentryLengthRequired(byte resType, int nameLength) Calculate the length required for the entry when encoded.shortflags()Get the flags for the resolution entry.flags(short flags) Set the flags for the resolution entry.intgetAddress(byte[] dstBuffer) Get the address for the entry by copying it into the destination buffer.intgetName(byte[] dstBuffer) Get the name for the entry by copying it into the destination buffer.static booleanisAnyLocalAddress(byte[] address, int addressLength) Is the local address a match for binding a socket to ANY IP.static intnameOffset(byte resType) Offset in the entry at which the name begins depending on resolution type.putAddress(byte[] address) Put the address into the resolution entry.putName(byte[] name) Put the name for the resolution entry into the frame.byteresType()Get the protocol type of the resolution entry.resType(byte type) Set the protocol type of the resolution.intudpPort()Get the UDP port of the resolver with a given name.udpPort(int udpPort) Set the UDP port of the resolver with a given name.Methods inherited from class io.aeron.protocol.HeaderFlyweight
appendFlagsAsChars, flagsToChars, frameLength, frameLength, headerType, headerType, version, versionMethods inherited from class org.agrona.concurrent.UnsafeBuffer
addIntOpaque, addIntOrdered, addIntRelease, addLongOpaque, addLongOrdered, addLongRelease, byteBuffer, compareAndExchangeInt, compareAndExchangeLong, compareAndSetInt, compareAndSetLong, ensureCapacity, getAndAddInt, getAndAddLong, getAndSetInt, getAndSetLong, getByteVolatile, getCharVolatile, getIntAcquire, getIntOpaque, getIntVolatile, getLongAcquire, getLongOpaque, getLongVolatile, getShortVolatile, isExpandable, putByteVolatile, putCharVolatile, putIntOpaque, putIntOrdered, putIntRelease, putIntVolatile, putLongOpaque, putLongOrdered, putLongRelease, putLongVolatile, putShortVolatile, toString, verifyAlignment, wrap, wrap, wrap, wrap, wrap, wrap, wrap, wrapAdjustmentMethods inherited from class org.agrona.AbstractMutableDirectBuffer
addressOffset, boundsCheck, boundsCheck0, byteArray, capacity, checkLimit, compareTo, equals, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringUtf8, getStringUtf8, getStringUtf8, getStringWithoutLengthAscii, getStringWithoutLengthAscii, getStringWithoutLengthUtf8, hashCode, parseIntAscii, parseLongAscii, parseNaturalIntAscii, parseNaturalLongAscii, putByte, putBytes, putBytes, putBytes, putBytes, putBytes, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putIntAscii, putLong, putLong, putLongAscii, putNaturalIntAscii, putNaturalIntAsciiFromEnd, putNaturalLongAscii, putNaturalPaddedIntAscii, putShort, putShort, putStringAscii, putStringAscii, putStringAscii, putStringAscii, putStringUtf8, putStringUtf8, putStringUtf8, putStringUtf8, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthUtf8, setMemoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.agrona.DirectBuffer
addressOffset, boundsCheck, byteArray, capacity, checkLimit, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getChar, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getShort, getShort, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringAscii, getStringUtf8, getStringUtf8, getStringUtf8, getStringWithoutLengthAscii, getStringWithoutLengthAscii, getStringWithoutLengthUtf8, parseIntAscii, parseLongAscii, parseNaturalIntAscii, parseNaturalLongAsciiMethods inherited from interface org.agrona.MutableDirectBuffer
putByte, putBytes, putBytes, putBytes, putBytes, putBytes, putChar, putChar, putDouble, putDouble, putFloat, putFloat, putInt, putInt, putIntAscii, putLong, putLong, putLongAscii, putNaturalIntAscii, putNaturalIntAsciiFromEnd, putNaturalLongAscii, putNaturalPaddedIntAscii, putShort, putShort, putStringAscii, putStringAscii, putStringAscii, putStringAscii, putStringUtf8, putStringUtf8, putStringUtf8, putStringUtf8, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthAscii, putStringWithoutLengthUtf8, setMemory
-
Field Details
-
RES_TYPE_NAME_TO_IP4_MD
public static final byte RES_TYPE_NAME_TO_IP4_MDResolution type field flag for IPv4.- See Also:
-
RES_TYPE_NAME_TO_IP6_MD
public static final byte RES_TYPE_NAME_TO_IP6_MDResolution type field flag for IPv6.- See Also:
-
ADDRESS_LENGTH_IP4
public static final int ADDRESS_LENGTH_IP4Length of an IPv4 address in bytes.- See Also:
-
ADDRESS_LENGTH_IP6
public static final int ADDRESS_LENGTH_IP6Length of an IPv6 address in bytes.- See Also:
-
SELF_FLAG
public static final short SELF_FLAG(S) - Self flag.- See Also:
-
RES_TYPE_FIELD_OFFSET
public static final int RES_TYPE_FIELD_OFFSETOffset in the frame at which the res-type (resolution type) field begins.- See Also:
-
RES_FLAGS_FIELD_OFFSET
public static final int RES_FLAGS_FIELD_OFFSETOffset in the frame at which the res-flags field begins.- See Also:
-
UDP_PORT_FIELD_OFFSET
public static final int UDP_PORT_FIELD_OFFSETOffset in the frame at which the UDP port field begins.- See Also:
-
AGE_IN_MS_FIELD_OFFSET
public static final int AGE_IN_MS_FIELD_OFFSETOffset in the frame at which the age field begins.- See Also:
-
ADDRESS_FIELD_OFFSET
public static final int ADDRESS_FIELD_OFFSETOffset in the frame at which the IP address field begins.- See Also:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHMaximum length allowed for a name.- See Also:
-
-
Constructor Details
-
ResolutionEntryFlyweight
public ResolutionEntryFlyweight()Default constructor which can later be used to wrap a frame. -
ResolutionEntryFlyweight
Construct the flyweight over a frame.- Parameters:
buffer- containing the frame.
-
ResolutionEntryFlyweight
Construct the flyweight over a frame.- Parameters:
buffer- containing the frame.
-
-
Method Details
-
resType
Set the protocol type of the resolution.- Parameters:
type- of the resolution entry protocol.- Returns:
- this for a fluent API.
- See Also:
-
resType
public byte resType()Get the protocol type of the resolution entry.- Returns:
- the protocol type of the resolution entry.
- See Also:
-
flags
Set the flags for the resolution entry.- Overrides:
flagsin classHeaderFlyweight- Parameters:
flags- field value.- Returns:
- this for a fluent API.
- See Also:
-
flags
public short flags()Get the flags for the resolution entry.- Overrides:
flagsin classHeaderFlyweight- Returns:
- the flags for the resolution entry.
-
udpPort
Set the UDP port of the resolver with a given name.- Parameters:
udpPort- of the resolver with a given name.- Returns:
- this for a fluent API.
-
udpPort
public int udpPort()Get the UDP port of the resolver with a given name.- Returns:
- the UDP port of the resolver with a given name.
-
ageInMs
Set the age of the entry based on last observed activity.- Parameters:
ageInMs- of the entry based on last observed activity.- Returns:
- this for a fluent API.
-
ageInMs
public int ageInMs()Get the age of the entry based on last observed activity.- Returns:
- the age of the entry based on last observed activity.
-
putAddress
Put the address into the resolution entry. It must come after callingresType(byte).- Parameters:
address- to be written for the resolution entry.- Returns:
- this for a fluent API.
-
getAddress
public int getAddress(byte[] dstBuffer) Get the address for the entry by copying it into the destination buffer.- Parameters:
dstBuffer- into which the address will be copied.- Returns:
- length of the address copied.
-
appendAddress
Append the address to the providedAppendablein ASCII format.- Parameters:
appendable- to which the address will be appended.
-
putName
Put the name for the resolution entry into the frame.- Parameters:
name- for the resolution entry.- Returns:
- this for a fluent API.
-
getName
public int getName(byte[] dstBuffer) Get the name for the entry by copying it into the destination buffer.- Parameters:
dstBuffer- into which the name will be copied.- Returns:
- the number of bytes copied.
-
appendName
Append the name to the providedAppendablein ASCII format.- Parameters:
appendable- to which the name will be appended.
-
entryLength
public int entryLength()Total length of the entry in bytes.- Returns:
- total length of the entry in bytes.
-
nameOffset
public static int nameOffset(byte resType) Offset in the entry at which the name begins depending on resolution type.- Parameters:
resType- for the protocol family.- Returns:
- offset in the entry at which the name field begins.
-
entryLengthRequired
public static int entryLengthRequired(byte resType, int nameLength) Calculate the length required for the entry when encoded.- Parameters:
resType- of the entry.nameLength- of the name in the entry.- Returns:
- the required length of the entry in bytes.
-
addressLength
public static int addressLength(byte resType) Get the length of the address given a resolution type.- Parameters:
resType- to lookup address length for.- Returns:
- the length of the address given a resolution type.
-
isAnyLocalAddress
public static boolean isAnyLocalAddress(byte[] address, int addressLength) Is the local address a match for binding a socket to ANY IP.- Parameters:
address- to check which can be IPv4 or IPv6.addressLength- of the address in bytes.- Returns:
- true if address is an ANY match otherwise false.
-