Skip to content

Commit 8fb87dc

Browse files
committed
[Java] Upgrade to Aeron 1.47.0, Agrona 2.0.1 and SBE 1.34.1.
1 parent 529a2e3 commit 8fb87dc

File tree

6 files changed

+31
-26
lines changed

6 files changed

+31
-26
lines changed

artio-codecs/src/main/java/uk/co/real_logic/artio/util/MessageTypeEncoding.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
*/
1616
package uk.co.real_logic.artio.util;
1717

18+
import org.agrona.UnsafeApi;
1819
import org.agrona.collections.LongHashSet;
1920

2021
import java.util.Set;
2122

2223
import static org.agrona.BufferUtil.ARRAY_BASE_OFFSET;
23-
import static org.agrona.UnsafeAccess.UNSAFE;
2424

2525
/**
2626
* Class for handling the encoding and decoding of Artio's packed message types.
27-
*
27+
* <p>
2828
* FIX uses 1 or 2 character ascii sequences as a way of representing the message type of messages. Some venues
2929
* have a longer representation with more message types in. Artio has a packed representation where the bytes of
3030
* the message type are encoded into a long.
@@ -69,7 +69,7 @@ public static LongHashSet packAllMessageTypes(final Set<String> messageTypes)
6969
* Creates a packed message type from a char[] and length.
7070
*
7171
* @param messageType message type as ascii char[].
72-
* @param length the number of characters within messageType to use.
72+
* @param length the number of characters within messageType to use.
7373
* @return the packed message type.
7474
* @throws IllegalArgumentException if messageType parameter is too long.
7575
*/
@@ -99,8 +99,8 @@ private static void checkLength(final int length)
9999
* Creates a packed message type from a byte[] and length.
100100
*
101101
* @param messageType message type as ascii byte[].
102-
* @param offset the offset within the messagetype to start looking
103-
* @param length the number of characters within messageType to use.
102+
* @param offset the offset within the messagetype to start looking
103+
* @param length the number of characters within messageType to use.
104104
* @return the packed message type.
105105
* @throws IllegalArgumentException if messageType parameter is too long.
106106
*/
@@ -115,18 +115,18 @@ static long packMessageType(final byte[] messageType, final long baseOffset, fin
115115

116116
if (length == 1)
117117
{
118-
return UNSAFE.getByte(messageType, baseOffset + offset);
118+
return UnsafeApi.getByte(messageType, baseOffset + offset);
119119
}
120120
else if (length == 2)
121121
{
122-
return UNSAFE.getShort(messageType, baseOffset + offset);
122+
return UnsafeApi.getShort(messageType, baseOffset + offset);
123123
}
124124
else
125125
{
126126
long packed = 0;
127127
for (int index = 0; index < length; index++)
128128
{
129-
final int asciiValue = UNSAFE.getByte(messageType, baseOffset + offset + index);
129+
final int asciiValue = UnsafeApi.getByte(messageType, baseOffset + offset + index);
130130
packed |= asciiValue << (MESSAGE_TYPE_BITSHIFT * index);
131131
}
132132
return packed;
@@ -141,10 +141,9 @@ else if (length == 2)
141141
* type.
142142
*
143143
* @param packedMessageType the FIX message type in packed format.
144-
* @param dest a destination byte array where the unpacked value is put, should be at least two bytes long.
145-
* @throws ArrayIndexOutOfBoundsException if dest is too short.
146-
*
144+
* @param dest a destination byte array where the unpacked value is put, should be at least two bytes long.
147145
* @return the length of the unpacked value
146+
* @throws ArrayIndexOutOfBoundsException if dest is too short.
148147
*/
149148
public static int unpackMessageType(final long packedMessageType, final byte[] dest)
150149
{

artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayIndex.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
import java.io.File;
3333
import java.io.IOException;
34+
import java.lang.invoke.VarHandle;
3435
import java.util.ArrayList;
3536
import java.util.List;
3637
import java.util.function.LongFunction;
3738

3839
import static io.aeron.archive.status.RecordingPos.NULL_RECORDING_ID;
3940
import static io.aeron.logbuffer.FrameDescriptor.*;
40-
import static org.agrona.UnsafeAccess.UNSAFE;
4141
import static uk.co.real_logic.artio.dictionary.SessionConstants.SEQUENCE_RESET_MESSAGE_TYPE;
4242
import static uk.co.real_logic.artio.engine.SequenceNumberExtractor.NO_SEQUENCE_NUMBER;
4343
import static uk.co.real_logic.artio.engine.logger.ReplayIndexDescriptor.*;
@@ -579,7 +579,7 @@ void onRecord(
579579
final long beginPosition = endPosition - length;
580580

581581
beginChangeOrdered(headerBuffer, changePosition);
582-
UNSAFE.storeFence();
582+
VarHandle.storeStoreFence();
583583

584584
final int segmentIndex = ReplayIndexDescriptor.segmentIndex(
585585
beginChangePosition, segmentSizeBitShift, indexFileSize);

artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayQuery.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
import uk.co.real_logic.artio.util.CharFormatter;
3434

3535
import java.io.File;
36+
import java.lang.invoke.VarHandle;
3637
import java.util.ArrayList;
3738
import java.util.List;
3839
import java.util.function.LongFunction;
3940

4041
import static io.aeron.Aeron.NULL_VALUE;
4142
import static io.aeron.CommonContext.IPC_CHANNEL;
4243
import static io.aeron.logbuffer.FrameDescriptor.FRAME_ALIGNMENT;
43-
import static org.agrona.UnsafeAccess.UNSAFE;
4444
import static uk.co.real_logic.artio.DebugLogger.IS_REPLAY_ATTEMPT_ENABLED;
4545
import static uk.co.real_logic.artio.engine.logger.ReplayIndexDescriptor.*;
4646
import static uk.co.real_logic.artio.engine.logger.Replayer.MOST_RECENT_MESSAGE;
@@ -284,7 +284,7 @@ ReplayOperation query(
284284
final long recordingId = indexRecord.recordingId();
285285
final int readLength = indexRecord.length();
286286

287-
UNSAFE.loadFence(); // LoadLoad required so previous loads don't move past version check below.
287+
VarHandle.loadLoadFence(); // LoadLoad required so previous loads don't move past version check below.
288288

289289
if (log)
290290
{
@@ -475,7 +475,7 @@ public Long2ObjectHashMap<PrunePosition> queryStartPositions()
475475
final long recordingId = indexRecord.recordingId();
476476
final int sequenceNumber = indexRecord.sequenceNumber();
477477

478-
UNSAFE.loadFence(); // LoadLoad required so previous loads don't move past version check below.
478+
VarHandle.loadLoadFence(); // LoadLoad required so previous loads don't move past version check below.
479479

480480
// if the block was read atomically with no updates
481481
if (changePosition == beginChangeVolatile(headerBuffer))

artio-system-tests/src/perf/java/uk/co/real_logic/artio/ArraysFillBenchmark.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717

1818
import org.agrona.BitUtil;
1919
import org.agrona.BufferUtil;
20+
import org.agrona.UnsafeApi;
2021
import org.openjdk.jmh.annotations.*;
2122

2223
import java.util.Arrays;
2324
import java.util.concurrent.TimeUnit;
2425

25-
import static org.agrona.UnsafeAccess.UNSAFE;
26-
2726
@State(Scope.Benchmark)
2827
@BenchmarkMode(Mode.AverageTime)
2928
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@@ -59,16 +58,16 @@ public int[] arraysFill()
5958
public int[] memset()
6059
{
6160
final int[] values = this.values;
62-
UNSAFE.setMemory(values, BufferUtil.ARRAY_BASE_OFFSET, sizeInBytes, MISSING_BYTE);
61+
UnsafeApi.setMemory(values, BufferUtil.ARRAY_BASE_OFFSET, sizeInBytes, MISSING_BYTE);
6362
return values;
6463
}
6564

6665
@Benchmark
6766
public int[] offsetMemset()
6867
{
6968
final int[] values = this.values;
70-
UNSAFE.putByte(values, BufferUtil.ARRAY_BASE_OFFSET, MISSING_BYTE);
71-
UNSAFE.setMemory(values, BufferUtil.ARRAY_BASE_OFFSET + 1, sizeInBytes - 1, MISSING_BYTE);
69+
UnsafeApi.putByte(values, BufferUtil.ARRAY_BASE_OFFSET, MISSING_BYTE);
70+
UnsafeApi.setMemory(values, BufferUtil.ARRAY_BASE_OFFSET + 1, sizeInBytes - 1, MISSING_BYTE);
7271
return values;
7372
}
7473

build.gradle

+8-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ allprojects {
121121
configurations.configureEach {
122122
resolutionStrategy {
123123
failOnVersionConflict()
124-
force "org.agrona:agrona:${libs.versions.agrona.get()}",
124+
force libs.agrona,
125125
libs.byteBuddy,
126126
libs.byteBuddy.agent,
127127
// patching conflicting Checkstyle dependencies
@@ -178,6 +178,7 @@ subprojects {
178178
useJUnitPlatform()
179179

180180
jvmArgs('--add-opens', 'java.base/sun.nio.ch=ALL-UNNAMED')
181+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
181182
jvmArgs('--add-opens', 'java.base/java.util.zip=ALL-UNNAMED')
182183

183184
if (buildJavaVersion >= 21) {
@@ -319,6 +320,7 @@ project(':artio-codecs') {
319320

320321
tasks.register('generateMessages', JavaExec) {
321322
mainClass.set('uk.co.real_logic.sbe.SbeTool')
323+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
322324
classpath = configurations.codecGeneration
323325
systemProperties('sbe.output.dir': generatedDir,
324326
'sbe.target.language': 'Java',
@@ -391,6 +393,7 @@ project(':artio-ilink3-codecs') {
391393

392394
tasks.register('generateMessages', JavaExec) {
393395
mainClass.set('uk.co.real_logic.sbe.SbeTool')
396+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
394397
classpath = configurations.codecGeneration
395398
systemProperties(
396399
'sbe.output.dir': generatedDir,
@@ -472,6 +475,7 @@ project(':artio-binary-entrypoint-codecs') {
472475

473476
tasks.register('generateMessages', JavaExec) {
474477
mainClass.set('uk.co.real_logic.sbe.SbeTool')
478+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
475479
classpath = configurations.codecGeneration
476480
systemProperties(
477481
'sbe.output.dir': generatedDir,
@@ -607,6 +611,7 @@ project(':artio-session-codecs') {
607611

608612
tasks.register('generateCodecs', JavaExec) {
609613
mainClass.set('uk.co.real_logic.artio.dictionary.CodecGenerationTool')
614+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
610615
classpath = configurations.codecGeneration
611616
def dictionaryFile = 'src/main/resources/session_dictionary.xml'
612617
inputs.file(dictionaryFile)
@@ -617,6 +622,7 @@ project(':artio-session-codecs') {
617622

618623
tasks.register('generateOtherCodecs', JavaExec) {
619624
mainClass.set('uk.co.real_logic.artio.dictionary.CodecGenerationTool')
625+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
620626
classpath = configurations.codecGeneration
621627
def dictionaryFile = 'src/main/resources/other_session_dictionary.xml'
622628
inputs.file(dictionaryFile)
@@ -684,6 +690,7 @@ project(':artio-session-fixt-codecs') {
684690

685691
tasks.register('generateCodecs', JavaExec) {
686692
mainClass.set('uk.co.real_logic.artio.dictionary.CodecGenerationTool')
693+
jvmArgs('--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED')
687694
classpath = configurations.codecGeneration
688695
systemProperty("fix.codecs.parent_package", "uk.co.real_logic.artio.fixt")
689696
args = [generatedDir, 'src/main/resources/FIXT11.xml']

gradle/libs.versions.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[versions]
2-
aeron = "1.46.8"
3-
agrona = "1.23.1"
2+
aeron = "1.47.0"
3+
agrona = "2.0.1"
44
byteBuddy = "1.15.11"
55
checkstyle = "10.20.1"
66
junit = "5.11.4"
77
gradle = "8.11.1"
88
jmh = "1.37"
99

1010
[libraries]
11-
agrona = { group = "org.agrona", name = "agrona", version = { strictly = "[1.23.1, 2.0[", require = "1.23.1" } }
11+
agrona = { group = "org.agrona", name = "agrona", version.ref = "agrona" }
1212
aeron-client = { group = "io.aeron", name = "aeron-client", version.ref = "aeron" }
1313
aeron-archive = { group = "io.aeron", name = "aeron-archive", version.ref = "aeron" }
14-
sbe = { group = "uk.co.real-logic", name = "sbe-tool", version = "1.33.2" }
14+
sbe = { group = "uk.co.real-logic", name = "sbe-tool", version = "1.34.1" }
1515
mockito = { group = "org.mockito", name = "mockito-core", version = "5.15.2" }
1616
hamcrest = { group = "org.hamcrest", name = "hamcrest", version = "3.0" }
1717
junit4 = { group = "junit", name = "junit", version = "4.13.2" }

0 commit comments

Comments
 (0)