|
50 | 50 | */
|
51 | 51 | public class TermAppender
|
52 | 52 | {
|
53 |
| - /** |
54 |
| - * The append operation tripped the end of the buffer and needs to rotate. |
55 |
| - */ |
56 |
| - public static final int TRIPPED = -1; |
57 |
| - |
58 | 53 | /**
|
59 | 54 | * The append operation failed because it was past the end of the buffer.
|
60 | 55 | */
|
@@ -98,8 +93,7 @@ public long rawTailVolatile()
|
98 | 93 | * @param length of the message to be written.
|
99 | 94 | * @param bufferClaim to be updated with the claimed region.
|
100 | 95 | * @param activeTermId used for flow control.
|
101 |
| - * @return the resulting offset of the term after the append on success otherwise {@link #TRIPPED} |
102 |
| - * or {@link #FAILED}. |
| 96 | + * @return the resulting offset of the term after the append on success otherwise {@link #FAILED}. |
103 | 97 | */
|
104 | 98 | public int claim(
|
105 | 99 | final HeaderWriter header,
|
@@ -141,8 +135,7 @@ public int claim(
|
141 | 135 | * @param length of the message in the source buffer.
|
142 | 136 | * @param reservedValueSupplier {@link ReservedValueSupplier} for the frame.
|
143 | 137 | * @param activeTermId used for flow control.
|
144 |
| - * @return the resulting offset of the term after the append on success otherwise {@link #TRIPPED} or |
145 |
| - * {@link #FAILED} |
| 138 | + * @return the resulting offset of the term after the append on success otherwise {@link #FAILED} |
146 | 139 | */
|
147 | 140 | public int appendUnfragmentedMessage(
|
148 | 141 | final HeaderWriter header,
|
@@ -193,8 +186,7 @@ public int appendUnfragmentedMessage(
|
193 | 186 | * @param length of the message as a sum of the vectors.
|
194 | 187 | * @param reservedValueSupplier {@link ReservedValueSupplier} for the frame.
|
195 | 188 | * @param activeTermId used for flow control.
|
196 |
| - * @return the resulting offset of the term after the append on success otherwise {@link #TRIPPED} or |
197 |
| - * {@link #FAILED}. |
| 189 | + * @return the resulting offset of the term after the append on success otherwise {@link #FAILED}. |
198 | 190 | */
|
199 | 191 | public int appendUnfragmentedMessage(
|
200 | 192 | final HeaderWriter header,
|
@@ -253,8 +245,7 @@ public int appendUnfragmentedMessage(
|
253 | 245 | * @param maxPayloadLength that the message will be fragmented into.
|
254 | 246 | * @param reservedValueSupplier {@link ReservedValueSupplier} for the frame.
|
255 | 247 | * @param activeTermId used for flow control.
|
256 |
| - * @return the resulting offset of the term after the append on success otherwise {@link #TRIPPED} |
257 |
| - * or {@link #FAILED}. |
| 248 | + * @return the resulting offset of the term after the append on success otherwise {@link #FAILED}. |
258 | 249 | */
|
259 | 250 | public int appendFragmentedMessage(
|
260 | 251 | final HeaderWriter header,
|
@@ -336,8 +327,7 @@ public int appendFragmentedMessage(
|
336 | 327 | * @param maxPayloadLength that the message will be fragmented into.
|
337 | 328 | * @param reservedValueSupplier {@link ReservedValueSupplier} for the frame.
|
338 | 329 | * @param activeTermId used for flow control.
|
339 |
| - * @return the resulting offset of the term after the append on success otherwise {@link #TRIPPED} |
340 |
| - * or {@link #FAILED}. |
| 330 | + * @return the resulting offset of the term after the append on success otherwise {@link #FAILED}. |
341 | 331 | */
|
342 | 332 | public int appendFragmentedMessage(
|
343 | 333 | final HeaderWriter header,
|
@@ -443,23 +433,16 @@ private int handleEndOfLogCondition(
|
443 | 433 | final int termLength,
|
444 | 434 | final int termId)
|
445 | 435 | {
|
446 |
| - int resultingOffset = FAILED; |
447 |
| - |
448 |
| - if (termOffset <= termLength) |
| 436 | + if (termOffset < termLength) |
449 | 437 | {
|
450 |
| - resultingOffset = TRIPPED; |
451 |
| - |
452 |
| - if (termOffset < termLength) |
453 |
| - { |
454 |
| - final int offset = (int)termOffset; |
455 |
| - final int paddingLength = termLength - offset; |
456 |
| - header.write(termBuffer, offset, paddingLength, termId); |
457 |
| - frameType(termBuffer, offset, PADDING_FRAME_TYPE); |
458 |
| - frameLengthOrdered(termBuffer, offset, paddingLength); |
459 |
| - } |
| 438 | + final int offset = (int)termOffset; |
| 439 | + final int paddingLength = termLength - offset; |
| 440 | + header.write(termBuffer, offset, paddingLength, termId); |
| 441 | + frameType(termBuffer, offset, PADDING_FRAME_TYPE); |
| 442 | + frameLengthOrdered(termBuffer, offset, paddingLength); |
460 | 443 | }
|
461 | 444 |
|
462 |
| - return resultingOffset; |
| 445 | + return FAILED; |
463 | 446 | }
|
464 | 447 |
|
465 | 448 | private long getAndAddRawTail(final int alignedLength)
|
|
0 commit comments