-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logbuffer metadata extra fields #1700
Changes from 2 commits
a378c8f
708407e
a0b6493
ce1040f
0c7a358
2bd9830
57ea62d
6c4e28e
e6039b3
b5cf57c
ee98864
b092c5f
8ee1291
a94276a
84c9146
37e060e
7a7fe9a
e4625f3
6066761
e177c9c
015496f
13264fe
c7e8a57
1fbfb2c
7742a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,11 +135,33 @@ public class LogBufferDescriptor | |
*/ | ||
public static final int LOG_DEFAULT_FRAME_HEADER_OFFSET; | ||
|
||
|
||
|
||
/** | ||
* Maximum length of a frame header. | ||
*/ | ||
public static final int LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH = CACHE_LINE_LENGTH * 2; | ||
|
||
|
||
// todo: Add documentation | ||
public static final int LOG_ACTIVE_TERM_ID_OFFSET; | ||
public static final int LOG_TERM_OFFSET_OFFSET; | ||
public static final int LOG_IS_SPARSE_OFFSET; | ||
public static final int LOG_IS_TETHER_OFFSET; | ||
vyazelenko marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static final int LOG_IS_REJOIN_OFFSET; | ||
pveentjer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static final int LOG_IS_RELIABLE_OFFSET; | ||
pveentjer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public static final int LOG_SOCKET_RCVBUF_LENGTH_OFFSET; | ||
public static final int LOG_SOCKET_SNDBUF_LENGTH_OFFSET; | ||
public static final int LOG_RECEIVER_WINDOW_LENGTH_OFFSET; | ||
public static final int LOG_PUBLICATION_WINDOW_LENGTH_OFFSET; | ||
public static final int LOG_GROUP_OFFSET; | ||
public static final int LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET; | ||
public static final int LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSET; | ||
public static final int LOG_MAX_RESEND_OFFSET; | ||
public static final int LOG_LINGER_TIMEOUT_NS_OFFSET; | ||
public static final int LOG_SIGNAL_EOS_OFFSET; | ||
public static final int LOG_SPIES_SIMULATE_CONNECTION_OFFSET; | ||
|
||
/** | ||
* Total length of the log metadata buffer in bytes. | ||
* <pre> | ||
|
@@ -217,7 +239,67 @@ public class LogBufferDescriptor | |
offset += CACHE_LINE_LENGTH; | ||
LOG_DEFAULT_FRAME_HEADER_OFFSET = offset; | ||
|
||
LOG_META_DATA_LENGTH = align(offset + LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH, PAGE_MIN_SIZE); | ||
// the new fields will be added with 1 cacheline of padding after the frame header. | ||
offset+= LOG_DEFAULT_FRAME_HEADER_MAX_LENGTH+CACHE_LINE_LENGTH; | ||
|
||
LOG_ACTIVE_TERM_ID_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_TERM_OFFSET_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_IS_SPARSE_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_IS_TETHER_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_IS_REJOIN_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_IS_RELIABLE_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_SOCKET_RCVBUF_LENGTH_OFFSET = offset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's try to use available space after the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
offset += SIZE_OF_INT; | ||
|
||
LOG_SOCKET_SNDBUF_LENGTH_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_RECEIVER_WINDOW_LENGTH_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_PUBLICATION_WINDOW_LENGTH_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_GROUP_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_MAX_RESEND_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET = offset; | ||
if((LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET % SIZE_OF_LONG)!=0){ | ||
throw new Error(); | ||
} | ||
offset += SIZE_OF_LONG; | ||
|
||
LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSET = offset; | ||
offset += SIZE_OF_LONG; | ||
|
||
LOG_LINGER_TIMEOUT_NS_OFFSET = offset; | ||
offset += SIZE_OF_LONG; | ||
|
||
LOG_SIGNAL_EOS_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
LOG_SPIES_SIMULATE_CONNECTION_OFFSET = offset; | ||
offset += SIZE_OF_INT; | ||
|
||
|
||
LOG_META_DATA_LENGTH = align(offset, PAGE_MIN_SIZE); | ||
System.out.println("Offset:"+offset); | ||
System.out.println("LOG_META_DATA_LENGTH:"+LOG_META_DATA_LENGTH); | ||
} | ||
|
||
/** | ||
|
@@ -878,4 +960,174 @@ public static int computeAssembledFrameLength(final int length, final int maxPay | |
|
||
return HEADER_LENGTH + (numMaxPayloads * maxPayloadSize) + remainingPayload; | ||
} | ||
|
||
// todo: javadoc | ||
public static int activeTermId(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_ACTIVE_TERM_ID_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void activeTermId(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_ACTIVE_TERM_ID_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static int termOffset(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_TERM_OFFSET_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void termOffset(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_TERM_OFFSET_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean isSparse(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_IS_SPARSE_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void isSparse(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_IS_SPARSE_OFFSET, value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean isTether(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_IS_TETHER_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void isTether(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_IS_TETHER_OFFSET, value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean isRejoin(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_IS_REJOIN_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void isRejoin(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_IS_REJOIN_OFFSET, value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean isReliable(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_IS_RELIABLE_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void isReliable(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_IS_RELIABLE_OFFSET, value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static int socketRcvbufLength(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_SOCKET_RCVBUF_LENGTH_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void socketRcvbufLength(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_SOCKET_RCVBUF_LENGTH_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static int socketSndbufLength(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_SOCKET_SNDBUF_LENGTH_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void socketSndbufLength(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_SOCKET_SNDBUF_LENGTH_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static int receiverWindowLength(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_RECEIVER_WINDOW_LENGTH_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void receiverWindowLength(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_RECEIVER_WINDOW_LENGTH_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static int publicationWindowLength(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_PUBLICATION_WINDOW_LENGTH_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void publicationWindowLength(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_PUBLICATION_WINDOW_LENGTH_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static long untetheredWindowLimitTimeoutNs(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getLong(LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void untetheredWindowLimitTimeoutNs(final UnsafeBuffer metadataBuffer, final long value) { | ||
metadataBuffer.putLong(LOG_UNTETHERED_WINDOW_LIMIT_TIMEOUT_NS_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static long untetheredRestingTimeoutNs(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getLong(LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void untetheredRestingTimeoutNs(final UnsafeBuffer metadataBuffer, final long value) { | ||
metadataBuffer.putLong(LOG_UNTETHERED_RESTING_TIMEOUT_NS_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean group(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_GROUP_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void group(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_GROUP_OFFSET, value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static int maxResend(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_MAX_RESEND_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void maxResend(final UnsafeBuffer metadataBuffer, final int value) { | ||
metadataBuffer.putInt(LOG_MAX_RESEND_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static long lingerTimeoutNs(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getLong(LOG_LINGER_TIMEOUT_NS_OFFSET); | ||
} | ||
|
||
// todo: javadoc | ||
public static void lingerTimeoutNs(final UnsafeBuffer metadataBuffer, final long value) { | ||
metadataBuffer.putLong(LOG_LINGER_TIMEOUT_NS_OFFSET, value); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean signalEos(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_SIGNAL_EOS_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void signalEos(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_SIGNAL_EOS_OFFSET,value ? 1 : 0); | ||
} | ||
|
||
// todo: javadoc | ||
public static boolean spiesSimulateConnection(final UnsafeBuffer metadataBuffer) { | ||
return metadataBuffer.getInt(LOG_SPIES_SIMULATE_CONNECTION_OFFSET) == 1; | ||
} | ||
|
||
// todo: javadoc | ||
public static void spiesSimulateConnection(final UnsafeBuffer metadataBuffer, final boolean value) { | ||
metadataBuffer.putInt(LOG_SPIES_SIMULATE_CONNECTION_OFFSET, value ? 1 : 0); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A natural place to store this information would the default frame header, i.e.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll set the term offset on the default frame header and will drop it from the LogBufferDescriptor